diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-01-16 03:14:11 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2010-02-17 11:48:20 -0500 |
commit | 00ce99ff506a17882747a7d6874e3f5206a99043 (patch) | |
tree | 571f5b106f25f35f326d456123c4af85147c3bce /drivers/pcmcia/pcmcia_ioctl.c | |
parent | 3d3de32fad19e37695e6649136e4cb17f9d46329 (diff) |
pcmcia: simplify locking
replace pcmcia_socket->lock and pcmcia_dev_list_lock by using the
per-socket "ops_mutex", as we do neither need different locks
nor a spinlock here.
Tested-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/pcmcia_ioctl.c')
-rw-r--r-- | drivers/pcmcia/pcmcia_ioctl.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index f73fd5beaa37..db2e3db8008b 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,14 @@ 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); | 190 | mutex_unlock(&s->ops_mutex); |
193 | 191 | ||
194 | switch (adj->Resource) { | 192 | switch (adj->Resource) { |
195 | case RES_MEMORY_RANGE: | 193 | case RES_MEMORY_RANGE: |
@@ -208,9 +206,9 @@ static int pcmcia_adjust_resource_info(adjust_t *adj) | |||
208 | * last call to adjust_resource_info, we | 206 | * last call to adjust_resource_info, we |
209 | * always need to assume this is the latest | 207 | * always need to assume this is the latest |
210 | * one... */ | 208 | * one... */ |
211 | spin_lock_irqsave(&s->lock, flags); | 209 | mutex_lock(&s->ops_mutex); |
212 | s->resource_setup_done = 1; | 210 | s->resource_setup_done = 1; |
213 | spin_unlock_irqrestore(&s->lock, flags); | 211 | mutex_unlock(&s->ops_mutex); |
214 | } | 212 | } |
215 | } | 213 | } |
216 | } | 214 | } |
@@ -470,7 +468,6 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
470 | struct pcmcia_driver *p_drv; | 468 | struct pcmcia_driver *p_drv; |
471 | struct pcmcia_device *p_dev; | 469 | struct pcmcia_device *p_dev; |
472 | int ret = 0; | 470 | int ret = 0; |
473 | unsigned long flags; | ||
474 | 471 | ||
475 | s = pcmcia_get_socket(s); | 472 | s = pcmcia_get_socket(s); |
476 | if (!s) | 473 | if (!s) |
@@ -490,7 +487,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
490 | goto err_put_driver; | 487 | goto err_put_driver; |
491 | } | 488 | } |
492 | 489 | ||
493 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | 490 | mutex_lock(&s->ops_mutex); |
494 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { | 491 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { |
495 | if (p_dev->func == bind_info->function) { | 492 | if (p_dev->func == bind_info->function) { |
496 | if ((p_dev->dev.driver == &p_drv->drv)) { | 493 | if ((p_dev->dev.driver == &p_drv->drv)) { |
@@ -499,7 +496,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
499 | * registered, and it was registered | 496 | * registered, and it was registered |
500 | * by userspace before, we need to | 497 | * by userspace before, we need to |
501 | * return the "instance". */ | 498 | * return the "instance". */ |
502 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 499 | mutex_unlock(&s->ops_mutex); |
503 | bind_info->instance = p_dev; | 500 | bind_info->instance = p_dev; |
504 | ret = -EBUSY; | 501 | ret = -EBUSY; |
505 | goto err_put_module; | 502 | goto err_put_module; |
@@ -507,7 +504,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
507 | /* the correct driver managed to bind | 504 | /* the correct driver managed to bind |
508 | * itself magically to the correct | 505 | * itself magically to the correct |
509 | * device. */ | 506 | * device. */ |
510 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 507 | mutex_unlock(&s->ops_mutex); |
511 | p_dev->cardmgr = p_drv; | 508 | p_dev->cardmgr = p_drv; |
512 | ret = 0; | 509 | ret = 0; |
513 | goto err_put_module; | 510 | goto err_put_module; |
@@ -516,12 +513,12 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) | |||
516 | /* there's already a device available where | 513 | /* there's already a device available where |
517 | * no device has been bound to yet. So we don't | 514 | * no device has been bound to yet. So we don't |
518 | * need to register a device! */ | 515 | * need to register a device! */ |
519 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 516 | mutex_unlock(&s->ops_mutex); |
520 | goto rescan; | 517 | goto rescan; |
521 | } | 518 | } |
522 | } | 519 | } |
523 | } | 520 | } |
524 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 521 | mutex_unlock(&s->ops_mutex); |
525 | 522 | ||
526 | p_dev = pcmcia_device_add(s, bind_info->function); | 523 | p_dev = pcmcia_device_add(s, bind_info->function); |
527 | if (!p_dev) { | 524 | if (!p_dev) { |
@@ -578,7 +575,6 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int | |||
578 | dev_node_t *node; | 575 | dev_node_t *node; |
579 | struct pcmcia_device *p_dev; | 576 | struct pcmcia_device *p_dev; |
580 | struct pcmcia_driver *p_drv; | 577 | struct pcmcia_driver *p_drv; |
581 | unsigned long flags; | ||
582 | int ret = 0; | 578 | int ret = 0; |
583 | 579 | ||
584 | #ifdef CONFIG_CARDBUS | 580 | #ifdef CONFIG_CARDBUS |
@@ -617,7 +613,7 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int | |||
617 | } | 613 | } |
618 | #endif | 614 | #endif |
619 | 615 | ||
620 | spin_lock_irqsave(&pcmcia_dev_list_lock, flags); | 616 | mutex_lock(&s->ops_mutex); |
621 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { | 617 | list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { |
622 | if (p_dev->func == bind_info->function) { | 618 | if (p_dev->func == bind_info->function) { |
623 | p_dev = pcmcia_get_dev(p_dev); | 619 | p_dev = pcmcia_get_dev(p_dev); |
@@ -626,11 +622,11 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int | |||
626 | goto found; | 622 | goto found; |
627 | } | 623 | } |
628 | } | 624 | } |
629 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 625 | mutex_unlock(&s->ops_mutex); |
630 | return -ENODEV; | 626 | return -ENODEV; |
631 | 627 | ||
632 | found: | 628 | found: |
633 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 629 | mutex_unlock(&s->ops_mutex); |
634 | 630 | ||
635 | p_drv = to_pcmcia_drv(p_dev->dev.driver); | 631 | p_drv = to_pcmcia_drv(p_dev->dev.driver); |
636 | if (p_drv && !p_dev->_locked) { | 632 | if (p_drv && !p_dev->_locked) { |