Commit e2f0b534 authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Linus Torvalds

[PATCH] pcmcia: rescan bus always upon echoing into setup_done

Always rescan the devices upon echo'ing something to
available_resources_setup_done.  This is needed for proper "coldplug" support.
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e94e15f7
...@@ -159,8 +159,7 @@ int pccard_access_configuration_register(struct pcmcia_socket *s, unsigned int f ...@@ -159,8 +159,7 @@ int pccard_access_configuration_register(struct pcmcia_socket *s, unsigned int f
struct pcmcia_callback{ struct pcmcia_callback{
struct module *owner; struct module *owner;
int (*event) (struct pcmcia_socket *s, event_t event, int priority); int (*event) (struct pcmcia_socket *s, event_t event, int priority);
int (*resources_done) (struct pcmcia_socket *s); void (*requery) (struct pcmcia_socket *s);
void (*replace_cis) (void);
}; };
int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
......
...@@ -717,9 +717,42 @@ static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s) ...@@ -717,9 +717,42 @@ static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s)
return; return;
} }
static void pcmcia_bus_rescan(void) static int pcmcia_requery(struct device *dev, void * _data)
{ {
struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
if (!p_dev->dev.driver)
pcmcia_device_query(p_dev);
return 0;
}
static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
{
int no_devices=0;
unsigned long flags;
/* must be called with skt_sem held */ /* must be called with skt_sem held */
spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
if (list_empty(&skt->pcmcia->devices_list))
no_devices=1;
spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
/* if no devices were added for this socket yet because of
* missing resource information or other trouble, we need to
* do this now. */
if (no_devices) {
int ret = pcmcia_card_add(skt);
if (ret)
return;
}
/* some device information might have changed because of a CIS
* update or because we can finally read it correctly... so
* determine it again, overwriting old values if necessary. */
bus_for_each_dev(&pcmcia_bus_type, NULL, NULL, pcmcia_requery);
/* we re-scan all devices, not just the ones connected to this
* socket. This does not matter, though. */
bus_rescan_devices(&pcmcia_bus_type); bus_rescan_devices(&pcmcia_bus_type);
} }
...@@ -1861,8 +1894,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) ...@@ -1861,8 +1894,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev)
/* Set up hotline to Card Services */ /* Set up hotline to Card Services */
s->callback.owner = THIS_MODULE; s->callback.owner = THIS_MODULE;
s->callback.event = &ds_event; s->callback.event = &ds_event;
s->callback.resources_done = &pcmcia_card_add; s->callback.requery = &pcmcia_bus_rescan;
s->callback.replace_cis = &pcmcia_bus_rescan;
socket->pcmcia = s; socket->pcmcia = s;
ret = pccard_register_pcmcia(socket, &s->callback); ret = pccard_register_pcmcia(socket, &s->callback);
......
...@@ -163,7 +163,7 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf, ...@@ -163,7 +163,7 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf,
return -EINVAL; return -EINVAL;
spin_lock_irqsave(&s->lock, flags); spin_lock_irqsave(&s->lock, flags);
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); spin_unlock_irqrestore(&s->lock, flags);
...@@ -172,16 +172,12 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf, ...@@ -172,16 +172,12 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf,
(s->state & SOCKET_PRESENT) && (s->state & SOCKET_PRESENT) &&
!(s->state & SOCKET_CARDBUS)) { !(s->state & SOCKET_CARDBUS)) {
if (try_module_get(s->callback->owner)) { if (try_module_get(s->callback->owner)) {
s->callback->resources_done(s); s->callback->requery(s);
module_put(s->callback->owner); module_put(s->callback->owner);
} }
} }
up(&s->skt_sem); up(&s->skt_sem);
return count;
}
spin_unlock_irqrestore(&s->lock, flags);
return count; return count;
} }
static CLASS_DEVICE_ATTR(available_resources_setup_done, 0600, pccard_show_resource, pccard_store_resource); static CLASS_DEVICE_ATTR(available_resources_setup_done, 0600, pccard_show_resource, pccard_store_resource);
...@@ -315,7 +311,7 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz ...@@ -315,7 +311,7 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
if ((s->callback) && (s->state & SOCKET_PRESENT) && if ((s->callback) && (s->state & SOCKET_PRESENT) &&
!(s->state & SOCKET_CARDBUS)) { !(s->state & SOCKET_CARDBUS)) {
if (try_module_get(s->callback->owner)) { if (try_module_get(s->callback->owner)) {
s->callback->replace_cis(); s->callback->requery(s);
module_put(s->callback->owner); module_put(s->callback->owner);
} }
} }
......
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