Commit 00ce99ff authored by Dominik Brodowski's avatar Dominik Brodowski

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: default avatarWolfram Sang <w.sang@pengutronix.de>
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 3d3de32f
...@@ -175,8 +175,6 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) ...@@ -175,8 +175,6 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
dev_dbg(&socket->dev, "pcmcia_register_socket(0x%p)\n", socket->ops); dev_dbg(&socket->dev, "pcmcia_register_socket(0x%p)\n", socket->ops);
spin_lock_init(&socket->lock);
/* try to obtain a socket number [yes, it gets ugly if we /* try to obtain a socket number [yes, it gets ugly if we
* register more than 2^sizeof(unsigned int) pcmcia * register more than 2^sizeof(unsigned int) pcmcia
* sockets... but the socket number is deprecated * sockets... but the socket number is deprecated
......
...@@ -182,8 +182,6 @@ int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple); ...@@ -182,8 +182,6 @@ int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple);
#ifdef CONFIG_PCMCIA_IOCTL #ifdef CONFIG_PCMCIA_IOCTL
/* ds.c */ /* ds.c */
extern spinlock_t pcmcia_dev_list_lock;
extern struct pcmcia_device *pcmcia_get_dev(struct pcmcia_device *p_dev); extern struct pcmcia_device *pcmcia_get_dev(struct pcmcia_device *p_dev);
extern void pcmcia_put_dev(struct pcmcia_device *p_dev); extern void pcmcia_put_dev(struct pcmcia_device *p_dev);
......
...@@ -42,8 +42,6 @@ MODULE_DESCRIPTION("PCMCIA Driver Services"); ...@@ -42,8 +42,6 @@ MODULE_DESCRIPTION("PCMCIA Driver Services");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
spinlock_t pcmcia_dev_list_lock;
/*====================================================================*/ /*====================================================================*/
static void pcmcia_check_driver(struct pcmcia_driver *p_drv) static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
...@@ -265,7 +263,6 @@ static int pcmcia_device_probe(struct device *dev) ...@@ -265,7 +263,6 @@ static int pcmcia_device_probe(struct device *dev)
struct pcmcia_device_id *did; struct pcmcia_device_id *did;
struct pcmcia_socket *s; struct pcmcia_socket *s;
cistpl_config_t cis_config; cistpl_config_t cis_config;
unsigned long flags;
int ret = 0; int ret = 0;
dev = get_device(dev); dev = get_device(dev);
...@@ -316,11 +313,11 @@ static int pcmcia_device_probe(struct device *dev) ...@@ -316,11 +313,11 @@ static int pcmcia_device_probe(struct device *dev)
goto put_module; goto put_module;
} }
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
(p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) (p_dev->socket->device_count == 1) && (p_dev->device_no == 0))
pcmcia_add_device_later(p_dev->socket, 0); pcmcia_add_device_later(p_dev->socket, 0);
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
put_module: put_module:
if (ret) if (ret)
...@@ -339,28 +336,27 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le ...@@ -339,28 +336,27 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
{ {
struct pcmcia_device *p_dev; struct pcmcia_device *p_dev;
struct pcmcia_device *tmp; struct pcmcia_device *tmp;
unsigned long flags;
dev_dbg(leftover ? &leftover->dev : &s->dev, dev_dbg(leftover ? &leftover->dev : &s->dev,
"pcmcia_card_remove(%d) %s\n", s->sock, "pcmcia_card_remove(%d) %s\n", s->sock,
leftover ? leftover->devname : ""); leftover ? leftover->devname : "");
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
if (!leftover) if (!leftover)
s->device_count = 0; s->device_count = 0;
else else
s->device_count = 1; s->device_count = 1;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
/* unregister all pcmcia_devices registered with this socket, except leftover */ /* unregister all pcmcia_devices registered with this socket, except leftover */
list_for_each_entry_safe(p_dev, tmp, &s->devices_list, socket_device_list) { list_for_each_entry_safe(p_dev, tmp, &s->devices_list, socket_device_list) {
if (p_dev == leftover) if (p_dev == leftover)
continue; continue;
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
list_del(&p_dev->socket_device_list); list_del(&p_dev->socket_device_list);
p_dev->_removed = 1; p_dev->_removed = 1;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
dev_dbg(&p_dev->dev, "unregistering device\n"); dev_dbg(&p_dev->dev, "unregistering device\n");
device_unregister(&p_dev->dev); device_unregister(&p_dev->dev);
...@@ -507,7 +503,6 @@ static DEFINE_MUTEX(device_add_lock); ...@@ -507,7 +503,6 @@ static DEFINE_MUTEX(device_add_lock);
struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int function) struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int function)
{ {
struct pcmcia_device *p_dev, *tmp_dev; struct pcmcia_device *p_dev, *tmp_dev;
unsigned long flags;
s = pcmcia_get_socket(s); s = pcmcia_get_socket(s);
if (!s) if (!s)
...@@ -521,9 +516,9 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu ...@@ -521,9 +516,9 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
if (!p_dev) if (!p_dev)
goto err_put; goto err_put;
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
p_dev->device_no = (s->device_count++); p_dev->device_no = (s->device_count++);
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
/* max of 4 devices per card */ /* max of 4 devices per card */
if (p_dev->device_no >= 4) if (p_dev->device_no >= 4)
...@@ -546,7 +541,7 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu ...@@ -546,7 +541,7 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
goto err_free; goto err_free;
dev_dbg(&p_dev->dev, "devname is %s\n", p_dev->devname); dev_dbg(&p_dev->dev, "devname is %s\n", p_dev->devname);
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
/* /*
* p_dev->function_config must be the same for all card functions. * p_dev->function_config must be the same for all card functions.
...@@ -564,7 +559,7 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu ...@@ -564,7 +559,7 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
/* Add to the list in pcmcia_bus_socket */ /* Add to the list in pcmcia_bus_socket */
list_add(&p_dev->socket_device_list, &s->devices_list); list_add(&p_dev->socket_device_list, &s->devices_list);
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
if (!p_dev->function_config) { if (!p_dev->function_config) {
dev_dbg(&p_dev->dev, "creating config_t\n"); dev_dbg(&p_dev->dev, "creating config_t\n");
...@@ -589,14 +584,14 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu ...@@ -589,14 +584,14 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
return p_dev; return p_dev;
err_unreg: err_unreg:
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
list_del(&p_dev->socket_device_list); list_del(&p_dev->socket_device_list);
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
err_free: err_free:
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
s->device_count--; s->device_count--;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
kfree(p_dev->devname); kfree(p_dev->devname);
kfree(p_dev); kfree(p_dev);
...@@ -650,13 +645,12 @@ static void pcmcia_delayed_add_device(struct work_struct *work) ...@@ -650,13 +645,12 @@ static void pcmcia_delayed_add_device(struct work_struct *work)
struct pcmcia_socket *s = struct pcmcia_socket *s =
container_of(work, struct pcmcia_socket, device_add); container_of(work, struct pcmcia_socket, device_add);
u8 mfc_pfc; u8 mfc_pfc;
unsigned long flags;
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
mfc_pfc = s->pcmcia_state.mfc_pfc; mfc_pfc = s->pcmcia_state.mfc_pfc;
s->pcmcia_state.device_add_pending = 0; s->pcmcia_state.device_add_pending = 0;
s->pcmcia_state.mfc_pfc = 0; s->pcmcia_state.mfc_pfc = 0;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
dev_dbg(&s->dev, "adding additional device to %d\n", s->sock); dev_dbg(&s->dev, "adding additional device to %d\n", s->sock);
pcmcia_device_add(s, mfc_pfc); pcmcia_device_add(s, mfc_pfc);
...@@ -677,15 +671,14 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis) ...@@ -677,15 +671,14 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis)
{ {
int no_devices = 0; int no_devices = 0;
int ret = 0; int ret = 0;
unsigned long flags;
/* must be called with skt_mutex held */ /* must be called with skt_mutex held */
dev_dbg(&skt->dev, "re-scanning socket %d\n", skt->sock); dev_dbg(&skt->dev, "re-scanning socket %d\n", skt->sock);
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&skt->ops_mutex);
if (list_empty(&skt->devices_list)) if (list_empty(&skt->devices_list))
no_devices = 1; no_devices = 1;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&skt->ops_mutex);
/* If this is because of a CIS override, start over */ /* If this is because of a CIS override, start over */
if (new_cis && !no_devices) if (new_cis && !no_devices)
...@@ -769,11 +762,9 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) ...@@ -769,11 +762,9 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
if (old_funcs > no_funcs) if (old_funcs > no_funcs)
pcmcia_card_remove(s, dev); pcmcia_card_remove(s, dev);
else if (no_funcs > old_funcs) { else if (no_funcs > old_funcs) {
unsigned long flags; mutex_lock(&s->ops_mutex);
spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
pcmcia_add_device_later(s, 1); pcmcia_add_device_later(s, 1);
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
} }
} }
release: release:
...@@ -1248,7 +1239,6 @@ static int pcmcia_bus_suspend(struct pcmcia_socket *skt) ...@@ -1248,7 +1239,6 @@ static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
{ {
struct pcmcia_socket *s = pcmcia_get_socket(skt); struct pcmcia_socket *s = pcmcia_get_socket(skt);
unsigned long flags;
if (!s) { if (!s) {
dev_printk(KERN_ERR, &skt->dev, dev_printk(KERN_ERR, &skt->dev,
...@@ -1262,9 +1252,9 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) ...@@ -1262,9 +1252,9 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
switch (event) { switch (event) {
case CS_EVENT_CARD_REMOVAL: case CS_EVENT_CARD_REMOVAL:
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
s->pcmcia_state.present = 0; s->pcmcia_state.present = 0;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
pcmcia_card_remove(skt, NULL); pcmcia_card_remove(skt, NULL);
handle_event(skt, event); handle_event(skt, event);
mutex_lock(&s->ops_mutex); mutex_lock(&s->ops_mutex);
...@@ -1273,10 +1263,8 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) ...@@ -1273,10 +1263,8 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
break; break;
case CS_EVENT_CARD_INSERTION: case CS_EVENT_CARD_INSERTION:
spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
s->pcmcia_state.present = 1;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
mutex_lock(&s->ops_mutex); mutex_lock(&s->ops_mutex);
s->pcmcia_state.present = 1;
destroy_cis_cache(s); /* to be on the safe side... */ destroy_cis_cache(s); /* to be on the safe side... */
mutex_unlock(&s->ops_mutex); mutex_unlock(&s->ops_mutex);
pcmcia_card_add(skt); pcmcia_card_add(skt);
...@@ -1321,13 +1309,12 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) ...@@ -1321,13 +1309,12 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev)
{ {
struct pcmcia_device *p_dev; struct pcmcia_device *p_dev;
struct pcmcia_device *ret = NULL; struct pcmcia_device *ret = NULL;
unsigned long flags;
p_dev = pcmcia_get_dev(_p_dev); p_dev = pcmcia_get_dev(_p_dev);
if (!p_dev) if (!p_dev)
return NULL; return NULL;
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&p_dev->socket->ops_mutex);
if (!p_dev->socket->pcmcia_state.present) if (!p_dev->socket->pcmcia_state.present)
goto out; goto out;
...@@ -1342,7 +1329,7 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev) ...@@ -1342,7 +1329,7 @@ struct pcmcia_device *pcmcia_dev_present(struct pcmcia_device *_p_dev)
ret = p_dev; ret = p_dev;
out: out:
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&p_dev->socket->ops_mutex);
pcmcia_put_dev(p_dev); pcmcia_put_dev(p_dev);
return ret; return ret;
} }
...@@ -1406,14 +1393,13 @@ static void pcmcia_bus_remove_socket(struct device *dev, ...@@ -1406,14 +1393,13 @@ static void pcmcia_bus_remove_socket(struct device *dev,
struct class_interface *class_intf) struct class_interface *class_intf)
{ {
struct pcmcia_socket *socket = dev_get_drvdata(dev); struct pcmcia_socket *socket = dev_get_drvdata(dev);
unsigned long flags;
if (!socket) if (!socket)
return; return;
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&socket->ops_mutex);
socket->pcmcia_state.dead = 1; socket->pcmcia_state.dead = 1;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&socket->ops_mutex);
pccard_register_pcmcia(socket, NULL); pccard_register_pcmcia(socket, NULL);
...@@ -1455,8 +1441,6 @@ static int __init init_pcmcia_bus(void) ...@@ -1455,8 +1441,6 @@ static int __init init_pcmcia_bus(void)
{ {
int ret; int ret;
spin_lock_init(&pcmcia_dev_list_lock);
ret = bus_register(&pcmcia_bus_type); ret = bus_register(&pcmcia_bus_type);
if (ret < 0) { if (ret < 0) {
printk(KERN_WARNING "pcmcia: bus_register error: %d\n", ret); printk(KERN_WARNING "pcmcia: bus_register error: %d\n", ret);
......
...@@ -62,16 +62,15 @@ static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s, ...@@ -62,16 +62,15 @@ static struct pcmcia_device *get_pcmcia_device(struct pcmcia_socket *s,
unsigned int function) unsigned int function)
{ {
struct pcmcia_device *p_dev = NULL; struct pcmcia_device *p_dev = NULL;
unsigned long flags;
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
if (p_dev->func == function) { if (p_dev->func == function) {
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
return pcmcia_get_dev(p_dev); return pcmcia_get_dev(p_dev);
} }
} }
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
return NULL; return NULL;
} }
...@@ -169,7 +168,6 @@ static int pcmcia_adjust_resource_info(adjust_t *adj) ...@@ -169,7 +168,6 @@ static int pcmcia_adjust_resource_info(adjust_t *adj)
{ {
struct pcmcia_socket *s; struct pcmcia_socket *s;
int ret = -ENOSYS; int ret = -ENOSYS;
unsigned long flags;
down_read(&pcmcia_socket_list_rwsem); down_read(&pcmcia_socket_list_rwsem);
list_for_each_entry(s, &pcmcia_socket_list, socket_list) { list_for_each_entry(s, &pcmcia_socket_list, socket_list) {
...@@ -182,14 +180,14 @@ static int pcmcia_adjust_resource_info(adjust_t *adj) ...@@ -182,14 +180,14 @@ static int pcmcia_adjust_resource_info(adjust_t *adj)
/* you can't use the old interface if the new /* you can't use the old interface if the new
* one was used before */ * one was used before */
spin_lock_irqsave(&s->lock, flags); mutex_lock(&s->ops_mutex);
if ((s->resource_setup_new) && if ((s->resource_setup_new) &&
!(s->resource_setup_old)) { !(s->resource_setup_old)) {
spin_unlock_irqrestore(&s->lock, flags); mutex_unlock(&s->ops_mutex);
continue; continue;
} else if (!(s->resource_setup_old)) } else if (!(s->resource_setup_old))
s->resource_setup_old = 1; s->resource_setup_old = 1;
spin_unlock_irqrestore(&s->lock, flags); mutex_unlock(&s->ops_mutex);
switch (adj->Resource) { switch (adj->Resource) {
case RES_MEMORY_RANGE: case RES_MEMORY_RANGE:
...@@ -208,9 +206,9 @@ static int pcmcia_adjust_resource_info(adjust_t *adj) ...@@ -208,9 +206,9 @@ static int pcmcia_adjust_resource_info(adjust_t *adj)
* last call to adjust_resource_info, we * last call to adjust_resource_info, we
* always need to assume this is the latest * always need to assume this is the latest
* one... */ * one... */
spin_lock_irqsave(&s->lock, flags); mutex_lock(&s->ops_mutex);
s->resource_setup_done = 1; s->resource_setup_done = 1;
spin_unlock_irqrestore(&s->lock, flags); mutex_unlock(&s->ops_mutex);
} }
} }
} }
...@@ -470,7 +468,6 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) ...@@ -470,7 +468,6 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info)
struct pcmcia_driver *p_drv; struct pcmcia_driver *p_drv;
struct pcmcia_device *p_dev; struct pcmcia_device *p_dev;
int ret = 0; int ret = 0;
unsigned long flags;
s = pcmcia_get_socket(s); s = pcmcia_get_socket(s);
if (!s) if (!s)
...@@ -490,7 +487,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) ...@@ -490,7 +487,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info)
goto err_put_driver; goto err_put_driver;
} }
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
if (p_dev->func == bind_info->function) { if (p_dev->func == bind_info->function) {
if ((p_dev->dev.driver == &p_drv->drv)) { 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,7 +496,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info)
* registered, and it was registered * registered, and it was registered
* by userspace before, we need to * by userspace before, we need to
* return the "instance". */ * return the "instance". */
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
bind_info->instance = p_dev; bind_info->instance = p_dev;
ret = -EBUSY; ret = -EBUSY;
goto err_put_module; goto err_put_module;
...@@ -507,7 +504,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) ...@@ -507,7 +504,7 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info)
/* the correct driver managed to bind /* the correct driver managed to bind
* itself magically to the correct * itself magically to the correct
* device. */ * device. */
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
p_dev->cardmgr = p_drv; p_dev->cardmgr = p_drv;
ret = 0; ret = 0;
goto err_put_module; goto err_put_module;
...@@ -516,12 +513,12 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) ...@@ -516,12 +513,12 @@ static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info)
/* there's already a device available where /* there's already a device available where
* no device has been bound to yet. So we don't * no device has been bound to yet. So we don't
* need to register a device! */ * need to register a device! */
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
goto rescan; goto rescan;
} }
} }
} }
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
p_dev = pcmcia_device_add(s, bind_info->function); p_dev = pcmcia_device_add(s, bind_info->function);
if (!p_dev) { if (!p_dev) {
...@@ -578,7 +575,6 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int ...@@ -578,7 +575,6 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
dev_node_t *node; dev_node_t *node;
struct pcmcia_device *p_dev; struct pcmcia_device *p_dev;
struct pcmcia_driver *p_drv; struct pcmcia_driver *p_drv;
unsigned long flags;
int ret = 0; int ret = 0;
#ifdef CONFIG_CARDBUS #ifdef CONFIG_CARDBUS
...@@ -617,7 +613,7 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int ...@@ -617,7 +613,7 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
} }
#endif #endif
spin_lock_irqsave(&pcmcia_dev_list_lock, flags); mutex_lock(&s->ops_mutex);
list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
if (p_dev->func == bind_info->function) { if (p_dev->func == bind_info->function) {
p_dev = pcmcia_get_dev(p_dev); 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,11 +622,11 @@ static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int
goto found; goto found;
} }
} }
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
return -ENODEV; return -ENODEV;
found: found:
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); mutex_unlock(&s->ops_mutex);
p_drv = to_pcmcia_drv(p_dev->dev.driver); p_drv = to_pcmcia_drv(p_dev->dev.driver);
if (p_drv && !p_dev->_locked) { if (p_drv && !p_dev->_locked) {
......
...@@ -23,14 +23,12 @@ ...@@ -23,14 +23,12 @@
static int static_init(struct pcmcia_socket *s) static int static_init(struct pcmcia_socket *s)
{ {
unsigned long flags;
/* the good thing about SS_CAP_STATIC_MAP sockets is /* the good thing about SS_CAP_STATIC_MAP sockets is
* that they don't need a resource database */ * that they don't need a resource database */
spin_lock_irqsave(&s->lock, flags); mutex_lock(&s->ops_mutex);
s->resource_setup_done = 1; s->resource_setup_done = 1;
spin_unlock_irqrestore(&s->lock, flags); mutex_unlock(&s->ops_mutex);
return 0; return 0;
} }
......
...@@ -189,16 +189,15 @@ static ssize_t pccard_store_resource(struct device *dev, ...@@ -189,16 +189,15 @@ static ssize_t pccard_store_resource(struct device *dev,
struct device_attribute *attr, struct device_attribute *attr,
const char *buf, size_t count) const char *buf, size_t count)
{ {
unsigned long flags;
struct pcmcia_socket *s = to_socket(dev); struct pcmcia_socket *s = to_socket(dev);
if (!count) if (!count)
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&s->lock, flags); mutex_lock(&s->ops_mutex);
if (!s->resource_setup_done) if (!s->resource_setup_done)
s->resource_setup_done = 1; s->resource_setup_done = 1;
spin_unlock_irqrestore(&s->lock, flags); mutex_unlock(&s->ops_mutex);
mutex_lock(&s->skt_mutex); mutex_lock(&s->skt_mutex);
if ((s->callback) && if ((s->callback) &&
......
...@@ -134,7 +134,6 @@ struct pccard_operations { ...@@ -134,7 +134,6 @@ struct pccard_operations {
struct pcmcia_socket { struct pcmcia_socket {
struct module *owner; struct module *owner;
spinlock_t lock;
socket_state_t socket; socket_state_t socket;
u_int state; u_int state;
u_int suspended_state; /* state before suspend */ u_int suspended_state; /* state before suspend */
...@@ -201,10 +200,12 @@ struct pcmcia_socket { ...@@ -201,10 +200,12 @@ struct pcmcia_socket {
struct task_struct *thread; struct task_struct *thread;
struct completion thread_done; struct completion thread_done;
unsigned int thread_events; unsigned int thread_events;
/* protects socket h/w state */
/* For the non-trivial interaction between these locks,
* see Documentation/pcmcia/locking.txt */
struct mutex skt_mutex; struct mutex skt_mutex;
/* protects PCMCIA state */
struct mutex ops_mutex; struct mutex ops_mutex;
/* protects thread_events */ /* protects thread_events */
spinlock_t thread_lock; spinlock_t thread_lock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment