aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia/ds.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2009-10-23 06:51:28 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2009-11-08 12:23:12 -0500
commitd50dbec3ce52e1608636b8a624d087da9ced8cde (patch)
tree536cced7021883bcc3a7f82e94c42cd4c614ba43 /drivers/pcmcia/ds.c
parent18a7a19b37838789452e0bd2855a51475628b971 (diff)
pcmcia: use dynamic debug instead of custom infrastructure
Use the generic "dynamic debug" infrastructure instead of CONIG_PCMCIA_DEBUG in the PCMCIA core (pcmcia.ko and pcmcia_core.ko). To enable debugging, enable CONFIG_DYNAMIC_DEBUG, mount debugfs and $ echo -n 'module pcmcia_core +p' > /sys/kernel/debug/dynamic_debug/control for the complete module "pcmcia_core", for example. For more detailled instructions, please see Documentation/dynamic-debug-howto.txt Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/pcmcia/ds.c')
-rw-r--r--drivers/pcmcia/ds.c87
1 files changed, 35 insertions, 52 deletions
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index f5b7079f13d3..5b069aeaf17a 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -41,23 +41,6 @@ MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
41MODULE_DESCRIPTION("PCMCIA Driver Services"); 41MODULE_DESCRIPTION("PCMCIA Driver Services");
42MODULE_LICENSE("GPL"); 42MODULE_LICENSE("GPL");
43 43
44#ifdef CONFIG_PCMCIA_DEBUG
45int ds_pc_debug;
46
47module_param_named(pc_debug, ds_pc_debug, int, 0644);
48
49#define ds_dbg(lvl, fmt, arg...) do { \
50 if (ds_pc_debug > (lvl)) \
51 printk(KERN_DEBUG "ds: " fmt , ## arg); \
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)
57#else
58#define ds_dbg(lvl, fmt, arg...) do { } while (0)
59#define ds_dev_dbg(lvl, dev, fmt, arg...) do { } while (0)
60#endif
61 44
62spinlock_t pcmcia_dev_list_lock; 45spinlock_t pcmcia_dev_list_lock;
63 46
@@ -303,7 +286,7 @@ int pcmcia_register_driver(struct pcmcia_driver *driver)
303 spin_lock_init(&driver->dynids.lock); 286 spin_lock_init(&driver->dynids.lock);
304 INIT_LIST_HEAD(&driver->dynids.list); 287 INIT_LIST_HEAD(&driver->dynids.list);
305 288
306 ds_dbg(3, "registering driver %s\n", driver->drv.name); 289 pr_debug("registering driver %s\n", driver->drv.name);
307 290
308 error = driver_register(&driver->drv); 291 error = driver_register(&driver->drv);
309 if (error < 0) 292 if (error < 0)
@@ -323,7 +306,7 @@ EXPORT_SYMBOL(pcmcia_register_driver);
323 */ 306 */
324void pcmcia_unregister_driver(struct pcmcia_driver *driver) 307void pcmcia_unregister_driver(struct pcmcia_driver *driver)
325{ 308{
326 ds_dbg(3, "unregistering driver %s\n", driver->drv.name); 309 pr_debug("unregistering driver %s\n", driver->drv.name);
327 driver_unregister(&driver->drv); 310 driver_unregister(&driver->drv);
328 pcmcia_free_dynids(driver); 311 pcmcia_free_dynids(driver);
329} 312}
@@ -350,14 +333,14 @@ void pcmcia_put_dev(struct pcmcia_device *p_dev)
350static void pcmcia_release_function(struct kref *ref) 333static void pcmcia_release_function(struct kref *ref)
351{ 334{
352 struct config_t *c = container_of(ref, struct config_t, ref); 335 struct config_t *c = container_of(ref, struct config_t, ref);
353 ds_dbg(1, "releasing config_t\n"); 336 pr_debug("releasing config_t\n");
354 kfree(c); 337 kfree(c);
355} 338}
356 339
357static void pcmcia_release_dev(struct device *dev) 340static void pcmcia_release_dev(struct device *dev)
358{ 341{
359 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 342 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
360 ds_dev_dbg(1, dev, "releasing device\n"); 343 dev_dbg(dev, "releasing device\n");
361 pcmcia_put_socket(p_dev->socket); 344 pcmcia_put_socket(p_dev->socket);
362 kfree(p_dev->devname); 345 kfree(p_dev->devname);
363 kref_put(&p_dev->function_config->ref, pcmcia_release_function); 346 kref_put(&p_dev->function_config->ref, pcmcia_release_function);
@@ -367,7 +350,7 @@ static void pcmcia_release_dev(struct device *dev)
367static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc) 350static void pcmcia_add_device_later(struct pcmcia_socket *s, int mfc)
368{ 351{
369 if (!s->pcmcia_state.device_add_pending) { 352 if (!s->pcmcia_state.device_add_pending) {
370 ds_dev_dbg(1, &s->dev, "scheduling to add %s secondary" 353 dev_dbg(&s->dev, "scheduling to add %s secondary"
371 " device to %d\n", mfc ? "mfc" : "pfc", s->sock); 354 " device to %d\n", mfc ? "mfc" : "pfc", s->sock);
372 s->pcmcia_state.device_add_pending = 1; 355 s->pcmcia_state.device_add_pending = 1;
373 s->pcmcia_state.mfc_pfc = mfc; 356 s->pcmcia_state.mfc_pfc = mfc;
@@ -405,7 +388,7 @@ static int pcmcia_device_probe(struct device * dev)
405 */ 388 */
406 did = dev_get_drvdata(&p_dev->dev); 389 did = dev_get_drvdata(&p_dev->dev);
407 390
408 ds_dev_dbg(1, dev, "trying to bind to %s\n", p_drv->drv.name); 391 dev_dbg(dev, "trying to bind to %s\n", p_drv->drv.name);
409 392
410 if ((!p_drv->probe) || (!p_dev->function_config) || 393 if ((!p_drv->probe) || (!p_dev->function_config) ||
411 (!try_module_get(p_drv->owner))) { 394 (!try_module_get(p_drv->owner))) {
@@ -428,7 +411,7 @@ static int pcmcia_device_probe(struct device * dev)
428 411
429 ret = p_drv->probe(p_dev); 412 ret = p_drv->probe(p_dev);
430 if (ret) { 413 if (ret) {
431 ds_dev_dbg(1, dev, "binding to %s failed with %d\n", 414 dev_dbg(dev, "binding to %s failed with %d\n",
432 p_drv->drv.name, ret); 415 p_drv->drv.name, ret);
433 goto put_module; 416 goto put_module;
434 } 417 }
@@ -456,7 +439,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
456 struct pcmcia_device *tmp; 439 struct pcmcia_device *tmp;
457 unsigned long flags; 440 unsigned long flags;
458 441
459 ds_dev_dbg(2, leftover ? &leftover->dev : &s->dev, 442 dev_dbg(leftover ? &leftover->dev : &s->dev,
460 "pcmcia_card_remove(%d) %s\n", s->sock, 443 "pcmcia_card_remove(%d) %s\n", s->sock,
461 leftover ? leftover->devname : ""); 444 leftover ? leftover->devname : "");
462 445
@@ -475,7 +458,7 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le
475 p_dev->_removed=1; 458 p_dev->_removed=1;
476 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 459 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
477 460
478 ds_dev_dbg(2, &p_dev->dev, "unregistering device\n"); 461 dev_dbg(&p_dev->dev, "unregistering device\n");
479 device_unregister(&p_dev->dev); 462 device_unregister(&p_dev->dev);
480 } 463 }
481 464
@@ -492,7 +475,7 @@ static int pcmcia_device_remove(struct device * dev)
492 p_dev = to_pcmcia_dev(dev); 475 p_dev = to_pcmcia_dev(dev);
493 p_drv = to_pcmcia_drv(dev->driver); 476 p_drv = to_pcmcia_drv(dev->driver);
494 477
495 ds_dev_dbg(1, dev, "removing device\n"); 478 dev_dbg(dev, "removing device\n");
496 479
497 /* If we're removing the primary module driving a 480 /* If we're removing the primary module driving a
498 * pseudo multi-function card, we need to unbind 481 * pseudo multi-function card, we need to unbind
@@ -572,7 +555,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev)
572 } 555 }
573 if (!pccard_read_tuple(p_dev->socket, p_dev->func, 556 if (!pccard_read_tuple(p_dev->socket, p_dev->func,
574 CISTPL_DEVICE_GEO, devgeo)) { 557 CISTPL_DEVICE_GEO, devgeo)) {
575 ds_dev_dbg(0, &p_dev->dev, 558 dev_dbg(&p_dev->dev,
576 "mem device geometry probably means " 559 "mem device geometry probably means "
577 "FUNCID_MEMORY\n"); 560 "FUNCID_MEMORY\n");
578 p_dev->func_id = CISTPL_FUNCID_MEMORY; 561 p_dev->func_id = CISTPL_FUNCID_MEMORY;
@@ -628,7 +611,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
628 611
629 mutex_lock(&device_add_lock); 612 mutex_lock(&device_add_lock);
630 613
631 ds_dbg(3, "adding device to %d, function %d\n", s->sock, function); 614 pr_debug("adding device to %d, function %d\n", s->sock, function);
632 615
633 /* max of 4 devices per card */ 616 /* max of 4 devices per card */
634 if (s->device_count == 4) 617 if (s->device_count == 4)
@@ -654,7 +637,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
654 p_dev->devname = kasprintf(GFP_KERNEL, "pcmcia%s", dev_name(&p_dev->dev)); 637 p_dev->devname = kasprintf(GFP_KERNEL, "pcmcia%s", dev_name(&p_dev->dev));
655 if (!p_dev->devname) 638 if (!p_dev->devname)
656 goto err_free; 639 goto err_free;
657 ds_dev_dbg(3, &p_dev->dev, "devname is %s\n", p_dev->devname); 640 dev_dbg(&p_dev->dev, "devname is %s\n", p_dev->devname);
658 641
659 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 642 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
660 643
@@ -677,7 +660,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
677 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 660 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
678 661
679 if (!p_dev->function_config) { 662 if (!p_dev->function_config) {
680 ds_dev_dbg(3, &p_dev->dev, "creating config_t\n"); 663 dev_dbg(&p_dev->dev, "creating config_t\n");
681 p_dev->function_config = kzalloc(sizeof(struct config_t), 664 p_dev->function_config = kzalloc(sizeof(struct config_t),
682 GFP_KERNEL); 665 GFP_KERNEL);
683 if (!p_dev->function_config) 666 if (!p_dev->function_config)
@@ -722,20 +705,20 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
722 int ret = 0; 705 int ret = 0;
723 706
724 if (!(s->resource_setup_done)) { 707 if (!(s->resource_setup_done)) {
725 ds_dev_dbg(3, &s->dev, 708 dev_dbg(&s->dev,
726 "no resources available, delaying card_add\n"); 709 "no resources available, delaying card_add\n");
727 return -EAGAIN; /* try again, but later... */ 710 return -EAGAIN; /* try again, but later... */
728 } 711 }
729 712
730 if (pcmcia_validate_mem(s)) { 713 if (pcmcia_validate_mem(s)) {
731 ds_dev_dbg(3, &s->dev, "validating mem resources failed, " 714 dev_dbg(&s->dev, "validating mem resources failed, "
732 "delaying card_add\n"); 715 "delaying card_add\n");
733 return -EAGAIN; /* try again, but later... */ 716 return -EAGAIN; /* try again, but later... */
734 } 717 }
735 718
736 ret = pccard_validate_cis(s, &no_chains); 719 ret = pccard_validate_cis(s, &no_chains);
737 if (ret || !no_chains) { 720 if (ret || !no_chains) {
738 ds_dev_dbg(0, &s->dev, "invalid CIS or invalid resources\n"); 721 dev_dbg(&s->dev, "invalid CIS or invalid resources\n");
739 return -ENODEV; 722 return -ENODEV;
740 } 723 }
741 724
@@ -756,7 +739,7 @@ static void pcmcia_delayed_add_device(struct work_struct *work)
756{ 739{
757 struct pcmcia_socket *s = 740 struct pcmcia_socket *s =
758 container_of(work, struct pcmcia_socket, device_add); 741 container_of(work, struct pcmcia_socket, device_add);
759 ds_dev_dbg(1, &s->dev, "adding additional device to %d\n", s->sock); 742 dev_dbg(&s->dev, "adding additional device to %d\n", s->sock);
760 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc); 743 pcmcia_device_add(s, s->pcmcia_state.mfc_pfc);
761 s->pcmcia_state.device_add_pending = 0; 744 s->pcmcia_state.device_add_pending = 0;
762 s->pcmcia_state.mfc_pfc = 0; 745 s->pcmcia_state.mfc_pfc = 0;
@@ -766,7 +749,7 @@ static int pcmcia_requery(struct device *dev, void * _data)
766{ 749{
767 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 750 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
768 if (!p_dev->dev.driver) { 751 if (!p_dev->dev.driver) {
769 ds_dev_dbg(1, dev, "update device information\n"); 752 dev_dbg(dev, "update device information\n");
770 pcmcia_device_query(p_dev); 753 pcmcia_device_query(p_dev);
771 } 754 }
772 755
@@ -780,7 +763,7 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt, int new_cis)
780 unsigned long flags; 763 unsigned long flags;
781 764
782 /* must be called with skt_mutex held */ 765 /* must be called with skt_mutex held */
783 ds_dev_dbg(0, &skt->dev, "re-scanning socket %d\n", skt->sock); 766 dev_dbg(&skt->dev, "re-scanning socket %d\n", skt->sock);
784 767
785 spin_lock_irqsave(&pcmcia_dev_list_lock, flags); 768 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
786 if (list_empty(&skt->devices_list)) 769 if (list_empty(&skt->devices_list))
@@ -835,7 +818,7 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
835 if (!filename) 818 if (!filename)
836 return -EINVAL; 819 return -EINVAL;
837 820
838 ds_dev_dbg(1, &dev->dev, "trying to load CIS file %s\n", filename); 821 dev_dbg(&dev->dev, "trying to load CIS file %s\n", filename);
839 822
840 if (request_firmware(&fw, filename, &dev->dev) == 0) { 823 if (request_firmware(&fw, filename, &dev->dev) == 0) {
841 if (fw->size >= CISTPL_MAX_CIS_SIZE) { 824 if (fw->size >= CISTPL_MAX_CIS_SIZE) {
@@ -953,14 +936,14 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev,
953 * after it has re-checked that there is no possible module 936 * after it has re-checked that there is no possible module
954 * with a prod_id/manf_id/card_id match. 937 * with a prod_id/manf_id/card_id match.
955 */ 938 */
956 ds_dev_dbg(0, &dev->dev, 939 dev_dbg(&dev->dev,
957 "skipping FUNC_ID match until userspace interaction\n"); 940 "skipping FUNC_ID match until userspace interaction\n");
958 if (!dev->allow_func_id_match) 941 if (!dev->allow_func_id_match)
959 return 0; 942 return 0;
960 } 943 }
961 944
962 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { 945 if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) {
963 ds_dev_dbg(0, &dev->dev, "device needs a fake CIS\n"); 946 dev_dbg(&dev->dev, "device needs a fake CIS\n");
964 if (!dev->socket->fake_cis) 947 if (!dev->socket->fake_cis)
965 pcmcia_load_firmware(dev, did->cisfile); 948 pcmcia_load_firmware(dev, did->cisfile);
966 949
@@ -992,9 +975,9 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
992 /* match dynamic devices first */ 975 /* match dynamic devices first */
993 spin_lock(&p_drv->dynids.lock); 976 spin_lock(&p_drv->dynids.lock);
994 list_for_each_entry(dynid, &p_drv->dynids.list, node) { 977 list_for_each_entry(dynid, &p_drv->dynids.list, node) {
995 ds_dev_dbg(3, dev, "trying to match to %s\n", drv->name); 978 dev_dbg(dev, "trying to match to %s\n", drv->name);
996 if (pcmcia_devmatch(p_dev, &dynid->id)) { 979 if (pcmcia_devmatch(p_dev, &dynid->id)) {
997 ds_dev_dbg(0, dev, "matched to %s\n", drv->name); 980 dev_dbg(dev, "matched to %s\n", drv->name);
998 spin_unlock(&p_drv->dynids.lock); 981 spin_unlock(&p_drv->dynids.lock);
999 return 1; 982 return 1;
1000 } 983 }
@@ -1004,15 +987,15 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
1004#ifdef CONFIG_PCMCIA_IOCTL 987#ifdef CONFIG_PCMCIA_IOCTL
1005 /* matching by cardmgr */ 988 /* matching by cardmgr */
1006 if (p_dev->cardmgr == p_drv) { 989 if (p_dev->cardmgr == p_drv) {
1007 ds_dev_dbg(0, dev, "cardmgr matched to %s\n", drv->name); 990 dev_dbg(dev, "cardmgr matched to %s\n", drv->name);
1008 return 1; 991 return 1;
1009 } 992 }
1010#endif 993#endif
1011 994
1012 while (did && did->match_flags) { 995 while (did && did->match_flags) {
1013 ds_dev_dbg(3, dev, "trying to match to %s\n", drv->name); 996 dev_dbg(dev, "trying to match to %s\n", drv->name);
1014 if (pcmcia_devmatch(p_dev, did)) { 997 if (pcmcia_devmatch(p_dev, did)) {
1015 ds_dev_dbg(0, dev, "matched to %s\n", drv->name); 998 dev_dbg(dev, "matched to %s\n", drv->name);
1016 return 1; 999 return 1;
1017 } 1000 }
1018 did++; 1001 did++;
@@ -1218,7 +1201,7 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1218 if (p_dev->suspended) 1201 if (p_dev->suspended)
1219 return 0; 1202 return 0;
1220 1203
1221 ds_dev_dbg(2, dev, "suspending\n"); 1204 dev_dbg(dev, "suspending\n");
1222 1205
1223 if (dev->driver) 1206 if (dev->driver)
1224 p_drv = to_pcmcia_drv(dev->driver); 1207 p_drv = to_pcmcia_drv(dev->driver);
@@ -1238,7 +1221,7 @@ static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
1238 } 1221 }
1239 1222
1240 if (p_dev->device_no == p_dev->func) { 1223 if (p_dev->device_no == p_dev->func) {
1241 ds_dev_dbg(2, dev, "releasing configuration\n"); 1224 dev_dbg(dev, "releasing configuration\n");
1242 pcmcia_release_configuration(p_dev); 1225 pcmcia_release_configuration(p_dev);
1243 } 1226 }
1244 1227
@@ -1258,7 +1241,7 @@ static int pcmcia_dev_resume(struct device * dev)
1258 if (!p_dev->suspended) 1241 if (!p_dev->suspended)
1259 return 0; 1242 return 0;
1260 1243
1261 ds_dev_dbg(2, dev, "resuming\n"); 1244 dev_dbg(dev, "resuming\n");
1262 1245
1263 if (dev->driver) 1246 if (dev->driver)
1264 p_drv = to_pcmcia_drv(dev->driver); 1247 p_drv = to_pcmcia_drv(dev->driver);
@@ -1267,7 +1250,7 @@ static int pcmcia_dev_resume(struct device * dev)
1267 goto out; 1250 goto out;
1268 1251
1269 if (p_dev->device_no == p_dev->func) { 1252 if (p_dev->device_no == p_dev->func) {
1270 ds_dev_dbg(2, dev, "requesting configuration\n"); 1253 dev_dbg(dev, "requesting configuration\n");
1271 ret = pcmcia_request_configuration(p_dev, &p_dev->conf); 1254 ret = pcmcia_request_configuration(p_dev, &p_dev->conf);
1272 if (ret) 1255 if (ret)
1273 goto out; 1256 goto out;
@@ -1309,14 +1292,14 @@ static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
1309 1292
1310static int pcmcia_bus_resume(struct pcmcia_socket *skt) 1293static int pcmcia_bus_resume(struct pcmcia_socket *skt)
1311{ 1294{
1312 ds_dev_dbg(2, &skt->dev, "resuming socket %d\n", skt->sock); 1295 dev_dbg(&skt->dev, "resuming socket %d\n", skt->sock);
1313 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback); 1296 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback);
1314 return 0; 1297 return 0;
1315} 1298}
1316 1299
1317static int pcmcia_bus_suspend(struct pcmcia_socket *skt) 1300static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
1318{ 1301{
1319 ds_dev_dbg(2, &skt->dev, "suspending socket %d\n", skt->sock); 1302 dev_dbg(&skt->dev, "suspending socket %d\n", skt->sock);
1320 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt, 1303 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt,
1321 pcmcia_bus_suspend_callback)) { 1304 pcmcia_bus_suspend_callback)) {
1322 pcmcia_bus_resume(skt); 1305 pcmcia_bus_resume(skt);
@@ -1348,7 +1331,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1348 return -ENODEV; 1331 return -ENODEV;
1349 } 1332 }
1350 1333
1351 ds_dev_dbg(1, &skt->dev, "ds_event(0x%06x, %d, 0x%p)\n", 1334 dev_dbg(&skt->dev, "ds_event(0x%06x, %d, 0x%p)\n",
1352 event, priority, skt); 1335 event, priority, skt);
1353 1336
1354 switch (event) { 1337 switch (event) {