aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/ds.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.osdl.org>2006-12-05 18:52:06 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-05 18:52:06 -0500
commitbf83c2a315637dee8a8b5c2221ce5030cc38c6db (patch)
treefb477f3affea75fcc79fa9d7006415576f79aadb /drivers/pcmcia/ds.c
parente62438630ca37539c8cc1553710bbfaa3cf960a7 (diff)
parent40a0017eb89c4c5a4bf81523edd867d730c9f143 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: [PATCH] pcmcia: at91_cf update [PATCH] pcmcia: fix m32r_cfc.c compilation [PATCH] pcmcia: ds.c debug enhancements [PATCH] pcmcia: at91_cf update [PATCH] pcmcia: conf.ConfigBase and conf.Present consolidation [PATCH] pcmcia: remove prod_id indirection [PATCH] pcmcia: remove manf_id and card_id indirection [PATCH] pcmcia: IDs for Elan serial PCMCIA devcies [PATCH] pcmcia: allow for four multifunction subdevices [PATCH] pcmcia: handle __copy_from_user() return value in ioctl [PATCH] pcmcia: multifunction card handling fixes [PATCH] pcmcia: allow shared IRQs on pd6729 sockets [PATCH] pcmcia: start over after CIS override [PATCH] cm4000_cs: fix return value check [PATCH] pcmcia: yet another IDE ID [PATCH] pcmcia: Add an id to ide-cs.c
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 21d83a895b21..45df12eda3c5 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,38 +675,49 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
698} 675}
699 676
700 677
701static void pcmcia_delayed_add_pseudo_device(void *data) 678static void pcmcia_delayed_add_device(void *data)
702{ 679{
703 struct pcmcia_socket *s = data; 680 struct pcmcia_socket *s = data;
704 pcmcia_device_add(s, 0); 681 ds_dbg(1, "adding additional device to %d\n", s->sock);
682 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc);
705 s->pcmcia_state.device_add_pending = 0; 683 s->pcmcia_state.device_add_pending = 0;
684 s->pcmcia_state.mfc_pfc = 0;
706} 685}
707 686
708static int pcmcia_requery(struct device *dev, void * _data) 687static int pcmcia_requery(struct device *dev, void * _data)
709{ 688{
710 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 689 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
711 if (!p_dev->dev.driver) 690 if (!p_dev->dev.driver) {
691 ds_dbg(1, "update device information for %s\n",
692 p_dev->dev.bus_id);
712 pcmcia_device_query(p_dev); 693 pcmcia_device_query(p_dev);
694 }
713 695
714 return 0; 696 return 0;
715} 697}
716 698
717static void pcmcia_bus_rescan(struct pcmcia_socket *skt) 699static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis)
718{ 700{
719 int no_devices=0; 701 int no_devices = 0;
720 int ret = 0; 702 int ret = 0;
721 unsigned long flags; 703 unsigned long flags;
722 704
723 /* must be called with skt_mutex held */ 705 /* must be called with skt_mutex held */
706 ds_dbg(0, "re-scanning socket %d\n", skt->sock);
707
724 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 708 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
725 if (list_empty(&skt->devices_list)) 709 if (list_empty(&skt->devices_list))
726 no_devices=1; 710 no_devices = 1;
727 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 711 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
728 712
713 /* If this is because of a CIS override, start over */
714 if (new_cis && !no_devices)
715 pcmcia_card_remove(skt, NULL);
716
729 /* if no devices were added for this socket yet because of 717 /* if no devices were added for this socket yet because of
730 * missing resource information or other trouble, we need to 718 * missing resource information or other trouble, we need to
731 * do this now. */ 719 * do this now. */
732 if (no_devices) { 720 if (no_devices || new_cis) {
733 ret = pcmcia_card_add(skt); 721 ret = pcmcia_card_add(skt);
734 if (ret) 722 if (ret)
735 return; 723 return;
@@ -747,6 +735,97 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt)
747 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n"); 735 printk(KERN_INFO "pcmcia: bus_rescan_devices failed\n");
748} 736}
749 737
738#ifdef CONFIG_PCMCIA_LOAD_CIS
739
740/**
741 * pcmcia_load_firmware - load CIS from userspace if device-provided is broken
742 * @dev - the pcmcia device which needs a CIS override
743 * @filename - requested filename in /lib/firmware/
744 *
745 * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if
746 * the one provided by the card is broken. The firmware files reside in
747 * /lib/firmware/ in userspace.
748 */
749static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
750{
751 struct pcmcia_socket *s = dev->socket;
752 const struct firmware *fw;
753 char path[20];
754 int ret = -ENOMEM;
755 int no_funcs;
756 int old_funcs;
757 cisdump_t *cis;
758 cistpl_longlink_mfc_t mfc;
759
760 if (!filename)
761 return -EINVAL;
762
763 ds_dbg(1, "trying to load CIS file %s\n", filename);
764
765 if (strlen(filename) > 14) {
766 printk(KERN_WARNING "pcmcia: CIS filename is too long\n");
767 return -EINVAL;
768 }
769
770 snprintf(path, 20, "%s", filename);
771
772 if (request_firmware(&fw, path, &dev->dev) == 0) {
773 if (fw->size >= CISTPL_MAX_CIS_SIZE) {
774 ret = -EINVAL;
775 printk(KERN_ERR "pcmcia: CIS override is too big\n");
776 goto release;
777 }
778
779 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
780 if (!cis) {
781 ret = -ENOMEM;
782 goto release;
783 }
784
785 cis->Length = fw->size + 1;
786 memcpy(cis->Data, fw->data, fw->size);
787
788 if (!pcmcia_replace_cis(s, cis))
789 ret = 0;
790 else {
791 printk(KERN_ERR "pcmcia: CIS override failed\n");
792 goto release;
793 }
794
795
796 /* update information */
797 pcmcia_device_query(dev);
798
799 /* does this cis override add or remove functions? */
800 old_funcs = s->functions;
801
802 if (!pccard_read_tuple(s, BIND_FN_ALL, CISTPL_LONGLINK_MFC, &mfc))
803 no_funcs = mfc.nfn;
804 else
805 no_funcs = 1;
806 s->functions = no_funcs;
807
808 if (old_funcs > no_funcs)
809 pcmcia_card_remove(s, dev);
810 else if (no_funcs > old_funcs)
811 pcmcia_add_device_later(s, 1);
812 }
813 release:
814 release_firmware(fw);
815
816 return (ret);
817}
818
819#else /* !CONFIG_PCMCIA_LOAD_CIS */
820
821static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
822{
823 return -ENODEV;
824}
825
826#endif
827
828
750static inline int pcmcia_devmatch(struct pcmcia_device *dev, 829static inline int pcmcia_devmatch(struct pcmcia_device *dev,
751 struct pcmcia_device_id *did) 830 struct pcmcia_device_id *did)
752{ 831{
@@ -813,11 +892,14 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
813 * after it has re-checked that there is no possible module 892 * after it has re-checked that there is no possible module
814 * with a prod_id/manf_id/card_id match. 893 * with a prod_id/manf_id/card_id match.
815 */ 894 */
895 ds_dbg(0, "skipping FUNC_ID match for %s until userspace "
896 "interaction\n", dev->dev.bus_id);
816 if (!dev->allow_func_id_match) 897 if (!dev->allow_func_id_match)
817 return 0; 898 return 0;
818 } 899 }
819 900
820 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 901 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) {
902 ds_dbg(0, "device %s needs a fake CIS\n", dev->dev.bus_id);
821 if (!dev->socket->fake_cis) 903 if (!dev->socket->fake_cis)
822 pcmcia_load_firmware(dev, did->cisfile); 904 pcmcia_load_firmware(dev, did->cisfile);
823 905
@@ -847,13 +929,21 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
847 929
848#ifdef CONFIG_PCMCIA_IOCTL 930#ifdef CONFIG_PCMCIA_IOCTL
849 /* matching by cardmgr */ 931 /* matching by cardmgr */
850 if (p_dev->cardmgr == p_drv) 932 if (p_dev->cardmgr == p_drv) {
933 ds_dbg(0, "cardmgr matched %s to %s\n", dev->bus_id,
934 drv->name);
851 return 1; 935 return 1;
936 }
852#endif 937#endif
853 938
854 while (did && did->match_flags) { 939 while (did && did->match_flags) {
855 if (pcmcia_devmatch(p_dev, did)) 940 ds_dbg(3, "trying to match %s to %s\n", dev->bus_id,
941 drv->name);
942 if (pcmcia_devmatch(p_dev, did)) {
943 ds_dbg(0, "matched %s to %s\n", dev->bus_id,
944 drv->name);
856 return 1; 945 return 1;
946 }
857 did++; 947 did++;
858 } 948 }
859 949
@@ -1044,6 +1134,8 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1044 struct pcmcia_driver *p_drv = NULL; 1134 struct pcmcia_driver *p_drv = NULL;
1045 int ret = 0; 1135 int ret = 0;
1046 1136
1137 ds_dbg(2, "suspending %s\n", dev->bus_id);
1138
1047 if (dev->driver) 1139 if (dev->driver)
1048 p_drv = to_pcmcia_drv(dev->driver); 1140 p_drv = to_pcmcia_drv(dev->driver);
1049 1141
@@ -1052,12 +1144,18 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1052 1144
1053 if (p_drv->suspend) { 1145 if (p_drv->suspend) {
1054 ret = p_drv->suspend(p_dev); 1146 ret = p_drv->suspend(p_dev);
1055 if (ret) 1147 if (ret) {
1148 printk(KERN_ERR "pcmcia: device %s (driver %s) did "
1149 "not want to go to sleep (%d)\n",
1150 p_dev->devname, p_drv->drv.name, ret);
1056 goto out; 1151 goto out;
1152 }
1057 } 1153 }
1058 1154
1059 if (p_dev->device_no == p_dev->func) 1155 if (p_dev->device_no == p_dev->func) {
1156 ds_dbg(2, "releasing configuration for %s\n", dev->bus_id);
1060 pcmcia_release_configuration(p_dev); 1157 pcmcia_release_configuration(p_dev);
1158 }
1061 1159
1062 out: 1160 out:
1063 if (!ret) 1161 if (!ret)
@@ -1072,6 +1170,8 @@ static int pcmcia_dev_resume(struct device * dev)
1072 struct pcmcia_driver *p_drv = NULL; 1170 struct pcmcia_driver *p_drv = NULL;
1073 int ret = 0; 1171 int ret = 0;
1074 1172
1173 ds_dbg(2, "resuming %s\n", dev->bus_id);
1174
1075 if (dev->driver) 1175 if (dev->driver)
1076 p_drv = to_pcmcia_drv(dev->driver); 1176 p_drv = to_pcmcia_drv(dev->driver);
1077 1177
@@ -1079,6 +1179,7 @@ static int pcmcia_dev_resume(struct device * dev)
1079 goto out; 1179 goto out;
1080 1180
1081 if (p_dev->device_no == p_dev->func) { 1181 if (p_dev->device_no == p_dev->func) {
1182 ds_dbg(2, "requesting configuration for %s\n", dev->bus_id);
1082 ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1183 ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
1083 if (ret) 1184 if (ret)
1084 goto out; 1185 goto out;
@@ -1120,12 +1221,14 @@ static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
1120 1221
1121static int pcmcia_bus_resume(struct pcmcia_socket *skt) 1222static int pcmcia_bus_resume(struct pcmcia_socket *skt)
1122{ 1223{
1224 ds_dbg(2, "resuming socket %d\n", skt->sock);
1123 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); 1225 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback);
1124 return 0; 1226 return 0;
1125} 1227}
1126 1228
1127static int pcmcia_bus_suspend(struct pcmcia_socket *skt) 1229static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
1128{ 1230{
1231 ds_dbg(2, "suspending socket %d\n", skt->sock);
1129 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, 1232 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt,
1130 pcmcia_bus_suspend_callback)) { 1233 pcmcia_bus_suspend_callback)) {
1131 pcmcia_bus_resume(skt); 1234 pcmcia_bus_resume(skt);
@@ -1246,7 +1349,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
1246 init_waitqueue_head(&socket->queue); 1349 init_waitqueue_head(&socket->queue);
1247#endif 1350#endif
1248 INIT_LIST_HEAD(&socket->devices_list); 1351 INIT_LIST_HEAD(&socket->devices_list);
1249 INIT_WORK(&socket->device_add, pcmcia_delayed_add_pseudo_device, socket); 1352 INIT_WORK(&socket->device_add, pcmcia_delayed_add_device, socket);
1250 memset(&socket->pcmcia_state, 0, sizeof(u8)); 1353 memset(&socket->pcmcia_state, 0, sizeof(u8));
1251 socket->device_count = 0; 1354 socket->device_count = 0;
1252 1355