aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/ds.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-12-06 10:01:18 -0500
committerDavid Howells <dhowells@warthog.cambridge.redhat.com>2006-12-06 10:01:18 -0500
commit4796b71fbb907ce6b8a9acf1852d3646a80b4576 (patch)
tree6263f165446c581efdbb760205c1f85378fe6259 /drivers/pcmcia/ds.c
parent6d5aefb8eaa38e44b5b8cf60c812aceafc02d924 (diff)
parentec0bf39a471bf6fcd01def2bd677128cea940b73 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: drivers/pcmcia/ds.c Fix up merge failures with Linus's head and fix new compile failures. Signed-Off-By: David Howells <dhowells@redhat.com>
Diffstat (limited to 'drivers/pcmcia/ds.c')
-rw-r--r--drivers/pcmcia/ds.c271
1 files changed, 187 insertions, 84 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index ff14fd8f0cd1..7355eb455a88 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -231,65 +231,6 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
231} 231}
232 232
233 233
234#ifdef CONFIG_PCMCIA_LOAD_CIS
235
236/**
237 * pcmcia_load_firmware - load CIS from userspace if device-provided is broken
238 * @dev - the pcmcia device which needs a CIS override
239 * @filename - requested filename in /lib/firmware/
240 *
241 * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if
242 * the one provided by the card is broken. The firmware files reside in
243 * /lib/firmware/ in userspace.
244 */
245static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
246{
247 struct pcmcia_socket *s = dev->socket;
248 const struct firmware *fw;
249 char path[20];
250 int ret=-ENOMEM;
251 cisdump_t *cis;
252
253 if (!filename)
254 return -EINVAL;
255
256 ds_dbg(1, "trying to load firmware %s\n", filename);
257
258 if (strlen(filename) > 14)
259 return -EINVAL;
260
261 snprintf(path, 20, "%s", filename);
262
263 if (request_firmware(&fw, path, &dev->dev) == 0) {
264 if (fw->size >= CISTPL_MAX_CIS_SIZE)
265 goto release;
266
267 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
268 if (!cis)
269 goto release;
270
271 cis->Length = fw->size + 1;
272 memcpy(cis->Data, fw->data, fw->size);
273
274 if (!pcmcia_replace_cis(s, cis))
275 ret = 0;
276 }
277 release:
278 release_firmware(fw);
279
280 return (ret);
281}
282
283#else /* !CONFIG_PCMCIA_LOAD_CIS */
284
285static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
286{
287 return -ENODEV;
288}
289
290#endif
291
292
293/*======================================================================*/ 234/*======================================================================*/
294 235
295 236
@@ -309,6 +250,8 @@ int pcmcia_register_driver(struct pcmcia_driver *driver)
309 driver->drv.bus = &pcmcia_bus_type; 250 driver->drv.bus = &pcmcia_bus_type;
310 driver->drv.owner = driver->owner; 251 driver->drv.owner = driver->owner;
311 252
253 ds_dbg(3, "registering driver %s\n", driver->drv.name);
254
312 return driver_register(&driver->drv); 255 return driver_register(&driver->drv);
313} 256}
314EXPORT_SYMBOL(pcmcia_register_driver); 257EXPORT_SYMBOL(pcmcia_register_driver);
@@ -318,6 +261,7 @@ EXPORT_SYMBOL(pcmcia_register_driver);
318 */ 261 */
319void pcmcia_unregister_driver(struct pcmcia_driver *driver) 262void pcmcia_unregister_driver(struct pcmcia_driver *driver)
320{ 263{
264 ds_dbg(3, "unregistering driver %s\n", driver->drv.name);
321 driver_unregister(&driver->drv); 265 driver_unregister(&driver->drv);
322} 266}
323EXPORT_SYMBOL(pcmcia_unregister_driver); 267EXPORT_SYMBOL(pcmcia_unregister_driver);
@@ -343,23 +287,27 @@ void pcmcia_put_dev(struct pcmcia_device *p_dev)
343static void pcmcia_release_function(struct kref *ref) 287static void pcmcia_release_function(struct kref *ref)
344{ 288{
345 struct config_t *c = container_of(ref, struct config_t, ref); 289 struct config_t *c = container_of(ref, struct config_t, ref);
290 ds_dbg(1, "releasing config_t\n");
346 kfree(c); 291 kfree(c);
347} 292}
348 293
349static void pcmcia_release_dev(struct device *dev) 294static void pcmcia_release_dev(struct device *dev)
350{ 295{
351 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 296 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
352 ds_dbg(1, "releasing dev %p\n", p_dev); 297 ds_dbg(1, "releasing device %s\n", p_dev->dev.bus_id);
353 pcmcia_put_socket(p_dev->socket); 298 pcmcia_put_socket(p_dev->socket);
354 kfree(p_dev->devname); 299 kfree(p_dev->devname);
355 kref_put(&p_dev->function_config->ref, pcmcia_release_function); 300 kref_put(&p_dev->function_config->ref, pcmcia_release_function);
356 kfree(p_dev); 301 kfree(p_dev);
357} 302}
358 303
359static void pcmcia_add_pseudo_device(struct pcmcia_socket *s) 304static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc)
360{ 305{
361 if (!s->pcmcia_state.device_add_pending) { 306 if (!s->pcmcia_state.device_add_pending) {
307 ds_dbg(1, "scheduling to add %s secondary"
308 " device to %d\n", mfc ? "mfc" : "pfc", s->sock);
362 s->pcmcia_state.device_add_pending = 1; 309 s->pcmcia_state.device_add_pending = 1;
310 s->pcmcia_state.mfc_pfc = mfc;
363 schedule_work(&s->device_add); 311 schedule_work(&s->device_add);
364 } 312 }
365 return; 313 return;
@@ -371,6 +319,7 @@ static int pcmcia_device_probe(struct device * dev)
371 struct pcmcia_driver *p_drv; 319 struct pcmcia_driver *p_drv;
372 struct pcmcia_device_id *did; 320 struct pcmcia_device_id *did;
373 struct pcmcia_socket *s; 321 struct pcmcia_socket *s;
322 cistpl_config_t cis_config;
374 int ret = 0; 323 int ret = 0;
375 324
376 dev = get_device(dev); 325 dev = get_device(dev);
@@ -381,15 +330,33 @@ static int pcmcia_device_probe(struct device * dev)
381 p_drv = to_pcmcia_drv(dev->driver); 330 p_drv = to_pcmcia_drv(dev->driver);
382 s = p_dev->socket; 331 s = p_dev->socket;
383 332
333 ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id,
334 p_drv->drv.name);
335
384 if ((!p_drv->probe) || (!p_dev->function_config) || 336 if ((!p_drv->probe) || (!p_dev->function_config) ||
385 (!try_module_get(p_drv->owner))) { 337 (!try_module_get(p_drv->owner))) {
386 ret = -EINVAL; 338 ret = -EINVAL;
387 goto put_dev; 339 goto put_dev;
388 } 340 }
389 341
342 /* set up some more device information */
343 ret = pccard_read_tuple(p_dev->socket, p_dev->func, CISTPL_CONFIG,
344 &cis_config);
345 if (!ret) {
346 p_dev->conf.ConfigBase = cis_config.base;
347 p_dev->conf.Present = cis_config.rmask[0];
348 } else {
349 printk(KERN_INFO "pcmcia: could not parse base and rmask0 of CIS\n");
350 p_dev->conf.ConfigBase = 0;
351 p_dev->conf.Present = 0;
352 }
353
390 ret = p_drv->probe(p_dev); 354 ret = p_drv->probe(p_dev);
391 if (ret) 355 if (ret) {
356 ds_dbg(1, "binding %s to %s failed with %d\n",
357 p_dev->dev.bus_id, p_drv->drv.name, ret);
392 goto put_module; 358 goto put_module;
359 }
393 360
394 /* handle pseudo multifunction devices: 361 /* handle pseudo multifunction devices:
395 * there are at most two pseudo multifunction devices. 362 * there are at most two pseudo multifunction devices.
@@ -400,7 +367,7 @@ static int pcmcia_device_probe(struct device * dev)
400 did = p_dev->dev.driver_data; 367 did = p_dev->dev.driver_data;
401 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && 368 if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) &&
402 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) 369 (p_dev->socket->device_count == 1) && (p_dev->device_no == 0))
403 pcmcia_add_pseudo_device(p_dev->socket); 370 pcmcia_add_device_later(p_dev->socket, 0);
404 371
405 put_module: 372 put_module:
406 if (ret) 373 if (ret)
@@ -421,8 +388,8 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
421 struct pcmcia_device *tmp; 388 struct pcmcia_device *tmp;
422 unsigned long flags; 389 unsigned long flags;
423 390
424 ds_dbg(2, "unbind_request(%d)\n", s->sock); 391 ds_dbg(2, "pcmcia_card_remove(%d) %s\n", s->sock,
425 392 leftover ? leftover->devname : "");
426 393
427 if (!leftover) 394 if (!leftover)
428 s->device_count = 0; 395 s->device_count = 0;
@@ -439,6 +406,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
439 p_dev->_removed=1; 406 p_dev->_removed=1;
440 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 407 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
441 408
409 ds_dbg(2, "unregistering device %s\n", p_dev->dev.bus_id);
442 device_unregister(&p_dev->dev); 410 device_unregister(&p_dev->dev);
443 } 411 }
444 412
@@ -455,6 +423,8 @@ static int pcmcia_device_remove(struct device * dev)
455 p_dev = to_pcmcia_dev(dev); 423 p_dev = to_pcmcia_dev(dev);
456 p_drv = to_pcmcia_drv(dev->driver); 424 p_drv = to_pcmcia_drv(dev->driver);
457 425
426 ds_dbg(1, "removing device %s\n", p_dev->dev.bus_id);
427
458 /* If we're removing the primary module driving a 428 /* If we're removing the primary module driving a
459 * pseudo multi-function card, we need to unbind 429 * pseudo multi-function card, we need to unbind
460 * all devices 430 * all devices
@@ -587,8 +557,10 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
587 557
588 mutex_lock(&device_add_lock); 558 mutex_lock(&device_add_lock);
589 559
590 /* max of 2 devices per card */ 560 ds_dbg(3, "adding device to %d, function %d\n", s->sock, function);
591 if (s->device_count == 2) 561
562 /* max of 4 devices per card */
563 if (s->device_count == 4)
592 goto err_put; 564 goto err_put;
593 565
594 p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL); 566 p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL);
@@ -598,8 +570,6 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
598 p_dev->socket = s; 570 p_dev->socket = s;
599 p_dev->device_no = (s->device_count++); 571 p_dev->device_no = (s->device_count++);
600 p_dev->func = function; 572 p_dev->func = function;
601 if (s->functions <= function)
602 s->functions = function + 1;
603 573
604 p_dev->dev.bus = &pcmcia_bus_type; 574 p_dev->dev.bus = &pcmcia_bus_type;
605 p_dev->dev.parent = s->dev.dev; 575 p_dev->dev.parent = s->dev.dev;
@@ -610,8 +580,8 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
610 if (!p_dev->devname) 580 if (!p_dev->devname)
611 goto err_free; 581 goto err_free;
612 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); 582 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id);
583 ds_dbg(3, "devname is %s\n", p_dev->devname);
613 584
614 /* compat */
615 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 585 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
616 586
617 /* 587 /*
@@ -631,6 +601,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
631 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 601 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
632 602
633 if (!p_dev->function_config) { 603 if (!p_dev->function_config) {
604 ds_dbg(3, "creating config_t for %s\n", p_dev->dev.bus_id);
634 p_dev->function_config = kzalloc(sizeof(struct config_t), 605 p_dev->function_config = kzalloc(sizeof(struct config_t),
635 GFP_KERNEL); 606 GFP_KERNEL);
636 if (!p_dev->function_config) 607 if (!p_dev->function_config)
@@ -674,11 +645,16 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
674 unsigned int no_funcs, i; 645 unsigned int no_funcs, i;
675 int ret = 0; 646 int ret = 0;
676 647
677 if (!(s->resource_setup_done)) 648 if (!(s->resource_setup_done)) {
649 ds_dbg(3, "no resources available, delaying card_add\n");
678 return -EAGAIN; /* try again, but later... */ 650 return -EAGAIN; /* try again, but later... */
651 }
679 652
680 if (pcmcia_validate_mem(s)) 653 if (pcmcia_validate_mem(s)) {
654 ds_dbg(3, "validating mem resources failed, "
655 "delaying card_add\n");
681 return -EAGAIN; /* try again, but later... */ 656 return -EAGAIN; /* try again, but later... */
657 }
682 658
683 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo); 659 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo);
684 if (ret || !cisinfo.Chains) { 660 if (ret || !cisinfo.Chains) {
@@ -690,6 +666,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
690 no_funcs = mfc.nfn; 666 no_funcs = mfc.nfn;
691 else 667 else
692 no_funcs = 1; 668 no_funcs = 1;
669 s->functions = no_funcs;
693 670
694 for (i=0; i < no_funcs; i++) 671 for (i=0; i < no_funcs; i++)
695 pcmcia_device_add(s, i); 672 pcmcia_device_add(s, i);
@@ -698,39 +675,50 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
698} 675}
699 676
700 677
701static void pcmcia_delayed_add_pseudo_device(struct work_struct *work) 678static void pcmcia_delayed_add_device(struct work_struct *work)
702{ 679{
703 struct pcmcia_socket *s = 680 struct pcmcia_socket *s =
704 container_of(work, struct pcmcia_socket, device_add); 681 container_of(work, struct pcmcia_socket, device_add);
705 pcmcia_device_add(s, 0); 682 ds_dbg(1, "adding additional device to %d\n", s->sock);
683 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc);
706 s->pcmcia_state.device_add_pending = 0; 684 s->pcmcia_state.device_add_pending = 0;
685 s->pcmcia_state.mfc_pfc = 0;
707} 686}
708 687
709static int pcmcia_requery(struct device *dev, void * _data) 688static int pcmcia_requery(struct device *dev, void * _data)
710{ 689{
711 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 690 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
712 if (!p_dev->dev.driver) 691 if (!p_dev->dev.driver) {
692 ds_dbg(1, "update device information for %s\n",
693 p_dev->dev.bus_id);
713 pcmcia_device_query(p_dev); 694 pcmcia_device_query(p_dev);
695 }
714 696
715 return 0; 697 return 0;
716} 698}
717 699
718static void pcmcia_bus_rescan(struct pcmcia_socket *skt) 700static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis)
719{ 701{
720 int no_devices=0; 702 int no_devices = 0;
721 int ret = 0; 703 int ret = 0;
722 unsigned long flags; 704 unsigned long flags;
723 705
724 /* must be called with skt_mutex held */ 706 /* must be called with skt_mutex held */
707 ds_dbg(0, "re-scanning socket %d\n", skt->sock);
708
725 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 709 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
726 if (list_empty(&skt->devices_list)) 710 if (list_empty(&skt->devices_list))
727 no_devices=1; 711 no_devices = 1;
728 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 712 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
729 713
714 /* If this is because of a CIS override, start over */
715 if (new_cis && !no_devices)
716 pcmcia_card_remove(skt, NULL);
717
730 /* if no devices were added for this socket yet because of 718 /* if no devices were added for this socket yet because of
731 * missing resource information or other trouble, we need to 719 * missing resource information or other trouble, we need to
732 * do this now. */ 720 * do this now. */
733 if (no_devices) { 721 if (no_devices || new_cis) {
734 ret = pcmcia_card_add(skt); 722 ret = pcmcia_card_add(skt);
735 if (ret) 723 if (ret)
736 return; 724 return;
@@ -748,6 +736,97 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
748 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n"); 736 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n");
749} 737}
750 738
739#ifdef CONFIG_PCMCIA_LOAD_CIS
740
741/**
742 * pcmcia_load_firmware - load CIS from userspace if device-provided is broken
743 * @dev - the pcmcia device which needs a CIS override
744 * @filename - requested filename in /lib/firmware/
745 *
746 * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if
747 * the one provided by the card is broken. The firmware files reside in
748 * /lib/firmware/ in userspace.
749 */
750static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
751{
752 struct pcmcia_socket *s = dev->socket;
753 const struct firmware *fw;
754 char path[20];
755 int ret = -ENOMEM;
756 int no_funcs;
757 int old_funcs;
758 cisdump_t *cis;
759 cistpl_longlink_mfc_t mfc;
760
761 if (!filename)
762 return -EINVAL;
763
764 ds_dbg(1, "trying to load CIS file %s\n", filename);
765
766 if (strlen(filename) > 14) {
767 printk(KERN_WARNING "pcmcia: CIS filename is too long\n");
768 return -EINVAL;
769 }
770
771 snprintf(path, 20, "%s", filename);
772
773 if (request_firmware(&fw, path, &dev->dev) == 0) {
774 if (fw->size >= CISTPL_MAX_CIS_SIZE) {
775 ret = -EINVAL;
776 printk(KERN_ERR "pcmcia: CIS override is too big\n");
777 goto release;
778 }
779
780 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
781 if (!cis) {
782 ret = -ENOMEM;
783 goto release;
784 }
785
786 cis->Length = fw->size + 1;
787 memcpy(cis->Data, fw->data, fw->size);
788
789 if (!pcmcia_replace_cis(s, cis))
790 ret = 0;
791 else {
792 printk(KERN_ERR "pcmcia: CIS override failed\n");
793 goto release;
794 }
795
796
797 /* update information */
798 pcmcia_device_query(dev);
799
800 /* does this cis override add or remove functions? */
801 old_funcs = s->functions;
802
803 if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, &mfc))
804 no_funcs = mfc.nfn;
805 else
806 no_funcs = 1;
807 s->functions = no_funcs;
808
809 if (old_funcs > no_funcs)
810 pcmcia_card_remove(s, dev);
811 else if (no_funcs > old_funcs)
812 pcmcia_add_device_later(s, 1);
813 }
814 release:
815 release_firmware(fw);
816
817 return (ret);
818}
819
820#else /* !CONFIG_PCMCIA_LOAD_CIS */
821
822static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
823{
824 return -ENODEV;
825}
826
827#endif
828
829
751static inline int pcmcia_devmatch(struct pcmcia_device *dev, 830static inline int pcmcia_devmatch(struct pcmcia_device *dev,
752 struct pcmcia_device_id *did) 831 struct pcmcia_device_id *did)
753{ 832{
@@ -814,11 +893,14 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
814 * after it has re-checked that there is no possible module 893 * after it has re-checked that there is no possible module
815 * with a prod_id/manf_id/card_id match. 894 * with a prod_id/manf_id/card_id match.
816 */ 895 */
896 ds_dbg(0, "skipping FUNC_ID match for %s until userspace "
897 "interaction\n", dev->dev.bus_id);
817 if (!dev->allow_func_id_match) 898 if (!dev->allow_func_id_match)
818 return 0; 899 return 0;
819 } 900 }
820 901
821 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 902 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) {
903 ds_dbg(0, "device %s needs a fake CIS\n", dev->dev.bus_id);
822 if (!dev->socket->fake_cis) 904 if (!dev->socket->fake_cis)
823 pcmcia_load_firmware(dev, did->cisfile); 905 pcmcia_load_firmware(dev, did->cisfile);
824 906
@@ -848,13 +930,21 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
848 930
849#ifdef CONFIG_PCMCIA_IOCTL 931#ifdef CONFIG_PCMCIA_IOCTL
850 /* matching by cardmgr */ 932 /* matching by cardmgr */
851 if (p_dev->cardmgr == p_drv) 933 if (p_dev->cardmgr == p_drv) {
934 ds_dbg(0, "cardmgr matched %s to %s\n", dev->bus_id,
935 drv->name);
852 return 1; 936 return 1;
937 }
853#endif 938#endif
854 939
855 while (did && did->match_flags) { 940 while (did && did->match_flags) {
856 if (pcmcia_devmatch(p_dev, did)) 941 ds_dbg(3, "trying to match %s to %s\n", dev->bus_id,
942 drv->name);
943 if (pcmcia_devmatch(p_dev, did)) {
944 ds_dbg(0, "matched %s to %s\n", dev->bus_id,
945 drv->name);
857 return 1; 946 return 1;
947 }
858 did++; 948 did++;
859 } 949 }
860 950
@@ -1045,6 +1135,8 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1045 struct pcmcia_driver *p_drv = NULL; 1135 struct pcmcia_driver *p_drv = NULL;
1046 int ret = 0; 1136 int ret = 0;
1047 1137
1138 ds_dbg(2, "suspending %s\n", dev->bus_id);
1139
1048 if (dev->driver) 1140 if (dev->driver)
1049 p_drv = to_pcmcia_drv(dev->driver); 1141 p_drv = to_pcmcia_drv(dev->driver);
1050 1142
@@ -1053,12 +1145,18 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1053 1145
1054 if (p_drv->suspend) { 1146 if (p_drv->suspend) {
1055 ret = p_drv->suspend(p_dev); 1147 ret = p_drv->suspend(p_dev);
1056 if (ret) 1148 if (ret) {
1149 printk(KERN_ERR "pcmcia: device %s (driver %s) did "
1150 "not want to go to sleep (%d)\n",
1151 p_dev->devname, p_drv->drv.name, ret);
1057 goto out; 1152 goto out;
1153 }
1058 } 1154 }
1059 1155
1060 if (p_dev->device_no == p_dev->func) 1156 if (p_dev->device_no == p_dev->func) {
1157 ds_dbg(2, "releasing configuration for %s\n", dev->bus_id);
1061 pcmcia_release_configuration(p_dev); 1158 pcmcia_release_configuration(p_dev);
1159 }
1062 1160
1063 out: 1161 out:
1064 if (!ret) 1162 if (!ret)
@@ -1073,6 +1171,8 @@ static int pcmcia_dev_resume(struct device * dev)
1073 struct pcmcia_driver *p_drv = NULL; 1171 struct pcmcia_driver *p_drv = NULL;
1074 int ret = 0; 1172 int ret = 0;
1075 1173
1174 ds_dbg(2, "resuming %s\n", dev->bus_id);
1175
1076 if (dev->driver) 1176 if (dev->driver)
1077 p_drv = to_pcmcia_drv(dev->driver); 1177 p_drv = to_pcmcia_drv(dev->driver);
1078 1178
@@ -1080,6 +1180,7 @@ static int pcmcia_dev_resume(struct device * dev)
1080 goto out; 1180 goto out;
1081 1181
1082 if (p_dev->device_no == p_dev->func) { 1182 if (p_dev->device_no == p_dev->func) {
1183 ds_dbg(2, "requesting configuration for %s\n", dev->bus_id);
1083 ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1184 ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
1084 if (ret) 1185 if (ret)
1085 goto out; 1186 goto out;
@@ -1121,12 +1222,14 @@ static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
1121 1222
1122static int pcmcia_bus_resume(struct pcmcia_socket *skt) 1223static int pcmcia_bus_resume(struct pcmcia_socket *skt)
1123{ 1224{
1225 ds_dbg(2, "resuming socket %d\n", skt->sock);
1124 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); 1226 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback);
1125 return 0; 1227 return 0;
1126} 1228}
1127 1229
1128static int pcmcia_bus_suspend(struct pcmcia_socket *skt) 1230static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
1129{ 1231{
1232 ds_dbg(2, "suspending socket %d\n", skt->sock);
1130 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, 1233 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt,
1131 pcmcia_bus_suspend_callback)) { 1234 pcmcia_bus_suspend_callback)) {
1132 pcmcia_bus_resume(skt); 1235 pcmcia_bus_resume(skt);
@@ -1247,7 +1350,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
1247 init_waitqueue_head(&socket->queue); 1350 init_waitqueue_head(&socket->queue);
1248#endif 1351#endif
1249 INIT_LIST_HEAD(&socket->devices_list); 1352 INIT_LIST_HEAD(&socket->devices_list);
1250 INIT_WORK(&socket->device_add, pcmcia_delayed_add_pseudo_device); 1353 INIT_WORK(&socket->device_add, pcmcia_delayed_add_device);
1251 memset(&socket->pcmcia_state, 0, sizeof(u8)); 1354 memset(&socket->pcmcia_state, 0, sizeof(u8));
1252 socket->device_count = 0; 1355 socket->device_count = 0;
1253 1356