|
@@ -27,6 +27,7 @@
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/poll.h>
|
|
#include <linux/poll.h>
|
|
#include <linux/pci.h>
|
|
#include <linux/pci.h>
|
|
|
|
+#include <linux/smp_lock.h>
|
|
#include <linux/workqueue.h>
|
|
#include <linux/workqueue.h>
|
|
|
|
|
|
#define IN_CARD_SERVICES
|
|
#define IN_CARD_SERVICES
|
|
@@ -397,20 +398,27 @@ static int ds_open(struct inode *inode, struct file *file)
|
|
struct pcmcia_socket *s;
|
|
struct pcmcia_socket *s;
|
|
user_info_t *user;
|
|
user_info_t *user;
|
|
static int warning_printed = 0;
|
|
static int warning_printed = 0;
|
|
|
|
+ int ret = 0;
|
|
|
|
|
|
ds_dbg(0, "ds_open(socket %d)\n", i);
|
|
ds_dbg(0, "ds_open(socket %d)\n", i);
|
|
|
|
|
|
|
|
+ lock_kernel();
|
|
s = pcmcia_get_socket_by_nr(i);
|
|
s = pcmcia_get_socket_by_nr(i);
|
|
- if (!s)
|
|
|
|
- return -ENODEV;
|
|
|
|
|
|
+ if (!s) {
|
|
|
|
+ ret = -ENODEV;
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
s = pcmcia_get_socket(s);
|
|
s = pcmcia_get_socket(s);
|
|
- if (!s)
|
|
|
|
- return -ENODEV;
|
|
|
|
|
|
+ if (!s) {
|
|
|
|
+ ret = -ENODEV;
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
|
|
if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
|
|
if ((file->f_flags & O_ACCMODE) != O_RDONLY) {
|
|
if (s->pcmcia_state.busy) {
|
|
if (s->pcmcia_state.busy) {
|
|
pcmcia_put_socket(s);
|
|
pcmcia_put_socket(s);
|
|
- return -EBUSY;
|
|
|
|
|
|
+ ret = -EBUSY;
|
|
|
|
+ goto out;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
s->pcmcia_state.busy = 1;
|
|
s->pcmcia_state.busy = 1;
|
|
@@ -419,7 +427,8 @@ static int ds_open(struct inode *inode, struct file *file)
|
|
user = kmalloc(sizeof(user_info_t), GFP_KERNEL);
|
|
user = kmalloc(sizeof(user_info_t), GFP_KERNEL);
|
|
if (!user) {
|
|
if (!user) {
|
|
pcmcia_put_socket(s);
|
|
pcmcia_put_socket(s);
|
|
- return -ENOMEM;
|
|
|
|
|
|
+ ret = -ENOMEM;
|
|
|
|
+ goto out;
|
|
}
|
|
}
|
|
user->event_tail = user->event_head = 0;
|
|
user->event_tail = user->event_head = 0;
|
|
user->next = s->user;
|
|
user->next = s->user;
|
|
@@ -441,7 +450,9 @@ static int ds_open(struct inode *inode, struct file *file)
|
|
|
|
|
|
if (s->pcmcia_state.present)
|
|
if (s->pcmcia_state.present)
|
|
queue_event(user, CS_EVENT_CARD_INSERTION);
|
|
queue_event(user, CS_EVENT_CARD_INSERTION);
|
|
- return 0;
|
|
|
|
|
|
+out:
|
|
|
|
+ unlock_kernel();
|
|
|
|
+ return ret;
|
|
} /* ds_open */
|
|
} /* ds_open */
|
|
|
|
|
|
/*====================================================================*/
|
|
/*====================================================================*/
|