diff options
Diffstat (limited to 'drivers/pcmcia/pcmcia_ioctl.c')
-rw-r--r-- | drivers/pcmcia/pcmcia_ioctl.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index f73fd5beaa37..13a7132cf688 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -62,16 +62,15 @@ static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s, | |||
62 | unsigned int function) | 62 | unsigned int function) |
63 | { | 63 | { |
64 | struct pcmcia_device *p_dev = NULL; | 64 | struct pcmcia_device *p_dev = NULL; |
65 | unsigned long flags; | ||
66 | 65 | ||
67 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | 66 | mutex_lock(&s->ops_mutex); |
68 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { | 67 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { |
69 | if (p_dev->func == function) { | 68 | if (p_dev->func == function) { |
70 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 69 | mutex_unlock(&s->ops_mutex); |
71 | return pcmcia_get_dev(p_dev); | 70 | return pcmcia_get_dev(p_dev); |
72 | } | 71 | } |
73 | } | 72 | } |
74 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 73 | mutex_unlock(&s->ops_mutex); |
75 | return NULL; | 74 | return NULL; |
76 | } | 75 | } |
77 | 76 | ||
@@ -169,7 +168,6 @@ static int pcmcia_adjust_resource_info(adjust_t *adj) | |||
169 | { | 168 | { |
170 | struct pcmcia_socket *s; | 169 | struct pcmcia_socket *s; |
171 | int ret = -ENOSYS; | 170 | int ret = -ENOSYS; |
172 | unsigned long flags; | ||
173 | 171 | ||
174 | down_read(&pcmcia_socket_list_rwsem); | 172 | down_read(&pcmcia_socket_list_rwsem); |
175 | list_for_each_entry(s, &pcmcia_socket_list, socket_list) { | 173 | list_for_each_entry(s, &pcmcia_socket_list, socket_list) { |
@@ -182,14 +180,13 @@ static int pcmcia_adjust_resource_info(adjust_t *adj) | |||
182 | 180 | ||
183 | /* you can't use the old interface if the new | 181 | /* you can't use the old interface if the new |
184 | * one was used before */ | 182 | * one was used before */ |
185 | spin_lock_irqsave(&s->lock, flags); | 183 | mutex_lock(&s->ops_mutex); |
186 | if ((s->resource_setup_new) && | 184 | if ((s->resource_setup_new) && |
187 | !(s->resource_setup_old)) { | 185 | !(s->resource_setup_old)) { |
188 | spin_unlock_irqrestore(&s->lock, flags); | 186 | mutex_unlock(&s->ops_mutex); |
189 | continue; | 187 | continue; |
190 | } else if (!(s->resource_setup_old)) | 188 | } else if (!(s->resource_setup_old)) |
191 | s->resource_setup_old = 1; | 189 | s->resource_setup_old = 1; |
192 | spin_unlock_irqrestore(&s->lock, flags); | ||
193 | 190 | ||
194 | switch (adj->Resource) { | 191 | switch (adj->Resource) { |
195 | case RES_MEMORY_RANGE: | 192 | case RES_MEMORY_RANGE: |
@@ -208,10 +205,9 @@ static int pcmcia_adjust_resource_info(adjust_t *adj) | |||
208 | * last call to adjust_resource_info, we | 205 | * last call to adjust_resource_info, we |
209 | * always need to assume this is the latest | 206 | * always need to assume this is the latest |
210 | * one... */ | 207 | * one... */ |
211 | spin_lock_irqsave(&s->lock, flags); | ||
212 | s->resource_setup_done = 1; | 208 | s->resource_setup_done = 1; |
213 | spin_unlock_irqrestore(&s->lock, flags); | ||
214 | } | 209 | } |
210 | mutex_unlock(&s->ops_mutex); | ||
215 | } | 211 | } |
216 | } | 212 | } |
217 | up_read(&pcmcia_socket_list_rwsem); | 213 | up_read(&pcmcia_socket_list_rwsem); |
@@ -470,7 +466,6 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
470 | struct pcmcia_driver *p_drv; | 466 | struct pcmcia_driver *p_drv; |
471 | struct pcmcia_device *p_dev; | 467 | struct pcmcia_device *p_dev; |
472 | int ret = 0; | 468 | int ret = 0; |
473 | unsigned long flags; | ||
474 | 469 | ||
475 | s = pcmcia_get_socket(s); | 470 | s = pcmcia_get_socket(s); |
476 | if (!s) | 471 | if (!s) |
@@ -490,7 +485,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
490 | goto err_put_driver; | 485 | goto err_put_driver; |
491 | } | 486 | } |
492 | 487 | ||
493 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | 488 | mutex_lock(&s->ops_mutex); |
494 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { | 489 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { |
495 | if (p_dev->func == bind_info->function) { | 490 | if (p_dev->func == bind_info->function) { |
496 | if ((p_dev->dev.driver == &p_drv->drv)) { | 491 | if ((p_dev->dev.driver == &p_drv->drv)) { |
@@ -499,7 +494,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
499 | * registered, and it was registered | 494 | * registered, and it was registered |
500 | * by userspace before, we need to | 495 | * by userspace before, we need to |
501 | * return the "instance". */ | 496 | * return the "instance". */ |
502 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 497 | mutex_unlock(&s->ops_mutex); |
503 | bind_info->instance = p_dev; | 498 | bind_info->instance = p_dev; |
504 | ret = -EBUSY; | 499 | ret = -EBUSY; |
505 | goto err_put_module; | 500 | goto err_put_module; |
@@ -507,7 +502,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
507 | /* the correct driver managed to bind | 502 | /* the correct driver managed to bind |
508 | * itself magically to the correct | 503 | * itself magically to the correct |
509 | * device. */ | 504 | * device. */ |
510 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 505 | mutex_unlock(&s->ops_mutex); |
511 | p_dev->cardmgr = p_drv; | 506 | p_dev->cardmgr = p_drv; |
512 | ret = 0; | 507 | ret = 0; |
513 | goto err_put_module; | 508 | goto err_put_module; |
@@ -516,12 +511,12 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
516 | /* there's already a device available where | 511 | /* there's already a device available where |
517 | * no device has been bound to yet. So we don't | 512 | * no device has been bound to yet. So we don't |
518 | * need to register a device! */ | 513 | * need to register a device! */ |
519 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 514 | mutex_unlock(&s->ops_mutex); |
520 | goto rescan; | 515 | goto rescan; |
521 | } | 516 | } |
522 | } | 517 | } |
523 | } | 518 | } |
524 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 519 | mutex_unlock(&s->ops_mutex); |
525 | 520 | ||
526 | p_dev = pcmcia_device_add(s, bind_info->function); | 521 | p_dev = pcmcia_device_add(s, bind_info->function); |
527 | if (!p_dev) { | 522 | if (!p_dev) { |
@@ -578,7 +573,6 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int | |||
578 | dev_node_t *node; | 573 | dev_node_t *node; |
579 | struct pcmcia_device *p_dev; | 574 | struct pcmcia_device *p_dev; |
580 | struct pcmcia_driver *p_drv; | 575 | struct pcmcia_driver *p_drv; |
581 | unsigned long flags; | ||
582 | int ret = 0; | 576 | int ret = 0; |
583 | 577 | ||
584 | #ifdef CONFIG_CARDBUS | 578 | #ifdef CONFIG_CARDBUS |
@@ -617,7 +611,7 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int | |||
617 | } | 611 | } |
618 | #endif | 612 | #endif |
619 | 613 | ||
620 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | 614 | mutex_lock(&s->ops_mutex); |
621 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { | 615 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { |
622 | if (p_dev->func == bind_info->function) { | 616 | if (p_dev->func == bind_info->function) { |
623 | p_dev = pcmcia_get_dev(p_dev); | 617 | p_dev = pcmcia_get_dev(p_dev); |
@@ -626,11 +620,11 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int | |||
626 | goto found; | 620 | goto found; |
627 | } | 621 | } |
628 | } | 622 | } |
629 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 623 | mutex_unlock(&s->ops_mutex); |
630 | return -ENODEV; | 624 | return -ENODEV; |
631 | 625 | ||
632 | found: | 626 | found: |
633 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 627 | mutex_unlock(&s->ops_mutex); |
634 | 628 | ||
635 | p_drv = to_pcmcia_drv(p_dev->dev.driver); | 629 | p_drv = to_pcmcia_drv(p_dev->dev.driver); |
636 | if (p_drv && !p_dev->_locked) { | 630 | if (p_drv && !p_dev->_locked) { |
@@ -931,16 +925,16 @@ static int ds_ioctl(struct inode *inode, struct file *file, | |||
931 | ret = pccard_validate_cis(s, &buf->cisinfo.Chains); | 925 | ret = pccard_validate_cis(s, &buf->cisinfo.Chains); |
932 | break; | 926 | break; |
933 | case DS_SUSPEND_CARD: | 927 | case DS_SUSPEND_CARD: |
934 | ret = pcmcia_suspend_card(s); | 928 | pcmcia_parse_uevents(s, PCMCIA_UEVENT_SUSPEND); |
935 | break; | 929 | break; |
936 | case DS_RESUME_CARD: | 930 | case DS_RESUME_CARD: |
937 | ret = pcmcia_resume_card(s); | 931 | pcmcia_parse_uevents(s, PCMCIA_UEVENT_RESUME); |
938 | break; | 932 | break; |
939 | case DS_EJECT_CARD: | 933 | case DS_EJECT_CARD: |
940 | err = pcmcia_eject_card(s); | 934 | pcmcia_parse_uevents(s, PCMCIA_UEVENT_EJECT); |
941 | break; | 935 | break; |
942 | case DS_INSERT_CARD: | 936 | case DS_INSERT_CARD: |
943 | err = pcmcia_insert_card(s); | 937 | pcmcia_parse_uevents(s, PCMCIA_UEVENT_INSERT); |
944 | break; | 938 | break; |
945 | case DS_ACCESS_CONFIGURATION_REGISTER: | 939 | case DS_ACCESS_CONFIGURATION_REGISTER: |
946 | if ((buf->conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN)) { | 940 | if ((buf->conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN)) { |