aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/ds.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:12:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 17:12:40 -0400
commit2be4ff2f084842839b041b793ed6237e8d1d315a (patch)
tree1d776ac1717edeff4ee7d59ab0aea2782cb86dba /drivers/pcmcia/ds.c
parentcf2fa66055d718ae13e62451bb546505f63906a2 (diff)
parenta45b3fb19ba1e4dfc3fc53563a072612092930a9 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia-2.6: (49 commits) pcmcia: ioctl-internal definitions pcmcia: cistpl header cleanup pcmcia: remove unused argument to pcmcia_parse_tuple() pcmcia: card services header cleanup pcmcia: device_id header cleanup pcmcia: encapsulate ioaddr_t pcmcia: cleanup device driver header file pcmcia: cleanup socket services header file pcmcia: merge ds_internal.h into cs_internal.h pcmcia: cleanup cs_internal.h pcmcia: cs_internal.h is internal pcmcia: use dev_printk for cs_error() pcmcia: remove CS_ error codes alltogether pcmcia: deprecate CS_BAD_TUPLE pcmcia: deprecate CS_BAD_ARGS pcmcia: deprecate CS_BAD_BASE, CS_BAD_IRQ, CS_BAD_OFFSET and CS_BAD_SIZE pcmcia: deprecate CS_BAD_ATTRIBUTE, CS_BAD_TYPE and CS_BAD_PAGE pcmcia: deprecate CS_NO_MORE_ITEMS pcmcia: deprecate CS_IN_USE pcmcia: deprecate CS_CONFIGURATION_LOCKED ... Fix trivial conflict in drivers/pcmcia/ds.c manually
Diffstat (limited to 'drivers/pcmcia/ds.c')
-rw-r--r--drivers/pcmcia/ds.c239
1 files changed, 101 insertions, 138 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 34c83d3ca0fa..795660255490 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -32,7 +32,6 @@
32#include <pcmcia/ss.h> 32#include <pcmcia/ss.h>
33 33
34#include "cs_internal.h" 34#include "cs_internal.h"
35#include "ds_internal.h"
36 35
37/*====================================================================*/ 36/*====================================================================*/
38 37
@@ -42,17 +41,22 @@ MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
42MODULE_DESCRIPTION("PCMCIA Driver Services"); 41MODULE_DESCRIPTION("PCMCIA Driver Services");
43MODULE_LICENSE("GPL"); 42MODULE_LICENSE("GPL");
44 43
45#ifdef DEBUG 44#ifdef CONFIG_PCMCIA_DEBUG
46int ds_pc_debug; 45int ds_pc_debug;
47 46
48module_param_named(pc_debug, ds_pc_debug, int, 0644); 47module_param_named(pc_debug, ds_pc_debug, int, 0644);
49 48
50#define ds_dbg(lvl, fmt, arg...) do { \ 49#define ds_dbg(lvl, fmt, arg...) do { \
51 if (ds_pc_debug > (lvl)) \ 50 if (ds_pc_debug > (lvl)) \
52 printk(KERN_DEBUG "ds: " fmt , ## arg); \ 51 printk(KERN_DEBUG "ds: " fmt , ## arg); \
53} while (0) 52} while (0)
53#define ds_dev_dbg(lvl, dev, fmt, arg...) do { \
54 if (ds_pc_debug > (lvl)) \
55 dev_printk(KERN_DEBUG, dev, "ds: " fmt , ## arg); \
56} while (0)
54#else 57#else
55#define ds_dbg(lvl, fmt, arg...) do { } while (0) 58#define ds_dbg(lvl, fmt, arg...) do { } while (0)
59#define ds_dev_dbg(lvl, dev, fmt, arg...) do { } while (0)
56#endif 60#endif
57 61
58spinlock_t pcmcia_dev_list_lock; 62spinlock_t pcmcia_dev_list_lock;
@@ -64,42 +68,19 @@ spinlock_t pcmcia_dev_list_lock;
64/* String tables for error messages */ 68/* String tables for error messages */
65 69
66typedef struct lookup_t { 70typedef struct lookup_t {
67 int key; 71 const int key;
68 char *msg; 72 const char *msg;
69} lookup_t; 73} lookup_t;
70 74
71static const lookup_t error_table[] = { 75static const lookup_t error_table[] = {
72 { CS_SUCCESS, "Operation succeeded" }, 76 { 0, "Operation succeeded" },
73 { CS_BAD_ADAPTER, "Bad adapter" }, 77 { -EIO, "Input/Output error" },
74 { CS_BAD_ATTRIBUTE, "Bad attribute", }, 78 { -ENODEV, "No card present" },
75 { CS_BAD_BASE, "Bad base address" }, 79 { -EINVAL, "Bad parameter" },
76 { CS_BAD_EDC, "Bad EDC" }, 80 { -EACCES, "Configuration locked" },
77 { CS_BAD_IRQ, "Bad IRQ" }, 81 { -EBUSY, "Resource in use" },
78 { CS_BAD_OFFSET, "Bad offset" }, 82 { -ENOSPC, "No more items" },
79 { CS_BAD_PAGE, "Bad page number" }, 83 { -ENOMEM, "Out of resource" },
80 { CS_READ_FAILURE, "Read failure" },
81 { CS_BAD_SIZE, "Bad size" },
82 { CS_BAD_SOCKET, "Bad socket" },
83 { CS_BAD_TYPE, "Bad type" },
84 { CS_BAD_VCC, "Bad Vcc" },
85 { CS_BAD_VPP, "Bad Vpp" },
86 { CS_BAD_WINDOW, "Bad window" },
87 { CS_WRITE_FAILURE, "Write failure" },
88 { CS_NO_CARD, "No card present" },
89 { CS_UNSUPPORTED_FUNCTION, "Usupported function" },
90 { CS_UNSUPPORTED_MODE, "Unsupported mode" },
91 { CS_BAD_SPEED, "Bad speed" },
92 { CS_BUSY, "Resource busy" },
93 { CS_GENERAL_FAILURE, "General failure" },
94 { CS_WRITE_PROTECTED, "Write protected" },
95 { CS_BAD_ARG_LENGTH, "Bad argument length" },
96 { CS_BAD_ARGS, "Bad arguments" },
97 { CS_CONFIGURATION_LOCKED, "Configuration locked" },
98 { CS_IN_USE, "Resource in use" },
99 { CS_NO_MORE_ITEMS, "No more items" },
100 { CS_OUT_OF_RESOURCE, "Out of resource" },
101 { CS_BAD_HANDLE, "Bad handle" },
102 { CS_BAD_TUPLE, "Bad CIS tuple" }
103}; 84};
104 85
105 86
@@ -155,46 +136,32 @@ static const lookup_t service_table[] = {
155 { ReplaceCIS, "ReplaceCIS" } 136 { ReplaceCIS, "ReplaceCIS" }
156}; 137};
157 138
158 139const char *pcmcia_error_func(int func)
159static int pcmcia_report_error(struct pcmcia_device *p_dev, error_info_t *err)
160{ 140{
161 int i; 141 int i;
162 char *serv;
163
164 if (!p_dev)
165 printk(KERN_NOTICE);
166 else
167 printk(KERN_NOTICE "%s: ", p_dev->dev.bus_id);
168 142
169 for (i = 0; i < ARRAY_SIZE(service_table); i++) 143 for (i = 0; i < ARRAY_SIZE(service_table); i++)
170 if (service_table[i].key == err->func) 144 if (service_table[i].key == func)
171 break; 145 return service_table[i].msg;
172 if (i < ARRAY_SIZE(service_table))
173 serv = service_table[i].msg;
174 else
175 serv = "Unknown service number";
176 146
177 for (i = 0; i < ARRAY_SIZE(error_table); i++) 147 return "Unknown service number";
178 if (error_table[i].key == err->retcode) 148}
179 break; 149EXPORT_SYMBOL(pcmcia_error_func);
180 if (i < ARRAY_SIZE(error_table))
181 printk("%s: %s\n", serv, error_table[i].msg);
182 else
183 printk("%s: Unknown error code %#x\n", serv, err->retcode);
184 150
185 return CS_SUCCESS; 151const char *pcmcia_error_ret(int ret)
186} /* report_error */ 152{
153 int i;
154
155 for (i = 0; i < ARRAY_SIZE(error_table); i++)
156 if (error_table[i].key == ret)
157 return error_table[i].msg;
187 158
188/* end of code which was in cs.c before */ 159 return "unknown";
160}
161EXPORT_SYMBOL(pcmcia_error_ret);
189 162
190/*======================================================================*/ 163/*======================================================================*/
191 164
192void cs_error(struct pcmcia_device *p_dev, int func, int ret)
193{
194 error_info_t err = { func, ret };
195 pcmcia_report_error(p_dev, &err);
196}
197EXPORT_SYMBOL(cs_error);
198 165
199 166
200static void pcmcia_check_driver(struct pcmcia_driver *p_drv) 167static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
@@ -391,7 +358,7 @@ static void pcmcia_release_function(struct kref *ref)
391static void pcmcia_release_dev(struct device *dev) 358static void pcmcia_release_dev(struct device *dev)
392{ 359{
393 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 360 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
394 ds_dbg(1, "releasing device %s\n", p_dev->dev.bus_id); 361 ds_dev_dbg(1, dev, "releasing device\n");
395 pcmcia_put_socket(p_dev->socket); 362 pcmcia_put_socket(p_dev->socket);
396 kfree(p_dev->devname); 363 kfree(p_dev->devname);
397 kref_put(&p_dev->function_config->ref, pcmcia_release_function); 364 kref_put(&p_dev->function_config->ref, pcmcia_release_function);
@@ -401,7 +368,7 @@ static void pcmcia_release_dev(struct device *dev)
401static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc) 368static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc)
402{ 369{
403 if (!s->pcmcia_state.device_add_pending) { 370 if (!s->pcmcia_state.device_add_pending) {
404 ds_dbg(1, "scheduling to add %s secondary" 371 ds_dev_dbg(1, &s->dev, "scheduling to add %s secondary"
405 " device to %d\n", mfc ? "mfc" : "pfc", s->sock); 372 " device to %d\n", mfc ? "mfc" : "pfc", s->sock);
406 s->pcmcia_state.device_add_pending = 1; 373 s->pcmcia_state.device_add_pending = 1;
407 s->pcmcia_state.mfc_pfc = mfc; 374 s->pcmcia_state.mfc_pfc = mfc;
@@ -439,8 +406,7 @@ static int pcmcia_device_probe(struct device * dev)
439 */ 406 */
440 did = p_dev->dev.driver_data; 407 did = p_dev->dev.driver_data;
441 408
442 ds_dbg(1, "trying to bind %s to %s\n", p_dev->dev.bus_id, 409 ds_dev_dbg(1, dev, "trying to bind to %s\n", p_drv->drv.name);
443 p_drv->drv.name);
444 410
445 if ((!p_drv->probe) || (!p_dev->function_config) || 411 if ((!p_drv->probe) || (!p_dev->function_config) ||
446 (!try_module_get(p_drv->owner))) { 412 (!try_module_get(p_drv->owner))) {
@@ -455,15 +421,16 @@ static int pcmcia_device_probe(struct device * dev)
455 p_dev->conf.ConfigBase = cis_config.base; 421 p_dev->conf.ConfigBase = cis_config.base;
456 p_dev->conf.Present = cis_config.rmask[0]; 422 p_dev->conf.Present = cis_config.rmask[0];
457 } else { 423 } else {
458 printk(KERN_INFO "pcmcia: could not parse base and rmask0 of CIS\n"); 424 dev_printk(KERN_INFO, dev,
425 "pcmcia: could not parse base and rmask0 of CIS\n");
459 p_dev->conf.ConfigBase = 0; 426 p_dev->conf.ConfigBase = 0;
460 p_dev->conf.Present = 0; 427 p_dev->conf.Present = 0;
461 } 428 }
462 429
463 ret = p_drv->probe(p_dev); 430 ret = p_drv->probe(p_dev);
464 if (ret) { 431 if (ret) {
465 ds_dbg(1, "binding %s to %s failed with %d\n", 432 ds_dev_dbg(1, dev, "binding to %s failed with %d\n",
466 p_dev->dev.bus_id, p_drv->drv.name, ret); 433 p_drv->drv.name, ret);
467 goto put_module; 434 goto put_module;
468 } 435 }
469 436
@@ -490,8 +457,9 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
490 struct pcmcia_device *tmp; 457 struct pcmcia_device *tmp;
491 unsigned long flags; 458 unsigned long flags;
492 459
493 ds_dbg(2, "pcmcia_card_remove(%d) %s\n", s->sock, 460 ds_dev_dbg(2, leftover ? &leftover->dev : &s->dev,
494 leftover ? leftover->devname : ""); 461 "pcmcia_card_remove(%d) %s\n", s->sock,
462 leftover ? leftover->devname : "");
495 463
496 if (!leftover) 464 if (!leftover)
497 s->device_count = 0; 465 s->device_count = 0;
@@ -508,7 +476,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
508 p_dev->_removed=1; 476 p_dev->_removed=1;
509 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 477 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
510 478
511 ds_dbg(2, "unregistering device %s\n", p_dev->dev.bus_id); 479 ds_dev_dbg(2, &p_dev->dev, "unregistering device\n");
512 device_unregister(&p_dev->dev); 480 device_unregister(&p_dev->dev);
513 } 481 }
514 482
@@ -525,7 +493,7 @@ static int pcmcia_device_remove(struct device * dev)
525 p_dev = to_pcmcia_dev(dev); 493 p_dev = to_pcmcia_dev(dev);
526 p_drv = to_pcmcia_drv(dev->driver); 494 p_drv = to_pcmcia_drv(dev->driver);
527 495
528 ds_dbg(1, "removing device %s\n", p_dev->dev.bus_id); 496 ds_dev_dbg(1, dev, "removing device\n");
529 497
530 /* If we're removing the primary module driving a 498 /* If we're removing the primary module driving a
531 * pseudo multi-function card, we need to unbind 499 * pseudo multi-function card, we need to unbind
@@ -548,13 +516,15 @@ static int pcmcia_device_remove(struct device * dev)
548 516
549 /* check for proper unloading */ 517 /* check for proper unloading */
550 if (p_dev->_irq || p_dev->_io || p_dev->_locked) 518 if (p_dev->_irq || p_dev->_io || p_dev->_locked)
551 printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", 519 dev_printk(KERN_INFO, dev,
552 p_drv->drv.name); 520 "pcmcia: driver %s did not release config properly\n",
521 p_drv->drv.name);
553 522
554 for (i = 0; i < MAX_WIN; i++) 523 for (i = 0; i < MAX_WIN; i++)
555 if (p_dev->_win & CLIENT_WIN_REQ(i)) 524 if (p_dev->_win & CLIENT_WIN_REQ(i))
556 printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n", 525 dev_printk(KERN_INFO, dev,
557 p_drv->drv.name); 526 "pcmcia: driver %s did not release window properly\n",
527 p_drv->drv.name);
558 528
559 /* references from pcmcia_probe_device */ 529 /* references from pcmcia_probe_device */
560 pcmcia_put_dev(p_dev); 530 pcmcia_put_dev(p_dev);
@@ -603,8 +573,9 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
603 } 573 }
604 if (!pccard_read_tuple(p_dev->socket, p_dev->func, 574 if (!pccard_read_tuple(p_dev->socket, p_dev->func,
605 CISTPL_DEVICE_GEO, devgeo)) { 575 CISTPL_DEVICE_GEO, devgeo)) {
606 ds_dbg(0, "mem device geometry probably means " 576 ds_dev_dbg(0, &p_dev->dev,
607 "FUNCID_MEMORY\n"); 577 "mem device geometry probably means "
578 "FUNCID_MEMORY\n");
608 p_dev->func_id = CISTPL_FUNCID_MEMORY; 579 p_dev->func_id = CISTPL_FUNCID_MEMORY;
609 p_dev->has_func_id = 1; 580 p_dev->has_func_id = 1;
610 } 581 }
@@ -685,7 +656,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
685 if (!p_dev->devname) 656 if (!p_dev->devname)
686 goto err_free; 657 goto err_free;
687 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id); 658 sprintf (p_dev->devname, "pcmcia%s", p_dev->dev.bus_id);
688 ds_dbg(3, "devname is %s\n", p_dev->devname); 659 ds_dev_dbg(3, &p_dev->dev, "devname is %s\n", p_dev->devname);
689 660
690 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 661 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
691 662
@@ -706,7 +677,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
706 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 677 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
707 678
708 if (!p_dev->function_config) { 679 if (!p_dev->function_config) {
709 ds_dbg(3, "creating config_t for %s\n", p_dev->dev.bus_id); 680 ds_dev_dbg(3, &p_dev->dev, "creating config_t\n");
710 p_dev->function_config = kzalloc(sizeof(struct config_t), 681 p_dev->function_config = kzalloc(sizeof(struct config_t),
711 GFP_KERNEL); 682 GFP_KERNEL);
712 if (!p_dev->function_config) 683 if (!p_dev->function_config)
@@ -714,8 +685,9 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
714 kref_init(&p_dev->function_config->ref); 685 kref_init(&p_dev->function_config->ref);
715 } 686 }
716 687
717 printk(KERN_NOTICE "pcmcia: registering new device %s\n", 688 dev_printk(KERN_NOTICE, &p_dev->dev,
718 p_dev->devname); 689 "pcmcia: registering new device %s\n",
690 p_dev->devname);
719 691
720 pcmcia_device_query(p_dev); 692 pcmcia_device_query(p_dev);
721 693
@@ -750,19 +722,20 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
750 int ret = 0; 722 int ret = 0;
751 723
752 if (!(s->resource_setup_done)) { 724 if (!(s->resource_setup_done)) {
753 ds_dbg(3, "no resources available, delaying card_add\n"); 725 ds_dev_dbg(3, &s->dev,
726 "no resources available, delaying card_add\n");
754 return -EAGAIN; /* try again, but later... */ 727 return -EAGAIN; /* try again, but later... */
755 } 728 }
756 729
757 if (pcmcia_validate_mem(s)) { 730 if (pcmcia_validate_mem(s)) {
758 ds_dbg(3, "validating mem resources failed, " 731 ds_dev_dbg(3, &s->dev, "validating mem resources failed, "
759 "delaying card_add\n"); 732 "delaying card_add\n");
760 return -EAGAIN; /* try again, but later... */ 733 return -EAGAIN; /* try again, but later... */
761 } 734 }
762 735
763 ret = pccard_validate_cis(s, BIND_FN_ALL, &no_chains); 736 ret = pccard_validate_cis(s, BIND_FN_ALL, &no_chains);
764 if (ret || !no_chains) { 737 if (ret || !no_chains) {
765 ds_dbg(0, "invalid CIS or invalid resources\n"); 738 ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n");
766 return -ENODEV; 739 return -ENODEV;
767 } 740 }
768 741
@@ -783,7 +756,7 @@ static void pcmcia_delayed_add_device(struct work_struct *work)
783{ 756{
784 struct pcmcia_socket *s = 757 struct pcmcia_socket *s =
785 container_of(work, struct pcmcia_socket, device_add); 758 container_of(work, struct pcmcia_socket, device_add);
786 ds_dbg(1, "adding additional device to %d\n", s->sock); 759 ds_dev_dbg(1, &s->dev, "adding additional device to %d\n", s->sock);
787 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc); 760 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc);
788 s->pcmcia_state.device_add_pending = 0; 761 s->pcmcia_state.device_add_pending = 0;
789 s->pcmcia_state.mfc_pfc = 0; 762 s->pcmcia_state.mfc_pfc = 0;
@@ -793,8 +766,7 @@ static int pcmcia_requery(struct device *dev, void * _data)
793{ 766{
794 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 767 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
795 if (!p_dev->dev.driver) { 768 if (!p_dev->dev.driver) {
796 ds_dbg(1, "update device information for %s\n", 769 ds_dev_dbg(1, dev, "update device information\n");
797 p_dev->dev.bus_id);
798 pcmcia_device_query(p_dev); 770 pcmcia_device_query(p_dev);
799 } 771 }
800 772
@@ -808,7 +780,7 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis)
808 unsigned long flags; 780 unsigned long flags;
809 781
810 /* must be called with skt_mutex held */ 782 /* must be called with skt_mutex held */
811 ds_dbg(0, "re-scanning socket %d\n", skt->sock); 783 ds_dev_dbg(0, &skt->dev, "re-scanning socket %d\n", skt->sock);
812 784
813 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 785 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
814 if (list_empty(&skt->devices_list)) 786 if (list_empty(&skt->devices_list))
@@ -859,17 +831,17 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
859 int ret = -ENOMEM; 831 int ret = -ENOMEM;
860 int no_funcs; 832 int no_funcs;
861 int old_funcs; 833 int old_funcs;
862 cisdump_t *cis;
863 cistpl_longlink_mfc_t mfc; 834 cistpl_longlink_mfc_t mfc;
864 835
865 if (!filename) 836 if (!filename)
866 return -EINVAL; 837 return -EINVAL;
867 838
868 ds_dbg(1, "trying to load CIS file %s\n", filename); 839 ds_dev_dbg(1, &dev->dev, "trying to load CIS file %s\n", filename);
869 840
870 if (strlen(filename) > (FIRMWARE_NAME_MAX - 1)) { 841 if (strlen(filename) > (FIRMWARE_NAME_MAX - 1)) {
871 printk(KERN_WARNING "pcmcia: CIS filename is too long [%s]\n", 842 dev_printk(KERN_WARNING, &dev->dev,
872 filename); 843 "pcmcia: CIS filename is too long [%s]\n",
844 filename);
873 return -EINVAL; 845 return -EINVAL;
874 } 846 }
875 847
@@ -878,23 +850,16 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
878 if (request_firmware(&fw, path, &dev->dev) == 0) { 850 if (request_firmware(&fw, path, &dev->dev) == 0) {
879 if (fw->size >= CISTPL_MAX_CIS_SIZE) { 851 if (fw->size >= CISTPL_MAX_CIS_SIZE) {
880 ret = -EINVAL; 852 ret = -EINVAL;
881 printk(KERN_ERR "pcmcia: CIS override is too big\n"); 853 dev_printk(KERN_ERR, &dev->dev,
854 "pcmcia: CIS override is too big\n");
882 goto release; 855 goto release;
883 } 856 }
884 857
885 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL); 858 if (!pcmcia_replace_cis(s, fw->data, fw->size))
886 if (!cis) {
887 ret = -ENOMEM;
888 goto release;
889 }
890
891 cis->Length = fw->size + 1;
892 memcpy(cis->Data, fw->data, fw->size);
893
894 if (!pcmcia_replace_cis(s, cis))
895 ret = 0; 859 ret = 0;
896 else { 860 else {
897 printk(KERN_ERR "pcmcia: CIS override failed\n"); 861 dev_printk(KERN_ERR, &dev->dev,
862 "pcmcia: CIS override failed\n");
898 goto release; 863 goto release;
899 } 864 }
900 865
@@ -998,14 +963,14 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
998 * after it has re-checked that there is no possible module 963 * after it has re-checked that there is no possible module
999 * with a prod_id/manf_id/card_id match. 964 * with a prod_id/manf_id/card_id match.
1000 */ 965 */
1001 ds_dbg(0, "skipping FUNC_ID match for %s until userspace " 966 ds_dev_dbg(0, &dev->dev,
1002 "interaction\n", dev->dev.bus_id); 967 "skipping FUNC_ID match until userspace interaction\n");
1003 if (!dev->allow_func_id_match) 968 if (!dev->allow_func_id_match)
1004 return 0; 969 return 0;
1005 } 970 }
1006 971
1007 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 972 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) {
1008 ds_dbg(0, "device %s needs a fake CIS\n", dev->dev.bus_id); 973 ds_dev_dbg(0, &dev->dev, "device needs a fake CIS\n");
1009 if (!dev->socket->fake_cis) 974 if (!dev->socket->fake_cis)
1010 pcmcia_load_firmware(dev, did->cisfile); 975 pcmcia_load_firmware(dev, did->cisfile);
1011 976
@@ -1037,11 +1002,9 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
1037 /* match dynamic devices first */ 1002 /* match dynamic devices first */
1038 spin_lock(&p_drv->dynids.lock); 1003 spin_lock(&p_drv->dynids.lock);
1039 list_for_each_entry(dynid, &p_drv->dynids.list, node) { 1004 list_for_each_entry(dynid, &p_drv->dynids.list, node) {
1040 ds_dbg(3, "trying to match %s to %s\n", dev->bus_id, 1005 ds_dev_dbg(3, dev, "trying to match to %s\n", drv->name);
1041 drv->name);
1042 if (pcmcia_devmatch(p_dev, &dynid->id)) { 1006 if (pcmcia_devmatch(p_dev, &dynid->id)) {
1043 ds_dbg(0, "matched %s to %s\n", dev->bus_id, 1007 ds_dev_dbg(0, dev, "matched to %s\n", drv->name);
1044 drv->name);
1045 spin_unlock(&p_drv->dynids.lock); 1008 spin_unlock(&p_drv->dynids.lock);
1046 return 1; 1009 return 1;
1047 } 1010 }
@@ -1051,18 +1014,15 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
1051#ifdef CONFIG_PCMCIA_IOCTL 1014#ifdef CONFIG_PCMCIA_IOCTL
1052 /* matching by cardmgr */ 1015 /* matching by cardmgr */
1053 if (p_dev->cardmgr == p_drv) { 1016 if (p_dev->cardmgr == p_drv) {
1054 ds_dbg(0, "cardmgr matched %s to %s\n", dev->bus_id, 1017 ds_dev_dbg(0, dev, "cardmgr matched to %s\n", drv->name);
1055 drv->name);
1056 return 1; 1018 return 1;
1057 } 1019 }
1058#endif 1020#endif
1059 1021
1060 while (did && did->match_flags) { 1022 while (did && did->match_flags) {
1061 ds_dbg(3, "trying to match %s to %s\n", dev->bus_id, 1023 ds_dev_dbg(3, dev, "trying to match to %s\n", drv->name);
1062 drv->name);
1063 if (pcmcia_devmatch(p_dev, did)) { 1024 if (pcmcia_devmatch(p_dev, did)) {
1064 ds_dbg(0, "matched %s to %s\n", dev->bus_id, 1025 ds_dev_dbg(0, dev, "matched to %s\n", drv->name);
1065 drv->name);
1066 return 1; 1026 return 1;
1067 } 1027 }
1068 did++; 1028 did++;
@@ -1268,7 +1228,7 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1268 if (p_dev->suspended) 1228 if (p_dev->suspended)
1269 return 0; 1229 return 0;
1270 1230
1271 ds_dbg(2, "suspending %s\n", dev->bus_id); 1231 ds_dev_dbg(2, dev, "suspending\n");
1272 1232
1273 if (dev->driver) 1233 if (dev->driver)
1274 p_drv = to_pcmcia_drv(dev->driver); 1234 p_drv = to_pcmcia_drv(dev->driver);
@@ -1279,15 +1239,16 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1279 if (p_drv->suspend) { 1239 if (p_drv->suspend) {
1280 ret = p_drv->suspend(p_dev); 1240 ret = p_drv->suspend(p_dev);
1281 if (ret) { 1241 if (ret) {
1282 printk(KERN_ERR "pcmcia: device %s (driver %s) did " 1242 dev_printk(KERN_ERR, dev,
1283 "not want to go to sleep (%d)\n", 1243 "pcmcia: device %s (driver %s) did "
1284 p_dev->devname, p_drv->drv.name, ret); 1244 "not want to go to sleep (%d)\n",
1245 p_dev->devname, p_drv->drv.name, ret);
1285 goto out; 1246 goto out;
1286 } 1247 }
1287 } 1248 }
1288 1249
1289 if (p_dev->device_no == p_dev->func) { 1250 if (p_dev->device_no == p_dev->func) {
1290 ds_dbg(2, "releasing configuration for %s\n", dev->bus_id); 1251 ds_dev_dbg(2, dev, "releasing configuration\n");
1291 pcmcia_release_configuration(p_dev); 1252 pcmcia_release_configuration(p_dev);
1292 } 1253 }
1293 1254
@@ -1307,7 +1268,7 @@ static int pcmcia_dev_resume(struct device * dev)
1307 if (!p_dev->suspended) 1268 if (!p_dev->suspended)
1308 return 0; 1269 return 0;
1309 1270
1310 ds_dbg(2, "resuming %s\n", dev->bus_id); 1271 ds_dev_dbg(2, dev, "resuming\n");
1311 1272
1312 if (dev->driver) 1273 if (dev->driver)
1313 p_drv = to_pcmcia_drv(dev->driver); 1274 p_drv = to_pcmcia_drv(dev->driver);
@@ -1316,7 +1277,7 @@ static int pcmcia_dev_resume(struct device * dev)
1316 goto out; 1277 goto out;
1317 1278
1318 if (p_dev->device_no == p_dev->func) { 1279 if (p_dev->device_no == p_dev->func) {
1319 ds_dbg(2, "requesting configuration for %s\n", dev->bus_id); 1280 ds_dev_dbg(2, dev, "requesting configuration\n");
1320 ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1281 ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
1321 if (ret) 1282 if (ret)
1322 goto out; 1283 goto out;
@@ -1358,14 +1319,14 @@ static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
1358 1319
1359static int pcmcia_bus_resume(struct pcmcia_socket *skt) 1320static int pcmcia_bus_resume(struct pcmcia_socket *skt)
1360{ 1321{
1361 ds_dbg(2, "resuming socket %d\n", skt->sock); 1322 ds_dev_dbg(2, &skt->dev, "resuming socket %d\n", skt->sock);
1362 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); 1323 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback);
1363 return 0; 1324 return 0;
1364} 1325}
1365 1326
1366static int pcmcia_bus_suspend(struct pcmcia_socket *skt) 1327static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
1367{ 1328{
1368 ds_dbg(2, "suspending socket %d\n", skt->sock); 1329 ds_dev_dbg(2, &skt->dev, "suspending socket %d\n", skt->sock);
1369 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, 1330 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt,
1370 pcmcia_bus_suspend_callback)) { 1331 pcmcia_bus_suspend_callback)) {
1371 pcmcia_bus_resume(skt); 1332 pcmcia_bus_resume(skt);
@@ -1391,13 +1352,14 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1391 struct pcmcia_socket *s = pcmcia_get_socket(skt); 1352 struct pcmcia_socket *s = pcmcia_get_socket(skt);
1392 1353
1393 if (!s) { 1354 if (!s) {
1394 printk(KERN_ERR "PCMCIA obtaining reference to socket %p " \ 1355 dev_printk(KERN_ERR, &skt->dev,
1395 "failed, event 0x%x lost!\n", skt, event); 1356 "PCMCIA obtaining reference to socket " \
1357 "failed, event 0x%x lost!\n", event);
1396 return -ENODEV; 1358 return -ENODEV;
1397 } 1359 }
1398 1360
1399 ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n", 1361 ds_dev_dbg(1, &skt->dev, "ds_event(0x%06x, %d, 0x%p)\n",
1400 event, priority, skt); 1362 event, priority, skt);
1401 1363
1402 switch (event) { 1364 switch (event) {
1403 case CS_EVENT_CARD_REMOVAL: 1365 case CS_EVENT_CARD_REMOVAL:
@@ -1472,7 +1434,8 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1472 1434
1473 socket = pcmcia_get_socket(socket); 1435 socket = pcmcia_get_socket(socket);
1474 if (!socket) { 1436 if (!socket) {
1475 printk(KERN_ERR "PCMCIA obtaining reference to socket %p failed\n", socket); 1437 dev_printk(KERN_ERR, dev,
1438 "PCMCIA obtaining reference to socket failed\n");
1476 return -ENODEV; 1439 return -ENODEV;
1477 } 1440 }
1478 1441
@@ -1492,7 +1455,7 @@ static int __devinit pcmcia_bus_add_socket(struct device *dev,
1492 1455
1493 ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback); 1456 ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback);
1494 if (ret) { 1457 if (ret) {
1495 printk(KERN_ERR "PCMCIA registration PCCard core failed for socket %p\n", socket); 1458 dev_printk(KERN_ERR, dev, "PCMCIA registration failed\n");
1496 pcmcia_put_socket(socket); 1459 pcmcia_put_socket(socket);
1497 return (ret); 1460 return (ret);
1498 } 1461 }