diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-10-23 06:51:28 -0400 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2009-11-08 12:23:12 -0500 |
commit | d50dbec3ce52e1608636b8a624d087da9ced8cde (patch) | |
tree | 536cced7021883bcc3a7f82e94c42cd4c614ba43 /drivers/pcmcia/pcmcia_resource.c | |
parent | 18a7a19b37838789452e0bd2855a51475628b971 (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/pcmcia_resource.c')
-rw-r--r-- | drivers/pcmcia/pcmcia_resource.c | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 0bfb05aa8f85..349bc5662fff 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -44,21 +44,6 @@ static u8 pcmcia_used_irq[NR_IRQS]; | |||
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | 46 | ||
47 | #ifdef CONFIG_PCMCIA_DEBUG | ||
48 | extern int ds_pc_debug; | ||
49 | |||
50 | #define ds_dbg(skt, lvl, fmt, arg...) do { \ | ||
51 | if (ds_pc_debug >= lvl) \ | ||
52 | dev_printk(KERN_DEBUG, &skt->dev, \ | ||
53 | "pcmcia_resource: " fmt, \ | ||
54 | ## arg); \ | ||
55 | } while (0) | ||
56 | #else | ||
57 | #define ds_dbg(skt, lvl, fmt, arg...) do { } while (0) | ||
58 | #endif | ||
59 | |||
60 | |||
61 | |||
62 | /** alloc_io_space | 47 | /** alloc_io_space |
63 | * | 48 | * |
64 | * Special stuff for managing IO windows, because they are scarce | 49 | * Special stuff for managing IO windows, because they are scarce |
@@ -73,14 +58,14 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, | |||
73 | align = (*base) ? (lines ? 1<<lines : 0) : 1; | 58 | align = (*base) ? (lines ? 1<<lines : 0) : 1; |
74 | if (align && (align < num)) { | 59 | if (align && (align < num)) { |
75 | if (*base) { | 60 | if (*base) { |
76 | ds_dbg(s, 0, "odd IO request: num %#x align %#x\n", | 61 | dev_dbg(&s->dev, "odd IO request: num %#x align %#x\n", |
77 | num, align); | 62 | num, align); |
78 | align = 0; | 63 | align = 0; |
79 | } else | 64 | } else |
80 | while (align && (align < num)) align <<= 1; | 65 | while (align && (align < num)) align <<= 1; |
81 | } | 66 | } |
82 | if (*base & ~(align-1)) { | 67 | if (*base & ~(align-1)) { |
83 | ds_dbg(s, 0, "odd IO request: base %#x align %#x\n", | 68 | dev_dbg(&s->dev, "odd IO request: base %#x align %#x\n", |
84 | *base, align); | 69 | *base, align); |
85 | align = 0; | 70 | align = 0; |
86 | } | 71 | } |
@@ -253,12 +238,12 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req) | |||
253 | return -EINVAL; | 238 | return -EINVAL; |
254 | s = win->sock; | 239 | s = win->sock; |
255 | if (req->Page != 0) { | 240 | if (req->Page != 0) { |
256 | ds_dbg(s, 0, "failure: requested page is zero\n"); | 241 | dev_dbg(&s->dev, "failure: requested page is zero\n"); |
257 | return -EINVAL; | 242 | return -EINVAL; |
258 | } | 243 | } |
259 | win->ctl.card_start = req->CardOffset; | 244 | win->ctl.card_start = req->CardOffset; |
260 | if (s->ops->set_mem_map(s, &win->ctl) != 0) { | 245 | if (s->ops->set_mem_map(s, &win->ctl) != 0) { |
261 | ds_dbg(s, 0, "failed to set_mem_map\n"); | 246 | dev_dbg(&s->dev, "failed to set_mem_map\n"); |
262 | return -EIO; | 247 | return -EIO; |
263 | } | 248 | } |
264 | return 0; | 249 | return 0; |
@@ -296,7 +281,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
296 | } | 281 | } |
297 | 282 | ||
298 | if (mod->Attributes & CONF_VCC_CHANGE_VALID) { | 283 | if (mod->Attributes & CONF_VCC_CHANGE_VALID) { |
299 | ds_dbg(s, 0, "changing Vcc is not allowed at this time\n"); | 284 | dev_dbg(&s->dev, "changing Vcc is not allowed at this time\n"); |
300 | return -EINVAL; | 285 | return -EINVAL; |
301 | } | 286 | } |
302 | 287 | ||
@@ -304,7 +289,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
304 | if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && | 289 | if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && |
305 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { | 290 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { |
306 | if (mod->Vpp1 != mod->Vpp2) { | 291 | if (mod->Vpp1 != mod->Vpp2) { |
307 | ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n"); | 292 | dev_dbg(&s->dev, "Vpp1 and Vpp2 must be the same\n"); |
308 | return -EINVAL; | 293 | return -EINVAL; |
309 | } | 294 | } |
310 | s->socket.Vpp = mod->Vpp1; | 295 | s->socket.Vpp = mod->Vpp1; |
@@ -315,7 +300,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev, | |||
315 | } | 300 | } |
316 | } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || | 301 | } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || |
317 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { | 302 | (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { |
318 | ds_dbg(s, 0, "changing Vcc is not allowed at this time\n"); | 303 | dev_dbg(&s->dev, "changing Vcc is not allowed at this time\n"); |
319 | return -EINVAL; | 304 | return -EINVAL; |
320 | } | 305 | } |
321 | 306 | ||
@@ -426,11 +411,11 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req) | |||
426 | if (c->state & CONFIG_LOCKED) | 411 | if (c->state & CONFIG_LOCKED) |
427 | return -EACCES; | 412 | return -EACCES; |
428 | if (c->irq.Attributes != req->Attributes) { | 413 | if (c->irq.Attributes != req->Attributes) { |
429 | ds_dbg(s, 0, "IRQ attributes must match assigned ones\n"); | 414 | dev_dbg(&s->dev, "IRQ attributes must match assigned ones\n"); |
430 | return -EINVAL; | 415 | return -EINVAL; |
431 | } | 416 | } |
432 | if (s->irq.AssignedIRQ != req->AssignedIRQ) { | 417 | if (s->irq.AssignedIRQ != req->AssignedIRQ) { |
433 | ds_dbg(s, 0, "IRQ must match assigned one\n"); | 418 | dev_dbg(&s->dev, "IRQ must match assigned one\n"); |
434 | return -EINVAL; | 419 | return -EINVAL; |
435 | } | 420 | } |
436 | if (--s->irq.Config == 0) { | 421 | if (--s->irq.Config == 0) { |
@@ -493,7 +478,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev, | |||
493 | return -ENODEV; | 478 | return -ENODEV; |
494 | 479 | ||
495 | if (req->IntType & INT_CARDBUS) { | 480 | if (req->IntType & INT_CARDBUS) { |
496 | ds_dbg(p_dev->socket, 0, "IntType may not be INT_CARDBUS\n"); | 481 | dev_dbg(&s->dev, "IntType may not be INT_CARDBUS\n"); |
497 | return -EINVAL; | 482 | return -EINVAL; |
498 | } | 483 | } |
499 | c = p_dev->function_config; | 484 | c = p_dev->function_config; |
@@ -619,31 +604,31 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req) | |||
619 | if (c->state & CONFIG_LOCKED) | 604 | if (c->state & CONFIG_LOCKED) |
620 | return -EACCES; | 605 | return -EACCES; |
621 | if (c->state & CONFIG_IO_REQ) { | 606 | if (c->state & CONFIG_IO_REQ) { |
622 | ds_dbg(s, 0, "IO already configured\n"); | 607 | dev_dbg(&s->dev, "IO already configured\n"); |
623 | return -EBUSY; | 608 | return -EBUSY; |
624 | } | 609 | } |
625 | if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) { | 610 | if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) { |
626 | ds_dbg(s, 0, "bad attribute setting for IO region 1\n"); | 611 | dev_dbg(&s->dev, "bad attribute setting for IO region 1\n"); |
627 | return -EINVAL; | 612 | return -EINVAL; |
628 | } | 613 | } |
629 | if ((req->NumPorts2 > 0) && | 614 | if ((req->NumPorts2 > 0) && |
630 | (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) { | 615 | (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) { |
631 | ds_dbg(s, 0, "bad attribute setting for IO region 2\n"); | 616 | dev_dbg(&s->dev, "bad attribute setting for IO region 2\n"); |
632 | return -EINVAL; | 617 | return -EINVAL; |
633 | } | 618 | } |
634 | 619 | ||
635 | ds_dbg(s, 1, "trying to allocate resource 1\n"); | 620 | dev_dbg(&s->dev, "trying to allocate resource 1\n"); |
636 | if (alloc_io_space(s, req->Attributes1, &req->BasePort1, | 621 | if (alloc_io_space(s, req->Attributes1, &req->BasePort1, |
637 | req->NumPorts1, req->IOAddrLines)) { | 622 | req->NumPorts1, req->IOAddrLines)) { |
638 | ds_dbg(s, 0, "allocation of resource 1 failed\n"); | 623 | dev_dbg(&s->dev, "allocation of resource 1 failed\n"); |
639 | return -EBUSY; | 624 | return -EBUSY; |
640 | } | 625 | } |
641 | 626 | ||
642 | if (req->NumPorts2) { | 627 | if (req->NumPorts2) { |
643 | ds_dbg(s, 1, "trying to allocate resource 2\n"); | 628 | dev_dbg(&s->dev, "trying to allocate resource 2\n"); |
644 | if (alloc_io_space(s, req->Attributes2, &req->BasePort2, | 629 | if (alloc_io_space(s, req->Attributes2, &req->BasePort2, |
645 | req->NumPorts2, req->IOAddrLines)) { | 630 | req->NumPorts2, req->IOAddrLines)) { |
646 | ds_dbg(s, 0, "allocation of resource 2 failed\n"); | 631 | dev_dbg(&s->dev, "allocation of resource 2 failed\n"); |
647 | release_io_space(s, req->BasePort1, req->NumPorts1); | 632 | release_io_space(s, req->BasePort1, req->NumPorts1); |
648 | return -EBUSY; | 633 | return -EBUSY; |
649 | } | 634 | } |
@@ -687,7 +672,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req) | |||
687 | if (c->state & CONFIG_LOCKED) | 672 | if (c->state & CONFIG_LOCKED) |
688 | return -EACCES; | 673 | return -EACCES; |
689 | if (c->state & CONFIG_IRQ_REQ) { | 674 | if (c->state & CONFIG_IRQ_REQ) { |
690 | ds_dbg(s, 0, "IRQ already configured\n"); | 675 | dev_dbg(&s->dev, "IRQ already configured\n"); |
691 | return -EBUSY; | 676 | return -EBUSY; |
692 | } | 677 | } |
693 | 678 | ||
@@ -798,7 +783,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
798 | if (!(s->state & SOCKET_PRESENT)) | 783 | if (!(s->state & SOCKET_PRESENT)) |
799 | return -ENODEV; | 784 | return -ENODEV; |
800 | if (req->Attributes & (WIN_PAGED | WIN_SHARED)) { | 785 | if (req->Attributes & (WIN_PAGED | WIN_SHARED)) { |
801 | ds_dbg(s, 0, "bad attribute setting for iomem region\n"); | 786 | dev_dbg(&s->dev, "bad attribute setting for iomem region\n"); |
802 | return -EINVAL; | 787 | return -EINVAL; |
803 | } | 788 | } |
804 | 789 | ||
@@ -809,12 +794,12 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
809 | (req->Attributes & WIN_STRICT_ALIGN)) ? | 794 | (req->Attributes & WIN_STRICT_ALIGN)) ? |
810 | req->Size : s->map_size); | 795 | req->Size : s->map_size); |
811 | if (req->Size & (s->map_size-1)) { | 796 | if (req->Size & (s->map_size-1)) { |
812 | ds_dbg(s, 0, "invalid map size\n"); | 797 | dev_dbg(&s->dev, "invalid map size\n"); |
813 | return -EINVAL; | 798 | return -EINVAL; |
814 | } | 799 | } |
815 | if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || | 800 | if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || |
816 | (req->Base & (align-1))) { | 801 | (req->Base & (align-1))) { |
817 | ds_dbg(s, 0, "invalid base address\n"); | 802 | dev_dbg(&s->dev, "invalid base address\n"); |
818 | return -EINVAL; | 803 | return -EINVAL; |
819 | } | 804 | } |
820 | if (req->Base) | 805 | if (req->Base) |
@@ -824,7 +809,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
824 | for (w = 0; w < MAX_WIN; w++) | 809 | for (w = 0; w < MAX_WIN; w++) |
825 | if (!(s->state & SOCKET_WIN_REQ(w))) break; | 810 | if (!(s->state & SOCKET_WIN_REQ(w))) break; |
826 | if (w == MAX_WIN) { | 811 | if (w == MAX_WIN) { |
827 | ds_dbg(s, 0, "all windows are used already\n"); | 812 | dev_dbg(&s->dev, "all windows are used already\n"); |
828 | return -EINVAL; | 813 | return -EINVAL; |
829 | } | 814 | } |
830 | 815 | ||
@@ -838,7 +823,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
838 | win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, | 823 | win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, |
839 | (req->Attributes & WIN_MAP_BELOW_1MB), s); | 824 | (req->Attributes & WIN_MAP_BELOW_1MB), s); |
840 | if (!win->ctl.res) { | 825 | if (!win->ctl.res) { |
841 | ds_dbg(s, 0, "allocating mem region failed\n"); | 826 | dev_dbg(&s->dev, "allocating mem region failed\n"); |
842 | return -EINVAL; | 827 | return -EINVAL; |
843 | } | 828 | } |
844 | } | 829 | } |
@@ -858,7 +843,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h | |||
858 | win->ctl.flags |= MAP_USE_WAIT; | 843 | win->ctl.flags |= MAP_USE_WAIT; |
859 | win->ctl.card_start = 0; | 844 | win->ctl.card_start = 0; |
860 | if (s->ops->set_mem_map(s, &win->ctl) != 0) { | 845 | if (s->ops->set_mem_map(s, &win->ctl) != 0) { |
861 | ds_dbg(s, 0, "failed to set memory mapping\n"); | 846 | dev_dbg(&s->dev, "failed to set memory mapping\n"); |
862 | return -EIO; | 847 | return -EIO; |
863 | } | 848 | } |
864 | s->state |= SOCKET_WIN_REQ(w); | 849 | s->state |= SOCKET_WIN_REQ(w); |