aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pcmcia
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
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')
-rw-r--r--drivers/pcmcia/Makefile4
-rw-r--r--drivers/pcmcia/au1000_generic.c2
-rw-r--r--drivers/pcmcia/au1000_generic.h2
-rw-r--r--drivers/pcmcia/au1000_pb1x00.c1
-rw-r--r--drivers/pcmcia/au1000_xxs1500.c1
-rw-r--r--drivers/pcmcia/cardbus.c2
-rw-r--r--drivers/pcmcia/cistpl.c297
-rw-r--r--drivers/pcmcia/cs.c78
-rw-r--r--drivers/pcmcia/cs_internal.h226
-rw-r--r--drivers/pcmcia/ds.c239
-rw-r--r--drivers/pcmcia/ds_internal.h23
-rw-r--r--drivers/pcmcia/hd64465_ss.c1
-rw-r--r--drivers/pcmcia/i82365.c2
-rw-r--r--drivers/pcmcia/m32r_cfc.c4
-rw-r--r--drivers/pcmcia/m32r_pcc.c4
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c4
-rw-r--r--drivers/pcmcia/o2micro.h10
-rw-r--r--drivers/pcmcia/pcmcia_ioctl.c120
-rw-r--r--drivers/pcmcia/pcmcia_resource.c381
-rw-r--r--drivers/pcmcia/pxa2xx_base.c1
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c67
-rw-r--r--drivers/pcmcia/soc_common.c2
-rw-r--r--drivers/pcmcia/soc_common.h3
-rw-r--r--drivers/pcmcia/socket_sysfs.c13
-rw-r--r--drivers/pcmcia/tcic.c2
-rw-r--r--drivers/pcmcia/ti113x.h78
-rw-r--r--drivers/pcmcia/yenta_socket.c86
27 files changed, 943 insertions, 710 deletions
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index a87902de8d3..74d1c906c5d 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -2,10 +2,6 @@
2# Makefile for the kernel pcmcia subsystem (c/o David Hinds) 2# Makefile for the kernel pcmcia subsystem (c/o David Hinds)
3# 3#
4 4
5ifeq ($(CONFIG_PCMCIA_DEBUG),y)
6EXTRA_CFLAGS += -DDEBUG
7endif
8
9pcmcia_core-y += cs.o cistpl.o rsrc_mgr.o socket_sysfs.o 5pcmcia_core-y += cs.o cistpl.o rsrc_mgr.o socket_sysfs.o
10pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o 6pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o
11obj-$(CONFIG_PCCARD) += pcmcia_core.o 7obj-$(CONFIG_PCCARD) += pcmcia_core.o
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 75e8f8505e4..fc1de46fd20 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -292,7 +292,7 @@ au1x00_pcmcia_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *map)
292 skt->spd_io[map->map] = speed; 292 skt->spd_io[map->map] = speed;
293 } 293 }
294 294
295 map->start=(ioaddr_t)(u32)skt->virt_io; 295 map->start=(unsigned int)(u32)skt->virt_io;
296 map->stop=map->start+MAP_SIZE; 296 map->stop=map->start+MAP_SIZE;
297 return 0; 297 return 0;
298 298
diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h
index a53ef590251..13a4fbc5871 100644
--- a/drivers/pcmcia/au1000_generic.h
+++ b/drivers/pcmcia/au1000_generic.h
@@ -116,7 +116,7 @@ struct au1000_pcmcia_socket {
116 struct resource res_attr; 116 struct resource res_attr;
117 117
118 void * virt_io; 118 void * virt_io;
119 ioaddr_t phys_io; 119 unsigned int phys_io;
120 unsigned int phys_attr; 120 unsigned int phys_attr;
121 unsigned int phys_mem; 121 unsigned int phys_mem;
122 unsigned short speed_io, speed_attr, speed_mem; 122 unsigned short speed_io, speed_attr, speed_mem;
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c
index aa1cd4d3aa2..d6b4bd1db7d 100644
--- a/drivers/pcmcia/au1000_pb1x00.c
+++ b/drivers/pcmcia/au1000_pb1x00.c
@@ -37,7 +37,6 @@
37#include <pcmcia/ss.h> 37#include <pcmcia/ss.h>
38#include <pcmcia/cistpl.h> 38#include <pcmcia/cistpl.h>
39#include <pcmcia/bus_ops.h> 39#include <pcmcia/bus_ops.h>
40#include "cs_internal.h"
41 40
42#include <asm/io.h> 41#include <asm/io.h>
43#include <asm/irq.h> 42#include <asm/irq.h>
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c
index 8a9b18cee84..9627390835c 100644
--- a/drivers/pcmcia/au1000_xxs1500.c
+++ b/drivers/pcmcia/au1000_xxs1500.c
@@ -41,7 +41,6 @@
41#include <pcmcia/ss.h> 41#include <pcmcia/ss.h>
42#include <pcmcia/cistpl.h> 42#include <pcmcia/cistpl.h>
43#include <pcmcia/bus_ops.h> 43#include <pcmcia/bus_ops.h>
44#include "cs_internal.h"
45 44
46#include <asm/io.h> 45#include <asm/io.h>
47#include <asm/irq.h> 46#include <asm/irq.h>
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c
index 911ca0e8dfc..db77e1f3309 100644
--- a/drivers/pcmcia/cardbus.c
+++ b/drivers/pcmcia/cardbus.c
@@ -238,7 +238,7 @@ int __ref cb_alloc(struct pcmcia_socket * s)
238 pci_bus_add_devices(bus); 238 pci_bus_add_devices(bus);
239 239
240 s->irq.AssignedIRQ = s->pci_irq; 240 s->irq.AssignedIRQ = s->pci_irq;
241 return CS_SUCCESS; 241 return 0;
242} 242}
243 243
244void cb_free(struct pcmcia_socket * s) 244void cb_free(struct pcmcia_socket * s)
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 65129b54eb0..dcce9f5d846 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -92,7 +92,8 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag
92 if (!(s->features & SS_CAP_STATIC_MAP) && (mem->res == NULL)) { 92 if (!(s->features & SS_CAP_STATIC_MAP) && (mem->res == NULL)) {
93 mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s); 93 mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s);
94 if (mem->res == NULL) { 94 if (mem->res == NULL) {
95 printk(KERN_NOTICE "cs: unable to map card memory!\n"); 95 dev_printk(KERN_NOTICE, &s->dev,
96 "cs: unable to map card memory!\n");
96 return NULL; 97 return NULL;
97 } 98 }
98 s->cis_virt = NULL; 99 s->cis_virt = NULL;
@@ -265,13 +266,13 @@ EXPORT_SYMBOL(pcmcia_write_cis_mem);
265======================================================================*/ 266======================================================================*/
266 267
267static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, 268static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr,
268 u_int len, void *ptr) 269 size_t len, void *ptr)
269{ 270{
270 struct cis_cache_entry *cis; 271 struct cis_cache_entry *cis;
271 int ret; 272 int ret;
272 273
273 if (s->fake_cis) { 274 if (s->fake_cis) {
274 if (s->fake_cis_len > addr+len) 275 if (s->fake_cis_len >= addr+len)
275 memcpy(ptr, s->fake_cis+addr, len); 276 memcpy(ptr, s->fake_cis+addr, len);
276 else 277 else
277 memset(ptr, 0xff, len); 278 memset(ptr, 0xff, len);
@@ -351,7 +352,9 @@ int verify_cis_cache(struct pcmcia_socket *s)
351 352
352 buf = kmalloc(256, GFP_KERNEL); 353 buf = kmalloc(256, GFP_KERNEL);
353 if (buf == NULL) 354 if (buf == NULL)
354 return -1; 355 dev_printk(KERN_WARNING, &s->dev,
356 "no memory for verifying CIS\n");
357 return -ENOMEM;
355 list_for_each_entry(cis, &s->cis_cache, node) { 358 list_for_each_entry(cis, &s->cis_cache, node) {
356 int len = cis->len; 359 int len = cis->len;
357 360
@@ -380,18 +383,22 @@ int verify_cis_cache(struct pcmcia_socket *s)
380 383
381======================================================================*/ 384======================================================================*/
382 385
383int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) 386int pcmcia_replace_cis(struct pcmcia_socket *s,
387 const u8 *data, const size_t len)
384{ 388{
385 kfree(s->fake_cis); 389 if (len > CISTPL_MAX_CIS_SIZE) {
386 s->fake_cis = NULL; 390 dev_printk(KERN_WARNING, &s->dev, "replacement CIS too big\n");
387 if (cis->Length > CISTPL_MAX_CIS_SIZE) 391 return -EINVAL;
388 return CS_BAD_SIZE; 392 }
389 s->fake_cis = kmalloc(cis->Length, GFP_KERNEL); 393 kfree(s->fake_cis);
390 if (s->fake_cis == NULL) 394 s->fake_cis = kmalloc(len, GFP_KERNEL);
391 return CS_OUT_OF_RESOURCE; 395 if (s->fake_cis == NULL) {
392 s->fake_cis_len = cis->Length; 396 dev_printk(KERN_WARNING, &s->dev, "no memory to replace CIS\n");
393 memcpy(s->fake_cis, cis->Data, cis->Length); 397 return -ENOMEM;
394 return CS_SUCCESS; 398 }
399 s->fake_cis_len = len;
400 memcpy(s->fake_cis, data, len);
401 return 0;
395} 402}
396EXPORT_SYMBOL(pcmcia_replace_cis); 403EXPORT_SYMBOL(pcmcia_replace_cis);
397 404
@@ -418,9 +425,9 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int func, tuple_t *t
418int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple) 425int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple_t *tuple)
419{ 426{
420 if (!s) 427 if (!s)
421 return CS_BAD_HANDLE; 428 return -EINVAL;
422 if (!(s->state & SOCKET_PRESENT)) 429 if (!(s->state & SOCKET_PRESENT))
423 return CS_NO_CARD; 430 return -ENODEV;
424 tuple->TupleLink = tuple->Flags = 0; 431 tuple->TupleLink = tuple->Flags = 0;
425#ifdef CONFIG_CARDBUS 432#ifdef CONFIG_CARDBUS
426 if (s->state & SOCKET_CARDBUS) { 433 if (s->state & SOCKET_CARDBUS) {
@@ -440,10 +447,10 @@ int pccard_get_first_tuple(struct pcmcia_socket *s, unsigned int function, tuple
440 !(tuple->Attributes & TUPLE_RETURN_COMMON)) { 447 !(tuple->Attributes & TUPLE_RETURN_COMMON)) {
441 cisdata_t req = tuple->DesiredTuple; 448 cisdata_t req = tuple->DesiredTuple;
442 tuple->DesiredTuple = CISTPL_LONGLINK_MFC; 449 tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
443 if (pccard_get_next_tuple(s, function, tuple) == CS_SUCCESS) { 450 if (pccard_get_next_tuple(s, function, tuple) == 0) {
444 tuple->DesiredTuple = CISTPL_LINKTARGET; 451 tuple->DesiredTuple = CISTPL_LINKTARGET;
445 if (pccard_get_next_tuple(s, function, tuple) != CS_SUCCESS) 452 if (pccard_get_next_tuple(s, function, tuple) != 0)
446 return CS_NO_MORE_ITEMS; 453 return -ENOSPC;
447 } else 454 } else
448 tuple->CISOffset = tuple->TupleLink = 0; 455 tuple->CISOffset = tuple->TupleLink = 0;
449 tuple->DesiredTuple = req; 456 tuple->DesiredTuple = req;
@@ -498,9 +505,9 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
498 int ofs, i, attr; 505 int ofs, i, attr;
499 506
500 if (!s) 507 if (!s)
501 return CS_BAD_HANDLE; 508 return -EINVAL;
502 if (!(s->state & SOCKET_PRESENT)) 509 if (!(s->state & SOCKET_PRESENT))
503 return CS_NO_CARD; 510 return -ENODEV;
504 511
505 link[1] = tuple->TupleLink; 512 link[1] = tuple->TupleLink;
506 ofs = tuple->CISOffset + tuple->TupleLink; 513 ofs = tuple->CISOffset + tuple->TupleLink;
@@ -519,7 +526,7 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
519 /* End of chain? Follow long link if possible */ 526 /* End of chain? Follow long link if possible */
520 if (link[0] == CISTPL_END) { 527 if (link[0] == CISTPL_END) {
521 if ((ofs = follow_link(s, tuple)) < 0) 528 if ((ofs = follow_link(s, tuple)) < 0)
522 return CS_NO_MORE_ITEMS; 529 return -ENOSPC;
523 attr = SPACE(tuple->Flags); 530 attr = SPACE(tuple->Flags);
524 read_cis_cache(s, attr, ofs, 2, link); 531 read_cis_cache(s, attr, ofs, 2, link);
525 } 532 }
@@ -577,13 +584,13 @@ int pccard_get_next_tuple(struct pcmcia_socket *s, unsigned int function, tuple_
577 } 584 }
578 if (i == MAX_TUPLES) { 585 if (i == MAX_TUPLES) {
579 cs_dbg(s, 1, "cs: overrun in pcmcia_get_next_tuple\n"); 586 cs_dbg(s, 1, "cs: overrun in pcmcia_get_next_tuple\n");
580 return CS_NO_MORE_ITEMS; 587 return -ENOSPC;
581 } 588 }
582 589
583 tuple->TupleCode = link[0]; 590 tuple->TupleCode = link[0];
584 tuple->TupleLink = link[1]; 591 tuple->TupleLink = link[1];
585 tuple->CISOffset = ofs + 2; 592 tuple->CISOffset = ofs + 2;
586 return CS_SUCCESS; 593 return 0;
587} 594}
588EXPORT_SYMBOL(pccard_get_next_tuple); 595EXPORT_SYMBOL(pccard_get_next_tuple);
589 596
@@ -596,18 +603,18 @@ int pccard_get_tuple_data(struct pcmcia_socket *s, tuple_t *tuple)
596 u_int len; 603 u_int len;
597 604
598 if (!s) 605 if (!s)
599 return CS_BAD_HANDLE; 606 return -EINVAL;
600 607
601 if (tuple->TupleLink < tuple->TupleOffset) 608 if (tuple->TupleLink < tuple->TupleOffset)
602 return CS_NO_MORE_ITEMS; 609 return -ENOSPC;
603 len = tuple->TupleLink - tuple->TupleOffset; 610 len = tuple->TupleLink - tuple->TupleOffset;
604 tuple->TupleDataLen = tuple->TupleLink; 611 tuple->TupleDataLen = tuple->TupleLink;
605 if (len == 0) 612 if (len == 0)
606 return CS_SUCCESS; 613 return 0;
607 read_cis_cache(s, SPACE(tuple->Flags), 614 read_cis_cache(s, SPACE(tuple->Flags),
608 tuple->CISOffset + tuple->TupleOffset, 615 tuple->CISOffset + tuple->TupleOffset,
609 _MIN(len, tuple->TupleDataMax), tuple->TupleData); 616 _MIN(len, tuple->TupleDataMax), tuple->TupleData);
610 return CS_SUCCESS; 617 return 0;
611} 618}
612EXPORT_SYMBOL(pccard_get_tuple_data); 619EXPORT_SYMBOL(pccard_get_tuple_data);
613 620
@@ -640,25 +647,31 @@ static int parse_device(tuple_t *tuple, cistpl_device_t *device)
640 case 3: device->dev[i].speed = 150; break; 647 case 3: device->dev[i].speed = 150; break;
641 case 4: device->dev[i].speed = 100; break; 648 case 4: device->dev[i].speed = 100; break;
642 case 7: 649 case 7:
643 if (++p == q) return CS_BAD_TUPLE; 650 if (++p == q)
651 return -EINVAL;
644 device->dev[i].speed = SPEED_CVT(*p); 652 device->dev[i].speed = SPEED_CVT(*p);
645 while (*p & 0x80) 653 while (*p & 0x80)
646 if (++p == q) return CS_BAD_TUPLE; 654 if (++p == q)
655 return -EINVAL;
647 break; 656 break;
648 default: 657 default:
649 return CS_BAD_TUPLE; 658 return -EINVAL;
650 } 659 }
651 660
652 if (++p == q) return CS_BAD_TUPLE; 661 if (++p == q)
653 if (*p == 0xff) break; 662 return -EINVAL;
663 if (*p == 0xff)
664 break;
654 scale = *p & 7; 665 scale = *p & 7;
655 if (scale == 7) return CS_BAD_TUPLE; 666 if (scale == 7)
667 return -EINVAL;
656 device->dev[i].size = ((*p >> 3) + 1) * (512 << (scale*2)); 668 device->dev[i].size = ((*p >> 3) + 1) * (512 << (scale*2));
657 device->ndev++; 669 device->ndev++;
658 if (++p == q) break; 670 if (++p == q)
671 break;
659 } 672 }
660 673
661 return CS_SUCCESS; 674 return 0;
662} 675}
663 676
664/*====================================================================*/ 677/*====================================================================*/
@@ -667,12 +680,12 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum)
667{ 680{
668 u_char *p; 681 u_char *p;
669 if (tuple->TupleDataLen < 5) 682 if (tuple->TupleDataLen < 5)
670 return CS_BAD_TUPLE; 683 return -EINVAL;
671 p = (u_char *) tuple->TupleData; 684 p = (u_char *) tuple->TupleData;
672 csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2; 685 csum->addr = tuple->CISOffset + get_unaligned_le16(p) - 2;
673 csum->len = get_unaligned_le16(p + 2); 686 csum->len = get_unaligned_le16(p + 2);
674 csum->sum = *(p + 4); 687 csum->sum = *(p + 4);
675 return CS_SUCCESS; 688 return 0;
676} 689}
677 690
678/*====================================================================*/ 691/*====================================================================*/
@@ -680,9 +693,9 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum)
680static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link) 693static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link)
681{ 694{
682 if (tuple->TupleDataLen < 4) 695 if (tuple->TupleDataLen < 4)
683 return CS_BAD_TUPLE; 696 return -EINVAL;
684 link->addr = get_unaligned_le32(tuple->TupleData); 697 link->addr = get_unaligned_le32(tuple->TupleData);
685 return CS_SUCCESS; 698 return 0;
686} 699}
687 700
688/*====================================================================*/ 701/*====================================================================*/
@@ -697,13 +710,13 @@ static int parse_longlink_mfc(tuple_t *tuple,
697 710
698 link->nfn = *p; p++; 711 link->nfn = *p; p++;
699 if (tuple->TupleDataLen <= link->nfn*5) 712 if (tuple->TupleDataLen <= link->nfn*5)
700 return CS_BAD_TUPLE; 713 return -EINVAL;
701 for (i = 0; i < link->nfn; i++) { 714 for (i = 0; i < link->nfn; i++) {
702 link->fn[i].space = *p; p++; 715 link->fn[i].space = *p; p++;
703 link->fn[i].addr = get_unaligned_le32(p); 716 link->fn[i].addr = get_unaligned_le32(p);
704 p += 4; 717 p += 4;
705 } 718 }
706 return CS_SUCCESS; 719 return 0;
707} 720}
708 721
709/*====================================================================*/ 722/*====================================================================*/
@@ -713,24 +726,27 @@ static int parse_strings(u_char *p, u_char *q, int max,
713{ 726{
714 int i, j, ns; 727 int i, j, ns;
715 728
716 if (p == q) return CS_BAD_TUPLE; 729 if (p == q)
730 return -EINVAL;
717 ns = 0; j = 0; 731 ns = 0; j = 0;
718 for (i = 0; i < max; i++) { 732 for (i = 0; i < max; i++) {
719 if (*p == 0xff) break; 733 if (*p == 0xff)
734 break;
720 ofs[i] = j; 735 ofs[i] = j;
721 ns++; 736 ns++;
722 for (;;) { 737 for (;;) {
723 s[j++] = (*p == 0xff) ? '\0' : *p; 738 s[j++] = (*p == 0xff) ? '\0' : *p;
724 if ((*p == '\0') || (*p == 0xff)) break; 739 if ((*p == '\0') || (*p == 0xff)) break;
725 if (++p == q) return CS_BAD_TUPLE; 740 if (++p == q)
741 return -EINVAL;
726 } 742 }
727 if ((*p == 0xff) || (++p == q)) break; 743 if ((*p == 0xff) || (++p == q)) break;
728 } 744 }
729 if (found) { 745 if (found) {
730 *found = ns; 746 *found = ns;
731 return CS_SUCCESS; 747 return 0;
732 } else { 748 } else {
733 return (ns == max) ? CS_SUCCESS : CS_BAD_TUPLE; 749 return (ns == max) ? 0 : -EINVAL;
734 } 750 }
735} 751}
736 752
@@ -745,7 +761,8 @@ static int parse_vers_1(tuple_t *tuple, cistpl_vers_1_t *vers_1)
745 761
746 vers_1->major = *p; p++; 762 vers_1->major = *p; p++;
747 vers_1->minor = *p; p++; 763 vers_1->minor = *p; p++;
748 if (p >= q) return CS_BAD_TUPLE; 764 if (p >= q)
765 return -EINVAL;
749 766
750 return parse_strings(p, q, CISTPL_VERS_1_MAX_PROD_STRINGS, 767 return parse_strings(p, q, CISTPL_VERS_1_MAX_PROD_STRINGS,
751 vers_1->str, vers_1->ofs, &vers_1->ns); 768 vers_1->str, vers_1->ofs, &vers_1->ns);
@@ -781,7 +798,7 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec)
781 p += 2; 798 p += 2;
782 } 799 }
783 jedec->nid = nid; 800 jedec->nid = nid;
784 return CS_SUCCESS; 801 return 0;
785} 802}
786 803
787/*====================================================================*/ 804/*====================================================================*/
@@ -789,10 +806,10 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec)
789static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) 806static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m)
790{ 807{
791 if (tuple->TupleDataLen < 4) 808 if (tuple->TupleDataLen < 4)
792 return CS_BAD_TUPLE; 809 return -EINVAL;
793 m->manf = get_unaligned_le16(tuple->TupleData); 810 m->manf = get_unaligned_le16(tuple->TupleData);
794 m->card = get_unaligned_le16(tuple->TupleData + 2); 811 m->card = get_unaligned_le16(tuple->TupleData + 2);
795 return CS_SUCCESS; 812 return 0;
796} 813}
797 814
798/*====================================================================*/ 815/*====================================================================*/
@@ -801,11 +818,11 @@ static int parse_funcid(tuple_t *tuple, cistpl_funcid_t *f)
801{ 818{
802 u_char *p; 819 u_char *p;
803 if (tuple->TupleDataLen < 2) 820 if (tuple->TupleDataLen < 2)
804 return CS_BAD_TUPLE; 821 return -EINVAL;
805 p = (u_char *)tuple->TupleData; 822 p = (u_char *)tuple->TupleData;
806 f->func = p[0]; 823 f->func = p[0];
807 f->sysinit = p[1]; 824 f->sysinit = p[1];
808 return CS_SUCCESS; 825 return 0;
809} 826}
810 827
811/*====================================================================*/ 828/*====================================================================*/
@@ -815,12 +832,12 @@ static int parse_funce(tuple_t *tuple, cistpl_funce_t *f)
815 u_char *p; 832 u_char *p;
816 int i; 833 int i;
817 if (tuple->TupleDataLen < 1) 834 if (tuple->TupleDataLen < 1)
818 return CS_BAD_TUPLE; 835 return -EINVAL;
819 p = (u_char *)tuple->TupleData; 836 p = (u_char *)tuple->TupleData;
820 f->type = p[0]; 837 f->type = p[0];
821 for (i = 1; i < tuple->TupleDataLen; i++) 838 for (i = 1; i < tuple->TupleDataLen; i++)
822 f->data[i-1] = p[i]; 839 f->data[i-1] = p[i];
823 return CS_SUCCESS; 840 return 0;
824} 841}
825 842
826/*====================================================================*/ 843/*====================================================================*/
@@ -834,7 +851,7 @@ static int parse_config(tuple_t *tuple, cistpl_config_t *config)
834 rasz = *p & 0x03; 851 rasz = *p & 0x03;
835 rmsz = (*p & 0x3c) >> 2; 852 rmsz = (*p & 0x3c) >> 2;
836 if (tuple->TupleDataLen < rasz+rmsz+4) 853 if (tuple->TupleDataLen < rasz+rmsz+4)
837 return CS_BAD_TUPLE; 854 return -EINVAL;
838 config->last_idx = *(++p); 855 config->last_idx = *(++p);
839 p++; 856 p++;
840 config->base = 0; 857 config->base = 0;
@@ -846,7 +863,7 @@ static int parse_config(tuple_t *tuple, cistpl_config_t *config)
846 for (i = 0; i <= rmsz; i++) 863 for (i = 0; i <= rmsz; i++)
847 config->rmask[i>>2] += p[i] << (8*(i%4)); 864 config->rmask[i>>2] += p[i] << (8*(i%4));
848 config->subtuples = tuple->TupleDataLen - (rasz+rmsz+4); 865 config->subtuples = tuple->TupleDataLen - (rasz+rmsz+4);
849 return CS_SUCCESS; 866 return 0;
850} 867}
851 868
852/*====================================================================== 869/*======================================================================
@@ -1002,10 +1019,12 @@ static u_char *parse_mem(u_char *p, u_char *q, cistpl_mem_t *mem)
1002 1019
1003static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq) 1020static u_char *parse_irq(u_char *p, u_char *q, cistpl_irq_t *irq)
1004{ 1021{
1005 if (p == q) return NULL; 1022 if (p == q)
1023 return NULL;
1006 irq->IRQInfo1 = *p; p++; 1024 irq->IRQInfo1 = *p; p++;
1007 if (irq->IRQInfo1 & IRQ_INFO2_VALID) { 1025 if (irq->IRQInfo1 & IRQ_INFO2_VALID) {
1008 if (p+2 > q) return NULL; 1026 if (p+2 > q)
1027 return NULL;
1009 irq->IRQInfo2 = (p[1]<<8) + p[0]; 1028 irq->IRQInfo2 = (p[1]<<8) + p[0];
1010 p += 2; 1029 p += 2;
1011 } 1030 }
@@ -1026,7 +1045,8 @@ static int parse_cftable_entry(tuple_t *tuple,
1026 if (*p & 0x40) 1045 if (*p & 0x40)
1027 entry->flags |= CISTPL_CFTABLE_DEFAULT; 1046 entry->flags |= CISTPL_CFTABLE_DEFAULT;
1028 if (*p & 0x80) { 1047 if (*p & 0x80) {
1029 if (++p == q) return CS_BAD_TUPLE; 1048 if (++p == q)
1049 return -EINVAL;
1030 if (*p & 0x10) 1050 if (*p & 0x10)
1031 entry->flags |= CISTPL_CFTABLE_BVDS; 1051 entry->flags |= CISTPL_CFTABLE_BVDS;
1032 if (*p & 0x20) 1052 if (*p & 0x20)
@@ -1040,30 +1060,35 @@ static int parse_cftable_entry(tuple_t *tuple,
1040 entry->interface = 0; 1060 entry->interface = 0;
1041 1061
1042 /* Process optional features */ 1062 /* Process optional features */
1043 if (++p == q) return CS_BAD_TUPLE; 1063 if (++p == q)
1064 return -EINVAL;
1044 features = *p; p++; 1065 features = *p; p++;
1045 1066
1046 /* Power options */ 1067 /* Power options */
1047 if ((features & 3) > 0) { 1068 if ((features & 3) > 0) {
1048 p = parse_power(p, q, &entry->vcc); 1069 p = parse_power(p, q, &entry->vcc);
1049 if (p == NULL) return CS_BAD_TUPLE; 1070 if (p == NULL)
1071 return -EINVAL;
1050 } else 1072 } else
1051 entry->vcc.present = 0; 1073 entry->vcc.present = 0;
1052 if ((features & 3) > 1) { 1074 if ((features & 3) > 1) {
1053 p = parse_power(p, q, &entry->vpp1); 1075 p = parse_power(p, q, &entry->vpp1);
1054 if (p == NULL) return CS_BAD_TUPLE; 1076 if (p == NULL)
1077 return -EINVAL;
1055 } else 1078 } else
1056 entry->vpp1.present = 0; 1079 entry->vpp1.present = 0;
1057 if ((features & 3) > 2) { 1080 if ((features & 3) > 2) {
1058 p = parse_power(p, q, &entry->vpp2); 1081 p = parse_power(p, q, &entry->vpp2);
1059 if (p == NULL) return CS_BAD_TUPLE; 1082 if (p == NULL)
1083 return -EINVAL;
1060 } else 1084 } else
1061 entry->vpp2.present = 0; 1085 entry->vpp2.present = 0;
1062 1086
1063 /* Timing options */ 1087 /* Timing options */
1064 if (features & 0x04) { 1088 if (features & 0x04) {
1065 p = parse_timing(p, q, &entry->timing); 1089 p = parse_timing(p, q, &entry->timing);
1066 if (p == NULL) return CS_BAD_TUPLE; 1090 if (p == NULL)
1091 return -EINVAL;
1067 } else { 1092 } else {
1068 entry->timing.wait = 0; 1093 entry->timing.wait = 0;
1069 entry->timing.ready = 0; 1094 entry->timing.ready = 0;
@@ -1073,14 +1098,16 @@ static int parse_cftable_entry(tuple_t *tuple,
1073 /* I/O window options */ 1098 /* I/O window options */
1074 if (features & 0x08) { 1099 if (features & 0x08) {
1075 p = parse_io(p, q, &entry->io); 1100 p = parse_io(p, q, &entry->io);
1076 if (p == NULL) return CS_BAD_TUPLE; 1101 if (p == NULL)
1102 return -EINVAL;
1077 } else 1103 } else
1078 entry->io.nwin = 0; 1104 entry->io.nwin = 0;
1079 1105
1080 /* Interrupt options */ 1106 /* Interrupt options */
1081 if (features & 0x10) { 1107 if (features & 0x10) {
1082 p = parse_irq(p, q, &entry->irq); 1108 p = parse_irq(p, q, &entry->irq);
1083 if (p == NULL) return CS_BAD_TUPLE; 1109 if (p == NULL)
1110 return -EINVAL;
1084 } else 1111 } else
1085 entry->irq.IRQInfo1 = 0; 1112 entry->irq.IRQInfo1 = 0;
1086 1113
@@ -1094,7 +1121,8 @@ static int parse_cftable_entry(tuple_t *tuple,
1094 entry->mem.win[0].card_addr = 0; 1121 entry->mem.win[0].card_addr = 0;
1095 entry->mem.win[0].host_addr = 0; 1122 entry->mem.win[0].host_addr = 0;
1096 p += 2; 1123 p += 2;
1097 if (p > q) return CS_BAD_TUPLE; 1124 if (p > q)
1125 return -EINVAL;
1098 break; 1126 break;
1099 case 0x40: 1127 case 0x40:
1100 entry->mem.nwin = 1; 1128 entry->mem.nwin = 1;
@@ -1102,26 +1130,30 @@ static int parse_cftable_entry(tuple_t *tuple,
1102 entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8; 1130 entry->mem.win[0].card_addr = get_unaligned_le16(p + 2) << 8;
1103 entry->mem.win[0].host_addr = 0; 1131 entry->mem.win[0].host_addr = 0;
1104 p += 4; 1132 p += 4;
1105 if (p > q) return CS_BAD_TUPLE; 1133 if (p > q)
1134 return -EINVAL;
1106 break; 1135 break;
1107 case 0x60: 1136 case 0x60:
1108 p = parse_mem(p, q, &entry->mem); 1137 p = parse_mem(p, q, &entry->mem);
1109 if (p == NULL) return CS_BAD_TUPLE; 1138 if (p == NULL)
1139 return -EINVAL;
1110 break; 1140 break;
1111 } 1141 }
1112 1142
1113 /* Misc features */ 1143 /* Misc features */
1114 if (features & 0x80) { 1144 if (features & 0x80) {
1115 if (p == q) return CS_BAD_TUPLE; 1145 if (p == q)
1146 return -EINVAL;
1116 entry->flags |= (*p << 8); 1147 entry->flags |= (*p << 8);
1117 while (*p & 0x80) 1148 while (*p & 0x80)
1118 if (++p == q) return CS_BAD_TUPLE; 1149 if (++p == q)
1150 return -EINVAL;
1119 p++; 1151 p++;
1120 } 1152 }
1121 1153
1122 entry->subtuples = q-p; 1154 entry->subtuples = q-p;
1123 1155
1124 return CS_SUCCESS; 1156 return 0;
1125} 1157}
1126 1158
1127/*====================================================================*/ 1159/*====================================================================*/
@@ -1132,12 +1164,12 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar)
1132{ 1164{
1133 u_char *p; 1165 u_char *p;
1134 if (tuple->TupleDataLen < 6) 1166 if (tuple->TupleDataLen < 6)
1135 return CS_BAD_TUPLE; 1167 return -EINVAL;
1136 p = (u_char *)tuple->TupleData; 1168 p = (u_char *)tuple->TupleData;
1137 bar->attr = *p; 1169 bar->attr = *p;
1138 p += 2; 1170 p += 2;
1139 bar->size = get_unaligned_le32(p); 1171 bar->size = get_unaligned_le32(p);
1140 return CS_SUCCESS; 1172 return 0;
1141} 1173}
1142 1174
1143static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config) 1175static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config)
@@ -1146,12 +1178,12 @@ static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config)
1146 1178
1147 p = (u_char *)tuple->TupleData; 1179 p = (u_char *)tuple->TupleData;
1148 if ((*p != 3) || (tuple->TupleDataLen < 6)) 1180 if ((*p != 3) || (tuple->TupleDataLen < 6))
1149 return CS_BAD_TUPLE; 1181 return -EINVAL;
1150 config->last_idx = *(++p); 1182 config->last_idx = *(++p);
1151 p++; 1183 p++;
1152 config->base = get_unaligned_le32(p); 1184 config->base = get_unaligned_le32(p);
1153 config->subtuples = tuple->TupleDataLen - 6; 1185 config->subtuples = tuple->TupleDataLen - 6;
1154 return CS_SUCCESS; 1186 return 0;
1155} 1187}
1156 1188
1157static int parse_cftable_entry_cb(tuple_t *tuple, 1189static int parse_cftable_entry_cb(tuple_t *tuple,
@@ -1167,29 +1199,34 @@ static int parse_cftable_entry_cb(tuple_t *tuple,
1167 entry->flags |= CISTPL_CFTABLE_DEFAULT; 1199 entry->flags |= CISTPL_CFTABLE_DEFAULT;
1168 1200
1169 /* Process optional features */ 1201 /* Process optional features */
1170 if (++p == q) return CS_BAD_TUPLE; 1202 if (++p == q)
1203 return -EINVAL;
1171 features = *p; p++; 1204 features = *p; p++;
1172 1205
1173 /* Power options */ 1206 /* Power options */
1174 if ((features & 3) > 0) { 1207 if ((features & 3) > 0) {
1175 p = parse_power(p, q, &entry->vcc); 1208 p = parse_power(p, q, &entry->vcc);
1176 if (p == NULL) return CS_BAD_TUPLE; 1209 if (p == NULL)
1210 return -EINVAL;
1177 } else 1211 } else
1178 entry->vcc.present = 0; 1212 entry->vcc.present = 0;
1179 if ((features & 3) > 1) { 1213 if ((features & 3) > 1) {
1180 p = parse_power(p, q, &entry->vpp1); 1214 p = parse_power(p, q, &entry->vpp1);
1181 if (p == NULL) return CS_BAD_TUPLE; 1215 if (p == NULL)
1216 return -EINVAL;
1182 } else 1217 } else
1183 entry->vpp1.present = 0; 1218 entry->vpp1.present = 0;
1184 if ((features & 3) > 2) { 1219 if ((features & 3) > 2) {
1185 p = parse_power(p, q, &entry->vpp2); 1220 p = parse_power(p, q, &entry->vpp2);
1186 if (p == NULL) return CS_BAD_TUPLE; 1221 if (p == NULL)
1222 return -EINVAL;
1187 } else 1223 } else
1188 entry->vpp2.present = 0; 1224 entry->vpp2.present = 0;
1189 1225
1190 /* I/O window options */ 1226 /* I/O window options */
1191 if (features & 0x08) { 1227 if (features & 0x08) {
1192 if (p == q) return CS_BAD_TUPLE; 1228 if (p == q)
1229 return -EINVAL;
1193 entry->io = *p; p++; 1230 entry->io = *p; p++;
1194 } else 1231 } else
1195 entry->io = 0; 1232 entry->io = 0;
@@ -1197,32 +1234,37 @@ static int parse_cftable_entry_cb(tuple_t *tuple,
1197 /* Interrupt options */ 1234 /* Interrupt options */
1198 if (features & 0x10) { 1235 if (features & 0x10) {
1199 p = parse_irq(p, q, &entry->irq); 1236 p = parse_irq(p, q, &entry->irq);
1200 if (p == NULL) return CS_BAD_TUPLE; 1237 if (p == NULL)
1238 return -EINVAL;
1201 } else 1239 } else
1202 entry->irq.IRQInfo1 = 0; 1240 entry->irq.IRQInfo1 = 0;
1203 1241
1204 if (features & 0x20) { 1242 if (features & 0x20) {
1205 if (p == q) return CS_BAD_TUPLE; 1243 if (p == q)
1244 return -EINVAL;
1206 entry->mem = *p; p++; 1245 entry->mem = *p; p++;
1207 } else 1246 } else
1208 entry->mem = 0; 1247 entry->mem = 0;
1209 1248
1210 /* Misc features */ 1249 /* Misc features */
1211 if (features & 0x80) { 1250 if (features & 0x80) {
1212 if (p == q) return CS_BAD_TUPLE; 1251 if (p == q)
1252 return -EINVAL;
1213 entry->flags |= (*p << 8); 1253 entry->flags |= (*p << 8);
1214 if (*p & 0x80) { 1254 if (*p & 0x80) {
1215 if (++p == q) return CS_BAD_TUPLE; 1255 if (++p == q)
1256 return -EINVAL;
1216 entry->flags |= (*p << 16); 1257 entry->flags |= (*p << 16);
1217 } 1258 }
1218 while (*p & 0x80) 1259 while (*p & 0x80)
1219 if (++p == q) return CS_BAD_TUPLE; 1260 if (++p == q)
1261 return -EINVAL;
1220 p++; 1262 p++;
1221 } 1263 }
1222 1264
1223 entry->subtuples = q-p; 1265 entry->subtuples = q-p;
1224 1266
1225 return CS_SUCCESS; 1267 return 0;
1226} 1268}
1227 1269
1228#endif 1270#endif
@@ -1248,7 +1290,7 @@ static int parse_device_geo(tuple_t *tuple, cistpl_device_geo_t *geo)
1248 p += 6; 1290 p += 6;
1249 } 1291 }
1250 geo->ngeo = n; 1292 geo->ngeo = n;
1251 return CS_SUCCESS; 1293 return 0;
1252} 1294}
1253 1295
1254/*====================================================================*/ 1296/*====================================================================*/
@@ -1258,7 +1300,7 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2)
1258 u_char *p, *q; 1300 u_char *p, *q;
1259 1301
1260 if (tuple->TupleDataLen < 10) 1302 if (tuple->TupleDataLen < 10)
1261 return CS_BAD_TUPLE; 1303 return -EINVAL;
1262 1304
1263 p = tuple->TupleData; 1305 p = tuple->TupleData;
1264 q = p + tuple->TupleDataLen; 1306 q = p + tuple->TupleDataLen;
@@ -1282,15 +1324,18 @@ static int parse_org(tuple_t *tuple, cistpl_org_t *org)
1282 1324
1283 p = tuple->TupleData; 1325 p = tuple->TupleData;
1284 q = p + tuple->TupleDataLen; 1326 q = p + tuple->TupleDataLen;
1285 if (p == q) return CS_BAD_TUPLE; 1327 if (p == q)
1328 return -EINVAL;
1286 org->data_org = *p; 1329 org->data_org = *p;
1287 if (++p == q) return CS_BAD_TUPLE; 1330 if (++p == q)
1331 return -EINVAL;
1288 for (i = 0; i < 30; i++) { 1332 for (i = 0; i < 30; i++) {
1289 org->desc[i] = *p; 1333 org->desc[i] = *p;
1290 if (*p == '\0') break; 1334 if (*p == '\0') break;
1291 if (++p == q) return CS_BAD_TUPLE; 1335 if (++p == q)
1336 return -EINVAL;
1292 } 1337 }
1293 return CS_SUCCESS; 1338 return 0;
1294} 1339}
1295 1340
1296/*====================================================================*/ 1341/*====================================================================*/
@@ -1300,7 +1345,7 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt)
1300 u_char *p; 1345 u_char *p;
1301 1346
1302 if (tuple->TupleDataLen < 10) 1347 if (tuple->TupleDataLen < 10)
1303 return CS_BAD_TUPLE; 1348 return -EINVAL;
1304 1349
1305 p = tuple->TupleData; 1350 p = tuple->TupleData;
1306 1351
@@ -1309,17 +1354,17 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt)
1309 fmt->offset = get_unaligned_le32(p + 2); 1354 fmt->offset = get_unaligned_le32(p + 2);
1310 fmt->length = get_unaligned_le32(p + 6); 1355 fmt->length = get_unaligned_le32(p + 6);
1311 1356
1312 return CS_SUCCESS; 1357 return 0;
1313} 1358}
1314 1359
1315/*====================================================================*/ 1360/*====================================================================*/
1316 1361
1317int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse) 1362int pcmcia_parse_tuple(tuple_t *tuple, cisparse_t *parse)
1318{ 1363{
1319 int ret = CS_SUCCESS; 1364 int ret = 0;
1320 1365
1321 if (tuple->TupleDataLen > tuple->TupleDataMax) 1366 if (tuple->TupleDataLen > tuple->TupleDataMax)
1322 return CS_BAD_TUPLE; 1367 return -EINVAL;
1323 switch (tuple->TupleCode) { 1368 switch (tuple->TupleCode) {
1324 case CISTPL_DEVICE: 1369 case CISTPL_DEVICE:
1325 case CISTPL_DEVICE_A: 1370 case CISTPL_DEVICE_A:
@@ -1387,15 +1432,17 @@ int pccard_parse_tuple(tuple_t *tuple, cisparse_t *parse)
1387 break; 1432 break;
1388 case CISTPL_NO_LINK: 1433 case CISTPL_NO_LINK:
1389 case CISTPL_LINKTARGET: 1434 case CISTPL_LINKTARGET:
1390 ret = CS_SUCCESS; 1435 ret = 0;
1391 break; 1436 break;
1392 default: 1437 default:
1393 ret = CS_UNSUPPORTED_FUNCTION; 1438 ret = -EINVAL;
1394 break; 1439 break;
1395 } 1440 }
1441 if (ret)
1442 __cs_dbg(0, "parse_tuple failed %d\n", ret);
1396 return ret; 1443 return ret;
1397} 1444}
1398EXPORT_SYMBOL(pccard_parse_tuple); 1445EXPORT_SYMBOL(pcmcia_parse_tuple);
1399 1446
1400/*====================================================================== 1447/*======================================================================
1401 1448
@@ -1410,18 +1457,22 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t
1410 int ret; 1457 int ret;
1411 1458
1412 buf = kmalloc(256, GFP_KERNEL); 1459 buf = kmalloc(256, GFP_KERNEL);
1413 if (buf == NULL) 1460 if (buf == NULL) {
1414 return CS_OUT_OF_RESOURCE; 1461 dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n");
1462 return -ENOMEM;
1463 }
1415 tuple.DesiredTuple = code; 1464 tuple.DesiredTuple = code;
1416 tuple.Attributes = TUPLE_RETURN_COMMON; 1465 tuple.Attributes = TUPLE_RETURN_COMMON;
1417 ret = pccard_get_first_tuple(s, function, &tuple); 1466 ret = pccard_get_first_tuple(s, function, &tuple);
1418 if (ret != CS_SUCCESS) goto done; 1467 if (ret != 0)
1468 goto done;
1419 tuple.TupleData = buf; 1469 tuple.TupleData = buf;
1420 tuple.TupleOffset = 0; 1470 tuple.TupleOffset = 0;
1421 tuple.TupleDataMax = 255; 1471 tuple.TupleDataMax = 255;
1422 ret = pccard_get_tuple_data(s, &tuple); 1472 ret = pccard_get_tuple_data(s, &tuple);
1423 if (ret != CS_SUCCESS) goto done; 1473 if (ret != 0)
1424 ret = pccard_parse_tuple(&tuple, parse); 1474 goto done;
1475 ret = pcmcia_parse_tuple(&tuple, parse);
1425done: 1476done:
1426 kfree(buf); 1477 kfree(buf);
1427 return ret; 1478 return ret;
@@ -1446,37 +1497,40 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned
1446 int ret, reserved, dev_ok = 0, ident_ok = 0; 1497 int ret, reserved, dev_ok = 0, ident_ok = 0;
1447 1498
1448 if (!s) 1499 if (!s)
1449 return CS_BAD_HANDLE; 1500 return -EINVAL;
1450 1501
1451 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL); 1502 tuple = kmalloc(sizeof(*tuple), GFP_KERNEL);
1452 if (tuple == NULL) 1503 if (tuple == NULL) {
1453 return CS_OUT_OF_RESOURCE; 1504 dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n");
1505 return -ENOMEM;
1506 }
1454 p = kmalloc(sizeof(*p), GFP_KERNEL); 1507 p = kmalloc(sizeof(*p), GFP_KERNEL);
1455 if (p == NULL) { 1508 if (p == NULL) {
1456 kfree(tuple); 1509 kfree(tuple);
1457 return CS_OUT_OF_RESOURCE; 1510 dev_printk(KERN_WARNING, &s->dev, "no memory to validate CIS\n");
1511 return -ENOMEM;
1458 } 1512 }
1459 1513
1460 count = reserved = 0; 1514 count = reserved = 0;
1461 tuple->DesiredTuple = RETURN_FIRST_TUPLE; 1515 tuple->DesiredTuple = RETURN_FIRST_TUPLE;
1462 tuple->Attributes = TUPLE_RETURN_COMMON; 1516 tuple->Attributes = TUPLE_RETURN_COMMON;
1463 ret = pccard_get_first_tuple(s, function, tuple); 1517 ret = pccard_get_first_tuple(s, function, tuple);
1464 if (ret != CS_SUCCESS) 1518 if (ret != 0)
1465 goto done; 1519 goto done;
1466 1520
1467 /* First tuple should be DEVICE; we should really have either that 1521 /* First tuple should be DEVICE; we should really have either that
1468 or a CFTABLE_ENTRY of some sort */ 1522 or a CFTABLE_ENTRY of some sort */
1469 if ((tuple->TupleCode == CISTPL_DEVICE) || 1523 if ((tuple->TupleCode == CISTPL_DEVICE) ||
1470 (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == CS_SUCCESS) || 1524 (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY, p) == 0) ||
1471 (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == CS_SUCCESS)) 1525 (pccard_read_tuple(s, function, CISTPL_CFTABLE_ENTRY_CB, p) == 0))
1472 dev_ok++; 1526 dev_ok++;
1473 1527
1474 /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2 1528 /* All cards should have a MANFID tuple, and/or a VERS_1 or VERS_2
1475 tuple, for card identification. Certain old D-Link and Linksys 1529 tuple, for card identification. Certain old D-Link and Linksys
1476 cards have only a broken VERS_2 tuple; hence the bogus test. */ 1530 cards have only a broken VERS_2 tuple; hence the bogus test. */
1477 if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == CS_SUCCESS) || 1531 if ((pccard_read_tuple(s, function, CISTPL_MANFID, p) == 0) ||
1478 (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == CS_SUCCESS) || 1532 (pccard_read_tuple(s, function, CISTPL_VERS_1, p) == 0) ||
1479 (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != CS_NO_MORE_ITEMS)) 1533 (pccard_read_tuple(s, function, CISTPL_VERS_2, p) != -ENOSPC))
1480 ident_ok++; 1534 ident_ok++;
1481 1535
1482 if (!dev_ok && !ident_ok) 1536 if (!dev_ok && !ident_ok)
@@ -1484,7 +1538,8 @@ int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function, unsigned
1484 1538
1485 for (count = 1; count < MAX_TUPLES; count++) { 1539 for (count = 1; count < MAX_TUPLES; count++) {
1486 ret = pccard_get_next_tuple(s, function, tuple); 1540 ret = pccard_get_next_tuple(s, function, tuple);
1487 if (ret != CS_SUCCESS) break; 1541 if (ret != 0)
1542 break;
1488 if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) || 1543 if (((tuple->TupleCode > 0x23) && (tuple->TupleCode < 0x40)) ||
1489 ((tuple->TupleCode > 0x47) && (tuple->TupleCode < 0x80)) || 1544 ((tuple->TupleCode > 0x47) && (tuple->TupleCode < 0x80)) ||
1490 ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff))) 1545 ((tuple->TupleCode > 0x90) && (tuple->TupleCode < 0xff)))
@@ -1499,6 +1554,6 @@ done:
1499 *info = count; 1554 *info = count;
1500 kfree(tuple); 1555 kfree(tuple);
1501 kfree(p); 1556 kfree(p);
1502 return CS_SUCCESS; 1557 return 0;
1503} 1558}
1504EXPORT_SYMBOL(pccard_validate_cis); 1559EXPORT_SYMBOL(pccard_validate_cis);
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index d1207393fc3..c68c5d33828 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -61,7 +61,7 @@ INT_MODULE_PARM(unreset_limit, 30); /* unreset_check's */
61/* Access speed for attribute memory windows */ 61/* Access speed for attribute memory windows */
62INT_MODULE_PARM(cis_speed, 300); /* ns */ 62INT_MODULE_PARM(cis_speed, 300); /* ns */
63 63
64#ifdef DEBUG 64#ifdef CONFIG_PCMCIA_DEBUG
65static int pc_debug; 65static int pc_debug;
66 66
67module_param(pc_debug, int, 0644); 67module_param(pc_debug, int, 0644);
@@ -247,7 +247,8 @@ int pcmcia_register_socket(struct pcmcia_socket *socket)
247 247
248 wait_for_completion(&socket->thread_done); 248 wait_for_completion(&socket->thread_done);
249 if (!socket->thread) { 249 if (!socket->thread) {
250 printk(KERN_WARNING "PCMCIA: warning: socket thread for socket %p did not start\n", socket); 250 dev_printk(KERN_WARNING, &socket->dev,
251 "PCMCIA: warning: socket thread did not start\n");
251 return -EIO; 252 return -EIO;
252 } 253 }
253 254
@@ -366,16 +367,16 @@ static int socket_reset(struct pcmcia_socket *skt)
366 skt->ops->get_status(skt, &status); 367 skt->ops->get_status(skt, &status);
367 368
368 if (!(status & SS_DETECT)) 369 if (!(status & SS_DETECT))
369 return CS_NO_CARD; 370 return -ENODEV;
370 371
371 if (status & SS_READY) 372 if (status & SS_READY)
372 return CS_SUCCESS; 373 return 0;
373 374
374 msleep(unreset_check * 10); 375 msleep(unreset_check * 10);
375 } 376 }
376 377
377 cs_err(skt, "time out after reset.\n"); 378 cs_err(skt, "time out after reset.\n");
378 return CS_GENERAL_FAILURE; 379 return -ETIMEDOUT;
379} 380}
380 381
381/* 382/*
@@ -412,7 +413,8 @@ static void socket_shutdown(struct pcmcia_socket *s)
412 413
413 s->ops->get_status(s, &status); 414 s->ops->get_status(s, &status);
414 if (status & SS_POWERON) { 415 if (status & SS_POWERON) {
415 printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); 416 dev_printk(KERN_ERR, &s->dev,
417 "*** DANGER *** unable to remove socket power\n");
416 } 418 }
417 419
418 cs_socket_put(s); 420 cs_socket_put(s);
@@ -426,14 +428,14 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
426 428
427 skt->ops->get_status(skt, &status); 429 skt->ops->get_status(skt, &status);
428 if (!(status & SS_DETECT)) 430 if (!(status & SS_DETECT))
429 return CS_NO_CARD; 431 return -ENODEV;
430 432
431 msleep(initial_delay * 10); 433 msleep(initial_delay * 10);
432 434
433 for (i = 0; i < 100; i++) { 435 for (i = 0; i < 100; i++) {
434 skt->ops->get_status(skt, &status); 436 skt->ops->get_status(skt, &status);
435 if (!(status & SS_DETECT)) 437 if (!(status & SS_DETECT))
436 return CS_NO_CARD; 438 return -ENODEV;
437 439
438 if (!(status & SS_PENDING)) 440 if (!(status & SS_PENDING))
439 break; 441 break;
@@ -443,13 +445,13 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
443 445
444 if (status & SS_PENDING) { 446 if (status & SS_PENDING) {
445 cs_err(skt, "voltage interrogation timed out.\n"); 447 cs_err(skt, "voltage interrogation timed out.\n");
446 return CS_GENERAL_FAILURE; 448 return -ETIMEDOUT;
447 } 449 }
448 450
449 if (status & SS_CARDBUS) { 451 if (status & SS_CARDBUS) {
450 if (!(skt->features & SS_CAP_CARDBUS)) { 452 if (!(skt->features & SS_CAP_CARDBUS)) {
451 cs_err(skt, "cardbus cards are not supported.\n"); 453 cs_err(skt, "cardbus cards are not supported.\n");
452 return CS_BAD_TYPE; 454 return -EINVAL;
453 } 455 }
454 skt->state |= SOCKET_CARDBUS; 456 skt->state |= SOCKET_CARDBUS;
455 } 457 }
@@ -463,7 +465,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
463 skt->socket.Vcc = skt->socket.Vpp = 50; 465 skt->socket.Vcc = skt->socket.Vpp = 50;
464 else { 466 else {
465 cs_err(skt, "unsupported voltage key.\n"); 467 cs_err(skt, "unsupported voltage key.\n");
466 return CS_BAD_TYPE; 468 return -EIO;
467 } 469 }
468 470
469 if (skt->power_hook) 471 if (skt->power_hook)
@@ -480,7 +482,7 @@ static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
480 skt->ops->get_status(skt, &status); 482 skt->ops->get_status(skt, &status);
481 if (!(status & SS_POWERON)) { 483 if (!(status & SS_POWERON)) {
482 cs_err(skt, "unable to apply power.\n"); 484 cs_err(skt, "unable to apply power.\n");
483 return CS_BAD_TYPE; 485 return -EIO;
484 } 486 }
485 487
486 status = socket_reset(skt); 488 status = socket_reset(skt);
@@ -502,15 +504,16 @@ static int socket_insert(struct pcmcia_socket *skt)
502 cs_dbg(skt, 4, "insert\n"); 504 cs_dbg(skt, 4, "insert\n");
503 505
504 if (!cs_socket_get(skt)) 506 if (!cs_socket_get(skt))
505 return CS_NO_CARD; 507 return -ENODEV;
506 508
507 ret = socket_setup(skt, setup_delay); 509 ret = socket_setup(skt, setup_delay);
508 if (ret == CS_SUCCESS) { 510 if (ret == 0) {
509 skt->state |= SOCKET_PRESENT; 511 skt->state |= SOCKET_PRESENT;
510 512
511 printk(KERN_NOTICE "pccard: %s card inserted into slot %d\n", 513 dev_printk(KERN_NOTICE, &skt->dev,
512 (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA", 514 "pccard: %s card inserted into slot %d\n",
513 skt->sock); 515 (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA",
516 skt->sock);
514 517
515#ifdef CONFIG_CARDBUS 518#ifdef CONFIG_CARDBUS
516 if (skt->state & SOCKET_CARDBUS) { 519 if (skt->state & SOCKET_CARDBUS) {
@@ -531,7 +534,7 @@ static int socket_insert(struct pcmcia_socket *skt)
531static int socket_suspend(struct pcmcia_socket *skt) 534static int socket_suspend(struct pcmcia_socket *skt)
532{ 535{
533 if (skt->state & SOCKET_SUSPEND) 536 if (skt->state & SOCKET_SUSPEND)
534 return CS_IN_USE; 537 return -EBUSY;
535 538
536 send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW); 539 send_event(skt, CS_EVENT_PM_SUSPEND, CS_EVENT_PRI_LOW);
537 skt->socket = dead_socket; 540 skt->socket = dead_socket;
@@ -540,7 +543,7 @@ static int socket_suspend(struct pcmcia_socket *skt)
540 skt->ops->suspend(skt); 543 skt->ops->suspend(skt);
541 skt->state |= SOCKET_SUSPEND; 544 skt->state |= SOCKET_SUSPEND;
542 545
543 return CS_SUCCESS; 546 return 0;
544} 547}
545 548
546/* 549/*
@@ -553,7 +556,7 @@ static int socket_resume(struct pcmcia_socket *skt)
553 int ret; 556 int ret;
554 557
555 if (!(skt->state & SOCKET_SUSPEND)) 558 if (!(skt->state & SOCKET_SUSPEND))
556 return CS_IN_USE; 559 return -EBUSY;
557 560
558 skt->socket = dead_socket; 561 skt->socket = dead_socket;
559 skt->ops->init(skt); 562 skt->ops->init(skt);
@@ -565,7 +568,7 @@ static int socket_resume(struct pcmcia_socket *skt)
565 } 568 }
566 569
567 ret = socket_setup(skt, resume_delay); 570 ret = socket_setup(skt, resume_delay);
568 if (ret == CS_SUCCESS) { 571 if (ret == 0) {
569 /* 572 /*
570 * FIXME: need a better check here for cardbus cards. 573 * FIXME: need a better check here for cardbus cards.
571 */ 574 */
@@ -590,12 +593,13 @@ static int socket_resume(struct pcmcia_socket *skt)
590 593
591 skt->state &= ~SOCKET_SUSPEND; 594 skt->state &= ~SOCKET_SUSPEND;
592 595
593 return CS_SUCCESS; 596 return 0;
594} 597}
595 598
596static void socket_remove(struct pcmcia_socket *skt) 599static void socket_remove(struct pcmcia_socket *skt)
597{ 600{
598 printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock); 601 dev_printk(KERN_NOTICE, &skt->dev,
602 "pccard: card ejected from slot %d\n", skt->sock);
599 socket_shutdown(skt); 603 socket_shutdown(skt);
600} 604}
601 605
@@ -641,8 +645,8 @@ static int pccardd(void *__skt)
641 /* register with the device core */ 645 /* register with the device core */
642 ret = device_register(&skt->dev); 646 ret = device_register(&skt->dev);
643 if (ret) { 647 if (ret) {
644 printk(KERN_WARNING "PCMCIA: unable to register socket 0x%p\n", 648 dev_printk(KERN_WARNING, &skt->dev,
645 skt); 649 "PCMCIA: unable to register socket\n");
646 skt->thread = NULL; 650 skt->thread = NULL;
647 complete(&skt->thread_done); 651 complete(&skt->thread_done);
648 return 0; 652 return 0;
@@ -748,7 +752,7 @@ EXPORT_SYMBOL(pccard_register_pcmcia);
748 * CIS register. 752 * CIS register.
749 */ 753 */
750 754
751int pccard_reset_card(struct pcmcia_socket *skt) 755int pcmcia_reset_card(struct pcmcia_socket *skt)
752{ 756{
753 int ret; 757 int ret;
754 758
@@ -757,15 +761,15 @@ int pccard_reset_card(struct pcmcia_socket *skt)
757 mutex_lock(&skt->skt_mutex); 761 mutex_lock(&skt->skt_mutex);
758 do { 762 do {
759 if (!(skt->state & SOCKET_PRESENT)) { 763 if (!(skt->state & SOCKET_PRESENT)) {
760 ret = CS_NO_CARD; 764 ret = -ENODEV;
761 break; 765 break;
762 } 766 }
763 if (skt->state & SOCKET_SUSPEND) { 767 if (skt->state & SOCKET_SUSPEND) {
764 ret = CS_IN_USE; 768 ret = -EBUSY;
765 break; 769 break;
766 } 770 }
767 if (skt->state & SOCKET_CARDBUS) { 771 if (skt->state & SOCKET_CARDBUS) {
768 ret = CS_UNSUPPORTED_FUNCTION; 772 ret = -EPERM;
769 break; 773 break;
770 } 774 }
771 775
@@ -774,20 +778,20 @@ int pccard_reset_card(struct pcmcia_socket *skt)
774 send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); 778 send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW);
775 if (skt->callback) 779 if (skt->callback)
776 skt->callback->suspend(skt); 780 skt->callback->suspend(skt);
777 if (socket_reset(skt) == CS_SUCCESS) { 781 if (socket_reset(skt) == 0) {
778 send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); 782 send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW);
779 if (skt->callback) 783 if (skt->callback)
780 skt->callback->resume(skt); 784 skt->callback->resume(skt);
781 } 785 }
782 } 786 }
783 787
784 ret = CS_SUCCESS; 788 ret = 0;
785 } while (0); 789 } while (0);
786 mutex_unlock(&skt->skt_mutex); 790 mutex_unlock(&skt->skt_mutex);
787 791
788 return ret; 792 return ret;
789} /* reset_card */ 793} /* reset_card */
790EXPORT_SYMBOL(pccard_reset_card); 794EXPORT_SYMBOL(pcmcia_reset_card);
791 795
792 796
793/* These shut down or wake up a socket. They are sort of user 797/* These shut down or wake up a socket. They are sort of user
@@ -802,11 +806,11 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt)
802 mutex_lock(&skt->skt_mutex); 806 mutex_lock(&skt->skt_mutex);
803 do { 807 do {
804 if (!(skt->state & SOCKET_PRESENT)) { 808 if (!(skt->state & SOCKET_PRESENT)) {
805 ret = CS_NO_CARD; 809 ret = -ENODEV;
806 break; 810 break;
807 } 811 }
808 if (skt->state & SOCKET_CARDBUS) { 812 if (skt->state & SOCKET_CARDBUS) {
809 ret = CS_UNSUPPORTED_FUNCTION; 813 ret = -EPERM;
810 break; 814 break;
811 } 815 }
812 if (skt->callback) { 816 if (skt->callback) {
@@ -832,11 +836,11 @@ int pcmcia_resume_card(struct pcmcia_socket *skt)
832 mutex_lock(&skt->skt_mutex); 836 mutex_lock(&skt->skt_mutex);
833 do { 837 do {
834 if (!(skt->state & SOCKET_PRESENT)) { 838 if (!(skt->state & SOCKET_PRESENT)) {
835 ret = CS_NO_CARD; 839 ret = -ENODEV;
836 break; 840 break;
837 } 841 }
838 if (skt->state & SOCKET_CARDBUS) { 842 if (skt->state & SOCKET_CARDBUS) {
839 ret = CS_UNSUPPORTED_FUNCTION; 843 ret = -EPERM;
840 break; 844 break;
841 } 845 }
842 ret = socket_resume(skt); 846 ret = socket_resume(skt);
@@ -892,7 +896,7 @@ int pcmcia_insert_card(struct pcmcia_socket *skt)
892 ret = -EBUSY; 896 ret = -EBUSY;
893 break; 897 break;
894 } 898 }
895 if (socket_insert(skt) == CS_NO_CARD) { 899 if (socket_insert(skt) == -ENODEV) {
896 ret = -ENODEV; 900 ret = -ENODEV;
897 break; 901 break;
898 } 902 }
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index 63dc1a28bda..79615e6d540 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * cs_internal.h 2 * cs_internal.h -- definitions internal to the PCMCIA core modules
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as 5 * it under the terms of the GNU General Public License version 2 as
@@ -10,6 +10,12 @@
10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. 10 * are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
11 * 11 *
12 * (C) 1999 David A. Hinds 12 * (C) 1999 David A. Hinds
13 * (C) 2003 - 2008 Dominik Brodowski
14 *
15 *
16 * This file contains definitions _only_ needed by the PCMCIA core modules.
17 * It must not be included by PCMCIA socket drivers or by PCMCIA device
18 * drivers.
13 */ 19 */
14 20
15#ifndef _LINUX_CS_INTERNAL_H 21#ifndef _LINUX_CS_INTERNAL_H
@@ -18,29 +24,24 @@
18#include <linux/kref.h> 24#include <linux/kref.h>
19 25
20/* Flags in client state */ 26/* Flags in client state */
21#define CLIENT_CONFIG_LOCKED 0x0001
22#define CLIENT_IRQ_REQ 0x0002
23#define CLIENT_IO_REQ 0x0004
24#define CLIENT_UNBOUND 0x0008
25#define CLIENT_STALE 0x0010
26#define CLIENT_WIN_REQ(i) (0x1<<(i)) 27#define CLIENT_WIN_REQ(i) (0x1<<(i))
27#define CLIENT_CARDBUS 0x8000
28 28
29/* Each card function gets one of these guys */ 29/* Each card function gets one of these guys */
30typedef struct config_t { 30typedef struct config_t {
31 struct kref ref; 31 struct kref ref;
32 u_int state; 32 unsigned int state;
33 u_int Attributes; 33 unsigned int Attributes;
34 u_int IntType; 34 unsigned int IntType;
35 u_int ConfigBase; 35 unsigned int ConfigBase;
36 u_char Status, Pin, Copy, Option, ExtStatus; 36 unsigned char Status, Pin, Copy, Option, ExtStatus;
37 u_int CardValues; 37 unsigned int CardValues;
38 io_req_t io; 38 io_req_t io;
39 struct { 39 struct {
40 u_int Attributes; 40 u_int Attributes;
41 } irq; 41 } irq;
42} config_t; 42} config_t;
43 43
44
44struct cis_cache_entry { 45struct cis_cache_entry {
45 struct list_head node; 46 struct list_head node;
46 unsigned int addr; 47 unsigned int addr;
@@ -49,6 +50,30 @@ struct cis_cache_entry {
49 unsigned char cache[0]; 50 unsigned char cache[0];
50}; 51};
51 52
53struct pccard_resource_ops {
54 int (*validate_mem) (struct pcmcia_socket *s);
55 int (*adjust_io_region) (struct resource *res,
56 unsigned long r_start,
57 unsigned long r_end,
58 struct pcmcia_socket *s);
59 struct resource* (*find_io) (unsigned long base, int num,
60 unsigned long align,
61 struct pcmcia_socket *s);
62 struct resource* (*find_mem) (unsigned long base, unsigned long num,
63 unsigned long align, int low,
64 struct pcmcia_socket *s);
65 int (*add_io) (struct pcmcia_socket *s,
66 unsigned int action,
67 unsigned long r_start,
68 unsigned long r_end);
69 int (*add_mem) (struct pcmcia_socket *s,
70 unsigned int action,
71 unsigned long r_start,
72 unsigned long r_end);
73 int (*init) (struct pcmcia_socket *s);
74 void (*exit) (struct pcmcia_socket *s);
75};
76
52/* Flags in config state */ 77/* Flags in config state */
53#define CONFIG_LOCKED 0x01 78#define CONFIG_LOCKED 0x01
54#define CONFIG_IRQ_REQ 0x02 79#define CONFIG_IRQ_REQ 0x02
@@ -59,7 +84,6 @@ struct cis_cache_entry {
59#define SOCKET_INUSE 0x0010 84#define SOCKET_INUSE 0x0010
60#define SOCKET_SUSPEND 0x0080 85#define SOCKET_SUSPEND 0x0080
61#define SOCKET_WIN_REQ(i) (0x0100<<(i)) 86#define SOCKET_WIN_REQ(i) (0x0100<<(i))
62#define SOCKET_REGION_INFO 0x4000
63#define SOCKET_CARDBUS 0x8000 87#define SOCKET_CARDBUS 0x8000
64#define SOCKET_CARDBUS_CONFIG 0x10000 88#define SOCKET_CARDBUS_CONFIG 0x10000
65 89
@@ -83,69 +107,153 @@ static inline void cs_socket_put(struct pcmcia_socket *skt)
83 } 107 }
84} 108}
85 109
86/* In cardbus.c */ 110#ifdef CONFIG_PCMCIA_DEBUG
87int cb_alloc(struct pcmcia_socket *s); 111extern int cs_debug_level(int);
88void cb_free(struct pcmcia_socket *s);
89int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len, void *ptr);
90 112
91/* In cistpl.c */ 113#define cs_dbg(skt, lvl, fmt, arg...) do { \
92int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, 114 if (cs_debug_level(lvl)) \
93 u_int addr, u_int len, void *ptr); 115 dev_printk(KERN_DEBUG, &skt->dev, \
94void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, 116 "cs: " fmt, ## arg); \
95 u_int addr, u_int len, void *ptr); 117} while (0)
96void release_cis_mem(struct pcmcia_socket *s); 118#define __cs_dbg(lvl, fmt, arg...) do { \
97void destroy_cis_cache(struct pcmcia_socket *s); 119 if (cs_debug_level(lvl)) \
120 printk(KERN_DEBUG \
121 "cs: " fmt, ## arg); \
122} while (0)
123
124#else
125#define cs_dbg(skt, lvl, fmt, arg...) do { } while (0)
126#define __cs_dbg(lvl, fmt, arg...) do { } while (0)
127#endif
128
129#define cs_err(skt, fmt, arg...) \
130 dev_printk(KERN_ERR, &skt->dev, "cs: " fmt, ## arg)
131
132
133/*
134 * Stuff internal to module "pcmcia_core":
135 */
136
137/* cistpl.c */
98int verify_cis_cache(struct pcmcia_socket *s); 138int verify_cis_cache(struct pcmcia_socket *s);
99int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse);
100 139
101/* In rsrc_mgr */ 140/* rsrc_mgr.c */
102int pcmcia_validate_mem(struct pcmcia_socket *s);
103struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align,
104 struct pcmcia_socket *s);
105int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start,
106 unsigned long r_end, struct pcmcia_socket *s);
107struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align,
108 int low, struct pcmcia_socket *s);
109void release_resource_db(struct pcmcia_socket *s); 141void release_resource_db(struct pcmcia_socket *s);
110 142
111/* In socket_sysfs.c */ 143/* socket_sysfs.c */
112extern int pccard_sysfs_add_socket(struct device *dev); 144extern int pccard_sysfs_add_socket(struct device *dev);
113extern void pccard_sysfs_remove_socket(struct device *dev); 145extern void pccard_sysfs_remove_socket(struct device *dev);
114 146
115/* In cs.c */ 147/* cardbus.c */
116extern struct rw_semaphore pcmcia_socket_list_rwsem; 148int cb_alloc(struct pcmcia_socket *s);
117extern struct list_head pcmcia_socket_list; 149void cb_free(struct pcmcia_socket *s);
118int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req); 150int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len,
119int pccard_get_configuration_info(struct pcmcia_socket *s, struct pcmcia_device *p_dev, config_info_t *config); 151 void *ptr);
120int pccard_reset_card(struct pcmcia_socket *skt); 152
121 153
122 154
155/*
156 * Stuff exported by module "pcmcia_core" to module "pcmcia"
157 */
158
123struct pcmcia_callback{ 159struct pcmcia_callback{
124 struct module *owner; 160 struct module *owner;
125 int (*event) (struct pcmcia_socket *s, event_t event, int priority); 161 int (*event) (struct pcmcia_socket *s,
162 event_t event, int priority);
126 void (*requery) (struct pcmcia_socket *s, int new_cis); 163 void (*requery) (struct pcmcia_socket *s, int new_cis);
127 int (*suspend) (struct pcmcia_socket *s); 164 int (*suspend) (struct pcmcia_socket *s);
128 int (*resume) (struct pcmcia_socket *s); 165 int (*resume) (struct pcmcia_socket *s);
129}; 166};
130 167
168/* cs.c */
169extern struct rw_semaphore pcmcia_socket_list_rwsem;
170extern struct list_head pcmcia_socket_list;
171extern struct class pcmcia_socket_class;
172
173int pcmcia_get_window(struct pcmcia_socket *s,
174 window_handle_t *handle,
175 int idx,
176 win_req_t *req);
131int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); 177int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
178struct pcmcia_socket *pcmcia_get_socket_by_nr(unsigned int nr);
132 179
133#define cs_socket_name(skt) ((skt)->dev.bus_id) 180int pcmcia_suspend_card(struct pcmcia_socket *skt);
181int pcmcia_resume_card(struct pcmcia_socket *skt);
134 182
135#ifdef DEBUG 183int pcmcia_eject_card(struct pcmcia_socket *skt);
136extern int cs_debug_level(int); 184int pcmcia_insert_card(struct pcmcia_socket *skt);
137 185
138#define cs_dbg(skt, lvl, fmt, arg...) do { \ 186struct pcmcia_socket *pcmcia_get_socket(struct pcmcia_socket *skt);
139 if (cs_debug_level(lvl)) \ 187void pcmcia_put_socket(struct pcmcia_socket *skt);
140 printk(KERN_DEBUG "cs: %s: " fmt, \
141 cs_socket_name(skt) , ## arg); \
142} while (0)
143 188
144#else 189/* cistpl.c */
145#define cs_dbg(skt, lvl, fmt, arg...) do { } while (0) 190int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr,
146#endif 191 u_int addr, u_int len, void *ptr);
192void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr,
193 u_int addr, u_int len, void *ptr);
194void release_cis_mem(struct pcmcia_socket *s);
195void destroy_cis_cache(struct pcmcia_socket *s);
196int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function,
197 cisdata_t code, void *parse);
198int pcmcia_replace_cis(struct pcmcia_socket *s,
199 const u8 *data, const size_t len);
200int pccard_validate_cis(struct pcmcia_socket *s, unsigned int function,
201 unsigned int *count);
147 202
148#define cs_err(skt, fmt, arg...) \ 203/* rsrc_mgr.c */
149 printk(KERN_ERR "cs: %s: " fmt, (skt)->dev.bus_id , ## arg) 204int pcmcia_validate_mem(struct pcmcia_socket *s);
205struct resource *pcmcia_find_io_region(unsigned long base,
206 int num,
207 unsigned long align,
208 struct pcmcia_socket *s);
209int pcmcia_adjust_io_region(struct resource *res,
210 unsigned long r_start,
211 unsigned long r_end,
212 struct pcmcia_socket *s);
213struct resource *pcmcia_find_mem_region(u_long base,
214 u_long num,
215 u_long align,
216 int low,
217 struct pcmcia_socket *s);
218
219/*
220 * Stuff internal to module "pcmcia".
221 */
222/* ds.c */
223extern struct bus_type pcmcia_bus_type;
224
225/* pcmcia_resource.c */
226extern int pcmcia_release_configuration(struct pcmcia_device *p_dev);
227
228#ifdef CONFIG_PCMCIA_IOCTL
229/* ds.c */
230extern spinlock_t pcmcia_dev_list_lock;
231
232extern struct pcmcia_device *pcmcia_get_dev(struct pcmcia_device *p_dev);
233extern void pcmcia_put_dev(struct pcmcia_device *p_dev);
234
235struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s,
236 unsigned int function);
237
238/* pcmcia_ioctl.c */
239extern void __init pcmcia_setup_ioctl(void);
240extern void __exit pcmcia_cleanup_ioctl(void);
241extern void handle_event(struct pcmcia_socket *s, event_t event);
242extern int handle_request(struct pcmcia_socket *s, event_t event);
243
244#else /* CONFIG_PCMCIA_IOCTL */
245
246static inline void __init pcmcia_setup_ioctl(void) { return; }
247static inline void __exit pcmcia_cleanup_ioctl(void) { return; }
248static inline void handle_event(struct pcmcia_socket *s, event_t event)
249{
250 return;
251}
252static inline int handle_request(struct pcmcia_socket *s, event_t event)
253{
254 return 0;
255}
256
257#endif /* CONFIG_PCMCIA_IOCTL */
150 258
151#endif /* _LINUX_CS_INTERNAL_H */ 259#endif /* _LINUX_CS_INTERNAL_H */
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 34c83d3ca0f..79566025549 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 }
diff --git a/drivers/pcmcia/ds_internal.h b/drivers/pcmcia/ds_internal.h
deleted file mode 100644
index 3a2b25e6ed7..00000000000
--- a/drivers/pcmcia/ds_internal.h
+++ /dev/null
@@ -1,23 +0,0 @@
1/* ds_internal.h - internal header for 16-bit PCMCIA devices management */
2
3extern spinlock_t pcmcia_dev_list_lock;
4extern struct bus_type pcmcia_bus_type;
5
6extern struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev);
7extern void pcmcia_put_dev(struct pcmcia_device *p_dev);
8
9struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function);
10
11extern int pcmcia_release_configuration(struct pcmcia_device *p_dev);
12
13#ifdef CONFIG_PCMCIA_IOCTL
14extern void __init pcmcia_setup_ioctl(void);
15extern void __exit pcmcia_cleanup_ioctl(void);
16extern void handle_event(struct pcmcia_socket *s, event_t event);
17extern int handle_request(struct pcmcia_socket *s, event_t event);
18#else
19static inline void __init pcmcia_setup_ioctl(void) { return; }
20static inline void __exit pcmcia_cleanup_ioctl(void) { return; }
21static inline void handle_event(struct pcmcia_socket *s, event_t event) { return; }
22static inline int handle_request(struct pcmcia_socket *s, event_t event) { return CS_SUCCESS; }
23#endif
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c
index fb2bc1fb015..117dc12ab43 100644
--- a/drivers/pcmcia/hd64465_ss.c
+++ b/drivers/pcmcia/hd64465_ss.c
@@ -46,7 +46,6 @@
46#include <pcmcia/cistpl.h> 46#include <pcmcia/cistpl.h>
47#include <pcmcia/ds.h> 47#include <pcmcia/ds.h>
48#include <pcmcia/ss.h> 48#include <pcmcia/ss.h>
49#include "cs_internal.h"
50 49
51#define MODNAME "hd64465_ss" 50#define MODNAME "hd64465_ss"
52 51
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index 68f6b2702bc..71653ab8489 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -63,7 +63,7 @@
63#include "vg468.h" 63#include "vg468.h"
64#include "ricoh.h" 64#include "ricoh.h"
65 65
66#ifdef DEBUG 66#ifdef CONFIG_PCMCIA_DEBUG
67static const char version[] = 67static const char version[] =
68"i82365.c 1.265 1999/11/10 18:36:21 (David Hinds)"; 68"i82365.c 1.265 1999/11/10 18:36:21 (David Hinds)";
69 69
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 3616da22715..2ab4f22c21d 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -38,7 +38,7 @@
38 38
39#include "m32r_cfc.h" 39#include "m32r_cfc.h"
40 40
41#ifdef DEBUG 41#ifdef CONFIG_PCMCIA_DEBUG
42static int m32r_cfc_debug; 42static int m32r_cfc_debug;
43module_param(m32r_cfc_debug, int, 0644); 43module_param(m32r_cfc_debug, int, 0644);
44#define debug(lvl, fmt, arg...) do { \ 44#define debug(lvl, fmt, arg...) do { \
@@ -505,7 +505,7 @@ static int _pcc_set_socket(u_short sock, socket_state_t *state)
505 pcc_set(sock,(unsigned int)PLD_CFBUFCR,1); 505 pcc_set(sock,(unsigned int)PLD_CFBUFCR,1);
506 } 506 }
507 507
508#ifdef DEBUG 508#ifdef CONFIG_PCMCIA_DEBUG
509 if(state->flags & SS_IOCARD){ 509 if(state->flags & SS_IOCARD){
510 debug(3, ":IOCARD"); 510 debug(3, ":IOCARD");
511 } 511 }
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 2b42b7155e3..2f108c23dbd 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -45,7 +45,7 @@
45 45
46#define PCC_DEBUG_DBEX 46#define PCC_DEBUG_DBEX
47 47
48#ifdef DEBUG 48#ifdef CONFIG_PCMCIA_DEBUG
49static int m32r_pcc_debug; 49static int m32r_pcc_debug;
50module_param(m32r_pcc_debug, int, 0644); 50module_param(m32r_pcc_debug, int, 0644);
51#define debug(lvl, fmt, arg...) do { \ 51#define debug(lvl, fmt, arg...) do { \
@@ -460,7 +460,7 @@ static int _pcc_set_socket(u_short sock, socket_state_t *state)
460 460
461 pcc_set(sock,PCCSIGCR,reg); 461 pcc_set(sock,PCCSIGCR,reg);
462 462
463#ifdef DEBUG 463#ifdef CONFIG_PCMCIA_DEBUG
464 if(state->flags & SS_IOCARD){ 464 if(state->flags & SS_IOCARD){
465 debug(3, ":IOCARD"); 465 debug(3, ":IOCARD");
466 } 466 }
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index ff66604e90d..d1ad0966392 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -64,8 +64,8 @@
64#include <pcmcia/cs.h> 64#include <pcmcia/cs.h>
65#include <pcmcia/ss.h> 65#include <pcmcia/ss.h>
66 66
67#ifdef PCMCIA_DEBUG 67#ifdef CONFIG_PCMCIA_DEBUG
68static int pc_debug = PCMCIA_DEBUG; 68static int pc_debug;
69module_param(pc_debug, int, 0); 69module_param(pc_debug, int, 0);
70#define dprintk(args...) printk(KERN_DEBUG "m8xx_pcmcia: " args); 70#define dprintk(args...) printk(KERN_DEBUG "m8xx_pcmcia: " args);
71#else 71#else
diff --git a/drivers/pcmcia/o2micro.h b/drivers/pcmcia/o2micro.h
index a234ce1967a..5554015a781 100644
--- a/drivers/pcmcia/o2micro.h
+++ b/drivers/pcmcia/o2micro.h
@@ -140,7 +140,8 @@ static int o2micro_override(struct yenta_socket *socket)
140 a = config_readb(socket, O2_RESERVED1); 140 a = config_readb(socket, O2_RESERVED1);
141 b = config_readb(socket, O2_RESERVED2); 141 b = config_readb(socket, O2_RESERVED2);
142 142
143 printk(KERN_INFO "Yenta O2: res at 0x94/0xD4: %02x/%02x\n", a, b); 143 dev_printk(KERN_INFO, &socket->dev->dev,
144 "O2: res at 0x94/0xD4: %02x/%02x\n", a, b);
144 145
145 switch (socket->dev->device) { 146 switch (socket->dev->device) {
146 /* 147 /*
@@ -153,7 +154,9 @@ static int o2micro_override(struct yenta_socket *socket)
153 case PCI_DEVICE_ID_O2_6812: 154 case PCI_DEVICE_ID_O2_6812:
154 case PCI_DEVICE_ID_O2_6832: 155 case PCI_DEVICE_ID_O2_6832:
155 case PCI_DEVICE_ID_O2_6836: 156 case PCI_DEVICE_ID_O2_6836:
156 printk(KERN_INFO "Yenta O2: old bridge, disabling read prefetch/write burst\n"); 157 dev_printk(KERN_INFO, &socket->dev->dev,
158 "Yenta O2: old bridge, disabling read "
159 "prefetch/write burst\n");
157 config_writeb(socket, O2_RESERVED1, 160 config_writeb(socket, O2_RESERVED1,
158 a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST)); 161 a & ~(O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST));
159 config_writeb(socket, O2_RESERVED2, 162 config_writeb(socket, O2_RESERVED2,
@@ -161,7 +164,8 @@ static int o2micro_override(struct yenta_socket *socket)
161 break; 164 break;
162 165
163 default: 166 default:
164 printk(KERN_INFO "Yenta O2: enabling read prefetch/write burst\n"); 167 dev_printk(KERN_INFO , &socket->dev->dev,
168 "O2: enabling read prefetch/write burst\n");
165 config_writeb(socket, O2_RESERVED1, 169 config_writeb(socket, O2_RESERVED1,
166 a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST); 170 a | O2_RES_READ_PREFETCH | O2_RES_WRITE_BURST);
167 config_writeb(socket, O2_RESERVED2, 171 config_writeb(socket, O2_RESERVED2,
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c
index 419f97fc9a6..1703b20cad5 100644
--- a/drivers/pcmcia/pcmcia_ioctl.c
+++ b/drivers/pcmcia/pcmcia_ioctl.c
@@ -38,7 +38,6 @@
38#include <pcmcia/ss.h> 38#include <pcmcia/ss.h>
39 39
40#include "cs_internal.h" 40#include "cs_internal.h"
41#include "ds_internal.h"
42 41
43static int major_dev = -1; 42static int major_dev = -1;
44 43
@@ -58,7 +57,7 @@ typedef struct user_info_t {
58} user_info_t; 57} user_info_t;
59 58
60 59
61#ifdef DEBUG 60#ifdef CONFIG_PCMCIA_DEBUG
62extern int ds_pc_debug; 61extern int ds_pc_debug;
63 62
64#define ds_dbg(lvl, fmt, arg...) do { \ 63#define ds_dbg(lvl, fmt, arg...) do { \
@@ -149,7 +148,7 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
149 148
150 irq = adj->resource.irq.IRQ; 149 irq = adj->resource.irq.IRQ;
151 if ((irq < 0) || (irq > 15)) 150 if ((irq < 0) || (irq > 15))
152 return CS_BAD_IRQ; 151 return -EINVAL;
153 152
154 if (adj->Action != REMOVE_MANAGED_RESOURCE) 153 if (adj->Action != REMOVE_MANAGED_RESOURCE)
155 return 0; 154 return 0;
@@ -167,7 +166,7 @@ static int adjust_irq(struct pcmcia_socket *s, adjust_t *adj)
167#else 166#else
168 167
169static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) { 168static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) {
170 return CS_SUCCESS; 169 return 0;
171} 170}
172 171
173#endif 172#endif
@@ -175,7 +174,7 @@ static inline int adjust_irq(struct pcmcia_socket *s, adjust_t *adj) {
175static int pcmcia_adjust_resource_info(adjust_t *adj) 174static int pcmcia_adjust_resource_info(adjust_t *adj)
176{ 175{
177 struct pcmcia_socket *s; 176 struct pcmcia_socket *s;
178 int ret = CS_UNSUPPORTED_FUNCTION; 177 int ret = -ENOSYS;
179 unsigned long flags; 178 unsigned long flags;
180 179
181 down_read(&pcmcia_socket_list_rwsem); 180 down_read(&pcmcia_socket_list_rwsem);
@@ -248,7 +247,7 @@ static int pccard_get_status(struct pcmcia_socket *s,
248 if (s->state & SOCKET_SUSPEND) 247 if (s->state & SOCKET_SUSPEND)
249 status->CardState |= CS_EVENT_PM_SUSPEND; 248 status->CardState |= CS_EVENT_PM_SUSPEND;
250 if (!(s->state & SOCKET_PRESENT)) 249 if (!(s->state & SOCKET_PRESENT))
251 return CS_NO_CARD; 250 return -ENODEV;
252 251
253 c = (p_dev) ? p_dev->function_config : NULL; 252 c = (p_dev) ? p_dev->function_config : NULL;
254 253
@@ -274,7 +273,7 @@ static int pccard_get_status(struct pcmcia_socket *s,
274 status->CardState |= 273 status->CardState |=
275 (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; 274 (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0;
276 } 275 }
277 return CS_SUCCESS; 276 return 0;
278 } 277 }
279 status->CardState |= 278 status->CardState |=
280 (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0; 279 (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0;
@@ -284,9 +283,81 @@ static int pccard_get_status(struct pcmcia_socket *s,
284 (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0; 283 (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0;
285 status->CardState |= 284 status->CardState |=
286 (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0; 285 (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0;
287 return CS_SUCCESS; 286 return 0;
288} /* pccard_get_status */ 287} /* pccard_get_status */
289 288
289int pccard_get_configuration_info(struct pcmcia_socket *s,
290 struct pcmcia_device *p_dev,
291 config_info_t *config)
292{
293 config_t *c;
294
295 if (!(s->state & SOCKET_PRESENT))
296 return -ENODEV;
297
298
299#ifdef CONFIG_CARDBUS
300 if (s->state & SOCKET_CARDBUS) {
301 memset(config, 0, sizeof(config_info_t));
302 config->Vcc = s->socket.Vcc;
303 config->Vpp1 = config->Vpp2 = s->socket.Vpp;
304 config->Option = s->cb_dev->subordinate->number;
305 if (s->state & SOCKET_CARDBUS_CONFIG) {
306 config->Attributes = CONF_VALID_CLIENT;
307 config->IntType = INT_CARDBUS;
308 config->AssignedIRQ = s->irq.AssignedIRQ;
309 if (config->AssignedIRQ)
310 config->Attributes |= CONF_ENABLE_IRQ;
311 if (s->io[0].res) {
312 config->BasePort1 = s->io[0].res->start;
313 config->NumPorts1 = s->io[0].res->end -
314 config->BasePort1 + 1;
315 }
316 }
317 return 0;
318 }
319#endif
320
321 if (p_dev) {
322 c = p_dev->function_config;
323 config->Function = p_dev->func;
324 } else {
325 c = NULL;
326 config->Function = 0;
327 }
328
329 if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
330 config->Attributes = 0;
331 config->Vcc = s->socket.Vcc;
332 config->Vpp1 = config->Vpp2 = s->socket.Vpp;
333 return 0;
334 }
335
336 config->Attributes = c->Attributes | CONF_VALID_CLIENT;
337 config->Vcc = s->socket.Vcc;
338 config->Vpp1 = config->Vpp2 = s->socket.Vpp;
339 config->IntType = c->IntType;
340 config->ConfigBase = c->ConfigBase;
341 config->Status = c->Status;
342 config->Pin = c->Pin;
343 config->Copy = c->Copy;
344 config->Option = c->Option;
345 config->ExtStatus = c->ExtStatus;
346 config->Present = config->CardValues = c->CardValues;
347 config->IRQAttributes = c->irq.Attributes;
348 config->AssignedIRQ = s->irq.AssignedIRQ;
349 config->BasePort1 = c->io.BasePort1;
350 config->NumPorts1 = c->io.NumPorts1;
351 config->Attributes1 = c->io.Attributes1;
352 config->BasePort2 = c->io.BasePort2;
353 config->NumPorts2 = c->io.NumPorts2;
354 config->Attributes2 = c->io.Attributes2;
355 config->IOAddrLines = c->io.IOAddrLines;
356
357 return 0;
358} /* pccard_get_configuration_info */
359
360
290/*====================================================================== 361/*======================================================================
291 362
292 These manage a ring buffer of events pending for one user process 363 These manage a ring buffer of events pending for one user process
@@ -764,7 +835,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
764 case DS_GET_CONFIGURATION_INFO: 835 case DS_GET_CONFIGURATION_INFO:
765 if (buf->config.Function && 836 if (buf->config.Function &&
766 (buf->config.Function >= s->functions)) 837 (buf->config.Function >= s->functions))
767 ret = CS_BAD_ARGS; 838 ret = -EINVAL;
768 else { 839 else {
769 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function); 840 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->config.Function);
770 ret = pccard_get_configuration_info(s, p_dev, &buf->config); 841 ret = pccard_get_configuration_info(s, p_dev, &buf->config);
@@ -787,15 +858,15 @@ static int ds_ioctl(struct inode * inode, struct file * file,
787 break; 858 break;
788 case DS_PARSE_TUPLE: 859 case DS_PARSE_TUPLE:
789 buf->tuple.TupleData = buf->tuple_parse.data; 860 buf->tuple.TupleData = buf->tuple_parse.data;
790 ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); 861 ret = pcmcia_parse_tuple(&buf->tuple, &buf->tuple_parse.parse);
791 break; 862 break;
792 case DS_RESET_CARD: 863 case DS_RESET_CARD:
793 ret = pccard_reset_card(s); 864 ret = pcmcia_reset_card(s);
794 break; 865 break;
795 case DS_GET_STATUS: 866 case DS_GET_STATUS:
796 if (buf->status.Function && 867 if (buf->status.Function &&
797 (buf->status.Function >= s->functions)) 868 (buf->status.Function >= s->functions))
798 ret = CS_BAD_ARGS; 869 ret = -EINVAL;
799 else { 870 else {
800 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function); 871 struct pcmcia_device *p_dev = get_pcmcia_device(s, buf->status.Function);
801 ret = pccard_get_status(s, p_dev, &buf->status); 872 ret = pccard_get_status(s, p_dev, &buf->status);
@@ -826,7 +897,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
826 goto free_out; 897 goto free_out;
827 } 898 }
828 899
829 ret = CS_BAD_ARGS; 900 ret = -EINVAL;
830 901
831 if (!(buf->conf_reg.Function && 902 if (!(buf->conf_reg.Function &&
832 (buf->conf_reg.Function >= s->functions))) { 903 (buf->conf_reg.Function >= s->functions))) {
@@ -867,7 +938,7 @@ static int ds_ioctl(struct inode * inode, struct file * file,
867 &buf->win_info.map); 938 &buf->win_info.map);
868 break; 939 break;
869 case DS_REPLACE_CIS: 940 case DS_REPLACE_CIS:
870 ret = pcmcia_replace_cis(s, &buf->cisdump); 941 ret = pcmcia_replace_cis(s, buf->cisdump.Data, buf->cisdump.Length);
871 break; 942 break;
872 case DS_BIND_REQUEST: 943 case DS_BIND_REQUEST:
873 if (!capable(CAP_SYS_ADMIN)) { 944 if (!capable(CAP_SYS_ADMIN)) {
@@ -889,22 +960,19 @@ static int ds_ioctl(struct inode * inode, struct file * file,
889 err = -EINVAL; 960 err = -EINVAL;
890 } 961 }
891 962
892 if ((err == 0) && (ret != CS_SUCCESS)) { 963 if ((err == 0) && (ret != 0)) {
893 ds_dbg(2, "ds_ioctl: ret = %d\n", ret); 964 ds_dbg(2, "ds_ioctl: ret = %d\n", ret);
894 switch (ret) { 965 switch (ret) {
895 case CS_BAD_SOCKET: case CS_NO_CARD: 966 case -ENODEV:
896 err = -ENODEV; break; 967 case -EINVAL:
897 case CS_BAD_ARGS: case CS_BAD_ATTRIBUTE: case CS_BAD_IRQ: 968 case -EBUSY:
898 case CS_BAD_TUPLE: 969 case -ENOSYS:
899 err = -EINVAL; break; 970 err = ret;
900 case CS_IN_USE: 971 break;
901 err = -EBUSY; break; 972 case -ENOMEM:
902 case CS_OUT_OF_RESOURCE:
903 err = -ENOSPC; break; 973 err = -ENOSPC; break;
904 case CS_NO_MORE_ITEMS: 974 case -ENOSPC:
905 err = -ENODATA; break; 975 err = -ENODATA; break;
906 case CS_UNSUPPORTED_FUNCTION:
907 err = -ENOSYS; break;
908 default: 976 default:
909 err = -EIO; break; 977 err = -EIO; break;
910 } 978 }
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 4884a18cf9e..afea2b2558b 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -29,7 +29,6 @@
29#include <pcmcia/ds.h> 29#include <pcmcia/ds.h>
30 30
31#include "cs_internal.h" 31#include "cs_internal.h"
32#include "ds_internal.h"
33 32
34 33
35/* Access speed for IO windows */ 34/* Access speed for IO windows */
@@ -44,16 +43,17 @@ static u8 pcmcia_used_irq[NR_IRQS];
44#endif 43#endif
45 44
46 45
47#ifdef DEBUG 46#ifdef CONFIG_PCMCIA_DEBUG
48extern int ds_pc_debug; 47extern int ds_pc_debug;
49 48
50#define ds_dbg(skt, lvl, fmt, arg...) do { \ 49#define ds_dbg(skt, lvl, fmt, arg...) do { \
51 if (ds_pc_debug >= lvl) \ 50 if (ds_pc_debug >= lvl) \
52 printk(KERN_DEBUG "pcmcia_resource: %s: " fmt, \ 51 dev_printk(KERN_DEBUG, &skt->dev, \
53 cs_socket_name(skt) , ## arg); \ 52 "pcmcia_resource: " fmt, \
53 ## arg); \
54} while (0) 54} while (0)
55#else 55#else
56#define ds_dbg(lvl, fmt, arg...) do { } while (0) 56#define ds_dbg(skt, lvl, fmt, arg...) do { } while (0)
57#endif 57#endif
58 58
59 59
@@ -168,13 +168,13 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
168 u_char val; 168 u_char val;
169 169
170 if (!p_dev || !p_dev->function_config) 170 if (!p_dev || !p_dev->function_config)
171 return CS_NO_CARD; 171 return -EINVAL;
172 172
173 s = p_dev->socket; 173 s = p_dev->socket;
174 c = p_dev->function_config; 174 c = p_dev->function_config;
175 175
176 if (!(c->state & CONFIG_LOCKED)) 176 if (!(c->state & CONFIG_LOCKED))
177 return CS_CONFIGURATION_LOCKED; 177 return -EACCES;
178 178
179 addr = (c->ConfigBase + reg->Offset) >> 1; 179 addr = (c->ConfigBase + reg->Offset) >> 1;
180 180
@@ -188,93 +188,14 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
188 pcmcia_write_cis_mem(s, 1, addr, 1, &val); 188 pcmcia_write_cis_mem(s, 1, addr, 1, &val);
189 break; 189 break;
190 default: 190 default:
191 return CS_BAD_ARGS; 191 return -EINVAL;
192 break; 192 break;
193 } 193 }
194 return CS_SUCCESS; 194 return 0;
195} /* pcmcia_access_configuration_register */ 195} /* pcmcia_access_configuration_register */
196EXPORT_SYMBOL(pcmcia_access_configuration_register); 196EXPORT_SYMBOL(pcmcia_access_configuration_register);
197 197
198 198
199int pccard_get_configuration_info(struct pcmcia_socket *s,
200 struct pcmcia_device *p_dev,
201 config_info_t *config)
202{
203 config_t *c;
204
205 if (!(s->state & SOCKET_PRESENT))
206 return CS_NO_CARD;
207
208
209#ifdef CONFIG_CARDBUS
210 if (s->state & SOCKET_CARDBUS) {
211 memset(config, 0, sizeof(config_info_t));
212 config->Vcc = s->socket.Vcc;
213 config->Vpp1 = config->Vpp2 = s->socket.Vpp;
214 config->Option = s->cb_dev->subordinate->number;
215 if (s->state & SOCKET_CARDBUS_CONFIG) {
216 config->Attributes = CONF_VALID_CLIENT;
217 config->IntType = INT_CARDBUS;
218 config->AssignedIRQ = s->irq.AssignedIRQ;
219 if (config->AssignedIRQ)
220 config->Attributes |= CONF_ENABLE_IRQ;
221 if (s->io[0].res) {
222 config->BasePort1 = s->io[0].res->start;
223 config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1;
224 }
225 }
226 return CS_SUCCESS;
227 }
228#endif
229
230 if (p_dev) {
231 c = p_dev->function_config;
232 config->Function = p_dev->func;
233 } else {
234 c = NULL;
235 config->Function = 0;
236 }
237
238 if ((c == NULL) || !(c->state & CONFIG_LOCKED)) {
239 config->Attributes = 0;
240 config->Vcc = s->socket.Vcc;
241 config->Vpp1 = config->Vpp2 = s->socket.Vpp;
242 return CS_SUCCESS;
243 }
244
245 config->Attributes = c->Attributes | CONF_VALID_CLIENT;
246 config->Vcc = s->socket.Vcc;
247 config->Vpp1 = config->Vpp2 = s->socket.Vpp;
248 config->IntType = c->IntType;
249 config->ConfigBase = c->ConfigBase;
250 config->Status = c->Status;
251 config->Pin = c->Pin;
252 config->Copy = c->Copy;
253 config->Option = c->Option;
254 config->ExtStatus = c->ExtStatus;
255 config->Present = config->CardValues = c->CardValues;
256 config->IRQAttributes = c->irq.Attributes;
257 config->AssignedIRQ = s->irq.AssignedIRQ;
258 config->BasePort1 = c->io.BasePort1;
259 config->NumPorts1 = c->io.NumPorts1;
260 config->Attributes1 = c->io.Attributes1;
261 config->BasePort2 = c->io.BasePort2;
262 config->NumPorts2 = c->io.NumPorts2;
263 config->Attributes2 = c->io.Attributes2;
264 config->IOAddrLines = c->io.IOAddrLines;
265
266 return CS_SUCCESS;
267} /* pccard_get_configuration_info */
268
269int pcmcia_get_configuration_info(struct pcmcia_device *p_dev,
270 config_info_t *config)
271{
272 return pccard_get_configuration_info(p_dev->socket, p_dev,
273 config);
274}
275EXPORT_SYMBOL(pcmcia_get_configuration_info);
276
277
278/** pcmcia_get_window 199/** pcmcia_get_window
279 */ 200 */
280int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, 201int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle,
@@ -284,12 +205,12 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle,
284 int w; 205 int w;
285 206
286 if (!s || !(s->state & SOCKET_PRESENT)) 207 if (!s || !(s->state & SOCKET_PRESENT))
287 return CS_NO_CARD; 208 return -ENODEV;
288 for (w = idx; w < MAX_WIN; w++) 209 for (w = idx; w < MAX_WIN; w++)
289 if (s->state & SOCKET_WIN_REQ(w)) 210 if (s->state & SOCKET_WIN_REQ(w))
290 break; 211 break;
291 if (w == MAX_WIN) 212 if (w == MAX_WIN)
292 return CS_NO_MORE_ITEMS; 213 return -EINVAL;
293 win = &s->win[w]; 214 win = &s->win[w];
294 req->Base = win->ctl.res->start; 215 req->Base = win->ctl.res->start;
295 req->Size = win->ctl.res->end - win->ctl.res->start + 1; 216 req->Size = win->ctl.res->end - win->ctl.res->start + 1;
@@ -304,7 +225,7 @@ int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle,
304 if (win->ctl.flags & MAP_USE_WAIT) 225 if (win->ctl.flags & MAP_USE_WAIT)
305 req->Attributes |= WIN_USE_WAIT; 226 req->Attributes |= WIN_USE_WAIT;
306 *handle = win; 227 *handle = win;
307 return CS_SUCCESS; 228 return 0;
308} /* pcmcia_get_window */ 229} /* pcmcia_get_window */
309EXPORT_SYMBOL(pcmcia_get_window); 230EXPORT_SYMBOL(pcmcia_get_window);
310 231
@@ -316,10 +237,10 @@ EXPORT_SYMBOL(pcmcia_get_window);
316int pcmcia_get_mem_page(window_handle_t win, memreq_t *req) 237int pcmcia_get_mem_page(window_handle_t win, memreq_t *req)
317{ 238{
318 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 239 if ((win == NULL) || (win->magic != WINDOW_MAGIC))
319 return CS_BAD_HANDLE; 240 return -EINVAL;
320 req->Page = 0; 241 req->Page = 0;
321 req->CardOffset = win->ctl.card_start; 242 req->CardOffset = win->ctl.card_start;
322 return CS_SUCCESS; 243 return 0;
323} /* pcmcia_get_mem_page */ 244} /* pcmcia_get_mem_page */
324EXPORT_SYMBOL(pcmcia_get_mem_page); 245EXPORT_SYMBOL(pcmcia_get_mem_page);
325 246
@@ -328,14 +249,18 @@ int pcmcia_map_mem_page(window_handle_t win, memreq_t *req)
328{ 249{
329 struct pcmcia_socket *s; 250 struct pcmcia_socket *s;
330 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 251 if ((win == NULL) || (win->magic != WINDOW_MAGIC))
331 return CS_BAD_HANDLE; 252 return -EINVAL;
332 if (req->Page != 0)
333 return CS_BAD_PAGE;
334 s = win->sock; 253 s = win->sock;
254 if (req->Page != 0) {
255 ds_dbg(s, 0, "failure: requested page is zero\n");
256 return -EINVAL;
257 }
335 win->ctl.card_start = req->CardOffset; 258 win->ctl.card_start = req->CardOffset;
336 if (s->ops->set_mem_map(s, &win->ctl) != 0) 259 if (s->ops->set_mem_map(s, &win->ctl) != 0) {
337 return CS_BAD_OFFSET; 260 ds_dbg(s, 0, "failed to set_mem_map\n");
338 return CS_SUCCESS; 261 return -EIO;
262 }
263 return 0;
339} /* pcmcia_map_mem_page */ 264} /* pcmcia_map_mem_page */
340EXPORT_SYMBOL(pcmcia_map_mem_page); 265EXPORT_SYMBOL(pcmcia_map_mem_page);
341 266
@@ -354,9 +279,9 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
354 c = p_dev->function_config; 279 c = p_dev->function_config;
355 280
356 if (!(s->state & SOCKET_PRESENT)) 281 if (!(s->state & SOCKET_PRESENT))
357 return CS_NO_CARD; 282 return -ENODEV;
358 if (!(c->state & CONFIG_LOCKED)) 283 if (!(c->state & CONFIG_LOCKED))
359 return CS_CONFIGURATION_LOCKED; 284 return -EACCES;
360 285
361 if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { 286 if (mod->Attributes & CONF_IRQ_CHANGE_VALID) {
362 if (mod->Attributes & CONF_ENABLE_IRQ) { 287 if (mod->Attributes & CONF_ENABLE_IRQ) {
@@ -369,20 +294,28 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
369 s->ops->set_socket(s, &s->socket); 294 s->ops->set_socket(s, &s->socket);
370 } 295 }
371 296
372 if (mod->Attributes & CONF_VCC_CHANGE_VALID) 297 if (mod->Attributes & CONF_VCC_CHANGE_VALID) {
373 return CS_BAD_VCC; 298 ds_dbg(s, 0, "changing Vcc is not allowed at this time\n");
299 return -EINVAL;
300 }
374 301
375 /* We only allow changing Vpp1 and Vpp2 to the same value */ 302 /* We only allow changing Vpp1 and Vpp2 to the same value */
376 if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && 303 if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) &&
377 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { 304 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) {
378 if (mod->Vpp1 != mod->Vpp2) 305 if (mod->Vpp1 != mod->Vpp2)
379 return CS_BAD_VPP; 306 ds_dbg(s, 0, "Vpp1 and Vpp2 must be the same\n");
307 return -EINVAL;
380 s->socket.Vpp = mod->Vpp1; 308 s->socket.Vpp = mod->Vpp1;
381 if (s->ops->set_socket(s, &s->socket)) 309 if (s->ops->set_socket(s, &s->socket)) {
382 return CS_BAD_VPP; 310 dev_printk(KERN_WARNING, &s->dev,
311 "Unable to set VPP\n");
312 return -EIO;
313 }
383 } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || 314 } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) ||
384 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) 315 (mod->Attributes & CONF_VPP2_CHANGE_VALID)) {
385 return CS_BAD_VPP; 316 ds_dbg(s, 0, "changing Vcc is not allowed at this time\n");
317 return -EINVAL;
318 }
386 319
387 if (mod->Attributes & CONF_IO_CHANGE_WIDTH) { 320 if (mod->Attributes & CONF_IO_CHANGE_WIDTH) {
388 pccard_io_map io_off = { 0, 0, 0, 0, 1 }; 321 pccard_io_map io_off = { 0, 0, 0, 0, 1 };
@@ -406,7 +339,7 @@ int pcmcia_modify_configuration(struct pcmcia_device *p_dev,
406 } 339 }
407 } 340 }
408 341
409 return CS_SUCCESS; 342 return 0;
410} /* modify_configuration */ 343} /* modify_configuration */
411EXPORT_SYMBOL(pcmcia_modify_configuration); 344EXPORT_SYMBOL(pcmcia_modify_configuration);
412 345
@@ -441,7 +374,7 @@ int pcmcia_release_configuration(struct pcmcia_device *p_dev)
441 } 374 }
442 } 375 }
443 376
444 return CS_SUCCESS; 377 return 0;
445} /* pcmcia_release_configuration */ 378} /* pcmcia_release_configuration */
446 379
447 380
@@ -459,7 +392,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
459 config_t *c = p_dev->function_config; 392 config_t *c = p_dev->function_config;
460 393
461 if (!p_dev->_io ) 394 if (!p_dev->_io )
462 return CS_BAD_HANDLE; 395 return -EINVAL;
463 396
464 p_dev->_io = 0; 397 p_dev->_io = 0;
465 398
@@ -467,7 +400,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
467 (c->io.NumPorts1 != req->NumPorts1) || 400 (c->io.NumPorts1 != req->NumPorts1) ||
468 (c->io.BasePort2 != req->BasePort2) || 401 (c->io.BasePort2 != req->BasePort2) ||
469 (c->io.NumPorts2 != req->NumPorts2)) 402 (c->io.NumPorts2 != req->NumPorts2))
470 return CS_BAD_ARGS; 403 return -EINVAL;
471 404
472 c->state &= ~CONFIG_IO_REQ; 405 c->state &= ~CONFIG_IO_REQ;
473 406
@@ -475,7 +408,7 @@ static int pcmcia_release_io(struct pcmcia_device *p_dev, io_req_t *req)
475 if (req->NumPorts2) 408 if (req->NumPorts2)
476 release_io_space(s, req->BasePort2, req->NumPorts2); 409 release_io_space(s, req->BasePort2, req->NumPorts2);
477 410
478 return CS_SUCCESS; 411 return 0;
479} /* pcmcia_release_io */ 412} /* pcmcia_release_io */
480 413
481 414
@@ -485,15 +418,19 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
485 config_t *c= p_dev->function_config; 418 config_t *c= p_dev->function_config;
486 419
487 if (!p_dev->_irq) 420 if (!p_dev->_irq)
488 return CS_BAD_HANDLE; 421 return -EINVAL;
489 p_dev->_irq = 0; 422 p_dev->_irq = 0;
490 423
491 if (c->state & CONFIG_LOCKED) 424 if (c->state & CONFIG_LOCKED)
492 return CS_CONFIGURATION_LOCKED; 425 return -EACCES;
493 if (c->irq.Attributes != req->Attributes) 426 if (c->irq.Attributes != req->Attributes) {
494 return CS_BAD_ATTRIBUTE; 427 ds_dbg(s, 0, "IRQ attributes must match assigned ones\n");
495 if (s->irq.AssignedIRQ != req->AssignedIRQ) 428 return -EINVAL;
496 return CS_BAD_IRQ; 429 }
430 if (s->irq.AssignedIRQ != req->AssignedIRQ) {
431 ds_dbg(s, 0, "IRQ must match assigned one\n");
432 return -EINVAL;
433 }
497 if (--s->irq.Config == 0) { 434 if (--s->irq.Config == 0) {
498 c->state &= ~CONFIG_IRQ_REQ; 435 c->state &= ~CONFIG_IRQ_REQ;
499 s->irq.AssignedIRQ = 0; 436 s->irq.AssignedIRQ = 0;
@@ -507,7 +444,7 @@ static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
507 pcmcia_used_irq[req->AssignedIRQ]--; 444 pcmcia_used_irq[req->AssignedIRQ]--;
508#endif 445#endif
509 446
510 return CS_SUCCESS; 447 return 0;
511} /* pcmcia_release_irq */ 448} /* pcmcia_release_irq */
512 449
513 450
@@ -516,10 +453,10 @@ int pcmcia_release_window(window_handle_t win)
516 struct pcmcia_socket *s; 453 struct pcmcia_socket *s;
517 454
518 if ((win == NULL) || (win->magic != WINDOW_MAGIC)) 455 if ((win == NULL) || (win->magic != WINDOW_MAGIC))
519 return CS_BAD_HANDLE; 456 return -EINVAL;
520 s = win->sock; 457 s = win->sock;
521 if (!(win->handle->_win & CLIENT_WIN_REQ(win->index))) 458 if (!(win->handle->_win & CLIENT_WIN_REQ(win->index)))
522 return CS_BAD_HANDLE; 459 return -EINVAL;
523 460
524 /* Shut down memory window */ 461 /* Shut down memory window */
525 win->ctl.flags &= ~MAP_ACTIVE; 462 win->ctl.flags &= ~MAP_ACTIVE;
@@ -536,7 +473,7 @@ int pcmcia_release_window(window_handle_t win)
536 473
537 win->magic = 0; 474 win->magic = 0;
538 475
539 return CS_SUCCESS; 476 return 0;
540} /* pcmcia_release_window */ 477} /* pcmcia_release_window */
541EXPORT_SYMBOL(pcmcia_release_window); 478EXPORT_SYMBOL(pcmcia_release_window);
542 479
@@ -551,18 +488,23 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
551 pccard_io_map iomap; 488 pccard_io_map iomap;
552 489
553 if (!(s->state & SOCKET_PRESENT)) 490 if (!(s->state & SOCKET_PRESENT))
554 return CS_NO_CARD; 491 return -ENODEV;;
555 492
556 if (req->IntType & INT_CARDBUS) 493 if (req->IntType & INT_CARDBUS) {
557 return CS_UNSUPPORTED_MODE; 494 ds_dbg(p_dev->socket, 0, "IntType may not be INT_CARDBUS\n");
495 return -EINVAL;
496 }
558 c = p_dev->function_config; 497 c = p_dev->function_config;
559 if (c->state & CONFIG_LOCKED) 498 if (c->state & CONFIG_LOCKED)
560 return CS_CONFIGURATION_LOCKED; 499 return -EACCES;
561 500
562 /* Do power control. We don't allow changes in Vcc. */ 501 /* Do power control. We don't allow changes in Vcc. */
563 s->socket.Vpp = req->Vpp; 502 s->socket.Vpp = req->Vpp;
564 if (s->ops->set_socket(s, &s->socket)) 503 if (s->ops->set_socket(s, &s->socket)) {
565 return CS_BAD_VPP; 504 dev_printk(KERN_WARNING, &s->dev,
505 "Unable to set socket state\n");
506 return -EINVAL;
507 }
566 508
567 /* Pick memory or I/O card, DMA mode, interrupt */ 509 /* Pick memory or I/O card, DMA mode, interrupt */
568 c->IntType = req->IntType; 510 c->IntType = req->IntType;
@@ -651,7 +593,7 @@ int pcmcia_request_configuration(struct pcmcia_device *p_dev,
651 593
652 c->state |= CONFIG_LOCKED; 594 c->state |= CONFIG_LOCKED;
653 p_dev->_locked = 1; 595 p_dev->_locked = 1;
654 return CS_SUCCESS; 596 return 0;
655} /* pcmcia_request_configuration */ 597} /* pcmcia_request_configuration */
656EXPORT_SYMBOL(pcmcia_request_configuration); 598EXPORT_SYMBOL(pcmcia_request_configuration);
657 599
@@ -667,37 +609,48 @@ int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req)
667 config_t *c; 609 config_t *c;
668 610
669 if (!(s->state & SOCKET_PRESENT)) 611 if (!(s->state & SOCKET_PRESENT))
670 return CS_NO_CARD; 612 return -ENODEV;
671 613
672 if (!req) 614 if (!req)
673 return CS_UNSUPPORTED_MODE; 615 return -EINVAL;
674 c = p_dev->function_config; 616 c = p_dev->function_config;
675 if (c->state & CONFIG_LOCKED) 617 if (c->state & CONFIG_LOCKED)
676 return CS_CONFIGURATION_LOCKED; 618 return -EACCES;
677 if (c->state & CONFIG_IO_REQ) 619 if (c->state & CONFIG_IO_REQ) {
678 return CS_IN_USE; 620 ds_dbg(s, 0, "IO already configured\n");
679 if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) 621 return -EBUSY;
680 return CS_BAD_ATTRIBUTE; 622 }
623 if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) {
624 ds_dbg(s, 0, "bad attribute setting for IO region 1\n");
625 return -EINVAL;
626 }
681 if ((req->NumPorts2 > 0) && 627 if ((req->NumPorts2 > 0) &&
682 (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) 628 (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) {
683 return CS_BAD_ATTRIBUTE; 629 ds_dbg(s, 0, "bad attribute setting for IO region 2\n");
630 return -EINVAL;
631 }
684 632
633 ds_dbg(s, 1, "trying to allocate resource 1\n");
685 if (alloc_io_space(s, req->Attributes1, &req->BasePort1, 634 if (alloc_io_space(s, req->Attributes1, &req->BasePort1,
686 req->NumPorts1, req->IOAddrLines)) 635 req->NumPorts1, req->IOAddrLines)) {
687 return CS_IN_USE; 636 ds_dbg(s, 0, "allocation of resource 1 failed\n");
637 return -EBUSY;
638 }
688 639
689 if (req->NumPorts2) { 640 if (req->NumPorts2) {
641 ds_dbg(s, 1, "trying to allocate resource 2\n");
690 if (alloc_io_space(s, req->Attributes2, &req->BasePort2, 642 if (alloc_io_space(s, req->Attributes2, &req->BasePort2,
691 req->NumPorts2, req->IOAddrLines)) { 643 req->NumPorts2, req->IOAddrLines)) {
644 ds_dbg(s, 0, "allocation of resource 2 failed\n");
692 release_io_space(s, req->BasePort1, req->NumPorts1); 645 release_io_space(s, req->BasePort1, req->NumPorts1);
693 return CS_IN_USE; 646 return -EBUSY;
694 } 647 }
695 } 648 }
696 649
697 c->io = *req; 650 c->io = *req;
698 c->state |= CONFIG_IO_REQ; 651 c->state |= CONFIG_IO_REQ;
699 p_dev->_io = 1; 652 p_dev->_io = 1;
700 return CS_SUCCESS; 653 return 0;
701} /* pcmcia_request_io */ 654} /* pcmcia_request_io */
702EXPORT_SYMBOL(pcmcia_request_io); 655EXPORT_SYMBOL(pcmcia_request_io);
703 656
@@ -723,16 +676,18 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
723{ 676{
724 struct pcmcia_socket *s = p_dev->socket; 677 struct pcmcia_socket *s = p_dev->socket;
725 config_t *c; 678 config_t *c;
726 int ret = CS_IN_USE, irq = 0; 679 int ret = -EINVAL, irq = 0;
727 int type; 680 int type;
728 681
729 if (!(s->state & SOCKET_PRESENT)) 682 if (!(s->state & SOCKET_PRESENT))
730 return CS_NO_CARD; 683 return -ENODEV;
731 c = p_dev->function_config; 684 c = p_dev->function_config;
732 if (c->state & CONFIG_LOCKED) 685 if (c->state & CONFIG_LOCKED)
733 return CS_CONFIGURATION_LOCKED; 686 return -EACCES;
734 if (c->state & CONFIG_IRQ_REQ) 687 if (c->state & CONFIG_IRQ_REQ) {
735 return CS_IN_USE; 688 ds_dbg(s, 0, "IRQ already configured\n");
689 return -EBUSY;
690 }
736 691
737 /* Decide what type of interrupt we are registering */ 692 /* Decide what type of interrupt we are registering */
738 type = 0; 693 type = 0;
@@ -795,15 +750,19 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
795 } 750 }
796 751
797 if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) { 752 if (ret && (req->Attributes & IRQ_HANDLE_PRESENT)) {
798 if (request_irq(irq, req->Handler, type, p_dev->devname, req->Instance)) 753 ret = request_irq(irq, req->Handler, type,
799 return CS_IN_USE; 754 p_dev->devname, req->Instance);
755 if (ret)
756 return ret;
800 } 757 }
801 758
802 /* Make sure the fact the request type was overridden is passed back */ 759 /* Make sure the fact the request type was overridden is passed back */
803 if (type == IRQF_SHARED && !(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) { 760 if (type == IRQF_SHARED && !(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) {
804 req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING; 761 req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
805 printk(KERN_WARNING "pcmcia: request for exclusive IRQ could not be fulfilled.\n"); 762 dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: "
806 printk(KERN_WARNING "pcmcia: the driver needs updating to supported shared IRQ lines.\n"); 763 "request for exclusive IRQ could not be fulfilled.\n");
764 dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: the driver "
765 "needs updating to supported shared IRQ lines.\n");
807 } 766 }
808 c->irq.Attributes = req->Attributes; 767 c->irq.Attributes = req->Attributes;
809 s->irq.AssignedIRQ = req->AssignedIRQ = irq; 768 s->irq.AssignedIRQ = req->AssignedIRQ = irq;
@@ -816,7 +775,7 @@ int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
816 pcmcia_used_irq[irq]++; 775 pcmcia_used_irq[irq]++;
817#endif 776#endif
818 777
819 return CS_SUCCESS; 778 return 0;
820} /* pcmcia_request_irq */ 779} /* pcmcia_request_irq */
821EXPORT_SYMBOL(pcmcia_request_irq); 780EXPORT_SYMBOL(pcmcia_request_irq);
822 781
@@ -834,9 +793,11 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
834 int w; 793 int w;
835 794
836 if (!(s->state & SOCKET_PRESENT)) 795 if (!(s->state & SOCKET_PRESENT))
837 return CS_NO_CARD; 796 return -ENODEV;
838 if (req->Attributes & (WIN_PAGED | WIN_SHARED)) 797 if (req->Attributes & (WIN_PAGED | WIN_SHARED)) {
839 return CS_BAD_ATTRIBUTE; 798 ds_dbg(s, 0, "bad attribute setting for iomem region\n");
799 return -EINVAL;
800 }
840 801
841 /* Window size defaults to smallest available */ 802 /* Window size defaults to smallest available */
842 if (req->Size == 0) 803 if (req->Size == 0)
@@ -844,19 +805,25 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
844 align = (((s->features & SS_CAP_MEM_ALIGN) || 805 align = (((s->features & SS_CAP_MEM_ALIGN) ||
845 (req->Attributes & WIN_STRICT_ALIGN)) ? 806 (req->Attributes & WIN_STRICT_ALIGN)) ?
846 req->Size : s->map_size); 807 req->Size : s->map_size);
847 if (req->Size & (s->map_size-1)) 808 if (req->Size & (s->map_size-1)) {
848 return CS_BAD_SIZE; 809 ds_dbg(s, 0, "invalid map size\n");
810 return -EINVAL;
811 }
849 if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || 812 if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) ||
850 (req->Base & (align-1))) 813 (req->Base & (align-1))) {
851 return CS_BAD_BASE; 814 ds_dbg(s, 0, "invalid base address\n");
815 return -EINVAL;
816 }
852 if (req->Base) 817 if (req->Base)
853 align = 0; 818 align = 0;
854 819
855 /* Allocate system memory window */ 820 /* Allocate system memory window */
856 for (w = 0; w < MAX_WIN; w++) 821 for (w = 0; w < MAX_WIN; w++)
857 if (!(s->state & SOCKET_WIN_REQ(w))) break; 822 if (!(s->state & SOCKET_WIN_REQ(w))) break;
858 if (w == MAX_WIN) 823 if (w == MAX_WIN) {
859 return CS_OUT_OF_RESOURCE; 824 ds_dbg(s, 0, "all windows are used already\n");
825 return -EINVAL;
826 }
860 827
861 win = &s->win[w]; 828 win = &s->win[w];
862 win->magic = WINDOW_MAGIC; 829 win->magic = WINDOW_MAGIC;
@@ -867,8 +834,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
867 if (!(s->features & SS_CAP_STATIC_MAP)) { 834 if (!(s->features & SS_CAP_STATIC_MAP)) {
868 win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, 835 win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align,
869 (req->Attributes & WIN_MAP_BELOW_1MB), s); 836 (req->Attributes & WIN_MAP_BELOW_1MB), s);
870 if (!win->ctl.res) 837 if (!win->ctl.res) {
871 return CS_IN_USE; 838 ds_dbg(s, 0, "allocating mem region failed\n");
839 return -EINVAL;
840 }
872 } 841 }
873 (*p_dev)->_win |= CLIENT_WIN_REQ(w); 842 (*p_dev)->_win |= CLIENT_WIN_REQ(w);
874 843
@@ -885,8 +854,10 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
885 if (req->Attributes & WIN_USE_WAIT) 854 if (req->Attributes & WIN_USE_WAIT)
886 win->ctl.flags |= MAP_USE_WAIT; 855 win->ctl.flags |= MAP_USE_WAIT;
887 win->ctl.card_start = 0; 856 win->ctl.card_start = 0;
888 if (s->ops->set_mem_map(s, &win->ctl) != 0) 857 if (s->ops->set_mem_map(s, &win->ctl) != 0) {
889 return CS_BAD_ARGS; 858 ds_dbg(s, 0, "failed to set memory mapping\n");
859 return -EIO;
860 }
890 s->state |= SOCKET_WIN_REQ(w); 861 s->state |= SOCKET_WIN_REQ(w);
891 862
892 /* Return window handle */ 863 /* Return window handle */
@@ -897,7 +868,7 @@ int pcmcia_request_window(struct pcmcia_device **p_dev, win_req_t *req, window_h
897 } 868 }
898 *wh = win; 869 *wh = win;
899 870
900 return CS_SUCCESS; 871 return 0;
901} /* pcmcia_request_window */ 872} /* pcmcia_request_window */
902EXPORT_SYMBOL(pcmcia_request_window); 873EXPORT_SYMBOL(pcmcia_request_window);
903 874
@@ -909,3 +880,79 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev) {
909 pcmcia_release_window(p_dev->win); 880 pcmcia_release_window(p_dev->win);
910} 881}
911EXPORT_SYMBOL(pcmcia_disable_device); 882EXPORT_SYMBOL(pcmcia_disable_device);
883
884
885struct pcmcia_cfg_mem {
886 tuple_t tuple;
887 cisparse_t parse;
888 u8 buf[256];
889 cistpl_cftable_entry_t dflt;
890};
891
892/**
893 * pcmcia_loop_config() - loop over configuration options
894 * @p_dev: the struct pcmcia_device which we need to loop for.
895 * @conf_check: function to call for each configuration option.
896 * It gets passed the struct pcmcia_device, the CIS data
897 * describing the configuration option, and private data
898 * being passed to pcmcia_loop_config()
899 * @priv_data: private data to be passed to the conf_check function.
900 *
901 * pcmcia_loop_config() loops over all configuration options, and calls
902 * the driver-specific conf_check() for each one, checking whether
903 * it is a valid one.
904 */
905int pcmcia_loop_config(struct pcmcia_device *p_dev,
906 int (*conf_check) (struct pcmcia_device *p_dev,
907 cistpl_cftable_entry_t *cfg,
908 cistpl_cftable_entry_t *dflt,
909 unsigned int vcc,
910 void *priv_data),
911 void *priv_data)
912{
913 struct pcmcia_cfg_mem *cfg_mem;
914
915 tuple_t *tuple;
916 int ret = -ENODEV;
917 unsigned int vcc;
918
919 cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL);
920 if (cfg_mem == NULL)
921 return -ENOMEM;
922
923 /* get the current Vcc setting */
924 vcc = p_dev->socket->socket.Vcc;
925
926 tuple = &cfg_mem->tuple;
927 tuple->TupleData = cfg_mem->buf;
928 tuple->TupleDataMax = 255;
929 tuple->TupleOffset = 0;
930 tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY;
931 tuple->Attributes = 0;
932
933 ret = pcmcia_get_first_tuple(p_dev, tuple);
934 while (!ret) {
935 cistpl_cftable_entry_t *cfg = &cfg_mem->parse.cftable_entry;
936
937 if (pcmcia_get_tuple_data(p_dev, tuple))
938 goto next_entry;
939
940 if (pcmcia_parse_tuple(tuple, &cfg_mem->parse))
941 goto next_entry;
942
943 /* default values */
944 p_dev->conf.ConfigIndex = cfg->index;
945 if (cfg->flags & CISTPL_CFTABLE_DEFAULT)
946 cfg_mem->dflt = *cfg;
947
948 ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data);
949 if (!ret)
950 break;
951
952next_entry:
953 ret = pcmcia_get_next_tuple(p_dev, tuple);
954 }
955
956 return ret;
957}
958EXPORT_SYMBOL(pcmcia_loop_config);
diff --git a/drivers/pcmcia/pxa2xx_base.c b/drivers/pcmcia/pxa2xx_base.c
index 13f1e0fd3f3..bb9ddb9532e 100644
--- a/drivers/pcmcia/pxa2xx_base.c
+++ b/drivers/pcmcia/pxa2xx_base.c
@@ -36,7 +36,6 @@
36#include <pcmcia/ss.h> 36#include <pcmcia/ss.h>
37#include <pcmcia/cistpl.h> 37#include <pcmcia/cistpl.h>
38 38
39#include "cs_internal.h"
40#include "soc_common.h" 39#include "soc_common.h"
41#include "pxa2xx_base.h" 40#include "pxa2xx_base.h"
42 41
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 203e579ebbd..17f4ecf1c0c 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -122,19 +122,22 @@ static void free_region(struct resource *res)
122 122
123static int add_interval(struct resource_map *map, u_long base, u_long num) 123static int add_interval(struct resource_map *map, u_long base, u_long num)
124{ 124{
125 struct resource_map *p, *q; 125 struct resource_map *p, *q;
126 126
127 for (p = map; ; p = p->next) { 127 for (p = map; ; p = p->next) {
128 if ((p != map) && (p->base+p->num-1 >= base)) 128 if ((p != map) && (p->base+p->num-1 >= base))
129 return -1; 129 return -1;
130 if ((p->next == map) || (p->next->base > base+num-1)) 130 if ((p->next == map) || (p->next->base > base+num-1))
131 break; 131 break;
132 } 132 }
133 q = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 133 q = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
134 if (!q) return CS_OUT_OF_RESOURCE; 134 if (!q) {
135 q->base = base; q->num = num; 135 printk(KERN_WARNING "out of memory to update resources\n");
136 q->next = p->next; p->next = q; 136 return -ENOMEM;
137 return CS_SUCCESS; 137 }
138 q->base = base; q->num = num;
139 q->next = p->next; p->next = q;
140 return 0;
138} 141}
139 142
140/*====================================================================*/ 143/*====================================================================*/
@@ -166,7 +169,10 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)
166 } else { 169 } else {
167 /* Split the block into two pieces */ 170 /* Split the block into two pieces */
168 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL); 171 p = kmalloc(sizeof(struct resource_map), GFP_KERNEL);
169 if (!p) return CS_OUT_OF_RESOURCE; 172 if (!p) {
173 printk(KERN_WARNING "out of memory to update resources\n");
174 return -ENOMEM;
175 }
170 p->base = base+num; 176 p->base = base+num;
171 p->num = q->base+q->num - p->base; 177 p->num = q->base+q->num - p->base;
172 q->num = base - q->base; 178 q->num = base - q->base;
@@ -174,7 +180,7 @@ static int sub_interval(struct resource_map *map, u_long base, u_long num)
174 } 180 }
175 } 181 }
176 } 182 }
177 return CS_SUCCESS; 183 return 0;
178} 184}
179 185
180/*====================================================================== 186/*======================================================================
@@ -194,13 +200,14 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,
194 int any; 200 int any;
195 u_char *b, hole, most; 201 u_char *b, hole, most;
196 202
197 printk(KERN_INFO "cs: IO port probe %#x-%#x:", 203 dev_printk(KERN_INFO, &s->dev, "cs: IO port probe %#x-%#x:",
198 base, base+num-1); 204 base, base+num-1);
199 205
200 /* First, what does a floating port look like? */ 206 /* First, what does a floating port look like? */
201 b = kzalloc(256, GFP_KERNEL); 207 b = kzalloc(256, GFP_KERNEL);
202 if (!b) { 208 if (!b) {
203 printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes"); 209 dev_printk(KERN_ERR, &s->dev,
210 "do_io_probe: unable to kmalloc 256 bytes");
204 return; 211 return;
205 } 212 }
206 for (i = base, most = 0; i < base+num; i += 8) { 213 for (i = base, most = 0; i < base+num; i += 8) {
@@ -366,8 +373,8 @@ static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s)
366 struct socket_data *s_data = s->resource_data; 373 struct socket_data *s_data = s->resource_data;
367 u_long i, j, bad, fail, step; 374 u_long i, j, bad, fail, step;
368 375
369 printk(KERN_INFO "cs: memory probe 0x%06lx-0x%06lx:", 376 dev_printk(KERN_INFO, &s->dev, "cs: memory probe 0x%06lx-0x%06lx:",
370 base, base+num-1); 377 base, base+num-1);
371 bad = fail = 0; 378 bad = fail = 0;
372 step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff); 379 step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff);
373 /* don't allow too large steps */ 380 /* don't allow too large steps */
@@ -431,8 +438,8 @@ static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
431 if (probe_mask & MEM_PROBE_HIGH) { 438 if (probe_mask & MEM_PROBE_HIGH) {
432 if (inv_probe(s_data->mem_db.next, s) > 0) 439 if (inv_probe(s_data->mem_db.next, s) > 0)
433 return 0; 440 return 0;
434 printk(KERN_NOTICE "cs: warning: no high memory space " 441 dev_printk(KERN_NOTICE, &s->dev,
435 "available!\n"); 442 "cs: warning: no high memory space available!\n");
436 return -ENODEV; 443 return -ENODEV;
437 } 444 }
438 445
@@ -794,10 +801,11 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
794 if (res->flags & IORESOURCE_IO) { 801 if (res->flags & IORESOURCE_IO) {
795 if (res == &ioport_resource) 802 if (res == &ioport_resource)
796 continue; 803 continue;
797 printk(KERN_INFO "pcmcia: parent PCI bridge I/O " 804 dev_printk(KERN_INFO, &s->cb_dev->dev,
798 "window: 0x%llx - 0x%llx\n", 805 "pcmcia: parent PCI bridge I/O "
799 (unsigned long long)res->start, 806 "window: 0x%llx - 0x%llx\n",
800 (unsigned long long)res->end); 807 (unsigned long long)res->start,
808 (unsigned long long)res->end);
801 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 809 if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end))
802 done |= IORESOURCE_IO; 810 done |= IORESOURCE_IO;
803 811
@@ -806,10 +814,11 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s)
806 if (res->flags & IORESOURCE_MEM) { 814 if (res->flags & IORESOURCE_MEM) {
807 if (res == &iomem_resource) 815 if (res == &iomem_resource)
808 continue; 816 continue;
809 printk(KERN_INFO "pcmcia: parent PCI bridge Memory " 817 dev_printk(KERN_INFO, &s->cb_dev->dev,
810 "window: 0x%llx - 0x%llx\n", 818 "pcmcia: parent PCI bridge Memory "
811 (unsigned long long)res->start, 819 "window: 0x%llx - 0x%llx\n",
812 (unsigned long long)res->end); 820 (unsigned long long)res->start,
821 (unsigned long long)res->end);
813 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) 822 if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end))
814 done |= IORESOURCE_MEM; 823 done |= IORESOURCE_MEM;
815 } 824 }
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index da397215322..f49ac666615 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -54,7 +54,7 @@
54#include <mach/pxa-regs.h> 54#include <mach/pxa-regs.h>
55#endif 55#endif
56 56
57#ifdef DEBUG 57#ifdef CONFIG_PCMCIA_DEBUG
58 58
59static int pc_debug; 59static int pc_debug;
60module_param(pc_debug, int, 0644); 60module_param(pc_debug, int, 0644);
diff --git a/drivers/pcmcia/soc_common.h b/drivers/pcmcia/soc_common.h
index 91ef6a0da3a..38c67375f36 100644
--- a/drivers/pcmcia/soc_common.h
+++ b/drivers/pcmcia/soc_common.h
@@ -15,7 +15,6 @@
15#include <pcmcia/cs.h> 15#include <pcmcia/cs.h>
16#include <pcmcia/ss.h> 16#include <pcmcia/ss.h>
17#include <pcmcia/cistpl.h> 17#include <pcmcia/cistpl.h>
18#include "cs_internal.h"
19 18
20 19
21struct device; 20struct device;
@@ -137,7 +136,7 @@ extern int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_lev
137extern int soc_common_drv_pcmcia_remove(struct device *dev); 136extern int soc_common_drv_pcmcia_remove(struct device *dev);
138 137
139 138
140#ifdef DEBUG 139#ifdef CONFIG_PCMCIA_DEBUG
141 140
142extern void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func, 141extern void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func,
143 int lvl, const char *fmt, ...); 142 int lvl, const char *fmt, ...);
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 006a29e91d8..ff9a3bb3c88 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -316,27 +316,18 @@ static ssize_t pccard_store_cis(struct kobject *kobj,
316 char *buf, loff_t off, size_t count) 316 char *buf, loff_t off, size_t count)
317{ 317{
318 struct pcmcia_socket *s = to_socket(container_of(kobj, struct device, kobj)); 318 struct pcmcia_socket *s = to_socket(container_of(kobj, struct device, kobj));
319 cisdump_t *cis;
320 int error; 319 int error;
321 320
322 if (off) 321 if (off)
323 return -EINVAL; 322 return -EINVAL;
324 323
325 if (count >= 0x200) 324 if (count >= CISTPL_MAX_CIS_SIZE)
326 return -EINVAL; 325 return -EINVAL;
327 326
328 if (!(s->state & SOCKET_PRESENT)) 327 if (!(s->state & SOCKET_PRESENT))
329 return -ENODEV; 328 return -ENODEV;
330 329
331 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL); 330 error = pcmcia_replace_cis(s, buf, count);
332 if (!cis)
333 return -ENOMEM;
334
335 cis->Length = count + 1;
336 memcpy(cis->Data, buf, count);
337
338 error = pcmcia_replace_cis(s, cis);
339 kfree(cis);
340 if (error) 331 if (error)
341 return -EIO; 332 return -EIO;
342 333
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index 5792bd5c54f..2a613e920fd 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -55,7 +55,7 @@
55#include <pcmcia/ss.h> 55#include <pcmcia/ss.h>
56#include "tcic.h" 56#include "tcic.h"
57 57
58#ifdef DEBUG 58#ifdef CONFIG_PCMCIA_DEBUG
59static int pc_debug; 59static int pc_debug;
60 60
61module_param(pc_debug, int, 0644); 61module_param(pc_debug, int, 0644);
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index 129db7bd06c..aaa70227bfb 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -339,8 +339,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket)
339 339
340 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); 340 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC);
341 devctl = config_readb(socket, TI113X_DEVICE_CONTROL); 341 devctl = config_readb(socket, TI113X_DEVICE_CONTROL);
342 printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n", 342 dev_printk(KERN_INFO, &socket->dev->dev,
343 pci_name(socket->dev), mfunc, devctl); 343 "TI: mfunc 0x%08x, devctl 0x%02x\n", mfunc, devctl);
344 344
345 /* make sure PCI interrupts are enabled before probing */ 345 /* make sure PCI interrupts are enabled before probing */
346 ti_init(socket); 346 ti_init(socket);
@@ -354,8 +354,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket)
354 * We're here which means PCI interrupts are _not_ delivered. try to 354 * We're here which means PCI interrupts are _not_ delivered. try to
355 * find the right setting (all serial or parallel) 355 * find the right setting (all serial or parallel)
356 */ 356 */
357 printk(KERN_INFO "Yenta TI: socket %s probing PCI interrupt failed, trying to fix\n", 357 dev_printk(KERN_INFO, &socket->dev->dev,
358 pci_name(socket->dev)); 358 "TI: probing PCI interrupt failed, trying to fix\n");
359 359
360 /* for serial PCI make sure MFUNC3 is set to IRQSER */ 360 /* for serial PCI make sure MFUNC3 is set to IRQSER */
361 if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { 361 if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) {
@@ -379,8 +379,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket)
379 379
380 pci_irq_status = yenta_probe_cb_irq(socket); 380 pci_irq_status = yenta_probe_cb_irq(socket);
381 if (pci_irq_status == 1) { 381 if (pci_irq_status == 1) {
382 printk(KERN_INFO "Yenta TI: socket %s all-serial interrupts ok\n", 382 dev_printk(KERN_INFO, &socket->dev->dev,
383 pci_name(socket->dev)); 383 "TI: all-serial interrupts ok\n");
384 mfunc_old = mfunc; 384 mfunc_old = mfunc;
385 goto out; 385 goto out;
386 } 386 }
@@ -395,8 +395,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket)
395 } 395 }
396 396
397 /* serial PCI interrupts not working fall back to parallel */ 397 /* serial PCI interrupts not working fall back to parallel */
398 printk(KERN_INFO "Yenta TI: socket %s falling back to parallel PCI interrupts\n", 398 dev_printk(KERN_INFO, &socket->dev->dev,
399 pci_name(socket->dev)); 399 "TI: falling back to parallel PCI interrupts\n");
400 devctl &= ~TI113X_DCR_IMODE_MASK; 400 devctl &= ~TI113X_DCR_IMODE_MASK;
401 devctl |= TI113X_DCR_IMODE_SERIAL; /* serial ISA could be right */ 401 devctl |= TI113X_DCR_IMODE_SERIAL; /* serial ISA could be right */
402 config_writeb(socket, TI113X_DEVICE_CONTROL, devctl); 402 config_writeb(socket, TI113X_DEVICE_CONTROL, devctl);
@@ -427,8 +427,8 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket)
427 pci_irq_status = yenta_probe_cb_irq(socket); 427 pci_irq_status = yenta_probe_cb_irq(socket);
428 if (pci_irq_status == 1) { 428 if (pci_irq_status == 1) {
429 mfunc_old = mfunc; 429 mfunc_old = mfunc;
430 printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts ok\n", 430 dev_printk(KERN_INFO, &socket->dev->dev,
431 pci_name(socket->dev)); 431 "TI: parallel PCI interrupts ok\n");
432 } else { 432 } else {
433 /* not working, back to old value */ 433 /* not working, back to old value */
434 mfunc = mfunc_old; 434 mfunc = mfunc_old;
@@ -440,8 +440,9 @@ static void ti12xx_irqroute_func0(struct yenta_socket *socket)
440out: 440out:
441 if (pci_irq_status < 1) { 441 if (pci_irq_status < 1) {
442 socket->cb_irq = 0; 442 socket->cb_irq = 0;
443 printk(KERN_INFO "Yenta TI: socket %s no PCI interrupts. Fish. Please report.\n", 443 dev_printk(KERN_INFO, &socket->dev->dev,
444 pci_name(socket->dev)); 444 "Yenta TI: no PCI interrupts. Fish. "
445 "Please report.\n");
445 } 446 }
446} 447}
447 448
@@ -513,8 +514,9 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket)
513 514
514 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC); 515 mfunc = mfunc_old = config_readl(socket, TI122X_MFUNC);
515 devctl = config_readb(socket, TI113X_DEVICE_CONTROL); 516 devctl = config_readb(socket, TI113X_DEVICE_CONTROL);
516 printk(KERN_INFO "Yenta TI: socket %s, mfunc 0x%08x, devctl 0x%02x\n", 517 dev_printk(KERN_INFO, &socket->dev->dev,
517 pci_name(socket->dev), mfunc, devctl); 518 "TI: mfunc 0x%08x, devctl 0x%02x\n",
519 mfunc, devctl);
518 520
519 /* if IRQs are configured as tied, align irq of func1 with func0 */ 521 /* if IRQs are configured as tied, align irq of func1 with func0 */
520 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL); 522 sysctl = config_readl(socket, TI113X_SYSTEM_CONTROL);
@@ -533,9 +535,8 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket)
533 * We're here which means PCI interrupts are _not_ delivered. try to 535 * We're here which means PCI interrupts are _not_ delivered. try to
534 * find the right setting 536 * find the right setting
535 */ 537 */
536 printk(KERN_INFO "Yenta TI: socket %s probing PCI interrupt failed, trying to fix\n", 538 dev_printk(KERN_INFO, &socket->dev->dev,
537 pci_name(socket->dev)); 539 "TI: probing PCI interrupt failed, trying to fix\n");
538
539 540
540 /* if all serial: set INTRTIE, probe again */ 541 /* if all serial: set INTRTIE, probe again */
541 if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) { 542 if ((devctl & TI113X_DCR_IMODE_MASK) == TI12XX_DCR_IMODE_ALL_SERIAL) {
@@ -544,8 +545,8 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket)
544 if (ti12xx_tie_interrupts(socket, &old_irq)) { 545 if (ti12xx_tie_interrupts(socket, &old_irq)) {
545 pci_irq_status = yenta_probe_cb_irq(socket); 546 pci_irq_status = yenta_probe_cb_irq(socket);
546 if (pci_irq_status == 1) { 547 if (pci_irq_status == 1) {
547 printk(KERN_INFO "Yenta TI: socket %s all-serial interrupts, tied ok\n", 548 dev_printk(KERN_INFO, &socket->dev->dev,
548 pci_name(socket->dev)); 549 "TI: all-serial interrupts, tied ok\n");
549 goto out; 550 goto out;
550 } 551 }
551 552
@@ -582,8 +583,8 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket)
582 583
583 pci_irq_status = yenta_probe_cb_irq(socket); 584 pci_irq_status = yenta_probe_cb_irq(socket);
584 if (pci_irq_status == 1) { 585 if (pci_irq_status == 1) {
585 printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts ok\n", 586 dev_printk(KERN_INFO, &socket->dev->dev,
586 pci_name(socket->dev)); 587 "TI: parallel PCI interrupts ok\n");
587 goto out; 588 goto out;
588 } 589 }
589 590
@@ -593,13 +594,13 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket)
593 if (pci_irq_status == -1) 594 if (pci_irq_status == -1)
594 goto out; 595 goto out;
595 } 596 }
596 597
597 /* still nothing: set INTRTIE */ 598 /* still nothing: set INTRTIE */
598 if (ti12xx_tie_interrupts(socket, &old_irq)) { 599 if (ti12xx_tie_interrupts(socket, &old_irq)) {
599 pci_irq_status = yenta_probe_cb_irq(socket); 600 pci_irq_status = yenta_probe_cb_irq(socket);
600 if (pci_irq_status == 1) { 601 if (pci_irq_status == 1) {
601 printk(KERN_INFO "Yenta TI: socket %s parallel PCI interrupts, tied ok\n", 602 dev_printk(KERN_INFO, &socket->dev->dev,
602 pci_name(socket->dev)); 603 "TI: parallel PCI interrupts, tied ok\n");
603 goto out; 604 goto out;
604 } 605 }
605 606
@@ -610,8 +611,8 @@ static void ti12xx_irqroute_func1(struct yenta_socket *socket)
610out: 611out:
611 if (pci_irq_status < 1) { 612 if (pci_irq_status < 1) {
612 socket->cb_irq = 0; 613 socket->cb_irq = 0;
613 printk(KERN_INFO "Yenta TI: socket %s no PCI interrupts. Fish. Please report.\n", 614 dev_printk(KERN_INFO, &socket->dev->dev,
614 pci_name(socket->dev)); 615 "TI: no PCI interrupts. Fish. Please report.\n");
615 } 616 }
616} 617}
617 618
@@ -815,11 +816,13 @@ static int ti12xx_override(struct yenta_socket *socket)
815 /* make sure that memory burst is active */ 816 /* make sure that memory burst is active */
816 val_orig = val = config_readl(socket, TI113X_SYSTEM_CONTROL); 817 val_orig = val = config_readl(socket, TI113X_SYSTEM_CONTROL);
817 if (disable_clkrun && PCI_FUNC(socket->dev->devfn) == 0) { 818 if (disable_clkrun && PCI_FUNC(socket->dev->devfn) == 0) {
818 printk(KERN_INFO "Yenta: Disabling CLKRUN feature\n"); 819 dev_printk(KERN_INFO, &socket->dev->dev,
820 "Disabling CLKRUN feature\n");
819 val |= TI113X_SCR_KEEPCLK; 821 val |= TI113X_SCR_KEEPCLK;
820 } 822 }
821 if (!(val & TI122X_SCR_MRBURSTUP)) { 823 if (!(val & TI122X_SCR_MRBURSTUP)) {
822 printk(KERN_INFO "Yenta: Enabling burst memory read transactions\n"); 824 dev_printk(KERN_INFO, &socket->dev->dev,
825 "Enabling burst memory read transactions\n");
823 val |= TI122X_SCR_MRBURSTUP; 826 val |= TI122X_SCR_MRBURSTUP;
824 } 827 }
825 if (val_orig != val) 828 if (val_orig != val)
@@ -830,10 +833,12 @@ static int ti12xx_override(struct yenta_socket *socket)
830 * CSC interrupts to PCI rather than INTVAL. 833 * CSC interrupts to PCI rather than INTVAL.
831 */ 834 */
832 val = config_readb(socket, TI1250_DIAGNOSTIC); 835 val = config_readb(socket, TI1250_DIAGNOSTIC);
833 printk(KERN_INFO "Yenta: Using %s to route CSC interrupts to PCI\n", 836 dev_printk(KERN_INFO, &socket->dev->dev,
834 (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL"); 837 "Using %s to route CSC interrupts to PCI\n",
835 printk(KERN_INFO "Yenta: Routing CardBus interrupts to %s\n", 838 (val & TI1250_DIAG_PCI_CSC) ? "CSCINT" : "INTVAL");
836 (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA"); 839 dev_printk(KERN_INFO, &socket->dev->dev,
840 "Routing CardBus interrupts to %s\n",
841 (val & TI1250_DIAG_PCI_IREQ) ? "PCI" : "ISA");
837 842
838 /* do irqrouting, depending on function */ 843 /* do irqrouting, depending on function */
839 if (PCI_FUNC(socket->dev->devfn) == 0) 844 if (PCI_FUNC(socket->dev->devfn) == 0)
@@ -858,8 +863,9 @@ static int ti1250_override(struct yenta_socket *socket)
858 diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ; 863 diag |= TI1250_DIAG_PCI_CSC | TI1250_DIAG_PCI_IREQ;
859 864
860 if (diag != old) { 865 if (diag != old) {
861 printk(KERN_INFO "Yenta: adjusting diagnostic: %02x -> %02x\n", 866 dev_printk(KERN_INFO, &socket->dev->dev,
862 old, diag); 867 "adjusting diagnostic: %02x -> %02x\n",
868 old, diag);
863 config_writeb(socket, TI1250_DIAGNOSTIC, diag); 869 config_writeb(socket, TI1250_DIAGNOSTIC, diag);
864 } 870 }
865 871
@@ -924,7 +930,9 @@ static void ene_tune_bridge(struct pcmcia_socket *sock, struct pci_bus *bus)
924 /* default to clear TLTEnable bit, old behaviour */ 930 /* default to clear TLTEnable bit, old behaviour */
925 test_c9 &= ~ENE_TEST_C9_TLTENABLE; 931 test_c9 &= ~ENE_TEST_C9_TLTENABLE;
926 932
927 printk(KERN_INFO "yenta EnE: chaning testregister 0xC9, %02x -> %02x\n", old_c9, test_c9); 933 dev_printk(KERN_INFO, &socket->dev->dev,
934 "EnE: chaning testregister 0xC9, %02x -> %02x\n",
935 old_c9, test_c9);
928 config_writeb(socket, ENE_TEST_C9, test_c9); 936 config_writeb(socket, ENE_TEST_C9, test_c9);
929} 937}
930 938
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index 0ab1fb65cdc..3ecd7c99d8e 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -38,11 +38,7 @@ static int pwr_irqs_off;
38module_param(pwr_irqs_off, bool, 0644); 38module_param(pwr_irqs_off, bool, 0644);
39MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!"); 39MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only when seeing IRQ storms!");
40 40
41#if 0 41#define debug(x, s, args...) dev_dbg(&s->dev->dev, x, ##args)
42#define debug(x,args...) printk(KERN_DEBUG "%s: " x, __func__ , ##args)
43#else
44#define debug(x,args...)
45#endif
46 42
47/* Don't ask.. */ 43/* Don't ask.. */
48#define to_cycles(ns) ((ns)/120) 44#define to_cycles(ns) ((ns)/120)
@@ -69,13 +65,13 @@ MODULE_PARM_DESC (override_bios, "yenta ignore bios resource allocation");
69static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg) 65static inline u32 cb_readl(struct yenta_socket *socket, unsigned reg)
70{ 66{
71 u32 val = readl(socket->base + reg); 67 u32 val = readl(socket->base + reg);
72 debug("%p %04x %08x\n", socket, reg, val); 68 debug("%04x %08x\n", socket, reg, val);
73 return val; 69 return val;
74} 70}
75 71
76static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val) 72static inline void cb_writel(struct yenta_socket *socket, unsigned reg, u32 val)
77{ 73{
78 debug("%p %04x %08x\n", socket, reg, val); 74 debug("%04x %08x\n", socket, reg, val);
79 writel(val, socket->base + reg); 75 writel(val, socket->base + reg);
80 readl(socket->base + reg); /* avoid problems with PCI write posting */ 76 readl(socket->base + reg); /* avoid problems with PCI write posting */
81} 77}
@@ -84,7 +80,7 @@ static inline u8 config_readb(struct yenta_socket *socket, unsigned offset)
84{ 80{
85 u8 val; 81 u8 val;
86 pci_read_config_byte(socket->dev, offset, &val); 82 pci_read_config_byte(socket->dev, offset, &val);
87 debug("%p %04x %02x\n", socket, offset, val); 83 debug("%04x %02x\n", socket, offset, val);
88 return val; 84 return val;
89} 85}
90 86
@@ -92,7 +88,7 @@ static inline u16 config_readw(struct yenta_socket *socket, unsigned offset)
92{ 88{
93 u16 val; 89 u16 val;
94 pci_read_config_word(socket->dev, offset, &val); 90 pci_read_config_word(socket->dev, offset, &val);
95 debug("%p %04x %04x\n", socket, offset, val); 91 debug("%04x %04x\n", socket, offset, val);
96 return val; 92 return val;
97} 93}
98 94
@@ -100,32 +96,32 @@ static inline u32 config_readl(struct yenta_socket *socket, unsigned offset)
100{ 96{
101 u32 val; 97 u32 val;
102 pci_read_config_dword(socket->dev, offset, &val); 98 pci_read_config_dword(socket->dev, offset, &val);
103 debug("%p %04x %08x\n", socket, offset, val); 99 debug("%04x %08x\n", socket, offset, val);
104 return val; 100 return val;
105} 101}
106 102
107static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val) 103static inline void config_writeb(struct yenta_socket *socket, unsigned offset, u8 val)
108{ 104{
109 debug("%p %04x %02x\n", socket, offset, val); 105 debug("%04x %02x\n", socket, offset, val);
110 pci_write_config_byte(socket->dev, offset, val); 106 pci_write_config_byte(socket->dev, offset, val);
111} 107}
112 108
113static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val) 109static inline void config_writew(struct yenta_socket *socket, unsigned offset, u16 val)
114{ 110{
115 debug("%p %04x %04x\n", socket, offset, val); 111 debug("%04x %04x\n", socket, offset, val);
116 pci_write_config_word(socket->dev, offset, val); 112 pci_write_config_word(socket->dev, offset, val);
117} 113}
118 114
119static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val) 115static inline void config_writel(struct yenta_socket *socket, unsigned offset, u32 val)
120{ 116{
121 debug("%p %04x %08x\n", socket, offset, val); 117 debug("%04x %08x\n", socket, offset, val);
122 pci_write_config_dword(socket->dev, offset, val); 118 pci_write_config_dword(socket->dev, offset, val);
123} 119}
124 120
125static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg) 121static inline u8 exca_readb(struct yenta_socket *socket, unsigned reg)
126{ 122{
127 u8 val = readb(socket->base + 0x800 + reg); 123 u8 val = readb(socket->base + 0x800 + reg);
128 debug("%p %04x %02x\n", socket, reg, val); 124 debug("%04x %02x\n", socket, reg, val);
129 return val; 125 return val;
130} 126}
131 127
@@ -134,20 +130,20 @@ static inline u8 exca_readw(struct yenta_socket *socket, unsigned reg)
134 u16 val; 130 u16 val;
135 val = readb(socket->base + 0x800 + reg); 131 val = readb(socket->base + 0x800 + reg);
136 val |= readb(socket->base + 0x800 + reg + 1) << 8; 132 val |= readb(socket->base + 0x800 + reg + 1) << 8;
137 debug("%p %04x %04x\n", socket, reg, val); 133 debug("%04x %04x\n", socket, reg, val);
138 return val; 134 return val;
139} 135}
140 136
141static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val) 137static inline void exca_writeb(struct yenta_socket *socket, unsigned reg, u8 val)
142{ 138{
143 debug("%p %04x %02x\n", socket, reg, val); 139 debug("%04x %02x\n", socket, reg, val);
144 writeb(val, socket->base + 0x800 + reg); 140 writeb(val, socket->base + 0x800 + reg);
145 readb(socket->base + 0x800 + reg); /* PCI write posting... */ 141 readb(socket->base + 0x800 + reg); /* PCI write posting... */
146} 142}
147 143
148static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val) 144static void exca_writew(struct yenta_socket *socket, unsigned reg, u16 val)
149{ 145{
150 debug("%p %04x %04x\n", socket, reg, val); 146 debug("%04x %04x\n", socket, reg, val);
151 writeb(val, socket->base + 0x800 + reg); 147 writeb(val, socket->base + 0x800 + reg);
152 writeb(val >> 8, socket->base + 0x800 + reg + 1); 148 writeb(val >> 8, socket->base + 0x800 + reg + 1);
153 149
@@ -207,7 +203,7 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value)
207 203
208 204
209 if (state & CB_CBCARD) { 205 if (state & CB_CBCARD) {
210 val |= SS_CARDBUS; 206 val |= SS_CARDBUS;
211 val |= (state & CB_CARDSTS) ? SS_STSCHG : 0; 207 val |= (state & CB_CARDSTS) ? SS_STSCHG : 0;
212 val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT; 208 val |= (state & (CB_CDETECT1 | CB_CDETECT2)) ? 0 : SS_DETECT;
213 val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0; 209 val |= (state & CB_PWRCYCLE) ? SS_POWERON | SS_READY : 0;
@@ -650,8 +646,10 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type
650 root = pci_find_parent_resource(socket->dev, res); 646 root = pci_find_parent_resource(socket->dev, res);
651 if (root && (request_resource(root, res) == 0)) 647 if (root && (request_resource(root, res) == 0))
652 return 0; 648 return 0;
653 printk(KERN_INFO "yenta %s: Preassigned resource %d busy or not available, reconfiguring...\n", 649 dev_printk(KERN_INFO, &socket->dev->dev,
654 pci_name(socket->dev), nr); 650 "Preassigned resource %d busy or not available, "
651 "reconfiguring...\n",
652 nr);
655 } 653 }
656 654
657 if (type & IORESOURCE_IO) { 655 if (type & IORESOURCE_IO) {
@@ -674,8 +672,9 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type
674 return 1; 672 return 1;
675 } 673 }
676 674
677 printk(KERN_INFO "yenta %s: no resource of type %x available, trying to continue...\n", 675 dev_printk(KERN_INFO, &socket->dev->dev,
678 pci_name(socket->dev), type); 676 "no resource of type %x available, trying to continue...\n",
677 type);
679 res->start = res->end = res->flags = 0; 678 res->start = res->end = res->flags = 0;
680 return 0; 679 return 0;
681} 680}
@@ -923,7 +922,8 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket)
923 socket->probe_status = 0; 922 socket->probe_status = 0;
924 923
925 if (request_irq(socket->cb_irq, yenta_probe_handler, IRQF_SHARED, "yenta", socket)) { 924 if (request_irq(socket->cb_irq, yenta_probe_handler, IRQF_SHARED, "yenta", socket)) {
926 printk(KERN_WARNING "Yenta: request_irq() in yenta_probe_cb_irq() failed!\n"); 925 dev_printk(KERN_WARNING, &socket->dev->dev,
926 "request_irq() in yenta_probe_cb_irq() failed!\n");
927 return -1; 927 return -1;
928 } 928 }
929 929
@@ -960,8 +960,9 @@ static void yenta_get_socket_capabilities(struct yenta_socket *socket, u32 isa_i
960 else 960 else
961 socket->socket.irq_mask = 0; 961 socket->socket.irq_mask = 0;
962 962
963 printk(KERN_INFO "Yenta: ISA IRQ mask 0x%04x, PCI irq %d\n", 963 dev_printk(KERN_INFO, &socket->dev->dev,
964 socket->socket.irq_mask, socket->cb_irq); 964 "ISA IRQ mask 0x%04x, PCI irq %d\n",
965 socket->socket.irq_mask, socket->cb_irq);
965} 966}
966 967
967/* 968/*
@@ -1051,8 +1052,9 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
1051 1052
1052 /* Show that the wanted subordinate number is not possible: */ 1053 /* Show that the wanted subordinate number is not possible: */
1053 if (cardbus_bridge->subordinate > upper_limit) 1054 if (cardbus_bridge->subordinate > upper_limit)
1054 printk(KERN_WARNING "Yenta: Upper limit for fixing this " 1055 dev_printk(KERN_WARNING, &cardbus_bridge->dev,
1055 "bridge's parent bridge: #%02x\n", upper_limit); 1056 "Upper limit for fixing this "
1057 "bridge's parent bridge: #%02x\n", upper_limit);
1056 1058
1057 /* If we have room to increase the bridge's subordinate number, */ 1059 /* If we have room to increase the bridge's subordinate number, */
1058 if (bridge_to_fix->subordinate < upper_limit) { 1060 if (bridge_to_fix->subordinate < upper_limit) {
@@ -1061,10 +1063,11 @@ static void yenta_fixup_parent_bridge(struct pci_bus *cardbus_bridge)
1061 unsigned char subordinate_to_assign = 1063 unsigned char subordinate_to_assign =
1062 min(cardbus_bridge->subordinate, upper_limit); 1064 min(cardbus_bridge->subordinate, upper_limit);
1063 1065
1064 printk(KERN_INFO "Yenta: Raising subordinate bus# of parent " 1066 dev_printk(KERN_INFO, &bridge_to_fix->dev,
1065 "bus (#%02x) from #%02x to #%02x\n", 1067 "Raising subordinate bus# of parent "
1066 bridge_to_fix->number, 1068 "bus (#%02x) from #%02x to #%02x\n",
1067 bridge_to_fix->subordinate, subordinate_to_assign); 1069 bridge_to_fix->number,
1070 bridge_to_fix->subordinate, subordinate_to_assign);
1068 1071
1069 /* Save the new subordinate in the bus struct of the bridge */ 1072 /* Save the new subordinate in the bus struct of the bridge */
1070 bridge_to_fix->subordinate = subordinate_to_assign; 1073 bridge_to_fix->subordinate = subordinate_to_assign;
@@ -1091,8 +1094,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1091 * Bail out if so. 1094 * Bail out if so.
1092 */ 1095 */
1093 if (!dev->subordinate) { 1096 if (!dev->subordinate) {
1094 printk(KERN_ERR "Yenta: no bus associated with %s! " 1097 dev_printk(KERN_ERR, &dev->dev, "no bus associated! "
1095 "(try 'pci=assign-busses')\n", pci_name(dev)); 1098 "(try 'pci=assign-busses')\n");
1096 return -ENODEV; 1099 return -ENODEV;
1097 } 1100 }
1098 1101
@@ -1127,7 +1130,7 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1127 goto disable; 1130 goto disable;
1128 1131
1129 if (!pci_resource_start(dev, 0)) { 1132 if (!pci_resource_start(dev, 0)) {
1130 printk(KERN_ERR "No cardbus resource!\n"); 1133 dev_printk(KERN_ERR, &dev->dev, "No cardbus resource!\n");
1131 ret = -ENODEV; 1134 ret = -ENODEV;
1132 goto release; 1135 goto release;
1133 } 1136 }
@@ -1146,8 +1149,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1146 * report the subsystem vendor and device for help debugging 1149 * report the subsystem vendor and device for help debugging
1147 * the irq stuff... 1150 * the irq stuff...
1148 */ 1151 */
1149 printk(KERN_INFO "Yenta: CardBus bridge found at %s [%04x:%04x]\n", 1152 dev_printk(KERN_INFO, &dev->dev, "CardBus bridge found [%04x:%04x]\n",
1150 pci_name(dev), dev->subsystem_vendor, dev->subsystem_device); 1153 dev->subsystem_vendor, dev->subsystem_device);
1151 1154
1152 yenta_config_init(socket); 1155 yenta_config_init(socket);
1153 1156
@@ -1179,8 +1182,12 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1179 socket->poll_timer.data = (unsigned long)socket; 1182 socket->poll_timer.data = (unsigned long)socket;
1180 socket->poll_timer.expires = jiffies + HZ; 1183 socket->poll_timer.expires = jiffies + HZ;
1181 add_timer(&socket->poll_timer); 1184 add_timer(&socket->poll_timer);
1182 printk(KERN_INFO "Yenta: no PCI IRQ, CardBus support disabled for this socket.\n" 1185 dev_printk(KERN_INFO, &dev->dev,
1183 KERN_INFO "Yenta: check your BIOS CardBus, BIOS IRQ or ACPI settings.\n"); 1186 "no PCI IRQ, CardBus support disabled for this "
1187 "socket.\n");
1188 dev_printk(KERN_INFO, &dev->dev,
1189 "check your BIOS CardBus, BIOS IRQ or ACPI "
1190 "settings.\n");
1184 } else { 1191 } else {
1185 socket->socket.features |= SS_CAP_CARDBUS; 1192 socket->socket.features |= SS_CAP_CARDBUS;
1186 } 1193 }
@@ -1188,7 +1195,8 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1188 /* Figure out what the dang thing can do for the PCMCIA layer... */ 1195 /* Figure out what the dang thing can do for the PCMCIA layer... */
1189 yenta_interrogate(socket); 1196 yenta_interrogate(socket);
1190 yenta_get_socket_capabilities(socket, isa_interrupts); 1197 yenta_get_socket_capabilities(socket, isa_interrupts);
1191 printk(KERN_INFO "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE)); 1198 dev_printk(KERN_INFO, &dev->dev,
1199 "Socket status: %08x\n", cb_readl(socket, CB_SOCKET_STATE));
1192 1200
1193 yenta_fixup_parent_bridge(dev->subordinate); 1201 yenta_fixup_parent_bridge(dev->subordinate);
1194 1202