From 6efd936046b123303ace4330fd2f26195ad7b1c4 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 27 Jun 2005 15:24:22 -0700 Subject: [PATCH] ide: fix ide-disk inability to handle LBA only devices. Years old bug, has to be fixed for it8212 to work Signed-off-by: Alan Cox Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/ide-disk.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index d6f934886b0..f9c1acb4ed6 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c @@ -119,6 +119,10 @@ static int lba_capacity_is_ok (struct hd_driveid *id) { unsigned long lba_sects, chs_sects, head, tail; + /* No non-LBA info .. so valid! */ + if (id->cyls == 0) + return 1; + /* * The ATA spec tells large drives to return * C/H/S = 16383/16/63 independent of their size. -- cgit v1.2.3 From 58ecd15652979f2001dc296dcfd303cc1bd33ce7 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 27 Jun 2005 15:24:24 -0700 Subject: [PATCH] ide: samsung SN-124 works perfectly well with DMA Been in Red Hat products for ages Signed-off-by: Alan Cox Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/ide-dma.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 2d2eefb610d..1e1531334c2 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c @@ -132,7 +132,6 @@ static const struct drive_list_entry drive_blacklist [] = { { "SAMSUNG CD-ROM SC-148C", "ALL" }, { "SAMSUNG CD-ROM SC", "ALL" }, { "SanDisk SDP3B-64" , "ALL" }, - { "SAMSUNG CD-ROM SN-124", "ALL" }, { "ATAPI CD-ROM DRIVE 40X MAXIMUM", "ALL" }, { "_NEC DV5800A", "ALL" }, { NULL , NULL } -- cgit v1.2.3 From 68ad9910b0525d0194f9c316c7cb14adbf8e0c0c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 27 Jun 2005 15:24:25 -0700 Subject: [PATCH] ide: IDE timing violation on reset Pretty much theoretical for non MMIO thankfully. We _must_ use OUTBSYNC for commands or they may be posted and thus ruin the 400nS required delay. Signed-off-by: Alan Cox Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/ide-iops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 53024942a7e..b443b04a4c5 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c @@ -1181,7 +1181,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) pre_reset(drive); SELECT_DRIVE(drive); udelay (20); - hwif->OUTB(WIN_SRST, IDE_COMMAND_REG); + hwif->OUTBSYNC(drive, WIN_SRST, IDE_COMMAND_REG); + ndelay(400); hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; hwgroup->polling = 1; __ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20, NULL); -- cgit v1.2.3 From b189346cd10e28fa080347591066f0688405faee Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 27 Jun 2005 15:24:26 -0700 Subject: [PATCH] ide: ide-generic, allow for capture of other unsupported devices The ide-generic driver gives you DMA at bios tuned speed so can actually run a lot of unsupported devices quite well. It has a pci table so that it doesn't grab disks owned by other drivers but no way to override this. The patch adds an option ide-generic-all which makes the driver grab everything going that is IDE class. The diff is messy because I put the special case as case 0 to make the if conditional and long term maintenance easier. This has been in Fedora for some time. Signed-off-by: Alan Cox Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/pci/generic.c | 73 +++++++++++++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index 4565cc311ff..da46577380f 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c @@ -39,6 +39,17 @@ #include +static int ide_generic_all; /* Set to claim all devices */ + +static int __init ide_generic_all_on(char *unused) +{ + ide_generic_all = 1; + printk(KERN_INFO "IDE generic will claim all unknown PCI IDE storage controllers.\n"); + return 1; +} + +__setup("all-generic-ide", ide_generic_all_on); + static void __devinit init_hwif_generic (ide_hwif_t *hwif) { switch(hwif->pci_dev->device) { @@ -78,79 +89,85 @@ static void __devinit init_hwif_generic (ide_hwif_t *hwif) static ide_pci_device_t generic_chipsets[] __devinitdata = { { /* 0 */ + .name = "Unknown", + .init_hwif = init_hwif_generic, + .channels = 2, + .autodma = AUTODMA, + .bootable = ON_BOARD, + },{ /* 1 */ .name = "NS87410", .init_hwif = init_hwif_generic, .channels = 2, .autodma = AUTODMA, .enablebits = {{0x43,0x08,0x08}, {0x47,0x08,0x08}}, .bootable = ON_BOARD, - },{ /* 1 */ + },{ /* 2 */ .name = "SAMURAI", .init_hwif = init_hwif_generic, .channels = 2, .autodma = AUTODMA, .bootable = ON_BOARD, - },{ /* 2 */ + },{ /* 3 */ .name = "HT6565", .init_hwif = init_hwif_generic, .channels = 2, .autodma = AUTODMA, .bootable = ON_BOARD, - },{ /* 3 */ + },{ /* 4 */ .name = "UM8673F", .init_hwif = init_hwif_generic, .channels = 2, .autodma = NODMA, .bootable = ON_BOARD, - },{ /* 4 */ + },{ /* 5 */ .name = "UM8886A", .init_hwif = init_hwif_generic, .channels = 2, .autodma = NODMA, .bootable = ON_BOARD, - },{ /* 5 */ + },{ /* 6 */ .name = "UM8886BF", .init_hwif = init_hwif_generic, .channels = 2, .autodma = NODMA, .bootable = ON_BOARD, - },{ /* 6 */ + },{ /* 7 */ .name = "HINT_IDE", .init_hwif = init_hwif_generic, .channels = 2, .autodma = AUTODMA, .bootable = ON_BOARD, - },{ /* 7 */ + },{ /* 8 */ .name = "VIA_IDE", .init_hwif = init_hwif_generic, .channels = 2, .autodma = NOAUTODMA, .bootable = ON_BOARD, - },{ /* 8 */ + },{ /* 9 */ .name = "OPTI621V", .init_hwif = init_hwif_generic, .channels = 2, .autodma = NOAUTODMA, .bootable = ON_BOARD, - },{ /* 9 */ + },{ /* 10 */ .name = "VIA8237SATA", .init_hwif = init_hwif_generic, .channels = 2, .autodma = AUTODMA, .bootable = OFF_BOARD, - },{ /* 10 */ + },{ /* 11 */ .name = "Piccolo0102", .init_hwif = init_hwif_generic, .channels = 2, .autodma = NOAUTODMA, .bootable = ON_BOARD, - },{ /* 11 */ + },{ /* 12 */ .name = "Piccolo0103", .init_hwif = init_hwif_generic, .channels = 2, .autodma = NOAUTODMA, .bootable = ON_BOARD, - },{ /* 12 */ + },{ /* 13 */ .name = "Piccolo0105", .init_hwif = init_hwif_generic, .channels = 2, @@ -174,6 +191,10 @@ static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_devi u16 command; int ret = -ENODEV; + /* Don't use the generic entry unless instructed to do so */ + if (id->driver_data == 0 && ide_generic_all == 0) + goto out; + if (dev->vendor == PCI_VENDOR_ID_UMC && dev->device == PCI_DEVICE_ID_UMC_UM8886A && (!(PCI_FUNC(dev->devfn) & 1))) @@ -195,21 +216,23 @@ out: } static struct pci_device_id generic_pci_tbl[] = { - { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, - { PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, - { PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_6565, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, - { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8673F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, - { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, - { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886BF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, - { PCI_VENDOR_ID_HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6}, - { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7}, - { PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8}, + { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, + { PCI_VENDOR_ID_PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, + { PCI_VENDOR_ID_HOLTEK, PCI_DEVICE_ID_HOLTEK_6565, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3}, + { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8673F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4}, + { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5}, + { PCI_VENDOR_ID_UMC, PCI_DEVICE_ID_UMC_UM8886BF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6}, + { PCI_VENDOR_ID_HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7}, + { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8}, + { PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9}, #ifdef CONFIG_BLK_DEV_IDE_SATA - { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237_SATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9}, + { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237_SATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10}, #endif - { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10}, - { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11}, - { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12}, + { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11}, + { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12}, + { PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 13}, + /* Must come last. If you add entries adjust this table appropriately and the init_one code */ + { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 0}, { 0, }, }; MODULE_DEVICE_TABLE(pci, generic_pci_tbl); -- cgit v1.2.3 From b39b01ffb75e14ed76510e4229ffb575007df0fb Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 27 Jun 2005 15:24:27 -0700 Subject: [PATCH] ide: fix the HPT366 driver layer The highpoint driver is unreadable, buggy and crashes on some chipsets. The -ac one is more readable (but not ideal) and doesn't crash all over the place. Been in Fedora for some time. Backported from the Fedora one to the old Bartlomiej IDE core. No other dependencies. Signed-off-by: Alan Cox Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/pci/hpt366.c | 470 +++++++++++++++++++++++------------------------ 1 file changed, 228 insertions(+), 242 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index c8ee0b8c029..7b64db10d1b 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -10,6 +10,11 @@ * donation of an ABit BP6 mainboard, processor, and memory acellerated * development and support. * + * + * Highpoint have their own driver (source except for the raid part) + * available from http://www.highpoint-tech.com/hpt3xx-opensource-v131.tgz + * This may be useful to anyone wanting to work on the mainstream hpt IDE. + * * Note that final HPT370 support was done by force extraction of GPL. * * - add function for getting/setting power status of drive @@ -446,44 +451,29 @@ static struct chipset_bus_clock_list_entry sixty_six_base_hpt374[] = { #define F_LOW_PCI_50 0x2d #define F_LOW_PCI_66 0x42 -/* FIXME: compare with driver's code before removing */ -#if 0 - if (hpt_minimum_revision(dev, 3)) { - u8 cbl; - cbl = inb(iobase + 0x7b); - outb(cbl | 1, iobase + 0x7b); - outb(cbl & ~1, iobase + 0x7b); - cbl = inb(iobase + 0x7a); - p += sprintf(p, "Cable: ATA-%d" - " ATA-%d\n", - (cbl & 0x02) ? 33 : 66, - (cbl & 0x01) ? 33 : 66); - p += sprintf(p, "\n"); - } - { - u8 c2, c3; - /* older revs don't have these registers mapped - * into io space */ - pci_read_config_byte(dev, 0x43, &c0); - pci_read_config_byte(dev, 0x47, &c1); - pci_read_config_byte(dev, 0x4b, &c2); - pci_read_config_byte(dev, 0x4f, &c3); - - p += sprintf(p, "Mode: %s %s" - " %s %s\n", - (c0 & 0x10) ? "UDMA" : (c0 & 0x20) ? "DMA " : - (c0 & 0x80) ? "PIO " : "off ", - (c1 & 0x10) ? "UDMA" : (c1 & 0x20) ? "DMA " : - (c1 & 0x80) ? "PIO " : "off ", - (c2 & 0x10) ? "UDMA" : (c2 & 0x20) ? "DMA " : - (c2 & 0x80) ? "PIO " : "off ", - (c3 & 0x10) ? "UDMA" : (c3 & 0x20) ? "DMA " : - (c3 & 0x80) ? "PIO " : "off "); - } - } -#endif +/* + * Hold all the highpoint quirks and revision information in one + * place. + */ -static u32 hpt_revision (struct pci_dev *dev) +struct hpt_info +{ + u8 max_mode; /* Speeds allowed */ + int revision; /* Chipset revision */ + int flags; /* Chipset properties */ +#define PLL_MODE 1 +#define IS_372N 2 + /* Speed table */ + struct chipset_bus_clock_list_entry *speed; +}; + +/* + * This wants fixing so that we do everything not by classrev + * (which breaks on the newest chips) but by creating an + * enumeration of chip variants and using that + */ + +static __devinit u32 hpt_revision (struct pci_dev *dev) { u32 class_rev; pci_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev); @@ -507,37 +497,33 @@ static u32 hpt_revision (struct pci_dev *dev) return class_rev; } -static u32 hpt_minimum_revision (struct pci_dev *dev, int revision) -{ - unsigned int class_rev = hpt_revision(dev); - revision--; - return ((int) (class_rev > revision) ? 1 : 0); -} - static int check_in_drive_lists(ide_drive_t *drive, const char **list); static u8 hpt3xx_ratemask (ide_drive_t *drive) { - struct pci_dev *dev = HWIF(drive)->pci_dev; + ide_hwif_t *hwif = drive->hwif; + struct hpt_info *info = ide_get_hwifdata(hwif); u8 mode = 0; - if (hpt_minimum_revision(dev, 8)) { /* HPT374 */ + /* FIXME: TODO - move this to set info->mode once at boot */ + + if (info->revision >= 8) { /* HPT374 */ mode = (HPT374_ALLOW_ATA133_6) ? 4 : 3; - } else if (hpt_minimum_revision(dev, 7)) { /* HPT371 */ + } else if (info->revision >= 7) { /* HPT371 */ mode = (HPT371_ALLOW_ATA133_6) ? 4 : 3; - } else if (hpt_minimum_revision(dev, 6)) { /* HPT302 */ + } else if (info->revision >= 6) { /* HPT302 */ mode = (HPT302_ALLOW_ATA133_6) ? 4 : 3; - } else if (hpt_minimum_revision(dev, 5)) { /* HPT372 */ + } else if (info->revision >= 5) { /* HPT372 */ mode = (HPT372_ALLOW_ATA133_6) ? 4 : 3; - } else if (hpt_minimum_revision(dev, 4)) { /* HPT370A */ + } else if (info->revision >= 4) { /* HPT370A */ mode = (HPT370_ALLOW_ATA100_5) ? 3 : 2; - } else if (hpt_minimum_revision(dev, 3)) { /* HPT370 */ + } else if (info->revision >= 3) { /* HPT370 */ mode = (HPT370_ALLOW_ATA100_5) ? 3 : 2; mode = (check_in_drive_lists(drive, bad_ata33)) ? 0 : mode; } else { /* HPT366 and HPT368 */ mode = (check_in_drive_lists(drive, bad_ata33)) ? 0 : 2; } - if (!eighty_ninty_three(drive) && (mode)) + if (!eighty_ninty_three(drive) && mode) mode = min(mode, (u8)1); return mode; } @@ -549,7 +535,8 @@ static u8 hpt3xx_ratemask (ide_drive_t *drive) static u8 hpt3xx_ratefilter (ide_drive_t *drive, u8 speed) { - struct pci_dev *dev = HWIF(drive)->pci_dev; + ide_hwif_t *hwif = drive->hwif; + struct hpt_info *info = ide_get_hwifdata(hwif); u8 mode = hpt3xx_ratemask(drive); if (drive->media != ide_disk) @@ -561,7 +548,7 @@ static u8 hpt3xx_ratefilter (ide_drive_t *drive, u8 speed) break; case 0x03: speed = min(speed, (u8)XFER_UDMA_5); - if (hpt_minimum_revision(dev, 5)) + if (info->revision >= 5) break; if (check_in_drive_lists(drive, bad_ata100_5)) speed = min(speed, (u8)XFER_UDMA_4); @@ -571,7 +558,7 @@ static u8 hpt3xx_ratefilter (ide_drive_t *drive, u8 speed) /* * CHECK ME, Does this need to be set to 5 ?? */ - if (hpt_minimum_revision(dev, 3)) + if (info->revision >= 3) break; if ((check_in_drive_lists(drive, bad_ata66_4)) || (!(HPT366_ALLOW_ATA66_4))) @@ -585,7 +572,7 @@ static u8 hpt3xx_ratefilter (ide_drive_t *drive, u8 speed) /* * CHECK ME, Does this need to be set to 5 ?? */ - if (hpt_minimum_revision(dev, 3)) + if (info->revision >= 3) break; if (check_in_drive_lists(drive, bad_ata33)) speed = min(speed, (u8)XFER_MW_DMA_2); @@ -624,11 +611,12 @@ static unsigned int pci_bus_clock_list (u8 speed, struct chipset_bus_clock_list_ static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed) { - struct pci_dev *dev = HWIF(drive)->pci_dev; + ide_hwif_t *hwif = drive->hwif; + struct pci_dev *dev = hwif->pci_dev; + struct hpt_info *info = ide_get_hwifdata(hwif); u8 speed = hpt3xx_ratefilter(drive, xferspeed); -// u8 speed = ide_rate_filter(hpt3xx_ratemask(drive), xferspeed); u8 regtime = (drive->select.b.unit & 0x01) ? 0x44 : 0x40; - u8 regfast = (HWIF(drive)->channel) ? 0x55 : 0x51; + u8 regfast = (hwif->channel) ? 0x55 : 0x51; u8 drive_fast = 0; u32 reg1 = 0, reg2 = 0; @@ -636,16 +624,11 @@ static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed) * Disable the "fast interrupt" prediction. */ pci_read_config_byte(dev, regfast, &drive_fast); -#if 0 - if (drive_fast & 0x02) - pci_write_config_byte(dev, regfast, drive_fast & ~0x20); -#else if (drive_fast & 0x80) pci_write_config_byte(dev, regfast, drive_fast & ~0x80); -#endif - reg2 = pci_bus_clock_list(speed, - (struct chipset_bus_clock_list_entry *) pci_get_drvdata(dev)); + reg2 = pci_bus_clock_list(speed, info->speed); + /* * Disable on-chip PIO FIFO/buffer * (to avoid problems handling I/O errors later) @@ -665,10 +648,11 @@ static int hpt36x_tune_chipset(ide_drive_t *drive, u8 xferspeed) static int hpt370_tune_chipset(ide_drive_t *drive, u8 xferspeed) { - struct pci_dev *dev = HWIF(drive)->pci_dev; + ide_hwif_t *hwif = drive->hwif; + struct pci_dev *dev = hwif->pci_dev; + struct hpt_info *info = ide_get_hwifdata(hwif); u8 speed = hpt3xx_ratefilter(drive, xferspeed); -// u8 speed = ide_rate_filter(hpt3xx_ratemask(drive), xferspeed); - u8 regfast = (HWIF(drive)->channel) ? 0x55 : 0x51; + u8 regfast = (drive->hwif->channel) ? 0x55 : 0x51; u8 drive_pci = 0x40 + (drive->dn * 4); u8 new_fast = 0, drive_fast = 0; u32 list_conf = 0, drive_conf = 0; @@ -693,17 +677,13 @@ static int hpt370_tune_chipset(ide_drive_t *drive, u8 xferspeed) if (new_fast != drive_fast) pci_write_config_byte(dev, regfast, new_fast); - list_conf = pci_bus_clock_list(speed, - (struct chipset_bus_clock_list_entry *) - pci_get_drvdata(dev)); + list_conf = pci_bus_clock_list(speed, info->speed); pci_read_config_dword(dev, drive_pci, &drive_conf); list_conf = (list_conf & ~conf_mask) | (drive_conf & conf_mask); - if (speed < XFER_MW_DMA_0) { + if (speed < XFER_MW_DMA_0) list_conf &= ~0x80000000; /* Disable on-chip PIO FIFO/buffer */ - } - pci_write_config_dword(dev, drive_pci, list_conf); return ide_config_drive_speed(drive, speed); @@ -711,10 +691,11 @@ static int hpt370_tune_chipset(ide_drive_t *drive, u8 xferspeed) static int hpt372_tune_chipset(ide_drive_t *drive, u8 xferspeed) { - struct pci_dev *dev = HWIF(drive)->pci_dev; + ide_hwif_t *hwif = drive->hwif; + struct pci_dev *dev = hwif->pci_dev; + struct hpt_info *info = ide_get_hwifdata(hwif); u8 speed = hpt3xx_ratefilter(drive, xferspeed); -// u8 speed = ide_rate_filter(hpt3xx_ratemask(drive), xferspeed); - u8 regfast = (HWIF(drive)->channel) ? 0x55 : 0x51; + u8 regfast = (drive->hwif->channel) ? 0x55 : 0x51; u8 drive_fast = 0, drive_pci = 0x40 + (drive->dn * 4); u32 list_conf = 0, drive_conf = 0; u32 conf_mask = (speed >= XFER_MW_DMA_0) ? 0xc0000000 : 0x30070000; @@ -726,10 +707,8 @@ static int hpt372_tune_chipset(ide_drive_t *drive, u8 xferspeed) pci_read_config_byte(dev, regfast, &drive_fast); drive_fast &= ~0x07; pci_write_config_byte(dev, regfast, drive_fast); - - list_conf = pci_bus_clock_list(speed, - (struct chipset_bus_clock_list_entry *) - pci_get_drvdata(dev)); + + list_conf = pci_bus_clock_list(speed, info->speed); pci_read_config_dword(dev, drive_pci, &drive_conf); list_conf = (list_conf & ~conf_mask) | (drive_conf & conf_mask); if (speed < XFER_MW_DMA_0) @@ -741,19 +720,14 @@ static int hpt372_tune_chipset(ide_drive_t *drive, u8 xferspeed) static int hpt3xx_tune_chipset (ide_drive_t *drive, u8 speed) { - struct pci_dev *dev = HWIF(drive)->pci_dev; + ide_hwif_t *hwif = drive->hwif; + struct hpt_info *info = ide_get_hwifdata(hwif); - if (hpt_minimum_revision(dev, 8)) + if (info->revision >= 8) return hpt372_tune_chipset(drive, speed); /* not a typo */ -#if 0 - else if (hpt_minimum_revision(dev, 7)) - hpt371_tune_chipset(drive, speed); - else if (hpt_minimum_revision(dev, 6)) - hpt302_tune_chipset(drive, speed); -#endif - else if (hpt_minimum_revision(dev, 5)) + else if (info->revision >= 5) return hpt372_tune_chipset(drive, speed); - else if (hpt_minimum_revision(dev, 3)) + else if (info->revision >= 3) return hpt370_tune_chipset(drive, speed); else /* hpt368: hpt_minimum_revision(dev, 2) */ return hpt36x_tune_chipset(drive, speed); @@ -779,8 +753,14 @@ static void hpt3xx_tune_drive (ide_drive_t *drive, u8 pio) static int config_chipset_for_dma (ide_drive_t *drive) { u8 speed = ide_dma_speed(drive, hpt3xx_ratemask(drive)); + ide_hwif_t *hwif = drive->hwif; + struct hpt_info *info = ide_get_hwifdata(hwif); - if (!(speed)) + if (!speed) + return 0; + + /* If we don't have any timings we can't do a lot */ + if (info->speed == NULL) return 0; (void) hpt3xx_tune_chipset(drive, speed); @@ -794,7 +774,7 @@ static int hpt3xx_quirkproc (ide_drive_t *drive) static void hpt3xx_intrproc (ide_drive_t *drive) { - ide_hwif_t *hwif = HWIF(drive); + ide_hwif_t *hwif = drive->hwif; if (drive->quirk_list) return; @@ -804,24 +784,26 @@ static void hpt3xx_intrproc (ide_drive_t *drive) static void hpt3xx_maskproc (ide_drive_t *drive, int mask) { - struct pci_dev *dev = HWIF(drive)->pci_dev; + ide_hwif_t *hwif = drive->hwif; + struct hpt_info *info = ide_get_hwifdata(hwif); + struct pci_dev *dev = hwif->pci_dev; if (drive->quirk_list) { - if (hpt_minimum_revision(dev,3)) { + if (info->revision >= 3) { u8 reg5a = 0; pci_read_config_byte(dev, 0x5a, ®5a); if (((reg5a & 0x10) >> 4) != mask) pci_write_config_byte(dev, 0x5a, mask ? (reg5a | 0x10) : (reg5a & ~0x10)); } else { if (mask) { - disable_irq(HWIF(drive)->irq); + disable_irq(hwif->irq); } else { - enable_irq(HWIF(drive)->irq); + enable_irq(hwif->irq); } } } else { if (IDE_CONTROL_REG) - HWIF(drive)->OUTB(mask ? (drive->ctl | 2) : + hwif->OUTB(mask ? (drive->ctl | 2) : (drive->ctl & ~2), IDE_CONTROL_REG); } @@ -829,12 +811,12 @@ static void hpt3xx_maskproc (ide_drive_t *drive, int mask) static int hpt366_config_drive_xfer_rate (ide_drive_t *drive) { - ide_hwif_t *hwif = HWIF(drive); + ide_hwif_t *hwif = drive->hwif; struct hd_driveid *id = drive->id; drive->init_speed = 0; - if (id && (id->capability & 1) && drive->autodma) { + if ((id->capability & 1) && drive->autodma) { if (ide_use_dma(drive)) { if (config_chipset_for_dma(drive)) @@ -868,15 +850,6 @@ static int hpt366_ide_dma_lostirq (ide_drive_t *drive) drive->name, __FUNCTION__, reg50h, reg52h, reg5ah); if (reg5ah & 0x10) pci_write_config_byte(dev, 0x5a, reg5ah & ~0x10); -#if 0 - /* how about we flush and reset, mmmkay? */ - pci_write_config_byte(dev, 0x51, 0x1F); - /* fall through to a reset */ - case dma_start: - case ide_dma_end: - /* reset the chips state over and over.. */ - pci_write_config_byte(dev, 0x51, 0x13); -#endif return __ide_dma_lostirq(drive); } @@ -919,7 +892,7 @@ static void hpt370_lostirq_timeout (ide_drive_t *drive) u8 dma_stat = 0, dma_cmd = 0; pci_read_config_byte(HWIF(drive)->pci_dev, reginfo, &bfifo); - printk("%s: %d bytes in FIFO\n", drive->name, bfifo); + printk(KERN_DEBUG "%s: %d bytes in FIFO\n", drive->name, bfifo); hpt370_clear_engine(drive); /* get dma command mode */ dma_cmd = hwif->INB(hwif->dma_command); @@ -1047,15 +1020,6 @@ static void hpt372n_rw_disk(ide_drive_t *drive, struct request *rq) static void hpt3xx_reset (ide_drive_t *drive) { -#if 0 - unsigned long high_16 = pci_resource_start(HWIF(drive)->pci_dev, 4); - u8 reset = (HWIF(drive)->channel) ? 0x80 : 0x40; - u8 reg59h = 0; - - pci_read_config_byte(HWIF(drive)->pci_dev, 0x59, ®59h); - pci_write_config_byte(HWIF(drive)->pci_dev, 0x59, reg59h|reset); - pci_write_config_byte(HWIF(drive)->pci_dev, 0x59, reg59h); -#endif } static int hpt3xx_tristate (ide_drive_t * drive, int state) @@ -1065,8 +1029,6 @@ static int hpt3xx_tristate (ide_drive_t * drive, int state) u8 reg59h = 0, reset = (hwif->channel) ? 0x80 : 0x40; u8 regXXh = 0, state_reg= (hwif->channel) ? 0x57 : 0x53; -// hwif->bus_state = state; - pci_read_config_byte(dev, 0x59, ®59h); pci_read_config_byte(dev, state_reg, ®XXh); @@ -1093,7 +1055,7 @@ static int hpt3xx_tristate (ide_drive_t * drive, int state) #define TRISTATE_BIT 0x8000 static int hpt370_busproc(ide_drive_t * drive, int state) { - ide_hwif_t *hwif = HWIF(drive); + ide_hwif_t *hwif = drive->hwif; struct pci_dev *dev = hwif->pci_dev; u8 tristate = 0, resetmask = 0, bus_reg = 0; u16 tri_reg; @@ -1148,33 +1110,44 @@ static int hpt370_busproc(ide_drive_t * drive, int state) return 0; } -static int __devinit init_hpt37x(struct pci_dev *dev) +static void __devinit hpt366_clocking(ide_hwif_t *hwif) { + u32 reg1 = 0; + struct hpt_info *info = ide_get_hwifdata(hwif); + + pci_read_config_dword(hwif->pci_dev, 0x40, ®1); + + /* detect bus speed by looking at control reg timing: */ + switch((reg1 >> 8) & 7) { + case 5: + info->speed = forty_base_hpt366; + break; + case 9: + info->speed = twenty_five_base_hpt366; + break; + case 7: + default: + info->speed = thirty_three_base_hpt366; + break; + } +} + +static void __devinit hpt37x_clocking(ide_hwif_t *hwif) +{ + struct hpt_info *info = ide_get_hwifdata(hwif); + struct pci_dev *dev = hwif->pci_dev; int adjust, i; u16 freq; u32 pll; u8 reg5bh; - u8 reg5ah = 0; - unsigned long dmabase = pci_resource_start(dev, 4); - u8 did, rid; - int is_372n = 0; - pci_read_config_byte(dev, 0x5a, ®5ah); - /* interrupt force enable */ - pci_write_config_byte(dev, 0x5a, (reg5ah & ~0x10)); - - if(dmabase) - { - did = inb(dmabase + 0x22); - rid = inb(dmabase + 0x28); - - if((did == 4 && rid == 6) || (did == 5 && rid > 1)) - is_372n = 1; - } - /* * default to pci clock. make sure MA15/16 are set to output - * to prevent drives having problems with 40-pin cables. + * to prevent drives having problems with 40-pin cables. Needed + * for some drives such as IBM-DTLA which will not enter ready + * state on reset when PDIAG is a input. + * + * ToDo: should we set 0x21 when using PLL mode ? */ pci_write_config_byte(dev, 0x5b, 0x23); @@ -1197,9 +1170,7 @@ static int __devinit init_hpt37x(struct pci_dev *dev) * Currently we always set up the PLL for the 372N */ - pci_set_drvdata(dev, NULL); - - if(is_372n) + if(info->flags & IS_372N) { printk(KERN_INFO "hpt: HPT372N detected, using 372N timing.\n"); if(freq < 0x55) @@ -1227,39 +1198,38 @@ static int __devinit init_hpt37x(struct pci_dev *dev) pll = F_LOW_PCI_66; if (pll == F_LOW_PCI_33) { - if (hpt_minimum_revision(dev,8)) - pci_set_drvdata(dev, (void *) thirty_three_base_hpt374); - else if (hpt_minimum_revision(dev,5)) - pci_set_drvdata(dev, (void *) thirty_three_base_hpt372); - else if (hpt_minimum_revision(dev,4)) - pci_set_drvdata(dev, (void *) thirty_three_base_hpt370a); + if (info->revision >= 8) + info->speed = thirty_three_base_hpt374; + else if (info->revision >= 5) + info->speed = thirty_three_base_hpt372; + else if (info->revision >= 4) + info->speed = thirty_three_base_hpt370a; else - pci_set_drvdata(dev, (void *) thirty_three_base_hpt370); - printk("HPT37X: using 33MHz PCI clock\n"); + info->speed = thirty_three_base_hpt370; + printk(KERN_DEBUG "HPT37X: using 33MHz PCI clock\n"); } else if (pll == F_LOW_PCI_40) { /* Unsupported */ } else if (pll == F_LOW_PCI_50) { - if (hpt_minimum_revision(dev,8)) - pci_set_drvdata(dev, (void *) fifty_base_hpt370a); - else if (hpt_minimum_revision(dev,5)) - pci_set_drvdata(dev, (void *) fifty_base_hpt372); - else if (hpt_minimum_revision(dev,4)) - pci_set_drvdata(dev, (void *) fifty_base_hpt370a); + if (info->revision >= 8) + info->speed = fifty_base_hpt370a; + else if (info->revision >= 5) + info->speed = fifty_base_hpt372; + else if (info->revision >= 4) + info->speed = fifty_base_hpt370a; else - pci_set_drvdata(dev, (void *) fifty_base_hpt370a); - printk("HPT37X: using 50MHz PCI clock\n"); + info->speed = fifty_base_hpt370a; + printk(KERN_DEBUG "HPT37X: using 50MHz PCI clock\n"); } else { - if (hpt_minimum_revision(dev,8)) - { + if (info->revision >= 8) { printk(KERN_ERR "HPT37x: 66MHz timings are not supported.\n"); } - else if (hpt_minimum_revision(dev,5)) - pci_set_drvdata(dev, (void *) sixty_six_base_hpt372); - else if (hpt_minimum_revision(dev,4)) - pci_set_drvdata(dev, (void *) sixty_six_base_hpt370a); + else if (info->revision >= 5) + info->speed = sixty_six_base_hpt372; + else if (info->revision >= 4) + info->speed = sixty_six_base_hpt370a; else - pci_set_drvdata(dev, (void *) sixty_six_base_hpt370); - printk("HPT37X: using 66MHz PCI clock\n"); + info->speed = sixty_six_base_hpt370; + printk(KERN_DEBUG "HPT37X: using 66MHz PCI clock\n"); } } @@ -1269,11 +1239,19 @@ static int __devinit init_hpt37x(struct pci_dev *dev) * result in slow reads when using a 33MHz PCI clock. we also * don't like to use the PLL because it will cause glitches * on PRST/SRST when the HPT state engine gets reset. + * + * ToDo: Use 66MHz PLL when ATA133 devices are present on a + * 372 device so we can get ATA133 support */ - if (pci_get_drvdata(dev)) + if (info->speed) goto init_hpt37X_done; + + info->flags |= PLL_MODE; /* + * FIXME: make this work correctly, esp with 372N as per + * reference driver code. + * * adjust PLL based upon PCI clock, enable it, and wait for * stabilization. */ @@ -1298,14 +1276,14 @@ static int __devinit init_hpt37x(struct pci_dev *dev) pci_write_config_dword(dev, 0x5c, pll & ~0x100); pci_write_config_byte(dev, 0x5b, 0x21); - if (hpt_minimum_revision(dev,8)) - pci_set_drvdata(dev, (void *) fifty_base_hpt370a); - else if (hpt_minimum_revision(dev,5)) - pci_set_drvdata(dev, (void *) fifty_base_hpt372); - else if (hpt_minimum_revision(dev,4)) - pci_set_drvdata(dev, (void *) fifty_base_hpt370a); + if (info->revision >= 8) + info->speed = fifty_base_hpt370a; + else if (info->revision >= 5) + info->speed = fifty_base_hpt372; + else if (info->revision >= 4) + info->speed = fifty_base_hpt370a; else - pci_set_drvdata(dev, (void *) fifty_base_hpt370a); + info->speed = fifty_base_hpt370a; printk("HPT37X: using 50MHz internal PLL\n"); goto init_hpt37X_done; } @@ -1318,10 +1296,22 @@ pll_recal: } init_hpt37X_done: + if (!info->speed) + printk(KERN_ERR "HPT37X%s: unknown bus timing [%d %d].\n", + (info->flags & IS_372N)?"N":"", pll, freq); /* reset state engine */ pci_write_config_byte(dev, 0x50, 0x37); pci_write_config_byte(dev, 0x54, 0x37); udelay(100); +} + +static int __devinit init_hpt37x(struct pci_dev *dev) +{ + u8 reg5ah; + + pci_read_config_byte(dev, 0x5a, ®5ah); + /* interrupt force enable */ + pci_write_config_byte(dev, 0x5a, (reg5ah & ~0x10)); return 0; } @@ -1338,59 +1328,27 @@ static int __devinit init_hpt366(struct pci_dev *dev) pci_write_config_byte(dev, 0x51, drive_fast & ~0x80); pci_read_config_dword(dev, 0x40, ®1); - /* detect bus speed by looking at control reg timing: */ - switch((reg1 >> 8) & 7) { - case 5: - pci_set_drvdata(dev, (void *) forty_base_hpt366); - break; - case 9: - pci_set_drvdata(dev, (void *) twenty_five_base_hpt366); - break; - case 7: - default: - pci_set_drvdata(dev, (void *) thirty_three_base_hpt366); - break; - } - - if (!pci_get_drvdata(dev)) - { - printk(KERN_ERR "hpt366: unknown bus timing.\n"); - pci_set_drvdata(dev, NULL); - } return 0; } static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const char *name) { int ret = 0; - u8 test = 0; - + /* FIXME: Not portable */ if (dev->resource[PCI_ROM_RESOURCE].start) pci_write_config_byte(dev, PCI_ROM_ADDRESS, dev->resource[PCI_ROM_RESOURCE].start | PCI_ROM_ADDRESS_ENABLE); - pci_read_config_byte(dev, PCI_CACHE_LINE_SIZE, &test); - if (test != (L1_CACHE_BYTES / 4)) - pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, - (L1_CACHE_BYTES / 4)); - - pci_read_config_byte(dev, PCI_LATENCY_TIMER, &test); - if (test != 0x78) - pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78); + pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); + pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x78); + pci_write_config_byte(dev, PCI_MIN_GNT, 0x08); + pci_write_config_byte(dev, PCI_MAX_LAT, 0x08); - pci_read_config_byte(dev, PCI_MIN_GNT, &test); - if (test != 0x08) - pci_write_config_byte(dev, PCI_MIN_GNT, 0x08); - - pci_read_config_byte(dev, PCI_MAX_LAT, &test); - if (test != 0x08) - pci_write_config_byte(dev, PCI_MAX_LAT, 0x08); - - if (hpt_minimum_revision(dev, 3)) { + if (hpt_revision(dev) >= 3) ret = init_hpt37x(dev); - } else { - ret =init_hpt366(dev); - } + else + ret = init_hpt366(dev); + if (ret) return ret; @@ -1400,27 +1358,16 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) { struct pci_dev *dev = hwif->pci_dev; + struct hpt_info *info = ide_get_hwifdata(hwif); u8 ata66 = 0, regmask = (hwif->channel) ? 0x01 : 0x02; - u8 did, rid; - unsigned long dmabase = hwif->dma_base; - int is_372n = 0; - if(dmabase) - { - did = inb(dmabase + 0x22); - rid = inb(dmabase + 0x28); - - if((did == 4 && rid == 6) || (did == 5 && rid > 1)) - is_372n = 1; - } - hwif->tuneproc = &hpt3xx_tune_drive; hwif->speedproc = &hpt3xx_tune_chipset; hwif->quirkproc = &hpt3xx_quirkproc; hwif->intrproc = &hpt3xx_intrproc; hwif->maskproc = &hpt3xx_maskproc; - if(is_372n) + if(info->flags & IS_372N) hwif->rw_disk = &hpt372n_rw_disk; /* @@ -1428,7 +1375,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) * address lines to access an external eeprom. To read valid * cable detect state the pins must be enabled as inputs. */ - if (hpt_minimum_revision(dev, 8) && PCI_FUNC(dev->devfn) & 1) { + if (info->revision >= 8 && (PCI_FUNC(dev->devfn) & 1)) { /* * HPT374 PCI function 1 * - set bit 15 of reg 0x52 to enable TCBLID as input @@ -1443,7 +1390,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) pci_read_config_byte(dev, 0x5a, &ata66); pci_write_config_word(dev, 0x52, mcr3); pci_write_config_word(dev, 0x56, mcr6); - } else if (hpt_minimum_revision(dev, 3)) { + } else if (info->revision >= 3) { /* * HPT370/372 and 374 pcifn 0 * - clear bit 0 of 0x5b to enable P/SCBLID as inputs @@ -1470,7 +1417,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) hwif->serialized = hwif->mate->serialized = 1; #endif - if (hpt_minimum_revision(dev,3)) { + if (info->revision >= 3) { u8 reg5ah = 0; pci_write_config_byte(dev, 0x5a, reg5ah & ~0x10); /* @@ -1480,8 +1427,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) */ hwif->resetproc = &hpt3xx_reset; hwif->busproc = &hpt370_busproc; -// hwif->drives[0].autotune = hwif->drives[1].autotune = 1; - } else if (hpt_minimum_revision(dev,2)) { + } else if (info->revision >= 2) { hwif->resetproc = &hpt3xx_reset; hwif->busproc = &hpt3xx_tristate; } else { @@ -1502,18 +1448,18 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) hwif->udma_four = ((ata66 & regmask) ? 0 : 1); hwif->ide_dma_check = &hpt366_config_drive_xfer_rate; - if (hpt_minimum_revision(dev,8)) { + if (info->revision >= 8) { hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; hwif->ide_dma_end = &hpt374_ide_dma_end; - } else if (hpt_minimum_revision(dev,5)) { + } else if (info->revision >= 5) { hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; hwif->ide_dma_end = &hpt374_ide_dma_end; - } else if (hpt_minimum_revision(dev,3)) { + } else if (info->revision >= 3) { hwif->dma_start = &hpt370_ide_dma_start; hwif->ide_dma_end = &hpt370_ide_dma_end; hwif->ide_dma_timeout = &hpt370_ide_dma_timeout; hwif->ide_dma_lostirq = &hpt370_ide_dma_lostirq; - } else if (hpt_minimum_revision(dev,2)) + } else if (info->revision >= 2) hwif->ide_dma_lostirq = &hpt366_ide_dma_lostirq; else hwif->ide_dma_lostirq = &hpt366_ide_dma_lostirq; @@ -1526,6 +1472,7 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) { + struct hpt_info *info = ide_get_hwifdata(hwif); u8 masterdma = 0, slavedma = 0; u8 dma_new = 0, dma_old = 0; u8 primary = hwif->channel ? 0x4b : 0x43; @@ -1535,8 +1482,7 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) if (!dmabase) return; - if(pci_get_drvdata(hwif->pci_dev) == NULL) - { + if(info->speed == NULL) { printk(KERN_WARNING "hpt: no known IDE timings, disabling DMA.\n"); return; } @@ -1559,6 +1505,40 @@ static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) ide_setup_dma(hwif, dmabase, 8); } +/* + * We "borrow" this hook in order to set the data structures + * up early enough before dma or init_hwif calls are made. + */ + +static void __devinit init_iops_hpt366(ide_hwif_t *hwif) +{ + struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL); + unsigned long dmabase = pci_resource_start(hwif->pci_dev, 4); + u8 did, rid; + + if(info == NULL) { + printk(KERN_WARNING "hpt366: out of memory.\n"); + return; + } + memset(info, 0, sizeof(struct hpt_info)); + ide_set_hwifdata(hwif, info); + + if(dmabase) { + did = inb(dmabase + 0x22); + rid = inb(dmabase + 0x28); + + if((did == 4 && rid == 6) || (did == 5 && rid > 1)) + info->flags |= IS_372N; + } + + info->revision = hpt_revision(hwif->pci_dev); + + if (info->revision >= 3) + hpt37x_clocking(hwif); + else + hpt366_clocking(hwif); +} + static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d) { struct pci_dev *findev = NULL; @@ -1646,6 +1626,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { .name = "HPT366", .init_setup = init_setup_hpt366, .init_chipset = init_chipset_hpt366, + .init_iops = init_iops_hpt366, .init_hwif = init_hwif_hpt366, .init_dma = init_dma_hpt366, .channels = 2, @@ -1656,6 +1637,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { .name = "HPT372A", .init_setup = init_setup_hpt37x, .init_chipset = init_chipset_hpt366, + .init_iops = init_iops_hpt366, .init_hwif = init_hwif_hpt366, .init_dma = init_dma_hpt366, .channels = 2, @@ -1665,6 +1647,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { .name = "HPT302", .init_setup = init_setup_hpt37x, .init_chipset = init_chipset_hpt366, + .init_iops = init_iops_hpt366, .init_hwif = init_hwif_hpt366, .init_dma = init_dma_hpt366, .channels = 2, @@ -1674,6 +1657,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { .name = "HPT371", .init_setup = init_setup_hpt37x, .init_chipset = init_chipset_hpt366, + .init_iops = init_iops_hpt366, .init_hwif = init_hwif_hpt366, .init_dma = init_dma_hpt366, .channels = 2, @@ -1683,6 +1667,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { .name = "HPT374", .init_setup = init_setup_hpt374, .init_chipset = init_chipset_hpt366, + .init_iops = init_iops_hpt366, .init_hwif = init_hwif_hpt366, .init_dma = init_dma_hpt366, .channels = 2, /* 4 */ @@ -1692,6 +1677,7 @@ static ide_pci_device_t hpt366_chipsets[] __devinitdata = { .name = "HPT372N", .init_setup = init_setup_hpt37x, .init_chipset = init_chipset_hpt366, + .init_iops = init_iops_hpt366, .init_hwif = init_hwif_hpt366, .init_dma = init_dma_hpt366, .channels = 2, /* 4 */ -- cgit v1.2.3 From bb732d7b3699afe8859f27e93000860bb4103cca Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 27 Jun 2005 15:24:29 -0700 Subject: [PATCH] ide: fix crashes with hotplug serverworks You can't install the base kernel on a Stratus box because of the overuse of __init. Affects both IDE layers identically. It isn't the only misuser of __init so more review of other drivers (or fixing ide_register code to know about hotplug v non-hotplug chipsets) would be good. Original issue found by Stratus and their patch was the inspiration for this trivial one. Signed-off-by: Alan Cox Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/pci/serverworks.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers') diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index 82a1103b241..c6f5fa4b4ca 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c @@ -442,7 +442,7 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha return (dev->irq) ? dev->irq : 0; } -static unsigned int __init ata66_svwks_svwks (ide_hwif_t *hwif) +static unsigned int __devinit ata66_svwks_svwks (ide_hwif_t *hwif) { return 1; } @@ -454,7 +454,7 @@ static unsigned int __init ata66_svwks_svwks (ide_hwif_t *hwif) * Bit 14 clear = primary IDE channel does not have 80-pin cable. * Bit 14 set = primary IDE channel has 80-pin cable. */ -static unsigned int __init ata66_svwks_dell (ide_hwif_t *hwif) +static unsigned int __devinit ata66_svwks_dell (ide_hwif_t *hwif) { struct pci_dev *dev = hwif->pci_dev; if (dev->subsystem_vendor == PCI_VENDOR_ID_DELL && @@ -472,7 +472,7 @@ static unsigned int __init ata66_svwks_dell (ide_hwif_t *hwif) * * WARNING: this only works on Alpine hardware! */ -static unsigned int __init ata66_svwks_cobalt (ide_hwif_t *hwif) +static unsigned int __devinit ata66_svwks_cobalt (ide_hwif_t *hwif) { struct pci_dev *dev = hwif->pci_dev; if (dev->subsystem_vendor == PCI_VENDOR_ID_SUN && @@ -483,7 +483,7 @@ static unsigned int __init ata66_svwks_cobalt (ide_hwif_t *hwif) return 0; } -static unsigned int __init ata66_svwks (ide_hwif_t *hwif) +static unsigned int __devinit ata66_svwks (ide_hwif_t *hwif) { struct pci_dev *dev = hwif->pci_dev; @@ -573,7 +573,7 @@ static int __devinit init_setup_svwks (struct pci_dev *dev, ide_pci_device_t *d) return ide_setup_pci_device(dev, d); } -static int __init init_setup_csb6 (struct pci_dev *dev, ide_pci_device_t *d) +static int __devinit init_setup_csb6 (struct pci_dev *dev, ide_pci_device_t *d) { if (!(PCI_FUNC(dev->devfn) & 1)) { d->bootable = NEVER_BOARD; -- cgit v1.2.3 From da9091ee3b5f9808c64abb925cefe7b100018614 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 27 Jun 2005 15:24:30 -0700 Subject: [PATCH] ide: it8212 backport for Bartlomiej IDE This lets you throw out the iteraid stuff that has ended up back in due to stupid goings on in the IDE world. Its the same heavily tested code shipped in Fedora/Red Hat products but without the other dependancies on the Bartlomiej IDE layer. Pre-requisite: the ide-disk patch I sent to handle pure LBA devices. Obviously you lose things like hot unplug with the Bartlomiej IDE layer at the moment but that won't matter to most users. The patch does the following - Add IT8211/12 to pci_ids.h - Add Makefile/Kconfig entry - Add it8212 driver No core IDE code is touched by this diff Embedded system testing and the ability to force raid mode off by David Howells Made possible by the ite reference code, documentation and also several clarifications and pieces of assistance provided by ITE themselves Signed-off-by: Alan Cox Acked-by: Bartlomiej Zolnierkiewicz Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/Kconfig | 6 + drivers/ide/pci/Makefile | 1 + drivers/ide/pci/it821x.c | 812 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 819 insertions(+) create mode 100644 drivers/ide/pci/it821x.c (limited to 'drivers') diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 0273f124a4f..5f33df47aa7 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig @@ -606,6 +606,12 @@ config BLK_DEV_IT8172 ; picture of the board at . +config BLK_DEV_IT821X + tristate "IT821X IDE support" + help + This driver adds support for the ITE 8211 IDE controller and the + IT 8212 IDE RAID controller in both RAID and pass-through mode. + config BLK_DEV_NS87415 tristate "NS87415 chipset support" help diff --git a/drivers/ide/pci/Makefile b/drivers/ide/pci/Makefile index 55e6e553e49..af46226c179 100644 --- a/drivers/ide/pci/Makefile +++ b/drivers/ide/pci/Makefile @@ -12,6 +12,7 @@ obj-$(CONFIG_BLK_DEV_HPT34X) += hpt34x.o obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o #obj-$(CONFIG_BLK_DEV_HPT37X) += hpt37x.o obj-$(CONFIG_BLK_DEV_IT8172) += it8172.o +obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o obj-$(CONFIG_BLK_DEV_NS87415) += ns87415.o obj-$(CONFIG_BLK_DEV_OPTI621) += opti621.o obj-$(CONFIG_BLK_DEV_PDC202XX_OLD) += pdc202xx_old.o diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c new file mode 100644 index 00000000000..e440036e651 --- /dev/null +++ b/drivers/ide/pci/it821x.c @@ -0,0 +1,812 @@ + +/* + * linux/drivers/ide/pci/it821x.c Version 0.09 December 2004 + * + * Copyright (C) 2004 Red Hat + * + * May be copied or modified under the terms of the GNU General Public License + * Based in part on the ITE vendor provided SCSI driver. + * + * Documentation available from + * http://www.ite.com.tw/pc/IT8212F_V04.pdf + * Some other documents are NDA. + * + * The ITE8212 isn't exactly a standard IDE controller. It has two + * modes. In pass through mode then it is an IDE controller. In its smart + * mode its actually quite a capable hardware raid controller disguised + * as an IDE controller. Smart mode only understands DMA read/write and + * identify, none of the fancier commands apply. The IT8211 is identical + * in other respects but lacks the raid mode. + * + * Errata: + * o Rev 0x10 also requires master/slave hold the same DMA timings and + * cannot do ATAPI MWDMA. + * o The identify data for raid volumes lacks CHS info (technically ok) + * but also fails to set the LBA28 and other bits. We fix these in + * the IDE probe quirk code. + * o If you write LBA48 sized I/O's (ie > 256 sector) in smart mode + * raid then the controller firmware dies + * o Smart mode without RAID doesn't clear all the necessary identify + * bits to reduce the command set to the one used + * + * This has a few impacts on the driver + * - In pass through mode we do all the work you would expect + * - In smart mode the clocking set up is done by the controller generally + * but we must watch the other limits and filter. + * - There are a few extra vendor commands that actually talk to the + * controller but only work PIO with no IRQ. + * + * Vendor areas of the identify block in smart mode are used for the + * timing and policy set up. Each HDD in raid mode also has a serial + * block on the disk. The hardware extra commands are get/set chip status, + * rebuild, get rebuild status. + * + * In Linux the driver supports pass through mode as if the device was + * just another IDE controller. If the smart mode is running then + * volumes are managed by the controller firmware and each IDE "disk" + * is a raid volume. Even more cute - the controller can do automated + * hotplug and rebuild. + * + * The pass through controller itself is a little demented. It has a + * flaw that it has a single set of PIO/MWDMA timings per channel so + * non UDMA devices restrict each others performance. It also has a + * single clock source per channel so mixed UDMA100/133 performance + * isn't perfect and we have to pick a clock. Thankfully none of this + * matters in smart mode. ATAPI DMA is not currently supported. + * + * It seems the smart mode is a win for RAID1/RAID10 but otherwise not. + * + * TODO + * - ATAPI UDMA is ok but not MWDMA it seems + * - RAID configuration ioctls + * - Move to libata once it grows up + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +struct it821x_dev +{ + unsigned int smart:1, /* Are we in smart raid mode */ + timing10:1; /* Rev 0x10 */ + u8 clock_mode; /* 0, ATA_50 or ATA_66 */ + u8 want[2][2]; /* Mode/Pri log for master slave */ + /* We need these for switching the clock when DMA goes on/off + The high byte is the 66Mhz timing */ + u16 pio[2]; /* Cached PIO values */ + u16 mwdma[2]; /* Cached MWDMA values */ + u16 udma[2]; /* Cached UDMA values (per drive) */ +}; + +#define ATA_66 0 +#define ATA_50 1 +#define ATA_ANY 2 + +#define UDMA_OFF 0 +#define MWDMA_OFF 0 + +/* + * We allow users to force the card into non raid mode without + * flashing the alternative BIOS. This is also neccessary right now + * for embedded platforms that cannot run a PC BIOS but are using this + * device. + */ + +static int it8212_noraid; + +/** + * it821x_program - program the PIO/MWDMA registers + * @drive: drive to tune + * + * Program the PIO/MWDMA timing for this channel according to the + * current clock. + */ + +static void it821x_program(ide_drive_t *drive, u16 timing) +{ + ide_hwif_t *hwif = drive->hwif; + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + int channel = hwif->channel; + u8 conf; + + /* Program PIO/MWDMA timing bits */ + if(itdev->clock_mode == ATA_66) + conf = timing >> 8; + else + conf = timing & 0xFF; + pci_write_config_byte(hwif->pci_dev, 0x54 + 4 * channel, conf); +} + +/** + * it821x_program_udma - program the UDMA registers + * @drive: drive to tune + * + * Program the UDMA timing for this drive according to the + * current clock. + */ + +static void it821x_program_udma(ide_drive_t *drive, u16 timing) +{ + ide_hwif_t *hwif = drive->hwif; + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + int channel = hwif->channel; + int unit = drive->select.b.unit; + u8 conf; + + /* Program UDMA timing bits */ + if(itdev->clock_mode == ATA_66) + conf = timing >> 8; + else + conf = timing & 0xFF; + if(itdev->timing10 == 0) + pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + unit, conf); + else { + pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel, conf); + pci_write_config_byte(hwif->pci_dev, 0x56 + 4 * channel + 1, conf); + } +} + + +/** + * it821x_clock_strategy + * @hwif: hardware interface + * + * Select between the 50 and 66Mhz base clocks to get the best + * results for this interface. + */ + +static void it821x_clock_strategy(ide_drive_t *drive) +{ + ide_hwif_t *hwif = drive->hwif; + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + + u8 unit = drive->select.b.unit; + ide_drive_t *pair = &hwif->drives[1-unit]; + + int clock, altclock; + u8 v; + int sel = 0; + + if(itdev->want[0][0] > itdev->want[1][0]) { + clock = itdev->want[0][1]; + altclock = itdev->want[1][1]; + } else { + clock = itdev->want[1][1]; + altclock = itdev->want[0][1]; + } + + /* Master doesn't care does the slave ? */ + if(clock == ATA_ANY) + clock = altclock; + + /* Nobody cares - keep the same clock */ + if(clock == ATA_ANY) + return; + /* No change */ + if(clock == itdev->clock_mode) + return; + + /* Load this into the controller ? */ + if(clock == ATA_66) + itdev->clock_mode = ATA_66; + else { + itdev->clock_mode = ATA_50; + sel = 1; + } + pci_read_config_byte(hwif->pci_dev, 0x50, &v); + v &= ~(1 << (1 + hwif->channel)); + v |= sel << (1 + hwif->channel); + pci_write_config_byte(hwif->pci_dev, 0x50, v); + + /* + * Reprogram the UDMA/PIO of the pair drive for the switch + * MWDMA will be dealt with by the dma switcher + */ + if(pair && itdev->udma[1-unit] != UDMA_OFF) { + it821x_program_udma(pair, itdev->udma[1-unit]); + it821x_program(pair, itdev->pio[1-unit]); + } + /* + * Reprogram the UDMA/PIO of our drive for the switch. + * MWDMA will be dealt with by the dma switcher + */ + if(itdev->udma[unit] != UDMA_OFF) { + it821x_program_udma(drive, itdev->udma[unit]); + it821x_program(drive, itdev->pio[unit]); + } +} + +/** + * it821x_ratemask - Compute available modes + * @drive: IDE drive + * + * Compute the available speeds for the devices on the interface. This + * is all modes to ATA133 clipped by drive cable setup. + */ + +static u8 it821x_ratemask (ide_drive_t *drive) +{ + u8 mode = 4; + if (!eighty_ninty_three(drive)) + mode = min(mode, (u8)1); + return mode; +} + +/** + * it821x_tuneproc - tune a drive + * @drive: drive to tune + * @mode_wanted: the target operating mode + * + * Load the timing settings for this device mode into the + * controller. By the time we are called the mode has been + * modified as neccessary to handle the absence of seperate + * master/slave timers for MWDMA/PIO. + * + * This code is only used in pass through mode. + */ + +static void it821x_tuneproc (ide_drive_t *drive, byte mode_wanted) +{ + ide_hwif_t *hwif = drive->hwif; + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + int unit = drive->select.b.unit; + + /* Spec says 89 ref driver uses 88 */ + static u16 pio[] = { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; + static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; + + if(itdev->smart) + return; + + /* We prefer 66Mhz clock for PIO 0-3, don't care for PIO4 */ + itdev->want[unit][1] = pio_want[mode_wanted]; + itdev->want[unit][0] = 1; /* PIO is lowest priority */ + itdev->pio[unit] = pio[mode_wanted]; + it821x_clock_strategy(drive); + it821x_program(drive, itdev->pio[unit]); +} + +/** + * it821x_tune_mwdma - tune a channel for MWDMA + * @drive: drive to set up + * @mode_wanted: the target operating mode + * + * Load the timing settings for this device mode into the + * controller when doing MWDMA in pass through mode. The caller + * must manage the whole lack of per device MWDMA/PIO timings and + * the shared MWDMA/PIO timing register. + */ + +static void it821x_tune_mwdma (ide_drive_t *drive, byte mode_wanted) +{ + ide_hwif_t *hwif = drive->hwif; + struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); + int unit = drive->select.b.unit; + int channel = hwif->channel; + u8 conf; + + static u16 dma[] = { 0x8866, 0x3222, 0x3121 }; + static u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY }; + + itdev->want[unit][1] = mwdma_want[mode_wanted]; + itdev->want[unit][0] = 2; /* MWDMA is low priority */ + itdev->mwdma[unit] = dma[mode_wanted]; + itdev->udma[unit] = UDMA_OFF; + + /* UDMA bits off - Revision 0x10 do them in pairs */ + pci_read_config_byte(hwif->pci_dev, 0x50, &conf); + if(itdev->timing10) + conf |= channel ? 0x60: 0x18; + else + conf |= 1 << (3 + 2 * channel + unit); + pci_write_config_byte(hwif->pci_dev, 0x50, conf); + + it821x_clock_strategy(drive); + /* FIXME: do we need to program this ? */ + /* it821x_program(drive, itdev->mwdma[unit]); */ +} + +/** + * it821x_tune_udma - tune a channel for UDMA + * @drive: drive to set up + * @mode_wanted: the target operating mode + * + * Load the timing settings for this device mode into the + * controller when doing UDMA modes in pass through. + */ + +static void it821x_tune_udma (ide_drive_t *drive, byte mode_wanted) +{ + ide_hwif_t *hwif = drive->hwif; + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + int unit = drive->select.b.unit; + int channel = hwif->channel; + u8 conf; + + static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 }; + static u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 }; + + itdev->want[unit][1] = udma_want[mode_wanted]; + itdev->want[unit][0] = 3; /* UDMA is high priority */ + itdev->mwdma[unit] = MWDMA_OFF; + itdev->udma[unit] = udma[mode_wanted]; + if(mode_wanted >= 5) + itdev->udma[unit] |= 0x8080; /* UDMA 5/6 select on */ + + /* UDMA on. Again revision 0x10 must do the pair */ + pci_read_config_byte(hwif->pci_dev, 0x50, &conf); + if(itdev->timing10) + conf &= channel ? 0x9F: 0xE7; + else + conf &= ~ (1 << (3 + 2 * channel + unit)); + pci_write_config_byte(hwif->pci_dev, 0x50, conf); + + it821x_clock_strategy(drive); + it821x_program_udma(drive, itdev->udma[unit]); + +} + +/** + * config_it821x_chipset_for_pio - set drive timings + * @drive: drive to tune + * @speed we want + * + * Compute the best pio mode we can for a given device. We must + * pick a speed that does not cause problems with the other device + * on the cable. + */ + +static void config_it821x_chipset_for_pio (ide_drive_t *drive, byte set_speed) +{ + u8 unit = drive->select.b.unit; + ide_hwif_t *hwif = drive->hwif; + ide_drive_t *pair = &hwif->drives[1-unit]; + u8 speed = 0, set_pio = ide_get_best_pio_mode(drive, 255, 5, NULL); + u8 pair_pio; + + /* We have to deal with this mess in pairs */ + if(pair != NULL) { + pair_pio = ide_get_best_pio_mode(pair, 255, 5, NULL); + /* Trim PIO to the slowest of the master/slave */ + if(pair_pio < set_pio) + set_pio = pair_pio; + } + it821x_tuneproc(drive, set_pio); + speed = XFER_PIO_0 + set_pio; + /* XXX - We trim to the lowest of the pair so the other drive + will always be fine at this point until we do hotplug passthru */ + + if (set_speed) + (void) ide_config_drive_speed(drive, speed); +} + +/** + * it821x_dma_read - DMA hook + * @drive: drive for DMA + * + * The IT821x has a single timing register for MWDMA and for PIO + * operations. As we flip back and forth we have to reload the + * clock. In addition the rev 0x10 device only works if the same + * timing value is loaded into the master and slave UDMA clock + * so we must also reload that. + * + * FIXME: we could figure out in advance if we need to do reloads + */ + +static void it821x_dma_start(ide_drive_t *drive) +{ + ide_hwif_t *hwif = drive->hwif; + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + int unit = drive->select.b.unit; + if(itdev->mwdma[unit] != MWDMA_OFF) + it821x_program(drive, itdev->mwdma[unit]); + else if(itdev->udma[unit] != UDMA_OFF && itdev->timing10) + it821x_program_udma(drive, itdev->udma[unit]); + ide_dma_start(drive); +} + +/** + * it821x_dma_write - DMA hook + * @drive: drive for DMA stop + * + * The IT821x has a single timing register for MWDMA and for PIO + * operations. As we flip back and forth we have to reload the + * clock. + */ + +static int it821x_dma_end(ide_drive_t *drive) +{ + ide_hwif_t *hwif = drive->hwif; + int unit = drive->select.b.unit; + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + int ret = __ide_dma_end(drive); + if(itdev->mwdma[unit] != MWDMA_OFF) + it821x_program(drive, itdev->pio[unit]); + return ret; +} + + +/** + * it821x_tune_chipset - set controller timings + * @drive: Drive to set up + * @xferspeed: speed we want to achieve + * + * Tune the ITE chipset for the desired mode. If we can't achieve + * the desired mode then tune for a lower one, but ultimately + * make the thing work. + */ + +static int it821x_tune_chipset (ide_drive_t *drive, byte xferspeed) +{ + + ide_hwif_t *hwif = drive->hwif; + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + u8 speed = ide_rate_filter(it821x_ratemask(drive), xferspeed); + + if(!itdev->smart) { + switch(speed) { + case XFER_PIO_4: + case XFER_PIO_3: + case XFER_PIO_2: + case XFER_PIO_1: + case XFER_PIO_0: + it821x_tuneproc(drive, (speed - XFER_PIO_0)); + break; + /* MWDMA tuning is really hard because our MWDMA and PIO + timings are kept in the same place. We can switch in the + host dma on/off callbacks */ + case XFER_MW_DMA_2: + case XFER_MW_DMA_1: + case XFER_MW_DMA_0: + it821x_tune_mwdma(drive, (speed - XFER_MW_DMA_0)); + break; + case XFER_UDMA_6: + case XFER_UDMA_5: + case XFER_UDMA_4: + case XFER_UDMA_3: + case XFER_UDMA_2: + case XFER_UDMA_1: + case XFER_UDMA_0: + it821x_tune_udma(drive, (speed - XFER_UDMA_0)); + break; + default: + return 1; + } + } + /* + * In smart mode the clocking is done by the host controller + * snooping the mode we picked. The rest of it is not our problem + */ + return ide_config_drive_speed(drive, speed); +} + +/** + * config_chipset_for_dma - configure for DMA + * @drive: drive to configure + * + * Called by the IDE layer when it wants the timings set up. + */ + +static int config_chipset_for_dma (ide_drive_t *drive) +{ + u8 speed = ide_dma_speed(drive, it821x_ratemask(drive)); + + config_it821x_chipset_for_pio(drive, !speed); + it821x_tune_chipset(drive, speed); + return ide_dma_enable(drive); +} + +/** + * it821x_configure_drive_for_dma - set up for DMA transfers + * @drive: drive we are going to set up + * + * Set up the drive for DMA, tune the controller and drive as + * required. If the drive isn't suitable for DMA or we hit + * other problems then we will drop down to PIO and set up + * PIO appropriately + */ + +static int it821x_config_drive_for_dma (ide_drive_t *drive) +{ + ide_hwif_t *hwif = drive->hwif; + + if (ide_use_dma(drive)) { + if (config_chipset_for_dma(drive)) + return hwif->ide_dma_on(drive); + } + config_it821x_chipset_for_pio(drive, 1); + return hwif->ide_dma_off_quietly(drive); +} + +/** + * ata66_it821x - check for 80 pin cable + * @hwif: interface to check + * + * Check for the presence of an ATA66 capable cable on the + * interface. Problematic as it seems some cards don't have + * the needed logic onboard. + */ + +static unsigned int __devinit ata66_it821x(ide_hwif_t *hwif) +{ + /* The reference driver also only does disk side */ + return 1; +} + +/** + * it821x_fixup - post init callback + * @hwif: interface + * + * This callback is run after the drives have been probed but + * before anything gets attached. It allows drivers to do any + * final tuning that is needed, or fixups to work around bugs. + */ + +static void __devinit it821x_fixups(ide_hwif_t *hwif) +{ + struct it821x_dev *itdev = ide_get_hwifdata(hwif); + int i; + + if(!itdev->smart) { + /* + * If we are in pass through mode then not much + * needs to be done, but we do bother to clear the + * IRQ mask as we may well be in PIO (eg rev 0x10) + * for now and we know unmasking is safe on this chipset. + */ + for (i = 0; i < 2; i++) { + ide_drive_t *drive = &hwif->drives[i]; + if(drive->present) + drive->unmask = 1; + } + return; + } + /* + * Perform fixups on smart mode. We need to "lose" some + * capabilities the firmware lacks but does not filter, and + * also patch up some capability bits that it forgets to set + * in RAID mode. + */ + + for(i = 0; i < 2; i++) { + ide_drive_t *drive = &hwif->drives[i]; + struct hd_driveid *id; + u16 *idbits; + + if(!drive->present) + continue; + id = drive->id; + idbits = (u16 *)drive->id; + + /* Check for RAID v native */ + if(strstr(id->model, "Integrated Technology Express")) { + /* In raid mode the ident block is slightly buggy + We need to set the bits so that the IDE layer knows + LBA28. LBA48 and DMA ar valid */ + id->capability |= 3; /* LBA28, DMA */ + id->command_set_2 |= 0x0400; /* LBA48 valid */ + id->cfs_enable_2 |= 0x0400; /* LBA48 on */ + /* Reporting logic */ + printk(KERN_INFO "%s: IT8212 %sRAID %d volume", + drive->name, + idbits[147] ? "Bootable ":"", + idbits[129]); + if(idbits[129] != 1) + printk("(%dK stripe)", idbits[146]); + printk(".\n"); + /* Now the core code will have wrongly decided no DMA + so we need to fix this */ + hwif->ide_dma_off_quietly(drive); +#ifdef CONFIG_IDEDMA_ONLYDISK + if (drive->media == ide_disk) +#endif + hwif->ide_dma_check(drive); + } else { + /* Non RAID volume. Fixups to stop the core code + doing unsupported things */ + id->field_valid &= 1; + id->queue_depth = 0; + id->command_set_1 = 0; + id->command_set_2 &= 0xC400; + id->cfsse &= 0xC000; + id->cfs_enable_1 = 0; + id->cfs_enable_2 &= 0xC400; + id->csf_default &= 0xC000; + id->word127 = 0; + id->dlf = 0; + id->csfo = 0; + id->cfa_power = 0; + printk(KERN_INFO "%s: Performing identify fixups.\n", + drive->name); + } + } + +} + +/** + * init_hwif_it821x - set up hwif structs + * @hwif: interface to set up + * + * We do the basic set up of the interface structure. The IT8212 + * requires several custom handlers so we override the default + * ide DMA handlers appropriately + */ + +static void __devinit init_hwif_it821x(ide_hwif_t *hwif) +{ + struct it821x_dev *idev = kmalloc(sizeof(struct it821x_dev), GFP_KERNEL); + u8 conf; + + if(idev == NULL) { + printk(KERN_ERR "it821x: out of memory, falling back to legacy behaviour.\n"); + goto fallback; + } + memset(idev, 0, sizeof(struct it821x_dev)); + ide_set_hwifdata(hwif, idev); + + pci_read_config_byte(hwif->pci_dev, 0x50, &conf); + if(conf & 1) { + idev->smart = 1; + hwif->atapi_dma = 0; + /* Long I/O's although allowed in LBA48 space cause the + onboard firmware to enter the twighlight zone */ + hwif->rqsize = 256; + } + + /* Pull the current clocks from 0x50 also */ + if (conf & (1 << (1 + hwif->channel))) + idev->clock_mode = ATA_50; + else + idev->clock_mode = ATA_66; + + idev->want[0][1] = ATA_ANY; + idev->want[1][1] = ATA_ANY; + + /* + * Not in the docs but according to the reference driver + * this is neccessary. + */ + + pci_read_config_byte(hwif->pci_dev, 0x08, &conf); + if(conf == 0x10) { + idev->timing10 = 1; + hwif->atapi_dma = 0; + if(!idev->smart) + printk(KERN_WARNING "it821x: Revision 0x10, workarounds activated.\n"); + } + + hwif->speedproc = &it821x_tune_chipset; + hwif->tuneproc = &it821x_tuneproc; + + /* MWDMA/PIO clock switching for pass through mode */ + if(!idev->smart) { + hwif->dma_start = &it821x_dma_start; + hwif->ide_dma_end = &it821x_dma_end; + } + + hwif->drives[0].autotune = 1; + hwif->drives[1].autotune = 1; + + if (!hwif->dma_base) + goto fallback; + + hwif->ultra_mask = 0x7f; + hwif->mwdma_mask = 0x07; + hwif->swdma_mask = 0x07; + + hwif->ide_dma_check = &it821x_config_drive_for_dma; + if (!(hwif->udma_four)) + hwif->udma_four = ata66_it821x(hwif); + + /* + * The BIOS often doesn't set up DMA on this controller + * so we always do it. + */ + + hwif->autodma = 1; + hwif->drives[0].autodma = hwif->autodma; + hwif->drives[1].autodma = hwif->autodma; + return; +fallback: + hwif->autodma = 0; + return; +} + +static void __devinit it8212_disable_raid(struct pci_dev *dev) +{ + /* Reset local CPU, and set BIOS not ready */ + pci_write_config_byte(dev, 0x5E, 0x01); + + /* Set to bypass mode, and reset PCI bus */ + pci_write_config_byte(dev, 0x50, 0x00); + pci_write_config_word(dev, PCI_COMMAND, + PCI_COMMAND_PARITY | PCI_COMMAND_IO | + PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); + pci_write_config_word(dev, 0x40, 0xA0F3); + + pci_write_config_dword(dev,0x4C, 0x02040204); + pci_write_config_byte(dev, 0x42, 0x36); + pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0); +} + +static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const char *name) +{ + u8 conf; + static char *mode[2] = { "pass through", "smart" }; + + /* Force the card into bypass mode if so requested */ + if (it8212_noraid) { + printk(KERN_INFO "it8212: forcing bypass mode.\n"); + it8212_disable_raid(dev); + } + pci_read_config_byte(dev, 0x50, &conf); + printk(KERN_INFO "it821x: controller in %s mode.\n", mode[conf & 1]); + return 0; +} + + +#define DECLARE_ITE_DEV(name_str) \ + { \ + .name = name_str, \ + .init_chipset = init_chipset_it821x, \ + .init_hwif = init_hwif_it821x, \ + .channels = 2, \ + .autodma = AUTODMA, \ + .bootable = ON_BOARD, \ + .fixup = it821x_fixups \ + } + +static ide_pci_device_t it821x_chipsets[] __devinitdata = { + /* 0 */ DECLARE_ITE_DEV("IT8212"), +}; + +/** + * it821x_init_one - pci layer discovery entry + * @dev: PCI device + * @id: ident table entry + * + * Called by the PCI code when it finds an ITE821x controller. + * We then use the IDE PCI generic helper to do most of the work. + */ + +static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) +{ + ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); + return 0; +} + +static struct pci_device_id it821x_pci_tbl[] = { + { PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { PCI_VENDOR_ID_ITE, PCI_DEVICE_ID_ITE_8212, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, + { 0, }, +}; + +MODULE_DEVICE_TABLE(pci, it821x_pci_tbl); + +static struct pci_driver driver = { + .name = "ITE821x IDE", + .id_table = it821x_pci_tbl, + .probe = it821x_init_one, +}; + +static int __init it821x_ide_init(void) +{ + return ide_pci_register_driver(&driver); +} + +module_init(it821x_ide_init); + +module_param_named(noraid, it8212_noraid, int, S_IRUGO); +MODULE_PARM_DESC(it8212_noraid, "Force card into bypass mode"); + +MODULE_AUTHOR("Alan Cox"); +MODULE_DESCRIPTION("PCI driver module for the ITE 821x"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 3c803e8e2f15d02c5ad0a3888eea2bbd31dc59c5 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 27 Jun 2005 17:49:45 -0700 Subject: Commit the manual part of the input layer merge. git did actually warn me about the fact that I hadn't actually done an "update-cache" on these two files, but the warning was at the bottom of a list of all the files that _did_ change in the merge, so I never noticed. My bad. --- drivers/input/gameport/gameport.c | 31 ++++++-------- drivers/input/serio/serio.c | 89 +++++++++++++++++++++++++++------------ 2 files changed, 74 insertions(+), 46 deletions(-) (limited to 'drivers') diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c index c77a82e4605..3e72c9b1461 100644 --- a/drivers/input/gameport/gameport.c +++ b/drivers/input/gameport/gameport.c @@ -17,11 +17,10 @@ #include #include #include -#include #include -#include #include #include +#include /*#include */ @@ -238,8 +237,7 @@ struct gameport_event { static DEFINE_SPINLOCK(gameport_event_lock); /* protects gameport_event_list */ static LIST_HEAD(gameport_event_list); static DECLARE_WAIT_QUEUE_HEAD(gameport_wait); -static DECLARE_COMPLETION(gameport_exited); -static int gameport_pid; +static struct task_struct *gameport_task; static void gameport_queue_event(void *object, struct module *owner, enum gameport_event_type event_type) @@ -250,12 +248,12 @@ static void gameport_queue_event(void *object, struct module *owner, spin_lock_irqsave(&gameport_event_lock, flags); /* - * Scan event list for the other events for the same gameport port, + * Scan event list for the other events for the same gameport port, * starting with the most recent one. If event is the same we * do not need add new one. If event is of different type we * need to add this event and should not look further because * we need to preseve sequence of distinct events. - */ + */ list_for_each_entry_reverse(event, &gameport_event_list, node) { if (event->object == object) { if (event->type == event_type) @@ -432,20 +430,15 @@ static struct gameport *gameport_get_pending_child(struct gameport *parent) static int gameport_thread(void *nothing) { - lock_kernel(); - daemonize("kgameportd"); - allow_signal(SIGTERM); - do { gameport_handle_events(); - wait_event_interruptible(gameport_wait, !list_empty(&gameport_event_list)); + wait_event_interruptible(gameport_wait, + kthread_should_stop() || !list_empty(&gameport_event_list)); try_to_freeze(); - } while (!signal_pending(current)); + } while (!kthread_should_stop()); printk(KERN_DEBUG "gameport: kgameportd exiting\n"); - - unlock_kernel(); - complete_and_exit(&gameport_exited, 0); + return 0; } @@ -773,9 +766,10 @@ void gameport_close(struct gameport *gameport) static int __init gameport_init(void) { - if (!(gameport_pid = kernel_thread(gameport_thread, NULL, CLONE_KERNEL))) { + gameport_task = kthread_run(gameport_thread, NULL, "kgameportd"); + if (IS_ERR(gameport_task)) { printk(KERN_ERR "gameport: Failed to start kgameportd\n"); - return -1; + return PTR_ERR(gameport_task); } gameport_bus.dev_attrs = gameport_device_attrs; @@ -789,8 +783,7 @@ static int __init gameport_init(void) static void __exit gameport_exit(void) { bus_unregister(&gameport_bus); - kill_proc(gameport_pid, SIGTERM, 1); - wait_for_completion(&gameport_exited); + kthread_stop(gameport_task); } module_init(gameport_init); diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 341824c4852..f367695e69b 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c @@ -31,10 +31,9 @@ #include #include #include -#include #include -#include #include +#include MODULE_AUTHOR("Vojtech Pavlik "); MODULE_DESCRIPTION("Serio abstraction core"); @@ -43,6 +42,7 @@ MODULE_LICENSE("GPL"); EXPORT_SYMBOL(serio_interrupt); EXPORT_SYMBOL(__serio_register_port); EXPORT_SYMBOL(serio_unregister_port); +EXPORT_SYMBOL(serio_unregister_child_port); EXPORT_SYMBOL(__serio_unregister_port_delayed); EXPORT_SYMBOL(__serio_register_driver); EXPORT_SYMBOL(serio_unregister_driver); @@ -68,6 +68,37 @@ static void serio_destroy_port(struct serio *serio); static void serio_reconnect_port(struct serio *serio); static void serio_disconnect_port(struct serio *serio); +static int serio_connect_driver(struct serio *serio, struct serio_driver *drv) +{ + int retval; + + down(&serio->drv_sem); + retval = drv->connect(serio, drv); + up(&serio->drv_sem); + + return retval; +} + +static int serio_reconnect_driver(struct serio *serio) +{ + int retval = -1; + + down(&serio->drv_sem); + if (serio->drv && serio->drv->reconnect) + retval = serio->drv->reconnect(serio); + up(&serio->drv_sem); + + return retval; +} + +static void serio_disconnect_driver(struct serio *serio) +{ + down(&serio->drv_sem); + if (serio->drv) + serio->drv->disconnect(serio); + up(&serio->drv_sem); +} + static int serio_match_port(const struct serio_device_id *ids, struct serio *serio) { while (ids->type || ids->proto) { @@ -91,7 +122,7 @@ static void serio_bind_driver(struct serio *serio, struct serio_driver *drv) if (serio_match_port(drv->id_table, serio)) { serio->dev.driver = &drv->driver; - if (drv->connect(serio, drv)) { + if (serio_connect_driver(serio, drv)) { serio->dev.driver = NULL; goto out; } @@ -138,8 +169,7 @@ struct serio_event { static DEFINE_SPINLOCK(serio_event_lock); /* protects serio_event_list */ static LIST_HEAD(serio_event_list); static DECLARE_WAIT_QUEUE_HEAD(serio_wait); -static DECLARE_COMPLETION(serio_exited); -static int serio_pid; +static struct task_struct *serio_task; static void serio_queue_event(void *object, struct module *owner, enum serio_event_type event_type) @@ -150,12 +180,12 @@ static void serio_queue_event(void *object, struct module *owner, spin_lock_irqsave(&serio_event_lock, flags); /* - * Scan event list for the other events for the same serio port, + * Scan event list for the other events for the same serio port, * starting with the most recent one. If event is the same we * do not need add new one. If event is of different type we * need to add this event and should not look further because * we need to preseve sequence of distinct events. - */ + */ list_for_each_entry_reverse(event, &serio_event_list, node) { if (event->object == object) { if (event->type == event_type) @@ -337,20 +367,15 @@ static struct serio *serio_get_pending_child(struct serio *parent) static int serio_thread(void *nothing) { - lock_kernel(); - daemonize("kseriod"); - allow_signal(SIGTERM); - do { serio_handle_events(); - wait_event_interruptible(serio_wait, !list_empty(&serio_event_list)); + wait_event_interruptible(serio_wait, + kthread_should_stop() || !list_empty(&serio_event_list)); try_to_freeze(); - } while (!signal_pending(current)); + } while (!kthread_should_stop()); printk(KERN_DEBUG "serio: kseriod exiting\n"); - - unlock_kernel(); - complete_and_exit(&serio_exited, 0); + return 0; } @@ -557,7 +582,7 @@ static void serio_destroy_port(struct serio *serio) static void serio_reconnect_port(struct serio *serio) { do { - if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) { + if (serio_reconnect_driver(serio)) { serio_disconnect_port(serio); serio_find_driver(serio); /* Ok, old children are now gone, we are done */ @@ -629,6 +654,19 @@ void serio_unregister_port(struct serio *serio) up(&serio_sem); } +/* + * Safely unregisters child port if one is present. + */ +void serio_unregister_child_port(struct serio *serio) +{ + down(&serio_sem); + if (serio->child) { + serio_disconnect_port(serio->child); + serio_destroy_port(serio->child); + } + up(&serio_sem); +} + /* * Submits register request to kseriod for subsequent execution. * Can be used when it is not obvious whether the serio_sem is @@ -686,15 +724,14 @@ static int serio_driver_probe(struct device *dev) struct serio *serio = to_serio_port(dev); struct serio_driver *drv = to_serio_driver(dev->driver); - return drv->connect(serio, drv); + return serio_connect_driver(serio, drv); } static int serio_driver_remove(struct device *dev) { struct serio *serio = to_serio_port(dev); - struct serio_driver *drv = to_serio_driver(dev->driver); - drv->disconnect(serio); + serio_disconnect_driver(serio); return 0; } @@ -730,11 +767,9 @@ start_over: static void serio_set_drv(struct serio *serio, struct serio_driver *drv) { - down(&serio->drv_sem); serio_pause_rx(serio); serio->drv = drv; serio_continue_rx(serio); - up(&serio->drv_sem); } static int serio_bus_match(struct device *dev, struct device_driver *drv) @@ -794,7 +829,7 @@ static int serio_resume(struct device *dev) { struct serio *serio = to_serio_port(dev); - if (!serio->drv || !serio->drv->reconnect || serio->drv->reconnect(serio)) { + if (serio_reconnect_driver(serio)) { /* * Driver re-probing can take a while, so better let kseriod * deal with it. @@ -848,9 +883,10 @@ irqreturn_t serio_interrupt(struct serio *serio, static int __init serio_init(void) { - if (!(serio_pid = kernel_thread(serio_thread, NULL, CLONE_KERNEL))) { + serio_task = kthread_run(serio_thread, NULL, "kseriod"); + if (IS_ERR(serio_task)) { printk(KERN_ERR "serio: Failed to start kseriod\n"); - return -1; + return PTR_ERR(serio_task); } serio_bus.dev_attrs = serio_device_attrs; @@ -866,8 +902,7 @@ static int __init serio_init(void) static void __exit serio_exit(void) { bus_unregister(&serio_bus); - kill_proc(serio_pid, SIGTERM, 1); - wait_for_completion(&serio_exited); + kthread_stop(serio_task); } module_init(serio_init); -- cgit v1.2.3 From 7925407aa02653ba462b1d8b0b1229b99aee5411 Mon Sep 17 00:00:00 2001 From: Ivan Kokshaysky Date: Mon, 27 Jun 2005 16:28:02 -0700 Subject: [PATCH] pci: yenta cardbus fix On Mon, Jun 20, 2005 at 07:15:34PM +1000, Grant Coady wrote: > Yenta: CardBus bridge found at 0000:00:0b.0 [1179:0001] > yenta 0000:00:0b.0: Preassigned resource 0 busy, reconfiguring... In -mm1 the cardbus resources might be assigned in pci_assign_unassigned_resources() pass. From your dmesg: PCI: Bus 2, cardbus bridge: 0000:00:0b.0 IO window: 00002000-00002fff IO window: 00003000-00003fff PREFETCH window: 12000000-13ffffff MEM window: 14000000-15ffffff Then yenta_allocate_res() tries to assign these resources again and, naturally, fails. This adds check for already assigned cardbus resources. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/yenta_socket.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c index bee05362fd2..02b23abc2df 100644 --- a/drivers/pcmcia/yenta_socket.c +++ b/drivers/pcmcia/yenta_socket.c @@ -549,6 +549,11 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ unsigned offset; unsigned mask; + res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; + /* Already allocated? */ + if (res->parent) + return 0; + /* The granularity of the memory limit is 4kB, on IO it's 4 bytes */ mask = ~0xfff; if (type & IORESOURCE_IO) @@ -556,7 +561,6 @@ static void yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned typ offset = 0x1c + 8*nr; bus = socket->dev->subordinate; - res = socket->dev->resource + PCI_BRIDGE_RESOURCES + nr; res->name = bus->name; res->flags = type; res->start = 0; -- cgit v1.2.3 From 840c2ac5d3c1d50e8a181e3f661da814e89c8cf8 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:04 -0700 Subject: [PATCH] pcmcia: hotplug event for PCMCIA devices Export information to /sbin/hotplug for PCMCIA devices: card_id, manf_id, func_id, bus_id (like pcmcia1.0) and crc32-hashes of the prod_id strings. Why not the prod_id strings themselves? a) They may contain all sorts of strange and difficult to handle characters, like " ". b) It's impossible to pass multiple strings to userspace. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 569e55feecf..35d479b0df6 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -601,6 +602,71 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) { return 0; } +#ifdef CONFIG_HOTPLUG + +static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size) +{ + struct pcmcia_device *p_dev; + int i, length = 0; + u32 hash[4] = { 0, 0, 0, 0}; + + if (!dev) + return -ENODEV; + + p_dev = to_pcmcia_dev(dev); + + /* calculate hashes */ + for (i=0; i<4; i++) { + if (!p_dev->prod_id[i]) + continue; + hash[i] = crc32(0, p_dev->prod_id[i], strlen(p_dev->prod_id[i])); + } + + i = 0; + + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "SOCKET_NO=%u", + p_dev->socket->sock)) + return -ENOMEM; + + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "DEVICE_NO=%02X", + p_dev->device_no)) + return -ENOMEM; + + if (add_hotplug_env_var(envp, num_envp, &i, + buffer, buffer_size, &length, + "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" + "pa%08Xpb%08Xpc%08Xpd%08X", + p_dev->has_manf_id ? p_dev->manf_id : 0, + p_dev->has_card_id ? p_dev->card_id : 0, + p_dev->has_func_id ? p_dev->func_id : 0, + p_dev->func, + p_dev->device_no, + hash[0], + hash[1], + hash[2], + hash[3])) + return -ENOMEM; + + envp[i] = NULL; + + return 0; +} + +#else + +static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, + char *buffer, int buffer_size) +{ + return -ENODEV; +} + +#endif + /************************ per-device sysfs output ***************************/ #define pcmcia_device_attr(field, test, format) \ @@ -1575,6 +1641,7 @@ static struct class_interface pcmcia_bus_interface = { struct bus_type pcmcia_bus_type = { .name = "pcmcia", + .hotplug = pcmcia_bus_hotplug, .match = pcmcia_bus_match, .dev_attrs = pcmcia_dev_attrs, }; -- cgit v1.2.3 From 3ee13937525f6044d769b1a84d5db5669ac1959e Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:05 -0700 Subject: [PATCH] pcmcia: hotplug event for PCMCIA socket devices Generate hotplug event for PCMCIA sockets being registered. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers') diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 48e4f04530d..fec9e030473 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -1866,6 +1866,21 @@ int pcmcia_insert_card(struct pcmcia_socket *skt) return ret; } /* insert_card */ +static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, + int num_envp, char *buffer, int buffer_size) +{ + struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); + int i = 0, length = 0; + + if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, + &length, "SOCKET_NO=%u", s->sock)) + return -ENOMEM; + + envp[i] = NULL; + + return 0; +} + /*====================================================================== OS-specific module glue goes here @@ -1895,6 +1910,7 @@ EXPORT_SYMBOL(pcmcia_parse_events); struct class pcmcia_socket_class = { .name = "pcmcia_socket", + .hotplug = pcmcia_socket_hotplug, .release = pcmcia_release_socket, }; EXPORT_SYMBOL(pcmcia_socket_class); -- cgit v1.2.3 From 1ad275e3e7d253d44f03868e85977c908e334fed Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:06 -0700 Subject: [PATCH] pcmcia: device and driver matching The actual matching of pcmcia drivers and pcmcia devices. The original version of this was written by David Woodhouse. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 35d479b0df6..5701b93b2dd 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -101,6 +101,9 @@ struct pcmcia_bus_socket { u8 device_count; /* the number of devices, used * only internally and subject * to incorrectness and change */ + + u8 device_add_pending; + struct work_struct device_add; }; static spinlock_t pcmcia_dev_list_lock; @@ -512,6 +515,10 @@ static struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, uns down(&device_add_lock); + /* max of 2 devices per card */ + if (s->device_count == 2) + goto err_put; + p_dev = kmalloc(sizeof(struct pcmcia_device), GFP_KERNEL); if (!p_dev) goto err_put; @@ -537,6 +544,8 @@ static struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, uns list_add_tail(&p_dev->socket_device_list, &s->devices_list); spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + pcmcia_device_query(p_dev); + if (device_register(&p_dev->dev)) { spin_lock_irqsave(&pcmcia_dev_list_lock, flags); list_del(&p_dev->socket_device_list); @@ -591,14 +600,123 @@ static int pcmcia_card_add(struct pcmcia_socket *s) } +static void pcmcia_delayed_add_pseudo_device(void *data) +{ + struct pcmcia_bus_socket *s = data; + pcmcia_device_add(s, 0); + s->device_add_pending = 0; +} + +static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s) +{ + if (!s->device_add_pending) { + schedule_work(&s->device_add); + s->device_add_pending = 1; + } + return; +} + + +static inline int pcmcia_devmatch(struct pcmcia_device *dev, + struct pcmcia_device_id *did) +{ + if (did->match_flags & PCMCIA_DEV_ID_MATCH_MANF_ID) { + if ((!dev->has_manf_id) || (dev->manf_id != did->manf_id)) + return 0; + } + + if (did->match_flags & PCMCIA_DEV_ID_MATCH_CARD_ID) { + if ((!dev->has_card_id) || (dev->card_id != did->card_id)) + return 0; + } + + if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNCTION) { + if (dev->func != did->function) + return 0; + } + + if (did->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID1) { + if (!dev->prod_id[0]) + return 0; + if (strcmp(did->prod_id[0], dev->prod_id[0])) + return 0; + } + + if (did->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID2) { + if (!dev->prod_id[1]) + return 0; + if (strcmp(did->prod_id[1], dev->prod_id[1])) + return 0; + } + + if (did->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID3) { + if (!dev->prod_id[2]) + return 0; + if (strcmp(did->prod_id[2], dev->prod_id[2])) + return 0; + } + + if (did->match_flags & PCMCIA_DEV_ID_MATCH_PROD_ID4) { + if (!dev->prod_id[3]) + return 0; + if (strcmp(did->prod_id[3], dev->prod_id[3])) + return 0; + } + + if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) { + /* handle pseudo multifunction devices: + * there are at most two pseudo multifunction devices. + * if we're matching against the first, schedule a + * call which will then check whether there are two + * pseudo devices, and if not, add the second one. + */ + if (dev->device_no == 0) + pcmcia_add_pseudo_device(dev->socket->pcmcia); + + if (dev->device_no != did->device_no) + return 0; + } + + if (did->match_flags & PCMCIA_DEV_ID_MATCH_FUNC_ID) { + if ((!dev->has_func_id) || (dev->func_id != did->func_id)) + return 0; + + /* if this is a pseudo-multi-function device, + * we need explicit matches */ + if (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) + return 0; + if (dev->device_no) + return 0; + + /* also, FUNC_ID matching needs to be activated by userspace + * after it has re-checked that there is no possible module + * with a prod_id/manf_id/card_id match. + */ + if (!dev->allow_func_id_match) + return 0; + } + + dev->dev.driver_data = (void *) did; + + return 1; +} + + static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) { struct pcmcia_device * p_dev = to_pcmcia_dev(dev); struct pcmcia_driver * p_drv = to_pcmcia_drv(drv); + struct pcmcia_device_id *did = p_drv->id_table; /* matching by cardmgr */ if (p_dev->cardmgr == p_drv) return 1; + while (did && did->match_flags) { + if (pcmcia_devmatch(p_dev, did)) + return 1; + did++; + } + return 0; } @@ -922,7 +1040,9 @@ static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info) rescan: p_dev->cardmgr = p_drv; - pcmcia_device_query(p_dev); + /* if a driver is already running, we can abort */ + if (p_dev->dev.driver) + goto err_put_module; /* * Prevent this racing with a card insertion. @@ -1595,6 +1715,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) init_waitqueue_head(&s->queue); INIT_LIST_HEAD(&s->devices_list); + INIT_WORK(&s->device_add, pcmcia_delayed_add_pseudo_device, s); /* Set up hotline to Card Services */ s->callback.owner = THIS_MODULE; -- cgit v1.2.3 From 23a83bfe6ab51c745d109d979c78a96fe3e93f5c Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:07 -0700 Subject: [PATCH] pcmcia: check for invalid crc32 hashes in id_tables Check for invalid crc32 hashes in drivers' id_tables if CONFIG_PCMCIA_DEBUG is set. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 5701b93b2dd..3ac7a443f66 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -260,6 +260,41 @@ void cs_error(client_handle_t handle, int func, int ret) } EXPORT_SYMBOL(cs_error); +#ifdef CONFIG_PCMCIA_DEBUG + + +static void pcmcia_check_driver(struct pcmcia_driver *p_drv) +{ + struct pcmcia_device_id *did = p_drv->id_table; + unsigned int i; + u32 hash; + + while (did && did->match_flags) { + for (i=0; i<4; i++) { + if (!did->prod_id[i]) + continue; + + hash = crc32(0, did->prod_id[i], strlen(did->prod_id[i])); + if (hash == did->prod_id_hash[i]) + continue; + + printk(KERN_DEBUG "pcmcia: %s: invalid hash for " + "product string \"%s\": is 0x%x, should " + "be 0x%x\n", p_drv->drv.name, did->prod_id[i], + did->prod_id_hash[i], hash); + } + did++; + } + + return; +} + +#else +static inline void pcmcia_check_driver(struct pcmcia_driver *p_drv) { + return; +} +#endif + /*======================================================================*/ static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); @@ -296,6 +331,8 @@ int pcmcia_register_driver(struct pcmcia_driver *driver) if (!driver) return -EINVAL; + pcmcia_check_driver(driver); + /* initialize common fields */ driver->drv.bus = &pcmcia_bus_type; driver->drv.owner = driver->owner; -- cgit v1.2.3 From ea7b38825bba66a81745a706da70a1c81adc95bd Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:07 -0700 Subject: [PATCH] pcmcia: match for fake CIS Add another match flag for devices needing a CIS override. The driver will only probe/attach if the CIS has been replaced before. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 3ac7a443f66..c0611d56eab 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -733,6 +733,14 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, return 0; } + if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { + if (!dev->socket->fake_cis) { + /* FIXME: evaluate using firmware helpers to + * automagically load it from userspace */ + return 0; + } + } + dev->dev.driver_data = (void *) did; return 1; -- cgit v1.2.3 From 7f299bccb422d707be3b074f9a669b34cb207a14 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:08 -0700 Subject: [PATCH] pcmcia: export CIS in sysfs Export the CIS to userspace using a sysfs binary file in /sys/class/pcmcia_socket/pcmcia_scoket%n/ Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/socket_sysfs.c | 105 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) (limited to 'drivers') diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index 8eed0393821..fd5a3b0557b 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c @@ -187,6 +187,102 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf, static CLASS_DEVICE_ATTR(available_resources_setup_done, 0600, pccard_show_resource, pccard_store_resource); +static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, loff_t off, size_t count) +{ + tuple_t tuple; + int status, i; + loff_t pointer = 0; + ssize_t ret = 0; + u_char *tuplebuffer; + u_char *tempbuffer; + + tuplebuffer = kmalloc(sizeof(u_char) * 256, GFP_KERNEL); + if (!tuplebuffer) + return -ENOMEM; + + tempbuffer = kmalloc(sizeof(u_char) * 258, GFP_KERNEL); + if (!tempbuffer) { + ret = -ENOMEM; + goto free_tuple; + } + + memset(&tuple, 0, sizeof(tuple_t)); + + tuple.Attributes = TUPLE_RETURN_LINK | TUPLE_RETURN_COMMON; + tuple.DesiredTuple = RETURN_FIRST_TUPLE; + tuple.TupleOffset = 0; + + status = pccard_get_first_tuple(s, BIND_FN_ALL, &tuple); + while (!status) { + tuple.TupleData = tuplebuffer; + tuple.TupleDataMax = 255; + memset(tuplebuffer, 0, sizeof(u_char) * 255); + + status = pccard_get_tuple_data(s, &tuple); + if (status) + break; + + if (off < (pointer + 2 + tuple.TupleDataLen)) { + tempbuffer[0] = tuple.TupleCode & 0xff; + tempbuffer[1] = tuple.TupleLink & 0xff; + for (i = 0; i < tuple.TupleDataLen; i++) + tempbuffer[i + 2] = tuplebuffer[i] & 0xff; + + for (i = 0; i < (2 + tuple.TupleDataLen); i++) { + if (((i + pointer) >= off) && + (i + pointer) < (off + count)) { + buf[ret] = tempbuffer[i]; + ret++; + } + } + } + + pointer += 2 + tuple.TupleDataLen; + + if (pointer >= (off + count)) + break; + + if (tuple.TupleCode == CISTPL_END) + break; + status = pccard_get_next_tuple(s, BIND_FN_ALL, &tuple); + } + + kfree(tempbuffer); + free_tuple: + kfree(tuplebuffer); + + return (ret); +} + +static ssize_t pccard_show_cis(struct kobject *kobj, char *buf, loff_t off, size_t count) +{ + unsigned int size = 0x200; + + if (off >= size) + count = 0; + else { + struct pcmcia_socket *s; + cisinfo_t cisinfo; + + if (off + count > size) + count = size - off; + + s = to_socket(container_of(kobj, struct class_device, kobj)); + + if (!(s->state & SOCKET_PRESENT)) + return -ENODEV; + if (pccard_validate_cis(s, BIND_FN_ALL, &cisinfo)) + return -EIO; + if (!cisinfo.Chains) + return -ENODATA; + + count = pccard_extract_cis(s, buf, off, count); + } + + return (count); +} + + static struct class_device_attribute *pccard_socket_attributes[] = { &class_device_attr_card_type, &class_device_attr_card_voltage, @@ -199,6 +295,12 @@ static struct class_device_attribute *pccard_socket_attributes[] = { NULL, }; +static struct bin_attribute pccard_cis_attr = { + .attr = { .name = "cis", .mode = S_IRUGO, .owner = THIS_MODULE}, + .size = 0x200, + .read = pccard_show_cis, +}; + static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) { struct class_device_attribute **attr; @@ -209,6 +311,8 @@ static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) if (ret) break; } + if (!ret) + ret = sysfs_create_bin_file(&class_dev->kobj, &pccard_cis_attr); return ret; } @@ -217,6 +321,7 @@ static void __devexit pccard_sysfs_remove_socket(struct class_device *class_dev) { struct class_device_attribute **attr; + sysfs_remove_bin_file(&class_dev->kobj, &pccard_cis_attr); for (attr = pccard_socket_attributes; *attr; attr++) class_device_remove_file(class_dev, *attr); } -- cgit v1.2.3 From ff1fa9ef3c9fb23a6baa06b63f4bdf3de089b29a Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:09 -0700 Subject: [PATCH] pcmcia: CIS overrid via sysfs The one thing which surprises me in this patch that cis->Length needs to be set to count+1. Without it, it doesn't work, but with it, it doesn't make sense to me. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cs_internal.h | 1 + drivers/pcmcia/ds.c | 6 ++++++ drivers/pcmcia/socket_sysfs.c | 47 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 7933a7db49d..211637390fb 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -160,6 +160,7 @@ struct pcmcia_callback{ struct module *owner; int (*event) (struct pcmcia_socket *s, event_t event, int priority); int (*resources_done) (struct pcmcia_socket *s); + void (*replace_cis) (void); }; int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index c0611d56eab..f657a2a77b2 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -653,6 +653,11 @@ static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s) return; } +static void pcmcia_bus_rescan(void) +{ + /* must be called with skt_sem held */ + bus_rescan_devices(&pcmcia_bus_type); +} static inline int pcmcia_devmatch(struct pcmcia_device *dev, struct pcmcia_device_id *did) @@ -1766,6 +1771,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) s->callback.owner = THIS_MODULE; s->callback.event = &ds_event; s->callback.resources_done = &pcmcia_card_add; + s->callback.replace_cis = &pcmcia_bus_rescan; socket->pcmcia = s; ret = pccard_register_pcmcia(socket, &s->callback); diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index fd5a3b0557b..8e66eeff672 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c @@ -282,6 +282,50 @@ static ssize_t pccard_show_cis(struct kobject *kobj, char *buf, loff_t off, size return (count); } +static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, size_t count) +{ + struct pcmcia_socket *s = to_socket(container_of(kobj, struct class_device, kobj)); + cisdump_t *cis; + ssize_t ret = count; + + if (off) + return -EINVAL; + + if (count >= 0x200) + return -EINVAL; + + if (!(s->state & SOCKET_PRESENT)) + return -ENODEV; + + cis = kmalloc(sizeof(cisdump_t), GFP_KERNEL); + if (!cis) + return -ENOMEM; + memset(cis, 0, sizeof(cisdump_t)); + + cis->Length = count + 1; + memcpy(cis->Data, buf, count); + + if (pcmcia_replace_cis(s, cis)) + ret = -EIO; + + kfree(cis); + + if (!ret) { + down(&s->skt_sem); + if ((s->callback) && (s->state & SOCKET_PRESENT) && + !(s->state & SOCKET_CARDBUS)) { + if (try_module_get(s->callback->owner)) { + s->callback->replace_cis(); + module_put(s->callback->owner); + } + } + up(&s->skt_sem); + } + + + return (ret); +} + static struct class_device_attribute *pccard_socket_attributes[] = { &class_device_attr_card_type, @@ -296,9 +340,10 @@ static struct class_device_attribute *pccard_socket_attributes[] = { }; static struct bin_attribute pccard_cis_attr = { - .attr = { .name = "cis", .mode = S_IRUGO, .owner = THIS_MODULE}, + .attr = { .name = "cis", .mode = S_IRUGO | S_IWUSR, .owner = THIS_MODULE}, .size = 0x200, .read = pccard_show_cis, + .write = pccard_store_cis, }; static int __devinit pccard_sysfs_add_socket(struct class_device *class_dev) -- cgit v1.2.3 From f602ff7eb4e44e7245bfeeba4d078144703fcd76 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:09 -0700 Subject: [PATCH] pcmcia: match "anonymous" cards If a card doesn't provide _any_ information about itself, assume it is a so-called "anonymous" card. pcmciamtd will bind to it if it is configured to do so. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index f657a2a77b2..66680699e91 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -746,6 +746,15 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, } } + if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) { + int i; + for (i=0; i<4; i++) + if (dev->prod_id[i]) + return 0; + if (dev->has_manf_id || dev->has_card_id || dev->has_func_id) + return 0; + } + dev->dev.driver_data = (void *) did; return 1; -- cgit v1.2.3 From a5b5577898d9330a78dea1c9e75da1540c36bf72 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:10 -0700 Subject: [PATCH] pcmcia: allow function-ID based match The "func_id"-based matching is very fuzzy and can lead to false positives. Therefore, it should be tried to avoid relying on these matches. Until most/all existing func_id-based matches are replaced by manf_id/card_id/prod_id matches (a patch which will ask to send the appropriate card information to the PCMCIA mailing list will be added once other, more pressing issues are adressed), we need to emulate cardmgr behaviour by allowing func_id matches if no manf_id/card_id/prod_id match occurs. This can only be done in userspace because of modules possibly loaded with long delays. So, add a per-device sysfs file for this purpose. Signed-off-by: Dominik Brodowski Signed-off-by: Brice Goglin Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 66680699e91..19b7dacdbe7 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -656,7 +656,7 @@ static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s) static void pcmcia_bus_rescan(void) { /* must be called with skt_sem held */ - bus_rescan_devices(&pcmcia_bus_type); + bus_rescan_devices(&pcmcia_bus_type); } static inline int pcmcia_devmatch(struct pcmcia_device *dev, @@ -869,6 +869,23 @@ pcmcia_device_stringattr(prod_id2, prod_id[1]); pcmcia_device_stringattr(prod_id3, prod_id[2]); pcmcia_device_stringattr(prod_id4, prod_id[3]); + +static ssize_t pcmcia_store_allow_func_id_match (struct device * dev, struct device_attribute *attr, + const char * buf, size_t count) +{ + struct pcmcia_device *p_dev = to_pcmcia_dev(dev); + if (!count) + return -EINVAL; + + down(&p_dev->socket->skt_sem); + p_dev->allow_func_id_match = 1; + up(&p_dev->socket->skt_sem); + + bus_rescan_devices(&pcmcia_bus_type); + + return count; +} + static struct device_attribute pcmcia_dev_attrs[] = { __ATTR(function, 0444, func_show, NULL), __ATTR_RO(func_id), @@ -878,6 +895,7 @@ static struct device_attribute pcmcia_dev_attrs[] = { __ATTR_RO(prod_id2), __ATTR_RO(prod_id3), __ATTR_RO(prod_id4), + __ATTR(allow_func_id_match, 0200, NULL, pcmcia_store_allow_func_id_match), __ATTR_NULL, }; -- cgit v1.2.3 From daa9517d9eccc3598b2b0cdfa0b016ae4a4fcdce Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:14 -0700 Subject: [PATCH] pcmcia: request CIS via firmware interface Use the firmware method to load replacement CIS tables. It is recommended that the /lib/firmware/cis/ points to /etc/pcmcia/cis or the other way round so that both old-style cardmgr and new-style hotplug/firmware can access these "overwrite" files Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/Kconfig | 14 ++++++++++ drivers/pcmcia/ds.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 81 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 14e4124e152..22f7e8ca658 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -58,6 +58,20 @@ config PCMCIA If unsure, say Y. +config PCMCIA_LOAD_CIS + bool "Load CIS updates from userspace (EXPERIMENTAL)" + depends on PCMCIA && EXPERIMENTAL + select FW_LOADER + default y + help + Some PCMCIA cards require an updated Card Information Structure (CIS) + to be loaded from userspace to work correctly. If you say Y here, + and your userspace is arranged correctly, this will be loaded + automatically using the in-kernel firmware loader and the hotplug + subsystem, instead of relying on cardmgr from pcmcia-cs to do so. + + If unsure, say Y. + config CARDBUS bool "32-bit CardBus support" depends on PCI diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 19b7dacdbe7..5c88ff8e7d7 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -295,6 +296,68 @@ static inline void pcmcia_check_driver(struct pcmcia_driver *p_drv) { } #endif + +#ifdef CONFIG_PCMCIA_LOAD_CIS + +/** + * pcmcia_load_firmware - load CIS from userspace if device-provided is broken + * @dev - the pcmcia device which needs a CIS override + * @filename - requested filename in /lib/firmware/cis/ + * + * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if + * the one provided by the card is broken. The firmware files reside in + * /lib/firmware/cis/ in userspace. + */ +static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) +{ + struct pcmcia_socket *s = dev->socket; + const struct firmware *fw; + char path[20]; + int ret=-ENOMEM; + cisdump_t *cis; + + if (!filename) + return -EINVAL; + + ds_dbg(1, "trying to load firmware %s\n", filename); + + if (strlen(filename) > 14) + return -EINVAL; + + snprintf(path, 20, "%s", filename); + + if (request_firmware(&fw, path, &dev->dev) == 0) { + if (fw->size >= CISTPL_MAX_CIS_SIZE) + goto release; + + cis = kmalloc(sizeof(cisdump_t), GFP_KERNEL); + if (!cis) + goto release; + + memset(cis, 0, sizeof(cisdump_t)); + + cis->Length = fw->size + 1; + memcpy(cis->Data, fw->data, fw->size); + + if (!pcmcia_replace_cis(s, cis)) + ret = 0; + } + release: + release_firmware(fw); + + return (ret); +} + +#else /* !CONFIG_PCMCIA_LOAD_CIS */ + +static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) +{ + return -ENODEV; +} + +#endif + + /*======================================================================*/ static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); @@ -739,11 +802,11 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, } if (did->match_flags & PCMCIA_DEV_ID_MATCH_FAKE_CIS) { - if (!dev->socket->fake_cis) { - /* FIXME: evaluate using firmware helpers to - * automagically load it from userspace */ + if (!dev->socket->fake_cis) + pcmcia_load_firmware(dev, did->cisfile); + + if (!dev->socket->fake_cis) return 0; - } } if (did->match_flags & PCMCIA_DEV_ID_MATCH_ANONYMOUS) { -- cgit v1.2.3 From e94e15f70559962f60915a09d44658b73a453fe2 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:15 -0700 Subject: [PATCH] pcmcia: cleanups From: Adrian Bunk This patch contains the following cleanups: - make needlessly global code static - remove the following unneeded EXPORT_SYMBOL's: - ds.c: pcmcia_report_error - ds.c: pcmcia_bus_type Signed-off-by: Adrian Bunk Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 10 +++++----- drivers/pcmcia/rsrc_nonstatic.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 5c88ff8e7d7..0de0f230045 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -60,7 +60,7 @@ MODULE_DESCRIPTION("PCMCIA Driver Services"); MODULE_LICENSE("GPL"); #ifdef DEBUG -int ds_pc_debug; +static int ds_pc_debug; module_param_named(pc_debug, ds_pc_debug, int, 0644); @@ -108,6 +108,8 @@ struct pcmcia_bus_socket { }; static spinlock_t pcmcia_dev_list_lock; +static struct bus_type pcmcia_bus_type; + #define DS_SOCKET_PRESENT 0x01 #define DS_SOCKET_BUSY 0x02 #define DS_SOCKET_REMOVAL_PENDING 0x10 @@ -218,7 +220,7 @@ static const lookup_t service_table[] = { }; -int pcmcia_report_error(client_handle_t handle, error_info_t *err) +static int pcmcia_report_error(client_handle_t handle, error_info_t *err) { int i; char *serv; @@ -248,7 +250,6 @@ int pcmcia_report_error(client_handle_t handle, error_info_t *err) return CS_SUCCESS; } /* report_error */ -EXPORT_SYMBOL(pcmcia_report_error); /* end of code which was in cs.c before */ @@ -1901,13 +1902,12 @@ static struct class_interface pcmcia_bus_interface = { }; -struct bus_type pcmcia_bus_type = { +static struct bus_type pcmcia_bus_type = { .name = "pcmcia", .hotplug = pcmcia_bus_hotplug, .match = pcmcia_bus_match, .dev_attrs = pcmcia_dev_attrs, }; -EXPORT_SYMBOL(pcmcia_bus_type); static int __init init_pcmcia_bus(void) diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 5876bab7c14..9a0b835d612 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -601,7 +601,7 @@ static int nonstatic_adjust_io_region(struct resource *res, unsigned long r_star ======================================================================*/ -struct resource *nonstatic_find_io_region(unsigned long base, int num, +static struct resource *nonstatic_find_io_region(unsigned long base, int num, unsigned long align, struct pcmcia_socket *s) { struct resource *res = make_resource(0, num, IORESOURCE_IO, s->dev.class_id); @@ -635,8 +635,8 @@ struct resource *nonstatic_find_io_region(unsigned long base, int num, return res; } -struct resource * nonstatic_find_mem_region(u_long base, u_long num, u_long align, - int low, struct pcmcia_socket *s) +static struct resource * nonstatic_find_mem_region(u_long base, u_long num, + u_long align, int low, struct pcmcia_socket *s) { struct resource *res = make_resource(0, num, IORESOURCE_MEM, s->dev.class_id); struct socket_data *s_data = s->resource_data; -- cgit v1.2.3 From e2f0b5344161dabfab102ac0a54f330f61477972 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:17 -0700 Subject: [PATCH] pcmcia: rescan bus always upon echoing into setup_done Always rescan the devices upon echo'ing something to available_resources_setup_done. This is needed for proper "coldplug" support. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cs_internal.h | 3 +-- drivers/pcmcia/ds.c | 38 +++++++++++++++++++++++++++++++++++--- drivers/pcmcia/socket_sysfs.c | 26 +++++++++++--------------- 3 files changed, 47 insertions(+), 20 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 211637390fb..7830d7e42ea 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -159,8 +159,7 @@ int pccard_access_configuration_register(struct pcmcia_socket *s, unsigned int f struct pcmcia_callback{ struct module *owner; int (*event) (struct pcmcia_socket *s, event_t event, int priority); - int (*resources_done) (struct pcmcia_socket *s); - void (*replace_cis) (void); + void (*requery) (struct pcmcia_socket *s); }; int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 0de0f230045..bde9b0513d9 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -717,9 +717,42 @@ static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s) return; } -static void pcmcia_bus_rescan(void) +static int pcmcia_requery(struct device *dev, void * _data) { + struct pcmcia_device *p_dev = to_pcmcia_dev(dev); + if (!p_dev->dev.driver) + pcmcia_device_query(p_dev); + + return 0; +} + +static void pcmcia_bus_rescan(struct pcmcia_socket *skt) +{ + int no_devices=0; + unsigned long flags; + /* must be called with skt_sem held */ + spin_lock_irqsave(&pcmcia_dev_list_lock, flags); + if (list_empty(&skt->pcmcia->devices_list)) + no_devices=1; + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + + /* if no devices were added for this socket yet because of + * missing resource information or other trouble, we need to + * do this now. */ + if (no_devices) { + int ret = pcmcia_card_add(skt); + if (ret) + return; + } + + /* some device information might have changed because of a CIS + * update or because we can finally read it correctly... so + * determine it again, overwriting old values if necessary. */ + bus_for_each_dev(&pcmcia_bus_type, NULL, NULL, pcmcia_requery); + + /* we re-scan all devices, not just the ones connected to this + * socket. This does not matter, though. */ bus_rescan_devices(&pcmcia_bus_type); } @@ -1861,8 +1894,7 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) /* Set up hotline to Card Services */ s->callback.owner = THIS_MODULE; s->callback.event = &ds_event; - s->callback.resources_done = &pcmcia_card_add; - s->callback.replace_cis = &pcmcia_bus_rescan; + s->callback.requery = &pcmcia_bus_rescan; socket->pcmcia = s; ret = pccard_register_pcmcia(socket, &s->callback); diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c index 8e66eeff672..fcef54c1c2d 100644 --- a/drivers/pcmcia/socket_sysfs.c +++ b/drivers/pcmcia/socket_sysfs.c @@ -163,24 +163,20 @@ static ssize_t pccard_store_resource(struct class_device *dev, const char *buf, return -EINVAL; spin_lock_irqsave(&s->lock, flags); - if (!s->resource_setup_done) { + if (!s->resource_setup_done) s->resource_setup_done = 1; - spin_unlock_irqrestore(&s->lock, flags); + spin_unlock_irqrestore(&s->lock, flags); - down(&s->skt_sem); - if ((s->callback) && - (s->state & SOCKET_PRESENT) && - !(s->state & SOCKET_CARDBUS)) { - if (try_module_get(s->callback->owner)) { - s->callback->resources_done(s); - module_put(s->callback->owner); - } + down(&s->skt_sem); + if ((s->callback) && + (s->state & SOCKET_PRESENT) && + !(s->state & SOCKET_CARDBUS)) { + if (try_module_get(s->callback->owner)) { + s->callback->requery(s); + module_put(s->callback->owner); } - up(&s->skt_sem); - - return count; } - spin_unlock_irqrestore(&s->lock, flags); + up(&s->skt_sem); return count; } @@ -315,7 +311,7 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz if ((s->callback) && (s->state & SOCKET_PRESENT) && !(s->state & SOCKET_CARDBUS)) { if (try_module_get(s->callback->owner)) { - s->callback->replace_cis(); + s->callback->requery(s); module_put(s->callback->owner); } } -- cgit v1.2.3 From 325aa29fe50eabe487efe360426c01eb42825e60 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:18 -0700 Subject: [PATCH] pcmcia: id_table for serial_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/serial_cs.c | 104 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'drivers') diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index 0d7b65f93e8..ca86f1f668f 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -772,6 +772,109 @@ serial_event(event_t event, int priority, event_callback_args_t * args) return 0; } +static struct pcmcia_device_id serial_ids[] = { + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0104, 0x000a), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0xea15), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0109, 0x0501), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0138, 0x110a), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0140, 0x000a), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0143, 0x3341), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0143, 0xc0ab), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x016c, 0x0081), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x021b, 0x0101), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x08a1, 0xc0ab), + PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x04cd2988, 0x46a52d63), + PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x0143b773, 0x46a52d63), + PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "EM1144T", "PCMCIA MODEM", 0xf510db04, 0x856d66c8, 0xbd6c43ef), + PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "XJEM1144/CCEM1144", "PCMCIA MODEM", 0xf510db04, 0x52d21e1e, 0xbd6c43ef), + PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "CEM28", 0x2e3ee845, 0x0ea978ea), + PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "CEM33", 0x2e3ee845, 0x80609023), + PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "CEM56", 0x2e3ee845, 0xa650c32a), + PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "REM10", 0x2e3ee845, 0x76df1d29), + PCMCIA_PFC_DEVICE_PROD_ID13(1, "Xircom", "XEM5600", 0x2e3ee845, 0xf1403719), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "AnyCom", "Fast Ethernet ", 0x578ba6e7, 0x02d92d1e), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "Gateway 2000", "XJEM3336", 0xdd9989be, 0x662c394c), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "Linksys", "EtherFast 10&100 + 56K PC Card (PCMLM56)", 0x0733cc81, 0xb3765033), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "LINKSYS", "PCMLM336", 0xf7cb0b07, 0x7a821b58), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "MEGAHERTZ", "XJEM1144/CCEM1144", 0xf510db04, 0x52d21e1e), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "Ositech", "Trumpcard", 0x0c2f80cd, 0x0573c29f), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "Ositech", "Trumpcard", 0x0c2f80cd, 0x0573c29f), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "PCMCIAs", "ComboCard", 0xdcfe12d3, 0xcd8906cc), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "PCMCIAs", "LanModem", 0xdcfe12d3, 0xc67c648f), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "TDK", "GlobalNetworker 3410/3412", 0x1eae9475, 0xd9a93bed), + PCMCIA_PFC_DEVICE_PROD_ID12(1, "Xircom", "CreditCard Ethernet", 0x2e3ee845, 0xc0e778c2), + PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0104, 0x0070), + PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0101, 0x0562), + PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0104, 0x0070), + PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x016c, 0x0020), + PCMCIA_MFC_DEVICE_PROD_ID123(1, "APEX DATA", "MULTICARD", "ETHERNET-MODEM", 0x11c2da09, 0x7289dc5d, 0xaad95e1f), + PCMCIA_MFC_DEVICE_PROD_ID12(1, "IBM", "Home and Away 28.8 PC Card ", 0xb569a6e5, 0x5bd4ff2c), + PCMCIA_MFC_DEVICE_PROD_ID12(1, "IBM", "Home and Away Credit Card Adapter", 0xb569a6e5, 0x4bdf15c3), + PCMCIA_MFC_DEVICE_PROD_ID12(1, "IBM", "w95 Home and Away Credit Card ", 0xb569a6e5, 0xae911c15), + PCMCIA_MFC_DEVICE_PROD_ID1(1, "Motorola MARQUIS", 0xf03e4e77), + PCMCIA_MFC_DEVICE_PROD_ID2(1, "FAX/Modem/Ethernet Combo Card ", 0x1ed59302), + PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0301), + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0039), + PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0006), + PCMCIA_DEVICE_MANF_CARD(0x0105, 0x410a), + PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d50), + PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d51), + PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d52), + PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0d53), + PCMCIA_DEVICE_MANF_CARD(0x010b, 0xd180), + PCMCIA_DEVICE_MANF_CARD(0x0137, 0x000e), + PCMCIA_DEVICE_MANF_CARD(0x0137, 0x001b), + PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0025), + PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0045), + PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0052), + PCMCIA_DEVICE_PROD_ID134("ADV", "TECH", "COMpad-32/85", 0x67459937, 0x916d02ba, 0x8fbe92ae), + PCMCIA_DEVICE_PROD_ID124("GATEWAY2000", "CC3144", "PCMCIA MODEM", 0x506bccae, 0xcb3685f1, 0xbd6c43ef), + PCMCIA_DEVICE_PROD_ID14("MEGAHERTZ", "PCMCIA MODEM", 0xf510db04, 0xbd6c43ef), + PCMCIA_DEVICE_PROD_ID124("TOSHIBA", "T144PF", "PCMCIA MODEM", 0xb4585a1a, 0x7271409c, 0xbd6c43ef), + PCMCIA_DEVICE_PROD_ID123("FUJITSU", "FC14F ", "MBH10213", 0x6ee5a3d8, 0x30ead12b, 0xb00f05a0), + PCMCIA_DEVICE_PROD_ID13("MEGAHERTZ", "V.34 PCMCIA MODEM", 0xf510db04, 0xbb2cce4a), + PCMCIA_DEVICE_PROD_ID12("Brain Boxes", "Bluetooth PC Card", 0xee138382, 0xd4ce9b02), + PCMCIA_DEVICE_PROD_ID12("CIRRUS LOGIC", "FAX MODEM", 0xe625f451, 0xcecd6dfa), + PCMCIA_DEVICE_PROD_ID12("COMPAQ", "PCMCIA 28800 FAX/DATA MODEM", 0xa3a3062c, 0x8cbd7c76), + PCMCIA_DEVICE_PROD_ID12("COMPAQ", "PCMCIA 33600 FAX/DATA MODEM", 0xa3a3062c, 0x5a00ce95), + PCMCIA_DEVICE_PROD_ID12("Computerboards, Inc.", "PCM-COM422", 0xd0b78f51, 0x7e2d49ed), + PCMCIA_DEVICE_PROD_ID12("Dr. Neuhaus", "FURY CARD 14K4", 0x76942813, 0x8b96ce65), + PCMCIA_DEVICE_PROD_ID12("Intelligent", "ANGIA FAX/MODEM", 0xb496e65e, 0xf31602a6), + PCMCIA_DEVICE_PROD_ID12("Intel", "MODEM 2400", 0x816cc815, 0x23539b80), + PCMCIA_DEVICE_PROD_ID12("IOTech Inc ", "PCMCIA Dual RS-232 Serial Port Card", 0x3bd2d898, 0x92abc92f), + PCMCIA_DEVICE_PROD_ID12("MACRONIX", "FAX/MODEM", 0x668388b3, 0x3f9bdf2f), + PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT1432LT", 0x5f73be51, 0x0b3e2383), + PCMCIA_DEVICE_PROD_ID12("Multi-Tech", "MT2834LT", 0x5f73be51, 0x4cd7c09e), + PCMCIA_DEVICE_PROD_ID12("OEM ", "C288MX ", 0xb572d360, 0xd2385b7a), + PCMCIA_DEVICE_PROD_ID12("PCMCIA ", "C336MX ", 0x99bcafe9, 0xaa25bcab), + PCMCIA_DEVICE_PROD_ID12("Quatech Inc", "PCMCIA Dual RS-232 Serial Port Card", 0xc4420b35, 0x92abc92f), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "PCMLM28.cis"), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(1, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"), + PCMCIA_MFC_DEVICE_CIS_PROD_ID12(1, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), + PCMCIA_MFC_DEVICE_CIS_PROD_ID4(1, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), + PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0556, "3CCFEM556.cis"), + PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0175, 0x0000, "DP83903.cis"), + PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x0035, "3CXEM556.cis"), + PCMCIA_MFC_DEVICE_CIS_MANF_CARD(1, 0x0101, 0x003d, "3CXEM556.cis"), + PCMCIA_DEVICE_CIS_PROD_ID12("MultiTech", "PCMCIA 56K DataFax", 0x842047ee, 0xc2efcf03, "MT5634ZLX.cis"), + PCMCIA_DEVICE_CIS_PROD_ID12("ADVANTECH", "COMpad-32/85B-4", 0x96913a85, 0xcec8f102, "COMpad4.cis"), + PCMCIA_DEVICE_CIS_PROD_ID123("ADVANTECH", "COMpad-32/85", "1.0", 0x96913a85, 0x8fbe92ae, 0x0877b627, "COMpad2.cis"), + PCMCIA_DEVICE_CIS_PROD_ID2("RS-COM 2P", 0xad20b156, "RS-COM-2P.cis"), + /* too generic */ + /* PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0160, 0x0002), */ + /* PCMCIA_MFC_DEVICE_MANF_CARD(1, 0x0160, 0x0002), */ + PCMCIA_DEVICE_FUNC_ID(2), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, serial_ids); + static struct pcmcia_driver serial_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -779,6 +882,7 @@ static struct pcmcia_driver serial_cs_driver = { }, .attach = serial_attach, .detach = serial_detach, + .id_table = serial_ids, }; static int __init init_serial_cs(void) -- cgit v1.2.3 From 270b6e94181d838194f621e773b9ab534371e618 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:18 -0700 Subject: [PATCH] pcmcia: id_table for 3c574_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/3c574_cs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index c6e8b25f968..f0fc04bd37c 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c @@ -1286,6 +1286,13 @@ static int el3_close(struct net_device *dev) return 0; } +static struct pcmcia_device_id tc574_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0574), + PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0556, "3CCFEM556.cis"), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, tc574_ids); + static struct pcmcia_driver tc574_driver = { .owner = THIS_MODULE, .drv = { @@ -1293,6 +1300,7 @@ static struct pcmcia_driver tc574_driver = { }, .attach = tc574_attach, .detach = tc574_detach, + .id_table = tc574_ids, }; static int __init init_tc574(void) -- cgit v1.2.3 From 7ffec58c1e35c1e8f716c64e4860dbb00be4b221 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:19 -0700 Subject: [PATCH] pcmcia: id_table for 3c589_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/3c589_cs.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index 89abdda1d34..8fa1b5f0fb6 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c @@ -1057,6 +1057,17 @@ static int el3_close(struct net_device *dev) return 0; } +static struct pcmcia_device_id tc589_ids[] = { + PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0101, 0x0562), + PCMCIA_MFC_DEVICE_PROD_ID1(0, "Motorola MARQUIS", 0xf03e4e77), + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0589), + PCMCIA_DEVICE_PROD_ID12("Farallon", "ENet", 0x58d93fc4, 0x992c2202), + PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0035, "3CXEM556.cis"), + PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x003d, "3CXEM556.cis"), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, tc589_ids); + static struct pcmcia_driver tc589_driver = { .owner = THIS_MODULE, .drv = { @@ -1064,6 +1075,7 @@ static struct pcmcia_driver tc589_driver = { }, .attach = tc589_attach, .detach = tc589_detach, + .id_table = tc589_ids, }; static int __init init_tc589(void) -- cgit v1.2.3 From 2dc27daa58ac579bff7d60043a23abd5e237cdda Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:19 -0700 Subject: [PATCH] pcmcia: id_table for aha152x Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/pcmcia/aha152x_stub.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c index e60b4c0a842..f1f6bf596dc 100644 --- a/drivers/scsi/pcmcia/aha152x_stub.c +++ b/drivers/scsi/pcmcia/aha152x_stub.c @@ -318,6 +318,16 @@ static int aha152x_event(event_t event, int priority, return 0; } +static struct pcmcia_device_id aha152x_ids[] = { + PCMCIA_DEVICE_PROD_ID123("New Media", "SCSI", "Bus Toaster", 0xcdf7e4cc, 0x35f26476, 0xa8851d6e), + PCMCIA_DEVICE_PROD_ID123("NOTEWORTHY", "SCSI", "Bus Toaster", 0xad89c6e8, 0x35f26476, 0xa8851d6e), + PCMCIA_DEVICE_PROD_ID12("Adaptec, Inc.", "APA-1460 SCSI Host Adapter", 0x24ba9738, 0x3a3c3d20), + PCMCIA_DEVICE_PROD_ID12("New Media Corporation", "Multimedia Sound/SCSI", 0x085a850b, 0x80a6535c), + PCMCIA_DEVICE_PROD_ID12("NOTEWORTHY", "NWCOMB02 SCSI/AUDIO COMBO CARD", 0xad89c6e8, 0x5f9a615b), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, aha152x_ids); + static struct pcmcia_driver aha152x_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -325,6 +335,7 @@ static struct pcmcia_driver aha152x_cs_driver = { }, .attach = aha152x_attach, .detach = aha152x_detach, + .id_table = aha152x_ids, }; static int __init init_aha152x_cs(void) -- cgit v1.2.3 From 7018d06d2371d67bdc995160fe2d38c6421b7c74 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:20 -0700 Subject: [PATCH] pcmcia: id_table for airo_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/airo_cs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers') diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c index fbf53af6cda..f10a9523034 100644 --- a/drivers/net/wireless/airo_cs.c +++ b/drivers/net/wireless/airo_cs.c @@ -559,6 +559,15 @@ static int airo_event(event_t event, int priority, return 0; } /* airo_event */ +static struct pcmcia_device_id airo_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a), + PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0005), + PCMCIA_DEVICE_MANF_CARD(0x015f, 0x0007), + PCMCIA_DEVICE_MANF_CARD(0x0105, 0x0007), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, airo_ids); + static struct pcmcia_driver airo_driver = { .owner = THIS_MODULE, .drv = { @@ -566,6 +575,7 @@ static struct pcmcia_driver airo_driver = { }, .attach = airo_attach, .detach = airo_detach, + .id_table = airo_ids, }; static int airo_cs_init(void) -- cgit v1.2.3 From c414f7550fedc0860a6cc65491006be49ac80edd Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:20 -0700 Subject: [PATCH] pcmcia: id_table for axnet_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/axnet_cs.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 853b586e481..23ce77b1d5b 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c @@ -850,6 +850,34 @@ static void block_output(struct net_device *dev, int count, outsw(nic_base + AXNET_DATAPORT, buf, count>>1); } +static struct pcmcia_device_id axnet_ids[] = { + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x016c, 0x0081), + PCMCIA_DEVICE_MANF_CARD(0x018a, 0x0301), + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0301), + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0303), + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0309), + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1106), + PCMCIA_DEVICE_MANF_CARD(0x8a01, 0xc1ab), + PCMCIA_DEVICE_PROD_ID124("Fast Ethernet", "16-bit PC Card", "AX88190", 0xb4be14e3, 0x9a12eb6a, 0xab9be5ef), + PCMCIA_DEVICE_PROD_ID12("ASIX", "AX88190", 0x0959823b, 0xab9be5ef), + PCMCIA_DEVICE_PROD_ID12("Billionton", "LNA-100B", 0x552ab682, 0xbc3b87e1), + PCMCIA_DEVICE_PROD_ID12("CHEETAH ETHERCARD", "EN2228", 0x00fa7bc8, 0x00e990cc), + PCMCIA_DEVICE_PROD_ID12("CNet", "CNF301", 0xbc477dde, 0x78c5f40b), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FEther PCC-TXD", 0x5261440f, 0x436768c5), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FEtherII PCC-TXD", 0x5261440f, 0x730df72e), + PCMCIA_DEVICE_PROD_ID12("Dynalink", "L100C16", 0x55632fd5, 0x66bc2a90), + PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100 V3)", 0x0733cc81, 0x232019a8), + PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC3-TX", 0x481e0094, 0xf91af609), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "100BASE", 0x281f1c5d, 0x7c2add04), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FastEtherCard", 0x281f1c5d, 0x7ef26116), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FEP501", 0x281f1c5d, 0x2e272058), + PCMCIA_DEVICE_PROD_ID14("Network Everywhere", "AX88190", 0x820a67b6, 0xab9be5ef), + /* this is not specific enough */ + /* PCMCIA_DEVICE_MANF_CARD(0x021b, 0x0202), */ + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, axnet_ids); + static struct pcmcia_driver axnet_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -857,6 +885,7 @@ static struct pcmcia_driver axnet_cs_driver = { }, .attach = axnet_attach, .detach = axnet_detach, + .id_table = axnet_ids, }; static int __init init_axnet_cs(void) -- cgit v1.2.3 From 2d1fb37621f40863929b60950406ec84d52bba16 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:21 -0700 Subject: [PATCH] pcmcia: id_table for fdomain_stub Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/pcmcia/fdomain_stub.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index 3df7bc72e35..853e6ee9b71 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -299,6 +299,15 @@ static int fdomain_event(event_t event, int priority, return 0; } /* fdomain_event */ + +static struct pcmcia_device_id fdomain_ids[] = { + PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20), + PCMCIA_DEVICE_PROD_ID1("SCSI PCMCIA Adapter Card", 0x8dacb57e), + PCMCIA_DEVICE_PROD_ID12(" SIMPLE TECHNOLOGY Corporation", "SCSI PCMCIA Credit Card Controller", 0x182bdafe, 0xc80d106f), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, fdomain_ids); + static struct pcmcia_driver fdomain_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -306,6 +315,7 @@ static struct pcmcia_driver fdomain_cs_driver = { }, .attach = fdomain_attach, .detach = fdomain_detach, + .id_table = fdomain_ids, }; static int __init init_fdomain_cs(void) -- cgit v1.2.3 From cda4de8e1e51d55f02c64210ddbaca73997f890d Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:22 -0700 Subject: [PATCH] pcmcia: id_table for fmvj18x_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/fmvj18x_cs.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 0424865e809..b17aedd5e5a 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -764,6 +764,29 @@ static int fmvj18x_event(event_t event, int priority, return 0; } /* fmvj18x_event */ +static struct pcmcia_device_id fmvj18x_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004), + PCMCIA_DEVICE_PROD_ID12("EAGLE Technology", "NE200 ETHERNET LAN MBH10302 04", 0x528c88c4, 0x74f91e59), + PCMCIA_DEVICE_PROD_ID12("Eiger Labs,Inc", "EPX-10BT PC Card Ethernet 10BT", 0x53af556e, 0x877f9922), + PCMCIA_DEVICE_PROD_ID12("Eiger labs,Inc.", "EPX-10BT PC Card Ethernet 10BT", 0xf47e6c66, 0x877f9922), + PCMCIA_DEVICE_PROD_ID12("FUJITSU", "LAN Card(FMV-J182)", 0x6ee5a3d8, 0x5baf31db), + PCMCIA_DEVICE_PROD_ID12("FUJITSU", "MBH10308", 0x6ee5a3d8, 0x3f04875e), + PCMCIA_DEVICE_PROD_ID12("FUJITSU TOWA", "LA501", 0xb8451188, 0x12939ba2), + PCMCIA_DEVICE_PROD_ID12("HITACHI", "HT-4840-11", 0xf4f43949, 0x773910f4), + PCMCIA_DEVICE_PROD_ID12("NextComK.K.", "NC5310B Ver1.0 ", 0x8cef4d3a, 0x075fc7b6), + PCMCIA_DEVICE_PROD_ID12("NextComK.K.", "NC5310 Ver1.0 ", 0x8cef4d3a, 0xbccf43e6), + PCMCIA_DEVICE_PROD_ID12("RATOC System Inc.", "10BASE_T CARD R280", 0x85c10e17, 0xd9413666), + PCMCIA_DEVICE_PROD_ID12("TDK", "LAC-CD02x", 0x1eae9475, 0x8fa0ee70), + PCMCIA_DEVICE_PROD_ID12("TDK", "LAC-CF010", 0x1eae9475, 0x7683bc9a), + PCMCIA_DEVICE_PROD_ID1("CONTEC Co.,Ltd.", 0x58d8fee2), + PCMCIA_DEVICE_PROD_ID1("PCMCIA LAN MBH10304 ES", 0x2599f454), + PCMCIA_DEVICE_PROD_ID1("PCMCIA MBH10302", 0x8f4005da), + PCMCIA_DEVICE_PROD_ID1("UBKK,V2.0", 0x90888080), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "TDK", "GlobalNetworker 3410/3412", 0x1eae9475, 0xd9a93bed), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, fmvj18x_ids); + static struct pcmcia_driver fmvj18x_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -771,6 +794,7 @@ static struct pcmcia_driver fmvj18x_cs_driver = { }, .attach = fmvj18x_attach, .detach = fmvj18x_detach, + .id_table = fmvj18x_ids, }; static int __init init_fmvj18x_cs(void) -- cgit v1.2.3 From 469bf2b9389c9265ac0920da5b1a5c71fe496213 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:22 -0700 Subject: [PATCH] pcmcia: id_table for ibmtr_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/ibmtr_cs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c index f0ff06e2041..cf6d073ea55 100644 --- a/drivers/net/pcmcia/ibmtr_cs.c +++ b/drivers/net/pcmcia/ibmtr_cs.c @@ -508,6 +508,13 @@ static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase) return; } +static struct pcmcia_device_id ibmtr_ids[] = { + PCMCIA_DEVICE_PROD_ID12("3Com", "TokenLink Velocity PC Card", 0x41240e5b, 0x82c3734e), + PCMCIA_DEVICE_PROD_ID12("IBM", "TOKEN RING", 0xb569a6e5, 0xbf8eed47), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, ibmtr_ids); + static struct pcmcia_driver ibmtr_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -515,6 +522,7 @@ static struct pcmcia_driver ibmtr_cs_driver = { }, .attach = ibmtr_attach, .detach = ibmtr_detach, + .id_table = ibmtr_ids, }; static int __init init_ibmtr_cs(void) -- cgit v1.2.3 From 5d402e95ebf8cc2fbf0e59e8424d65fe7847ad34 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:23 -0700 Subject: [PATCH] pcmcia: id_table for netwave_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/netwave_cs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index 382241e7edb..e12bd75b269 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c @@ -1668,6 +1668,12 @@ static int netwave_close(struct net_device *dev) { return 0; } +static struct pcmcia_device_id netwave_ids[] = { + PCMCIA_DEVICE_PROD_ID12("Xircom", "CreditCard Netwave", 0x2e3ee845, 0x54e28a28), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, netwave_ids); + static struct pcmcia_driver netwave_driver = { .owner = THIS_MODULE, .drv = { @@ -1675,6 +1681,7 @@ static struct pcmcia_driver netwave_driver = { }, .attach = netwave_attach, .detach = netwave_detach, + .id_table = netwave_ids, }; static int __init init_netwave_cs(void) -- cgit v1.2.3 From a58e26cb1163353d8a9b9cfd0d3f35df34f63141 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:23 -0700 Subject: [PATCH] pcmcia: id_table for nmclan_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/nmclan_cs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index 4603807fcaf..b86e7253fbf 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c @@ -1675,6 +1675,13 @@ static void set_multicast_list(struct net_device *dev) } /* set_multicast_list */ +static struct pcmcia_device_id nmclan_ids[] = { + PCMCIA_DEVICE_PROD_ID12("New Media Corporation", "Ethernet", 0x085a850b, 0x00b2e941), + PCMCIA_DEVICE_PROD_ID12("Portable Add-ons", "Ethernet", 0x0ebf1d60, 0x00b2e941), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, nmclan_ids); + static struct pcmcia_driver nmclan_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -1682,6 +1689,7 @@ static struct pcmcia_driver nmclan_cs_driver = { }, .attach = nmclan_attach, .detach = nmclan_detach, + .id_table = nmclan_ids, }; static int __init init_nmclan_cs(void) -- cgit v1.2.3 From 0a10d73dad86a023f343f80cc9cb71ea4e140192 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:24 -0700 Subject: [PATCH] pcmcia: id_table for teles_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/hisax/teles_cs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c index 63e8e20c17a..107376ff5b9 100644 --- a/drivers/isdn/hisax/teles_cs.c +++ b/drivers/isdn/hisax/teles_cs.c @@ -489,6 +489,12 @@ static int teles_cs_event(event_t event, int priority, return 0; } /* teles_cs_event */ +static struct pcmcia_device_id teles_ids[] = { + PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, teles_ids); + static struct pcmcia_driver teles_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -496,6 +502,7 @@ static struct pcmcia_driver teles_cs_driver = { }, .attach = teles_attach, .detach = teles_detach, + .id_table = teles_ids, }; static int __init init_teles_cs(void) -- cgit v1.2.3 From f57ea2a23245ba6db68f6a84ae903b3901965ade Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:24 -0700 Subject: [PATCH] pcmcia: id_table for ray_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/ray_cs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index 6e5bda56b8f..31652af52ea 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -2904,6 +2904,12 @@ static int write_int(struct file *file, const char __user *buffer, unsigned long } #endif +static struct pcmcia_device_id ray_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, ray_ids); + static struct pcmcia_driver ray_driver = { .owner = THIS_MODULE, .drv = { @@ -2911,6 +2917,7 @@ static struct pcmcia_driver ray_driver = { }, .attach = ray_attach, .detach = ray_detach, + .id_table = ray_ids, }; static int __init init_ray_cs(void) -- cgit v1.2.3 From b942123bcd6430afbb4d4c541bd6df996f02a68f Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:25 -0700 Subject: [PATCH] pcmcia: id_table for wavelan_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/wavelan_cs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers') diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index ec8329788e4..89532fd9294 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c @@ -4889,6 +4889,15 @@ wavelan_event(event_t event, /* The event received */ return 0; } +static struct pcmcia_device_id wavelan_ids[] = { + PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975), + PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06), + PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/PCMCIA", 0x23eb9949, 0x1bc50975), + PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/PCMCIA", 0x24358cd4, 0x1bc50975), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, wavelan_ids); + static struct pcmcia_driver wavelan_driver = { .owner = THIS_MODULE, .drv = { @@ -4896,6 +4905,7 @@ static struct pcmcia_driver wavelan_driver = { }, .attach = wavelan_attach, .detach = wavelan_detach, + .id_table = wavelan_ids, }; static int __init -- cgit v1.2.3 From 2a355d07f2196d1d17aeebaa29a743f90e53dbd7 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:25 -0700 Subject: [PATCH] pcmcia: id_table for sym53c500_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/pcmcia/sym53c500_cs.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 1667da9508b..7d4b16b6797 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -999,6 +999,14 @@ MODULE_AUTHOR("Bob Tracy "); MODULE_DESCRIPTION("SYM53C500 PCMCIA SCSI driver"); MODULE_LICENSE("GPL"); +static struct pcmcia_device_id sym53c500_ids[] = { + PCMCIA_DEVICE_PROD_ID12("BASICS by New Media Corporation", "SCSI Sym53C500", 0x23c78a9d, 0x0099e7f7), + PCMCIA_DEVICE_PROD_ID12("New Media Corporation", "SCSI Bus Toaster Sym53C500", 0x085a850b, 0x45432eb8), + PCMCIA_DEVICE_PROD_ID2("SCSI9000", 0x21648f44), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, sym53c500_ids); + static struct pcmcia_driver sym53c500_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -1006,6 +1014,7 @@ static struct pcmcia_driver sym53c500_cs_driver = { }, .attach = SYM53C500_attach, .detach = SYM53C500_detach, + .id_table = sym53c500_ids, }; static int __init -- cgit v1.2.3 From 7a5a6eeb6de79ab36ef1fceae8cc3c334b43fddc Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:26 -0700 Subject: [PATCH] pcmcia: id_table for qlogic_stub.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/pcmcia/qlogic_stub.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c index a0175f5d11c..0dcf41102ab 100644 --- a/drivers/scsi/pcmcia/qlogic_stub.c +++ b/drivers/scsi/pcmcia/qlogic_stub.c @@ -395,6 +395,27 @@ static int qlogic_event(event_t event, int priority, event_callback_args_t * arg return 0; } /* qlogic_event */ +static struct pcmcia_device_id qlogic_ids[] = { + PCMCIA_DEVICE_PROD_ID12("EIger Labs", "PCMCIA-to-SCSI Adapter", 0x88395fa7, 0x33b7a5e6), + PCMCIA_DEVICE_PROD_ID12("EPSON", "SCSI-2 PC Card SC200", 0xd361772f, 0x299d1751), + PCMCIA_DEVICE_PROD_ID12("MACNICA", "MIRACLE SCSI-II mPS110", 0x20841b68, 0xab3c3b6d), + PCMCIA_DEVICE_PROD_ID12("MIDORI ELECTRONICS ", "CN-SC43", 0x6534382a, 0xd67eee79), + PCMCIA_DEVICE_PROD_ID12("NEC", "PC-9801N-J03R", 0x18df0ba0, 0x24662e8a), + PCMCIA_DEVICE_PROD_ID12("KME ", "KXLC003", 0x82375a27, 0xf68e5bf7), + PCMCIA_DEVICE_PROD_ID12("KME ", "KXLC004", 0x82375a27, 0x68eace54), + PCMCIA_DEVICE_PROD_ID12("KME", "KXLC101", 0x3faee676, 0x194250ec), + PCMCIA_DEVICE_PROD_ID12("QLOGIC CORPORATION", "pc05", 0xd77b2930, 0xa85b2735), + PCMCIA_DEVICE_PROD_ID12("QLOGIC CORPORATION", "pc05 rev 1.10", 0xd77b2930, 0x70f8b5f8), + PCMCIA_DEVICE_PROD_ID123("KME", "KXLC002", "00", 0x3faee676, 0x81896b61, 0xf99f065f), + PCMCIA_DEVICE_PROD_ID12("RATOC System Inc.", "SCSI2 CARD 37", 0x85c10e17, 0x1a2640c1), + PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "SCSC200A PC CARD SCSI", 0xb4585a1a, 0xa6f06ebe), + PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "SCSC200B PC CARD SCSI-10", 0xb4585a1a, 0x0a88dea0), + /* these conflict with other cards! */ + /* PCMCIA_DEVICE_PROD_ID123("MACNICA", "MIRACLE SCSI", "mPS100", 0x20841b68, 0xf8dedaeb, 0x89f7fafb), */ + /* PCMCIA_DEVICE_PROD_ID123("MACNICA", "MIRACLE SCSI", "mPS100", 0x20841b68, 0xf8dedaeb, 0x89f7fafb), */ + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, qlogic_ids); static struct pcmcia_driver qlogic_cs_driver = { .owner = THIS_MODULE, @@ -403,6 +424,7 @@ static struct pcmcia_driver qlogic_cs_driver = { }, .attach = qlogic_attach, .detach = qlogic_detach, + .id_table = qlogic_ids, }; static int __init init_qlogic_cs(void) -- cgit v1.2.3 From 5c672220694345ee5c3f2cf0becd3bd27dd663ad Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:27 -0700 Subject: [PATCH] pcmcia: id_table for smc91c92_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/smc91c92_cs.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 8a5e52c40e4..bc01c88c670 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c @@ -2327,6 +2327,38 @@ static int smc_ioctl (struct net_device *dev, struct ifreq *rq, int cmd) return rc; } +static struct pcmcia_device_id smc91c92_ids[] = { + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0109, 0x0501), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0140, 0x000a), + PCMCIA_PFC_DEVICE_PROD_ID123(0, "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x04cd2988, 0x46a52d63), + PCMCIA_PFC_DEVICE_PROD_ID123(0, "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x0143b773, 0x46a52d63), + PCMCIA_PFC_DEVICE_PROD_ID123(0, "MEGAHERTZ", "EM1144T", "PCMCIA MODEM", 0xf510db04, 0x856d66c8, 0xbd6c43ef), + PCMCIA_PFC_DEVICE_PROD_ID123(0, "MEGAHERTZ", "XJEM1144/CCEM1144", "PCMCIA MODEM", 0xf510db04, 0x52d21e1e, 0xbd6c43ef), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "Gateway 2000", "XJEM3336", 0xdd9989be, 0x662c394c), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "MEGAHERTZ", "XJEM1144/CCEM1144", 0xf510db04, 0x52d21e1e), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "Ositech", "Trumpcard", 0x0c2f80cd, 0x0573c29f), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "Ositech", "Trumpcard", 0x0c2f80cd, 0x0573c29f), + PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x016c, 0x0020), + PCMCIA_DEVICE_MANF_CARD(0x016c, 0x0023), + PCMCIA_DEVICE_PROD_ID123("BASICS by New Media Corporation", "Ethernet", "SMC91C94", 0x23c78a9d, 0x00b2e941, 0xcef397fb), + PCMCIA_DEVICE_PROD_ID12("ARGOSY", "Fast Ethernet PCCard", 0x78f308dc, 0xdcea68bc), + PCMCIA_DEVICE_PROD_ID12("dit Co., Ltd.", "PC Card-10/100BTX", 0xe59365c8, 0x6a2161d1), + PCMCIA_DEVICE_PROD_ID12("DYNALINK", "L100C", 0x6a26d1cf, 0xc16ce9c5), + PCMCIA_DEVICE_PROD_ID12("Farallon", "Farallon Enet", 0x58d93fc4, 0x244734e9), + PCMCIA_DEVICE_PROD_ID12("Megahertz", "CC10BT/2", 0x33234748, 0x3c95b953), + PCMCIA_DEVICE_PROD_ID12("MELCO/SMC", "LPC-TX", 0xa2cd8e6d, 0x42da662a), + PCMCIA_DEVICE_PROD_ID12("Ositech", "Trumpcard", 0x0c2f80cd, 0x0573c29f), + PCMCIA_DEVICE_PROD_ID12("Ositech", "Trumpcard", 0x0c2f80cd, 0x0573c29f), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Fast Ethernet PCCard", 0x281f1c5d, 0xdcea68bc), + PCMCIA_DEVICE_PROD_ID12("Psion", "10Mb Ethernet", 0x4ef00b21, 0x844be9e9), + PCMCIA_DEVICE_PROD_ID12("SMC", "EtherEZ Ethernet 8020", 0xc4f8b18b, 0x4a0eeb2d), + /* These conflict with other cards! */ + /* PCMCIA_DEVICE_MANF_CARD(0x0186, 0x0100), */ + /* PCMCIA_DEVICE_MANF_CARD(0x8a01, 0xc1ab), */ + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, smc91c92_ids); + static struct pcmcia_driver smc91c92_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -2334,6 +2366,7 @@ static struct pcmcia_driver smc91c92_cs_driver = { }, .attach = smc91c92_attach, .detach = smc91c92_detach, + .id_table = smc91c92_ids, }; static int __init init_smc91c92_cs(void) -- cgit v1.2.3 From 7422c56da9d985234e0b62307cbbd0dcf9b97593 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:27 -0700 Subject: [PATCH] pcmcia: id_table for orinoco_cs Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/orinoco_cs.c | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'drivers') diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c index 74a8227256a..597c4586d04 100644 --- a/drivers/net/wireless/orinoco_cs.c +++ b/drivers/net/wireless/orinoco_cs.c @@ -608,6 +608,56 @@ static char version[] __initdata = DRIVER_NAME " " DRIVER_VERSION " (David Gibson , " "Pavel Roskin , et al)"; +static struct pcmcia_device_id orinoco_cs_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), + PCMCIA_DEVICE_MANF_CARD(0x0089, 0x0001), + PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0x0156, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0x01eb, 0x080a), + PCMCIA_DEVICE_MANF_CARD(0x0261, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0x0268, 0x0001), + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0305), + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613), + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0673), + PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0x02ac, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0x14ea, 0xb001), + PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300), + PCMCIA_DEVICE_MANF_CARD(0x9005, 0x0021), + PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002), + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005), + PCMCIA_DEVICE_PROD_ID12("3Com", "3CRWE737A AirConnect Wireless LAN PC Card", 0x41240e5b, 0x56010af3), + PCMCIA_DEVICE_PROD_ID123("Instant Wireless ", " Network PC CARD", "Version 01.02", 0x11d901af, 0x6e9bd926, 0x4b74baa0), + PCMCIA_DEVICE_PROD_ID12("ACTIONTEC", "PRISM Wireless LAN PC Card", 0x393089da, 0xa71e69d5), + PCMCIA_DEVICE_PROD_ID12("Avaya Communication", "Avaya Wireless PC Card", 0xd8a43b78, 0x0d341169), + PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-PCM-L11G", 0x2decece3, 0xf57ca4b3), + PCMCIA_DEVICE_PROD_ID12("Cabletron", "RoamAbout 802.11 DS", 0x32d445f5, 0xedeffd90), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCC-11", 0x5261440f, 0xa6405584), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "Wireless LAN PCCA-11", 0x5261440f, 0xdf6115f9), + PCMCIA_DEVICE_PROD_ID12("D", "Link DRC-650 11Mbps WLAN Card", 0x71b18589, 0xf144e3ac), + PCMCIA_DEVICE_PROD_ID12("D", "Link DWL-650 11Mbps WLAN Card", 0x71b18589, 0xb6f1b0ab), + PCMCIA_DEVICE_PROD_ID12("ELSA", "AirLancer MC-11", 0x4507a33a, 0xef54f0e3), + PCMCIA_DEVICE_PROD_ID12("HyperLink", "Wireless PC Card 11Mbps", 0x56cc3f1a, 0x0bcf220c), + PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE", 0x74c5e40d, 0xdb472a18), + PCMCIA_DEVICE_PROD_ID12("Lucent Technologies", "WaveLAN/IEEE", 0x23eb9949, 0xc562e72a), + PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11", 0x481e0094, 0x7360e410), + PCMCIA_DEVICE_PROD_ID12("MELCO", "WLI-PCM-L11G", 0x481e0094, 0xf57ca4b3), + PCMCIA_DEVICE_PROD_ID12("Microsoft", "Wireless Notebook Adapter MN-520", 0x5961bf85, 0x6eec8c01), + PCMCIA_DEVICE_PROD_ID12("NCR", "WaveLAN/IEEE", 0x24358cd4, 0xc562e72a), + PCMCIA_DEVICE_PROD_ID12("NETGEAR MA401RA Wireless PC", "Card", 0x0306467f, 0x9762e8f1), + PCMCIA_DEVICE_PROD_ID12("PLANEX", "GeoWave/GW-CF110", 0x209f40ab, 0xd9715264), + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PC CARD HARMONY 80211B", 0xc6536a5e, 0x090c3cd9), + PCMCIA_DEVICE_PROD_ID12("PROXIM", "LAN PCI CARD HARMONY 80211B", 0xc6536a5e, 0x9f494e26), + PCMCIA_DEVICE_PROD_ID12("SAMSUNG", "11Mbps WLAN Card", 0x43d74cb4, 0x579bd91b), + PCMCIA_DEVICE_PROD_ID1("Symbol Technologies", 0x3f02b4d6), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, orinoco_cs_ids); + static struct pcmcia_driver orinoco_driver = { .owner = THIS_MODULE, .drv = { @@ -615,6 +665,7 @@ static struct pcmcia_driver orinoco_driver = { }, .attach = orinoco_cs_attach, .detach = orinoco_cs_detach, + .id_table = orinoco_cs_ids, }; static int __init -- cgit v1.2.3 From ff07bb19d0f605d08a9649a3f94acf3e4a79819c Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:28 -0700 Subject: [PATCH] pcmcia: id_table for xirc2ps_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/xirc2ps_cs.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index 58177d67ea1..0cd225e1595 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c @@ -1983,6 +1983,33 @@ do_stop(struct net_device *dev) return 0; } +static struct pcmcia_device_id xirc2ps_ids[] = { + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0089, 0x110a), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0138, 0x110a), + PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "CEM28", 0x2e3ee845, 0x0ea978ea), + PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "CEM33", 0x2e3ee845, 0x80609023), + PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "CEM56", 0x2e3ee845, 0xa650c32a), + PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "REM10", 0x2e3ee845, 0x76df1d29), + PCMCIA_PFC_DEVICE_PROD_ID13(0, "Xircom", "XEM5600", 0x2e3ee845, 0xf1403719), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "Xircom", "CreditCard Ethernet", 0x2e3ee845, 0xc0e778c2), + PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x010a), + PCMCIA_DEVICE_PROD_ID13("Toshiba Information Systems", "TPCENET", 0x1b3b94fe, 0xf381c1a2), + PCMCIA_DEVICE_PROD_ID13("Xircom", "CE3-10/100", 0x2e3ee845, 0x0ec0ac37), + PCMCIA_DEVICE_PROD_ID13("Xircom", "PS-CE2-10", 0x2e3ee845, 0x947d9073), + PCMCIA_DEVICE_PROD_ID13("Xircom", "R2E-100BTX", 0x2e3ee845, 0x2464a6e3), + PCMCIA_DEVICE_PROD_ID13("Xircom", "RE-10", 0x2e3ee845, 0x3e08d609), + PCMCIA_DEVICE_PROD_ID13("Xircom", "XE2000", 0x2e3ee845, 0xf7188e46), + PCMCIA_DEVICE_PROD_ID12("Compaq", "Ethernet LAN Card", 0x54f7c49c, 0x9fd2f0a2), + PCMCIA_DEVICE_PROD_ID12("Compaq", "Netelligent 10/100 PC Card", 0x54f7c49c, 0xefe96769), + PCMCIA_DEVICE_PROD_ID12("Intel", "EtherExpress(TM) PRO/100 PC Card Mobile Adapter16", 0x816cc815, 0x174397db), + PCMCIA_DEVICE_PROD_ID12("Toshiba", "10/100 Ethernet PC Card", 0x44a09d9c, 0xb44deecf), + /* also matches CFE-10 cards! */ + /* PCMCIA_DEVICE_MANF_CARD(0x0105, 0x010a), */ + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, xirc2ps_ids); + + static struct pcmcia_driver xirc2ps_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -1990,6 +2017,7 @@ static struct pcmcia_driver xirc2ps_cs_driver = { }, .attach = xirc2ps_attach, .detach = xirc2ps_detach, + .id_table = xirc2ps_ids, }; static int __init -- cgit v1.2.3 From f70b7d40d85a50c1f6d35350942501c4b0558335 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:28 -0700 Subject: [PATCH] pcmcia: id_table for ide_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/legacy/ide-cs.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'drivers') diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index e20327e54b1..3c6ef260471 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -457,6 +457,39 @@ int ide_event(event_t event, int priority, return 0; } /* ide_event */ +static struct pcmcia_device_id ide_ids[] = { + PCMCIA_DEVICE_FUNC_ID(4), + PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), + PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), + PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), + PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), + PCMCIA_DEVICE_PROD_ID123("CDROM", "IDE", "MCD-601p", 0x1b9179ca, 0xede88951, 0x0d902f74), + PCMCIA_DEVICE_PROD_ID123("PCMCIA", "IDE CARD", "F1", 0x281f1c5d, 0x1907960c, 0xf7fde8b9), + PCMCIA_DEVICE_PROD_ID12("ARGOSY", "CD-ROM", 0x78f308dc, 0x66536591), + PCMCIA_DEVICE_PROD_ID12("ARGOSY", "PnPIDE", 0x78f308dc, 0x0c694728), + PCMCIA_DEVICE_PROD_ID12("CNF CD-M", "CD-ROM", 0x7d93b852, 0x66536591), + PCMCIA_DEVICE_PROD_ID12("Creative Technology Ltd.", "PCMCIA CD-ROM Interface Card", 0xff8c8a45, 0xfe8020c4), + PCMCIA_DEVICE_PROD_ID12("Digital Equipment Corporation.", "Digital Mobile Media CD-ROM", 0x17692a66, 0xef1dcbde), + PCMCIA_DEVICE_PROD_ID12("EXP", "CD", 0x6f58c983, 0xaae5994f), + PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591), + PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728), + PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), + PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), + PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), + PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), + PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDEII", 0x547e66dc, 0xb3662674), + PCMCIA_DEVICE_PROD_ID12("LOOKMEET", "CBIDE2 ", 0xe37be2b5, 0x8671043b), + PCMCIA_DEVICE_PROD_ID12(" ", "NinjaATA-", 0x3b6e20c8, 0xebe0bd79), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "CD-ROM", 0x281f1c5d, 0x66536591), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "PnPIDE", 0x281f1c5d, 0x0c694728), + PCMCIA_DEVICE_PROD_ID12("SHUTTLE TECHNOLOGY LTD.", "PCCARD-IDE/ATAPI Adapter", 0x4a3f0ba0, 0x322560e1), + PCMCIA_DEVICE_PROD_ID12("TOSHIBA", "MK2001MPL", 0xb4585a1a, 0x3489e003), + PCMCIA_DEVICE_PROD_ID12("WIT", "IDE16", 0x244e5994, 0x3e232852), + PCMCIA_DEVICE_PROD_ID1("STI Flash", 0xe4a13209), + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, ide_ids); + static struct pcmcia_driver ide_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -464,6 +497,7 @@ static struct pcmcia_driver ide_cs_driver = { }, .attach = ide_attach, .detach = ide_detach, + .id_table = ide_ids, }; static int __init init_ide_cs(void) -- cgit v1.2.3 From f8f7cc03bcb52e3f4894635aa1e7b9fca2f9ec67 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:29 -0700 Subject: [PATCH] pcmcia: more IDs for ide_cs Add another ID for ide-cs Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/ide/legacy/ide-cs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 3c6ef260471..978d27d6452 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c @@ -462,6 +462,7 @@ static struct pcmcia_device_id ide_ids[] = { PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), + PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), PCMCIA_DEVICE_PROD_ID123("CDROM", "IDE", "MCD-601p", 0x1b9179ca, 0xede88951, 0x0d902f74), PCMCIA_DEVICE_PROD_ID123("PCMCIA", "IDE CARD", "F1", 0x281f1c5d, 0x1907960c, 0xf7fde8b9), -- cgit v1.2.3 From 476835afd7fefa353e932e160c14effc67e2ba6e Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:29 -0700 Subject: [PATCH] pcmcia: id_table for parport_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/parport/parport_cs.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index a3fa8185af2..ff45662c4f7 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c @@ -373,6 +373,13 @@ int parport_event(event_t event, int priority, return 0; } /* parport_event */ +static struct pcmcia_device_id parport_ids[] = { + PCMCIA_DEVICE_FUNC_ID(3), + PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0003), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, parport_ids); + static struct pcmcia_driver parport_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -380,6 +387,8 @@ static struct pcmcia_driver parport_cs_driver = { }, .attach = parport_attach, .detach = parport_detach, + .id_table = parport_ids, + }; static int __init init_parport_cs(void) -- cgit v1.2.3 From ce8a0037e110c1f4ec2fac7a3d791043e4e38cfc Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:30 -0700 Subject: [PATCH] pcmcia: id_table for pcnet_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/pcnet_cs.c | 198 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index f3ea4a9f2bf..cdcc46e1f11 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -1637,6 +1637,203 @@ failed: /*====================================================================*/ +static struct pcmcia_device_id pcnet_ids[] = { + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0057, 0x0021), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0104, 0x000a), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0xea15), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0143, 0x3341), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0143, 0xc0ab), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x021b, 0x0101), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x08a1, 0xc0ab), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "AnyCom", "Fast Ethernet ", 0x578ba6e7, 0x02d92d1e), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "D-Link", "DME336T", 0x1a424a1c, 0xb23897ff), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "Grey Cell", "GCS3000", 0x2a151fac, 0x48b932ae), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "Linksys", "EtherFast 10&100 + 56K PC Card (PCMLM56)", 0x0733cc81, 0xb3765033), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "LINKSYS", "PCMLM336", 0xf7cb0b07, 0x7a821b58), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "PCMCIAs", "ComboCard", 0xdcfe12d3, 0xcd8906cc), + PCMCIA_PFC_DEVICE_PROD_ID12(0, "PCMCIAs", "LanModem", 0xdcfe12d3, 0xc67c648f), + PCMCIA_MFC_DEVICE_PROD_ID12(0, "IBM", "Home and Away 28.8 PC Card ", 0xb569a6e5, 0x5bd4ff2c), + PCMCIA_MFC_DEVICE_PROD_ID12(0, "IBM", "Home and Away Credit Card Adapter", 0xb569a6e5, 0x4bdf15c3), + PCMCIA_MFC_DEVICE_PROD_ID12(0, "IBM", "w95 Home and Away Credit Card ", 0xb569a6e5, 0xae911c15), + PCMCIA_MFC_DEVICE_PROD_ID123(0, "APEX DATA", "MULTICARD", "ETHERNET-MODEM", 0x11c2da09, 0x7289dc5d, 0xaad95e1f), + PCMCIA_MFC_DEVICE_PROD_ID2(0, "FAX/Modem/Ethernet Combo Card ", 0x1ed59302), + PCMCIA_DEVICE_MANF_CARD(0x0057, 0x1004), + PCMCIA_DEVICE_MANF_CARD(0x0104, 0x000d), + PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0075), + PCMCIA_DEVICE_MANF_CARD(0x0104, 0x0145), + PCMCIA_DEVICE_MANF_CARD(0x0149, 0x0230), + PCMCIA_DEVICE_MANF_CARD(0x0149, 0x4530), +/* PCMCIA_DEVICE_MANF_CARD(0x0149, 0xc1ab), conflict with axnet_cs */ + PCMCIA_DEVICE_MANF_CARD(0x0186, 0x0110), + PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x2328), + PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x8041), + PCMCIA_DEVICE_MANF_CARD(0x0213, 0x2452), +/* PCMCIA_DEVICE_MANF_CARD(0x021b, 0x0202), conflict with axnet_cs */ + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0300), + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x0307), + PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030a), + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1103), + PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1121), + PCMCIA_DEVICE_PROD_ID12("2408LAN", "Ethernet", 0x352fff7f, 0x00b2e941), + PCMCIA_DEVICE_PROD_ID123("Cardwell", "PCMCIA", "ETHERNET", 0x9533672e, 0x281f1c5d, 0x3ff7175b), + PCMCIA_DEVICE_PROD_ID123("CNet ", "CN30BC", "ETHERNET", 0x9fe55d3d, 0x85601198, 0x3ff7175b), + PCMCIA_DEVICE_PROD_ID123("Digital", "Ethernet", "Adapter", 0x9999ab35, 0x00b2e941, 0x4b0d829e), + PCMCIA_DEVICE_PROD_ID123("Edimax Technology Inc.", "PCMCIA", "Ethernet Card", 0x738a0019, 0x281f1c5d, 0x5e9d92c0), + PCMCIA_DEVICE_PROD_ID123("EFA ", "EFA207", "ETHERNET", 0x3d294be4, 0xeb9aab6c, 0x3ff7175b), + PCMCIA_DEVICE_PROD_ID123("I-O DATA", "PCLA", "ETHERNET", 0x1d55d7ec, 0xe4c64d34, 0x3ff7175b), + PCMCIA_DEVICE_PROD_ID123("IO DATA", "PCLATE", "ETHERNET", 0x547e66dc, 0x6b260753, 0x3ff7175b), + PCMCIA_DEVICE_PROD_ID123("KingMax Technology Inc.", "EN10-T2", "PCMCIA Ethernet Card", 0x932b7189, 0x699e4436, 0x6f6652e0), + PCMCIA_DEVICE_PROD_ID123("PCMCIA", "PCMCIA-ETHERNET-CARD", "UE2216", 0x281f1c5d, 0xd4cd2f20, 0xb87add82), + PCMCIA_DEVICE_PROD_ID123("PCMCIA", "PCMCIA-ETHERNET-CARD", "UE2620", 0x281f1c5d, 0xd4cd2f20, 0x7d3d83a8), + PCMCIA_DEVICE_PROD_ID1("2412LAN", 0x67f236ab), + PCMCIA_DEVICE_PROD_ID12("ACCTON", "EN2212", 0xdfc6b5b2, 0xcb112a11), + PCMCIA_DEVICE_PROD_ID12("ACCTON", "EN2216-PCMCIA-ETHERNET", 0xdfc6b5b2, 0x5542bfff), + PCMCIA_DEVICE_PROD_ID12("Allied Telesis, K.K.", "CentreCOM LA100-PCM-T V2 100/10M LAN PC Card", 0xbb7fbdd7, 0xcd91cc68), + PCMCIA_DEVICE_PROD_ID12("Allied Telesis, K.K.", "CentreCOM LA-PCM", 0xbb7fbdd7, 0x5ba10d49), + PCMCIA_DEVICE_PROD_ID12("Allied Telesis K.K.", "LA100-PCM V2", 0x36634a66, 0xc6d05997), + PCMCIA_DEVICE_PROD_ID12("AmbiCom", "AMB8010", 0x5070a7f9, 0x82f96e96), + PCMCIA_DEVICE_PROD_ID12("AmbiCom", "AMB8610", 0x5070a7f9, 0x86741224), + PCMCIA_DEVICE_PROD_ID12("AmbiCom Inc", "AMB8002", 0x93b15570, 0x75ec3efb), + PCMCIA_DEVICE_PROD_ID12("AmbiCom Inc", "AMB8002T", 0x93b15570, 0x461c5247), + PCMCIA_DEVICE_PROD_ID12("AmbiCom Inc", "AMB8010", 0x93b15570, 0x82f96e96), + PCMCIA_DEVICE_PROD_ID12("AnyCom", "ECO Ethernet", 0x578ba6e7, 0x0a9888c1), + PCMCIA_DEVICE_PROD_ID12("AnyCom", "ECO Ethernet 10/100", 0x578ba6e7, 0x939fedbd), + PCMCIA_DEVICE_PROD_ID12("AROWANA", "PCMCIA Ethernet LAN Card", 0x313adbc8, 0x08d9f190), + PCMCIA_DEVICE_PROD_ID12("ASANTE", "FriendlyNet PC Card", 0x3a7ade0f, 0x41c64504), + PCMCIA_DEVICE_PROD_ID12("Billionton", "LNT-10TB", 0x552ab682, 0xeeb1ba6a), + PCMCIA_DEVICE_PROD_ID12("CF", "10Base-Ethernet", 0x44ebf863, 0x93ae4d79), + PCMCIA_DEVICE_PROD_ID12("CNet", "CN40BC Ethernet", 0xbc477dde, 0xfba775a7), + PCMCIA_DEVICE_PROD_ID12("COMPU-SHACK", "BASEline PCMCIA 10 MBit Ethernetadapter", 0xfa2e424d, 0xe9190d8a), + PCMCIA_DEVICE_PROD_ID12("COMPU-SHACK", "FASTline PCMCIA 10/100 Fast-Ethernet", 0xfa2e424d, 0x3953d9b9), + PCMCIA_DEVICE_PROD_ID12("CONTEC", "C-NET(PC)C-10L", 0x21cab552, 0xf6f90722), + PCMCIA_DEVICE_PROD_ID12("corega", "FEther PCC-TXF", 0x0a21501a, 0xa51564a2), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-T", 0x5261440f, 0xfa9d85bd), + PCMCIA_DEVICE_PROD_ID12("Corega K.K.", "corega EtherII PCC-TD", 0xd4fdcbd8, 0xc49bd73d), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega Ether PCC-T", 0x5261440f, 0x6705fcaa), + PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FastEther PCC-TX", 0x5261440f, 0x485e85d9), + PCMCIA_DEVICE_PROD_ID12("Corega,K.K.", "Ethernet LAN Card", 0x110d26d9, 0x9fd2f0a2), + PCMCIA_DEVICE_PROD_ID12("corega,K.K.", "Ethernet LAN Card", 0x9791a90e, 0x9fd2f0a2), + PCMCIA_DEVICE_PROD_ID12("CouplerlessPCMCIA", "100BASE", 0xee5af0ad, 0x7c2add04), + PCMCIA_DEVICE_PROD_ID12("CyQ've", "ELA-010", 0x77008979, 0x9d8d445d), + PCMCIA_DEVICE_PROD_ID12("CyQ've", "ELA-110E 10/100M LAN Card", 0x77008979, 0xfd184814), + PCMCIA_DEVICE_PROD_ID12("DataTrek.", "NetCard ", 0x5cd66d9d, 0x84697ce0), + PCMCIA_DEVICE_PROD_ID12("Dayna Communications, Inc.", "CommuniCard E", 0x0c629325, 0xb4e7dbaf), + PCMCIA_DEVICE_PROD_ID12("Digicom", "Palladio LAN 10/100", 0x697403d8, 0xe160b995), + PCMCIA_DEVICE_PROD_ID12("Digicom", "Palladio LAN 10/100 Dongless", 0x697403d8, 0xa6d3b233), + PCMCIA_DEVICE_PROD_ID12("DIGITAL", "DEPCM-XX", 0x69616cb3, 0xe600e76e), + PCMCIA_DEVICE_PROD_ID12("D-Link", "DE-650", 0x1a424a1c, 0xf28c8398), + PCMCIA_DEVICE_PROD_ID12("D-Link", "DE-660", 0x1a424a1c, 0xd9a1d05b), + PCMCIA_DEVICE_PROD_ID12("D-Link", "DFE-650", 0x1a424a1c, 0x0f0073f9), + PCMCIA_DEVICE_PROD_ID12("Dual Speed", "10/100 PC Card", 0x725b842d, 0xf1efee84), + PCMCIA_DEVICE_PROD_ID12("Dual Speed", "10/100 Port Attached PC Card", 0x725b842d, 0x2db1f8e9), + PCMCIA_DEVICE_PROD_ID12("Dynalink", "L10BC", 0x55632fd5, 0xdc65f2b1), + PCMCIA_DEVICE_PROD_ID12("DYNALINK", "L10BC", 0x6a26d1cf, 0xdc65f2b1), + PCMCIA_DEVICE_PROD_ID12("DYNALINK", "L10C", 0x6a26d1cf, 0xc4f84efb), + PCMCIA_DEVICE_PROD_ID12("E-CARD", "E-CARD", 0x6701da11, 0x6701da11), + PCMCIA_DEVICE_PROD_ID12("EIGER Labs Inc.", "Ethernet 10BaseT card", 0x53c864c6, 0xedd059f6), + PCMCIA_DEVICE_PROD_ID12("EIGER Labs Inc.", "Ethernet Combo card", 0x53c864c6, 0x929c486c), + PCMCIA_DEVICE_PROD_ID12("Ethernet", "Adapter", 0x00b2e941, 0x4b0d829e), + PCMCIA_DEVICE_PROD_ID12("Ethernet Adapter", "E2000 PCMCIA Ethernet", 0x96767301, 0x71fbbc61), + PCMCIA_DEVICE_PROD_ID12("Ethernet PCMCIA adapter", "EP-210", 0x8dd86181, 0xf2b52517), + PCMCIA_DEVICE_PROD_ID12("Fast Ethernet", "Adapter", 0xb4be14e3, 0x4b0d829e), + PCMCIA_DEVICE_PROD_ID12("Grey Cell", "GCS2000", 0x2a151fac, 0xf00555cb), + PCMCIA_DEVICE_PROD_ID12("Grey Cell", "GCS2220", 0x2a151fac, 0xc1b7e327), + PCMCIA_DEVICE_PROD_ID12("GVC", "NIC-2000p", 0x76e171bd, 0x6eb1c947), + PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "Ethernet", 0xe3736c88, 0x00b2e941), + PCMCIA_DEVICE_PROD_ID12("IC-CARD", "IC-CARD", 0x60cb09a6, 0x60cb09a6), + PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCETTX", 0x547e66dc, 0x6fc5459b), + PCMCIA_DEVICE_PROD_ID12("iPort", "10/100 Ethernet Card", 0x56c538d2, 0x11b0ffc0), + PCMCIA_DEVICE_PROD_ID12("KANSAI ELECTRIC CO.,LTD", "KLA-PCM/T", 0xb18dc3b4, 0xcc51a956), + PCMCIA_DEVICE_PROD_ID12("KCI", "PE520 PCMCIA Ethernet Adapter", 0xa89b87d3, 0x1eb88e64), + PCMCIA_DEVICE_PROD_ID12("KINGMAX", "EN10T2T", 0x7bcb459a, 0xa5c81fa5), + PCMCIA_DEVICE_PROD_ID12("Kingston", "KNE-PC2", 0x1128e633, 0xce2a89b3), + PCMCIA_DEVICE_PROD_ID12("Kingston Technology Corp.", "EtheRx PC Card Ethernet Adapter", 0x313c7be3, 0x0afb54a2), + PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-10/100CD", 0x1b7827b2, 0xcda71d1c), + PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-CDF", 0x1b7827b2, 0xfec71e40), + PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-CDL/T", 0x1b7827b2, 0x79fba4f7), + PCMCIA_DEVICE_PROD_ID12("Linksys", "Combo PCMCIA EthernetCard (EC2T)", 0x0733cc81, 0x32ee8c78), + PCMCIA_DEVICE_PROD_ID12("LINKSYS", "E-CARD", 0xf7cb0b07, 0x6701da11), + PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 Integrated PC Card (PCM100)", 0x0733cc81, 0x453c3f9d), + PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100)", 0x0733cc81, 0x66c5a389), + PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 PC Card (PCMPC100 V2)", 0x0733cc81, 0x3a3b28e9), + PCMCIA_DEVICE_PROD_ID12("Linksys", "HomeLink Phoneline ", 0x0733cc81, 0x5e07cfa0), + PCMCIA_DEVICE_PROD_ID12("Logitec", "LPM-LN100TX", 0x88fcdeda, 0x6d772737), + PCMCIA_DEVICE_PROD_ID12("Logitec", "LPM-LN20T", 0x88fcdeda, 0x81090922), + PCMCIA_DEVICE_PROD_ID12("LONGSHINE", "PCMCIA Ethernet Card", 0xf866b0b0, 0x6f6652e0), + PCMCIA_DEVICE_PROD_ID12("MACNICA", "ME1-JEIDA", 0x20841b68, 0xaf8a3578), + PCMCIA_DEVICE_PROD_ID12("Macsense", "MPC-10", 0xd830297f, 0xd265c307), + PCMCIA_DEVICE_PROD_ID12("Matsushita Electric Industrial Co.,LTD.", "CF-VEL211", 0x44445376, 0x8ded41d4), + PCMCIA_DEVICE_PROD_ID12("MAXTECH", "PCN2000", 0x78d64bc0, 0xca0ca4b8), + PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC2-T", 0x481e0094, 0xa2eb0cf3), + PCMCIA_DEVICE_PROD_ID12("MELCO", "LPC2-TX", 0x481e0094, 0x41a6916c), + PCMCIA_DEVICE_PROD_ID12("Microcom C.E.", "Travel Card LAN 10/100", 0x4b91cec7, 0xe70220d6), + PCMCIA_DEVICE_PROD_ID12("Microdyne", "NE4200", 0x2e6da59b, 0x0478e472), + PCMCIA_DEVICE_PROD_ID12("MIDORI ELEC.", "LT-PCMT", 0x648d55c1, 0xbde526c7), + PCMCIA_DEVICE_PROD_ID12("National Semiconductor", "InfoMover 4100", 0x36e1191f, 0x60c229b9), + PCMCIA_DEVICE_PROD_ID12("National Semiconductor", "InfoMover NE4100", 0x36e1191f, 0xa6617ec8), + PCMCIA_DEVICE_PROD_ID12("NEC", "PC-9801N-J12", 0x18df0ba0, 0xbc912d76), + PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA410TX", 0x9aa79dc3, 0x60e5bc0e), + PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA411", 0x9aa79dc3, 0x40fad875), + PCMCIA_DEVICE_PROD_ID12("Network Everywhere", "Fast Ethernet 10/100 PC Card", 0x820a67b6, 0x31ed1a5f), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100Mbps Ethernet Card", 0x281f1c5d, 0x6e41773b), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet", 0x281f1c5d, 0x00b2e941), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "ETHERNET", 0x281f1c5d, 0x3ff7175b), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet 10BaseT Card", 0x281f1c5d, 0x4de2f6c8), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet Card", 0x281f1c5d, 0x5e9d92c0), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet Combo card", 0x281f1c5d, 0x929c486c), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "ETHERNET V1.0", 0x281f1c5d, 0x4d8817c8), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FastEthernet", 0x281f1c5d, 0xfe871eeb), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Fast-Ethernet", 0x281f1c5d, 0x45f1f3b4), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "FAST ETHERNET CARD", 0x281f1c5d, 0xec5dbca7), + PCMCIA_DEVICE_PROD_ID12("PCMCIA LAN", "Ethernet", 0x7500e246, 0x00b2e941), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "LNT-10TN", 0x281f1c5d, 0xe707f641), + PCMCIA_DEVICE_PROD_ID12("PCMCIAs", "ComboCard", 0xdcfe12d3, 0xcd8906cc), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", "UE2212", 0x281f1c5d, 0xbf17199b), + PCMCIA_DEVICE_PROD_ID12("PCMCIA", " Ethernet NE2000 Compatible", 0x281f1c5d, 0x42d5d7e1), + PCMCIA_DEVICE_PROD_ID12("PRETEC", "Ethernet CompactLAN 10baseT 3.3V", 0xebf91155, 0x30074c80), + PCMCIA_DEVICE_PROD_ID12("PRETEC", "Ethernet CompactLAN 10BaseT 3.3V", 0xebf91155, 0x7f5a4f50), + PCMCIA_DEVICE_PROD_ID12("Psion Dacom", "Gold Card Ethernet", 0xf5f025c2, 0x3a30e110), + PCMCIA_DEVICE_PROD_ID12("=RELIA==", "Ethernet", 0xcdd0644a, 0x00b2e941), + PCMCIA_DEVICE_PROD_ID12("RP", "1625B Ethernet NE2000 Compatible", 0xe3e66e22, 0xb96150df), + PCMCIA_DEVICE_PROD_ID12("RPTI", "EP400 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4a7e2ae0), + PCMCIA_DEVICE_PROD_ID12("RPTI", "EP401 Ethernet NE2000 Compatible", 0xdc6f88fd, 0x4bcbd7fd), + PCMCIA_DEVICE_PROD_ID12("RPTI LTD.", "EP400", 0xc53ac515, 0x81e39388), + PCMCIA_DEVICE_PROD_ID12("SCM", "Ethernet Combo card", 0xbdc3b102, 0x929c486c), + PCMCIA_DEVICE_PROD_ID12("Seiko Epson Corp.", "Ethernet", 0x09928730, 0x00b2e941), + PCMCIA_DEVICE_PROD_ID12("SMC", "EZCard-10-PCMCIA", 0xc4f8b18b, 0xfb21d265), + PCMCIA_DEVICE_PROD_ID12("Socket Communications Inc", "Socket EA PCMCIA LAN Adapter Revision D", 0xc70a4760, 0x2ade483e), + PCMCIA_DEVICE_PROD_ID12("Socket Communications Inc", "Socket EA PCMCIA LAN Adapter Revision E", 0xc70a4760, 0x5dd978a8), + PCMCIA_DEVICE_PROD_ID12("TDK", "LAK-CD031 for PCMCIA", 0x1eae9475, 0x0ed386fa), + PCMCIA_DEVICE_PROD_ID12("Telecom Device K.K.", "SuperSocket RE450T", 0x466b05f0, 0x8b74bc4f), + PCMCIA_DEVICE_PROD_ID13("Hypertec", "EP401", 0x8787bec7, 0xf6e4a31e), + PCMCIA_DEVICE_PROD_ID13("KingMax Technology Inc.", "Ethernet Card", 0x932b7189, 0x5e9d92c0), + PCMCIA_DEVICE_PROD_ID13("LONGSHINE", "EP401", 0xf866b0b0, 0xf6e4a31e), + PCMCIA_DEVICE_PROD_ID13("Xircom", "CFE-10", 0x2e3ee845, 0x22a49f89), + PCMCIA_DEVICE_PROD_ID1("CyQ've 10 Base-T LAN CARD", 0x94faf360), + PCMCIA_DEVICE_PROD_ID1("EP-210 PCMCIA LAN CARD.", 0x8850b4de), + PCMCIA_DEVICE_PROD_ID1("ETHER-C16", 0x06a8514f), + PCMCIA_DEVICE_PROD_ID1("IC-CARD", 0x60cb09a6), + PCMCIA_DEVICE_PROD_ID1("NE2000 Compatible", 0x75b8ad5a), + PCMCIA_DEVICE_PROD_ID2("EN-6200P2", 0xa996d078), + /* too generic! */ + /* PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100 Ethernet Card", 0x281f1c5d, 0x11b0ffc0), */ + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "EN2218-LAN/MODEM", 0x281f1c5d, 0x570f348e, "PCMLM28.cis"), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "PCMCIA", "UE2218-LAN/MODEM", 0x281f1c5d, 0x6fdcacee, "PCMLM28.cis"), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet", 0xf5f025c2, 0x338e8155, "PCMLM28.cis"), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "Psion Dacom", "Gold Card V34 Ethernet GSM", 0xf5f025c2, 0x4ae85d35, "PCMLM28.cis"), + PCMCIA_PFC_DEVICE_CIS_PROD_ID12(0, "LINKSYS", "PCMLM28", 0xf7cb0b07, 0x66881874, "PCMLM28.cis"), + PCMCIA_MFC_DEVICE_CIS_PROD_ID12(0, "DAYNA COMMUNICATIONS", "LAN AND MODEM MULTIFUNCTION", 0x8fdf8f89, 0xdd5ed9e8, "DP83903.cis"), + PCMCIA_MFC_DEVICE_CIS_PROD_ID4(0, "NSC MF LAN/Modem", 0x58fc6056, "DP83903.cis"), + PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0175, 0x0000, "DP83903.cis"), + PCMCIA_DEVICE_CIS_MANF_CARD(0xc00f, 0x0002, "LA-PCM.cis"), + PCMCIA_DEVICE_CIS_PROD_ID12("KTI", "PE520 PLUS", 0xad180345, 0x9d58d392, "PE520.cis"), + PCMCIA_DEVICE_CIS_PROD_ID12("NDC", "Ethernet", 0x01c43ae1, 0x00b2e941, "NE2K.cis"), + PCMCIA_DEVICE_CIS_PROD_ID12("PMX ", "PE-200", 0x34f3f1c8, 0x10b59f8c, "PE-200.cis"), + PCMCIA_DEVICE_CIS_PROD_ID12("TAMARACK", "Ethernet", 0xcf434fba, 0x00b2e941, "tamarack.cis"), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, pcnet_ids); + static struct pcmcia_driver pcnet_driver = { .drv = { .name = "pcnet_cs", @@ -1644,6 +1841,7 @@ static struct pcmcia_driver pcnet_driver = { .attach = pcnet_attach, .detach = pcnet_detach, .owner = THIS_MODULE, + .id_table = pcnet_ids, }; static int __init init_pcnet_cs(void) -- cgit v1.2.3 From 9c7046cd06c66bd81b285d15e422faeecdc9ca82 Mon Sep 17 00:00:00 2001 From: Jun Komuro Date: Mon, 27 Jun 2005 16:28:30 -0700 Subject: [PATCH] pcmcia: add a few more IDs for pcnet_cs Add new pcmcia id_table for pcnet_cs. (Allied, Laneed, NextCom and Telecom Device) Signed-off-by: Jun Komuro Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/pcnet_cs.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers') diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index cdcc46e1f11..855a45d062b 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c @@ -1691,6 +1691,8 @@ static struct pcmcia_device_id pcnet_ids[] = { PCMCIA_DEVICE_PROD_ID12("Allied Telesis, K.K.", "CentreCOM LA100-PCM-T V2 100/10M LAN PC Card", 0xbb7fbdd7, 0xcd91cc68), PCMCIA_DEVICE_PROD_ID12("Allied Telesis, K.K.", "CentreCOM LA-PCM", 0xbb7fbdd7, 0x5ba10d49), PCMCIA_DEVICE_PROD_ID12("Allied Telesis K.K.", "LA100-PCM V2", 0x36634a66, 0xc6d05997), + PCMCIA_DEVICE_PROD_ID12("Allied Telesis, K.K.", "CentreCOM LA-PCM_V2", 0xbb7fBdd7, 0x28e299f8), + PCMCIA_DEVICE_PROD_ID12("Allied Telesis K.K.", "LA-PCM V3", 0x36634a66, 0x62241d96), PCMCIA_DEVICE_PROD_ID12("AmbiCom", "AMB8010", 0x5070a7f9, 0x82f96e96), PCMCIA_DEVICE_PROD_ID12("AmbiCom", "AMB8610", 0x5070a7f9, 0x86741224), PCMCIA_DEVICE_PROD_ID12("AmbiCom Inc", "AMB8002", 0x93b15570, 0x75ec3efb), @@ -1751,6 +1753,7 @@ static struct pcmcia_device_id pcnet_ids[] = { PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-10/100CD", 0x1b7827b2, 0xcda71d1c), PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-CDF", 0x1b7827b2, 0xfec71e40), PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-CDL/T", 0x1b7827b2, 0x79fba4f7), + PCMCIA_DEVICE_PROD_ID12("Laneed", "LD-CDS", 0x1b7827b2, 0x931afaab), PCMCIA_DEVICE_PROD_ID12("Linksys", "Combo PCMCIA EthernetCard (EC2T)", 0x0733cc81, 0x32ee8c78), PCMCIA_DEVICE_PROD_ID12("LINKSYS", "E-CARD", 0xf7cb0b07, 0x6701da11), PCMCIA_DEVICE_PROD_ID12("Linksys", "EtherFast 10/100 Integrated PC Card (PCM100)", 0x0733cc81, 0x453c3f9d), @@ -1775,6 +1778,7 @@ static struct pcmcia_device_id pcnet_ids[] = { PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA410TX", 0x9aa79dc3, 0x60e5bc0e), PCMCIA_DEVICE_PROD_ID12("NETGEAR", "FA411", 0x9aa79dc3, 0x40fad875), PCMCIA_DEVICE_PROD_ID12("Network Everywhere", "Fast Ethernet 10/100 PC Card", 0x820a67b6, 0x31ed1a5f), + PCMCIA_DEVICE_PROD_ID12("NextCom K.K.", "Next Hawk", 0xaedaec74, 0xad050ef1), PCMCIA_DEVICE_PROD_ID12("PCMCIA", "10/100Mbps Ethernet Card", 0x281f1c5d, 0x6e41773b), PCMCIA_DEVICE_PROD_ID12("PCMCIA", "Ethernet", 0x281f1c5d, 0x00b2e941), PCMCIA_DEVICE_PROD_ID12("PCMCIA", "ETHERNET", 0x281f1c5d, 0x3ff7175b), @@ -1805,6 +1809,7 @@ static struct pcmcia_device_id pcnet_ids[] = { PCMCIA_DEVICE_PROD_ID12("Socket Communications Inc", "Socket EA PCMCIA LAN Adapter Revision E", 0xc70a4760, 0x5dd978a8), PCMCIA_DEVICE_PROD_ID12("TDK", "LAK-CD031 for PCMCIA", 0x1eae9475, 0x0ed386fa), PCMCIA_DEVICE_PROD_ID12("Telecom Device K.K.", "SuperSocket RE450T", 0x466b05f0, 0x8b74bc4f), + PCMCIA_DEVICE_PROD_ID12("Telecom Device K.K.", "SuperSocket RE550T", 0x466b05f0, 0x33c8db2a), PCMCIA_DEVICE_PROD_ID13("Hypertec", "EP401", 0x8787bec7, 0xf6e4a31e), PCMCIA_DEVICE_PROD_ID13("KingMax Technology Inc.", "Ethernet Card", 0x932b7189, 0x5e9d92c0), PCMCIA_DEVICE_PROD_ID13("LONGSHINE", "EP401", 0xf866b0b0, 0xf6e4a31e), -- cgit v1.2.3 From 11d28a30219671607a235a518f395659599a748e Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:32 -0700 Subject: [PATCH] pcmcia: id_table for pcmciamtd.c Add pcmcia_device_id table to pcmciamtd. The binding of anonymus cards (i.e. those who do neither report MANFID, CARDID, FUNCID nor product strings) is protected by a new config option. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/mtd/maps/Kconfig | 10 ++++++++++ drivers/mtd/maps/pcmciamtd.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index 8480057eadb..2bea2e0b06f 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig @@ -607,6 +607,16 @@ config MTD_PCMCIA cards are usually around 4-16MiB in size. This does not include Compact Flash cards which are treated as IDE devices. +config MTD_PCMCIA_ANONYMOUS + bool "Use PCMCIA MTD drivers for anonymous PCMCIA cards" + depends on MTD_PCMCIA + default N + help + If this option is enabled, PCMCIA cards which do not report + anything about themselves are assumed to be MTD cards. + + If unsure, say N. + config MTD_UCLINUX tristate "Generic uClinux RAM/ROM filesystem support" depends on MTD_PARTITIONS && !MMU diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index e37b4c1976e..c2655a817e3 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c @@ -818,6 +818,32 @@ static dev_link_t *pcmciamtd_attach(void) return link; } +static struct pcmcia_device_id pcmciamtd_ids[] = { + PCMCIA_DEVICE_FUNC_ID(1), + PCMCIA_DEVICE_PROD_ID123("IO DATA", "PCS-2M", "2MB SRAM", 0x547e66dc, 0x1fed36cd, 0x36eadd21), + PCMCIA_DEVICE_PROD_ID12("IBM", "2MB SRAM", 0xb569a6e5, 0x36eadd21), + PCMCIA_DEVICE_PROD_ID12("IBM", "4MB FLASH", 0xb569a6e5, 0x8bc54d2a), + PCMCIA_DEVICE_PROD_ID12("IBM", "8MB FLASH", 0xb569a6e5, 0x6df1be3e), + PCMCIA_DEVICE_PROD_ID12("Intel", "S2E20SW", 0x816cc815, 0xd14c9dcf), + PCMCIA_DEVICE_PROD_ID12("Intel", "S2E8 SW", 0x816cc815, 0xa2d7dedb), + PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-02 ", 0x40ade711, 0x145cea5c), + PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-04 ", 0x40ade711, 0x42064dda), + PCMCIA_DEVICE_PROD_ID12("intel", "SERIES2-20 ", 0x40ade711, 0x25ee5cb0), + PCMCIA_DEVICE_PROD_ID12("intel", "VALUE SERIES 100 ", 0x40ade711, 0xdf8506d8), + PCMCIA_DEVICE_PROD_ID12("KINGMAX TECHNOLOGY INC.", "SRAM 256K Bytes", 0x54d0c69c, 0xad12c29c), + PCMCIA_DEVICE_PROD_ID12("Maxtor", "MAXFL MobileMax Flash Memory Card", 0xb68968c8, 0x2dfb47b0), + PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB101EN20", 0xf9876baf, 0xad0b207b), + PCMCIA_DEVICE_PROD_ID12("SEIKO EPSON", "WWB513EN20", 0xf9876baf, 0xe8d884ad), + PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-3000", 0x05ddca47, 0xe7d67bca), + PCMCIA_DEVICE_PROD_ID12("Starfish, Inc.", "REX-4100", 0x05ddca47, 0x7bc32944), + /* the following was commented out in pcmcia-cs-3.2.7 */ + /* PCMCIA_DEVICE_PROD_ID12("RATOC Systems,Inc.", "SmartMedia ADAPTER PC Card", 0xf4a2fefe, 0x5885b2ae), */ +#ifdef CONFIG_MTD_PCMCIA_ANONYMOUS + { .match_flags = PCMCIA_DEV_ID_MATCH_ANONYMOUS, }, +#endif + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, pcmciamtd_ids); static struct pcmcia_driver pcmciamtd_driver = { .drv = { @@ -825,7 +851,8 @@ static struct pcmcia_driver pcmciamtd_driver = { }, .attach = pcmciamtd_attach, .detach = pcmciamtd_detach, - .owner = THIS_MODULE + .owner = THIS_MODULE, + .id_table = pcmciamtd_ids, }; -- cgit v1.2.3 From 4a17a119381a5467144b18eaa954ba324e8a140b Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:34 -0700 Subject: [PATCH] pcmcia: id_table for atmel_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/atmel_cs.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'drivers') diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c index a4ed28d9c78..86379d4998a 100644 --- a/drivers/net/wireless/atmel_cs.c +++ b/drivers/net/wireless/atmel_cs.c @@ -646,6 +646,27 @@ static int atmel_event(event_t event, int priority, } /* atmel_event */ /*====================================================================*/ +static struct pcmcia_device_id atmel_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0620), + PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0696), + PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3302), + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0007), + PCMCIA_DEVICE_PROD_ID12("11WAVE", "11WP611AL-E", 0x9eb2da1f, 0xc9a0d3f9), + PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C502AR", 0xabda4164, 0x41b37e1f), + PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C504", 0xabda4164, 0x5040670a), + PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C504A", 0xabda4164, 0xe15ed87f), + PCMCIA_DEVICE_PROD_ID12("BT", "Voyager 1020 Laptop Adapter", 0xae49b86a, 0x1e957cd5), + PCMCIA_DEVICE_PROD_ID12("CNet", "CNWLC 11Mbps Wireless PC Card V-5", 0xbc477dde, 0x502fae6b), + PCMCIA_DEVICE_PROD_ID12("IEEE 802.11b", "Wireless LAN PC Card", 0x5b878724, 0x122f1df6), + PCMCIA_DEVICE_PROD_ID12("OEM", "11Mbps Wireless LAN PC Card V-3", 0xfea54c90, 0x1c5b0f68), + PCMCIA_DEVICE_PROD_ID12("SMC", "2632W", 0xc4f8b18b, 0x30f38774), + PCMCIA_DEVICE_PROD_ID12("SMC", "2632W-V2", 0xc4f8b18b, 0x172d1377), + PCMCIA_DEVICE_PROD_ID12("Wireless", "PC", 0xa407ecdd, 0x556e4d7e), + PCMCIA_DEVICE_PROD_ID12("WLAN", "802.11b PC CARD", 0x575c516c, 0xb1f6dbc4), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, atmel_ids); + static struct pcmcia_driver atmel_driver = { .owner = THIS_MODULE, .drv = { @@ -653,6 +674,7 @@ static struct pcmcia_driver atmel_driver = { }, .attach = atmel_attach, .detach = atmel_detach, + .id_table = atmel_ids, }; static int atmel_cs_init(void) -- cgit v1.2.3 From c594c12cefa7c49f99d82cd2ccbcbf8baeb773ed Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:34 -0700 Subject: [PATCH] pcmcia: id_table for avma1_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/hisax/avma1_cs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c index 663a0bf703b..67c60e04a37 100644 --- a/drivers/isdn/hisax/avma1_cs.c +++ b/drivers/isdn/hisax/avma1_cs.c @@ -501,6 +501,13 @@ static int avma1cs_event(event_t event, int priority, return 0; } /* avma1cs_event */ +static struct pcmcia_device_id avma1cs_ids[] = { + PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb), + PCMCIA_DEVICE_PROD_ID12("ISDN", "CARD", 0x8d9761c8, 0x01c5aa7b), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, avma1cs_ids); + static struct pcmcia_driver avma1cs_driver = { .owner = THIS_MODULE, .drv = { @@ -508,6 +515,7 @@ static struct pcmcia_driver avma1cs_driver = { }, .attach = avma1cs_attach, .detach = avma1cs_detach, + .id_table = avma1cs_ids, }; /*====================================================================*/ -- cgit v1.2.3 From a13bcf0d5abaf21a1eb7a988915ab97152f57f78 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:35 -0700 Subject: [PATCH] pcmcia: id_table for avm_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/hardware/avm/avm_cs.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c index dc00c85e3e3..ee750e9456d 100644 --- a/drivers/isdn/hardware/avm/avm_cs.c +++ b/drivers/isdn/hardware/avm/avm_cs.c @@ -486,6 +486,14 @@ static int avmcs_event(event_t event, int priority, return 0; } /* avmcs_event */ +static struct pcmcia_device_id avmcs_ids[] = { + PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335), + PCMCIA_DEVICE_PROD_ID12("AVM", "Mobile ISDN-Controller M1", 0x95d42008, 0x81e10430), + PCMCIA_DEVICE_PROD_ID12("AVM", "Mobile ISDN-Controller M2", 0x95d42008, 0x18e8558a), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, avmcs_ids); + static struct pcmcia_driver avmcs_driver = { .owner = THIS_MODULE, .drv = { @@ -493,6 +501,7 @@ static struct pcmcia_driver avmcs_driver = { }, .attach = avmcs_attach, .detach = avmcs_detach, + .id_table = avmcs_ids, }; static int __init avmcs_init(void) -- cgit v1.2.3 From 7f70cb6d9f8b0fd97215250cff797ff8c3b24f1d Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:35 -0700 Subject: [PATCH] pcmcia: id_table for bluecard_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Acked-by: Marcel Holtmann Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/bluetooth/bluecard_cs.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'drivers') diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index e481cc411b5..5ef9adb9fe7 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -1089,6 +1089,14 @@ static int bluecard_event(event_t event, int priority, event_callback_args_t *ar return 0; } +static struct pcmcia_device_id bluecard_ids[] = { + PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e), + PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c), + PCMCIA_DEVICE_PROD_ID12("WSS", "LSE039", 0x0a0736ec, 0x24e6dfab), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, bluecard_ids); + static struct pcmcia_driver bluecard_driver = { .owner = THIS_MODULE, .drv = { @@ -1096,6 +1104,7 @@ static struct pcmcia_driver bluecard_driver = { }, .attach = bluecard_attach, .detach = bluecard_detach, + .id_table = bluecard_ids, }; static int __init init_bluecard_cs(void) -- cgit v1.2.3 From a01c3ed48e3319f9a4eb4e43b8c6abe00f1a1389 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:37 -0700 Subject: [PATCH] pcmcia: id_table for bt3c_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Acked-by: Marcel Holtmann Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/bluetooth/bt3c_cs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index f71e5c76963..9013cd759af 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -935,6 +935,12 @@ static int bt3c_event(event_t event, int priority, event_callback_args_t *args) return 0; } +static struct pcmcia_device_id bt3c_ids[] = { + PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, bt3c_ids); + static struct pcmcia_driver bt3c_driver = { .owner = THIS_MODULE, .drv = { @@ -942,6 +948,7 @@ static struct pcmcia_driver bt3c_driver = { }, .attach = bt3c_attach, .detach = bt3c_detach, + .id_table = bt3c_ids, }; static int __init init_bt3c_cs(void) -- cgit v1.2.3 From 279c936153199e105b96429dec11233ae153667c Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:38 -0700 Subject: [PATCH] pcmcia: id_table for btuart_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/bluetooth/btuart_cs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index ad8d972444a..c479484a1f7 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -855,6 +855,12 @@ static int btuart_event(event_t event, int priority, event_callback_args_t *args return 0; } +static struct pcmcia_device_id btuart_ids[] = { + /* don't use this driver. Use serial_cs + hci_uart instead */ + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, btuart_ids); + static struct pcmcia_driver btuart_driver = { .owner = THIS_MODULE, .drv = { @@ -862,6 +868,7 @@ static struct pcmcia_driver btuart_driver = { }, .attach = btuart_attach, .detach = btuart_detach, + .id_table = btuart_ids, }; static int __init init_btuart_cs(void) -- cgit v1.2.3 From 7fb22bb4d044f11a675c6947eac4923b84e0289e Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:38 -0700 Subject: [PATCH] pcmcia: id_table for com20020_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/com20020_cs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c index 4294e1e3f15..68d58cc58d3 100644 --- a/drivers/net/pcmcia/com20020_cs.c +++ b/drivers/net/pcmcia/com20020_cs.c @@ -483,7 +483,11 @@ static int com20020_event(event_t event, int priority, return 0; } /* com20020_event */ - +static struct pcmcia_device_id com20020_ids[] = { + PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, com20020_ids); static struct pcmcia_driver com20020_cs_driver = { .owner = THIS_MODULE, @@ -492,6 +496,7 @@ static struct pcmcia_driver com20020_cs_driver = { }, .attach = com20020_attach, .detach = com20020_detach, + .id_table = com20020_ids, }; static int __init init_com20020_cs(void) -- cgit v1.2.3 From 88eca2e526d087797a529aad478e5e6b42188415 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:39 -0700 Subject: [PATCH] pcmcia: id_table for dtl1_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Acked-by: Marcel Holtmann Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/bluetooth/dtl1_cs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index fe954e5d9a1..bb12f7daeb9 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -807,6 +807,13 @@ static int dtl1_event(event_t event, int priority, event_callback_args_t *args) return 0; } +static struct pcmcia_device_id dtl1_ids[] = { + PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), + PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, dtl1_ids); + static struct pcmcia_driver dtl1_driver = { .owner = THIS_MODULE, .drv = { @@ -814,6 +821,7 @@ static struct pcmcia_driver dtl1_driver = { }, .attach = dtl1_attach, .detach = dtl1_detach, + .id_table = dtl1_ids, }; static int __init init_dtl1_cs(void) -- cgit v1.2.3 From 02ae38cfc5a49dde1ce979e710eec1d02279cb53 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:39 -0700 Subject: [PATCH] pcmcia: id_table for elsa_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/hisax/elsa_cs.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c index bfc013225f4..9146be54704 100644 --- a/drivers/isdn/hisax/elsa_cs.c +++ b/drivers/isdn/hisax/elsa_cs.c @@ -508,6 +508,13 @@ static int elsa_cs_event(event_t event, int priority, return 0; } /* elsa_cs_event */ +static struct pcmcia_device_id elsa_ids[] = { + PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257), + PCMCIA_DEVICE_PROD_ID12("ELSA GmbH, Aachen", "MicroLink ISDN/MC ", 0x639e5718, 0x333ba257), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, elsa_ids); + static struct pcmcia_driver elsa_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -515,6 +522,7 @@ static struct pcmcia_driver elsa_cs_driver = { }, .attach = elsa_cs_attach, .detach = elsa_cs_detach, + .id_table = elsa_ids, }; static int __init init_elsa_cs(void) -- cgit v1.2.3 From 070812734facccf2d891eec0da2497ec3824e616 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:40 -0700 Subject: [PATCH] pcmcia: id_table for ixj_pcmcia.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/telephony/ixj_pcmcia.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c index e1ef0d7ee8d..ce5ebfe4af2 100644 --- a/drivers/telephony/ixj_pcmcia.c +++ b/drivers/telephony/ixj_pcmcia.c @@ -295,6 +295,12 @@ static int ixj_event(event_t event, int priority, event_callback_args_t * args) return 0; } +static struct pcmcia_device_id ixj_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x0257, 0x0600), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, ixj_ids); + static struct pcmcia_driver ixj_driver = { .owner = THIS_MODULE, .drv = { @@ -302,6 +308,7 @@ static struct pcmcia_driver ixj_driver = { }, .attach = ixj_attach, .detach = ixj_detach, + .id_table = ixj_ids, }; static int __init ixj_pcmcia_init(void) -- cgit v1.2.3 From aba14100055325c5af432fe3fd1aa5521cec3e0c Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:40 -0700 Subject: [PATCH] pcmcia: id_table for nsp_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/scsi/pcmcia/nsp_cs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers') diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index 3dddb323e71..91b3f28e7a1 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -2125,6 +2125,18 @@ static int nsp_cs_event(event_t event, * module entry point *====================================================================*/ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68)) +static struct pcmcia_device_id nsp_cs_ids[] = { + PCMCIA_DEVICE_PROD_ID123("IO DATA", "CBSC16 ", "1", 0x547e66dc, 0x0d63a3fd, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-001", "1", 0x534c02bc, 0x52008408, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-002", "1", 0x534c02bc, 0xcb09d5b2, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-003", "1", 0x534c02bc, 0xbc0ee524, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-004", "1", 0x534c02bc, 0x226a7087, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("WBT", "NinjaSCSI-3", "R1.0", 0xc7ba805f, 0xfdc7c97d, 0x6973710e), + PCMCIA_DEVICE_PROD_ID123("WORKBIT", "UltraNinja-16", "1", 0x28191418, 0xb70f4b09, 0x51de003a), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, nsp_cs_ids); + static struct pcmcia_driver nsp_driver = { .owner = THIS_MODULE, .drv = { @@ -2132,6 +2144,7 @@ static struct pcmcia_driver nsp_driver = { }, .attach = nsp_cs_attach, .detach = nsp_cs_detach, + .id_table = nsp_cs_ids, }; #endif -- cgit v1.2.3 From 707997343a1e5193fff74798af572a4d03740476 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:41 -0700 Subject: [PATCH] pcmcia: id_table for sedlbauer_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/hisax/sedlbauer_cs.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers') diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c index 44965124147..058147a6957 100644 --- a/drivers/isdn/hisax/sedlbauer_cs.c +++ b/drivers/isdn/hisax/sedlbauer_cs.c @@ -616,6 +616,18 @@ static int sedlbauer_event(event_t event, int priority, return 0; } /* sedlbauer_event */ +static struct pcmcia_device_id sedlbauer_ids[] = { + PCMCIA_DEVICE_PROD_ID1234("SEDLBAUER", "speed star II", "V 3.1", "(c) 93 - 98 cb ", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a, 0x50d4149c), + PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", "4D67", 0x81fb79f5, 0xe4e9bc12, 0x397b7e90), + PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", "4D98", 0x81fb79f5, 0xe4e9bc12, 0x2e5c7fce), + PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", " (C) 93-94 VK", 0x81fb79f5, 0xe4e9bc12, 0x8db143fe), + PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "ISDN-Adapter", " (c) 93-95 VK", 0x81fb79f5, 0xe4e9bc12, 0xb391ab4c), + PCMCIA_DEVICE_PROD_ID12("HST High Soft Tech GmbH", "Saphir II B", 0xd79e0b84, 0x21d083ae), +/* PCMCIA_DEVICE_PROD_ID1234("SEDLBAUER", 0x81fb79f5), */ /* too generic*/ + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, sedlbauer_ids); + static struct pcmcia_driver sedlbauer_driver = { .owner = THIS_MODULE, .drv = { @@ -623,6 +635,7 @@ static struct pcmcia_driver sedlbauer_driver = { }, .attach = sedlbauer_attach, .detach = sedlbauer_detach, + .id_table = sedlbauer_ids, }; static int __init init_sedlbauer_cs(void) -- cgit v1.2.3 From 77b73f9b00e3bea43ab4d30ae70fb85660dd07f1 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:41 -0700 Subject: [PATCH] pcmcia: id_table for wl3501_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/wl3501_cs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 1433e5aaf1b..e3a900482d9 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -2239,6 +2239,12 @@ static int wl3501_event(event_t event, int pri, event_callback_args_t *args) return 0; } +static struct pcmcia_device_id wl3501_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, wl3501_ids); + static struct pcmcia_driver wl3501_driver = { .owner = THIS_MODULE, .drv = { @@ -2246,6 +2252,7 @@ static struct pcmcia_driver wl3501_driver = { }, .attach = wl3501_attach, .detach = wl3501_detach, + .id_table = wl3501_ids, }; static int __init wl3501_init_module(void) -- cgit v1.2.3 From 4af48c8c16dfc37400f63633373dd180b5540ead Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:42 -0700 Subject: [PATCH] pcmcia: id_table for synclink_cs.c Add pcmcia_device_id table. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/pcmcia/synclink_cs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 1c8d866a49d..f2ca4fffa21 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -3081,6 +3081,12 @@ void mgslpc_remove_device(MGSLPC_INFO *remove_info) } } +static struct pcmcia_device_id mgslpc_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0x02c5, 0x0050), + PCMCIA_DEVICE_NULL +}; +MODULE_DEVICE_TABLE(pcmcia, mgslpc_ids); + static struct pcmcia_driver mgslpc_driver = { .owner = THIS_MODULE, .drv = { @@ -3088,6 +3094,7 @@ static struct pcmcia_driver mgslpc_driver = { }, .attach = mgslpc_attach, .detach = mgslpc_detach, + .id_table = mgslpc_ids, }; static struct tty_operations mgslpc_ops = { -- cgit v1.2.3 From 22f3a8f5fc94be4dd31c4c5ec1d1dc2b9c83a8ac Mon Sep 17 00:00:00 2001 From: David Brownell Date: Mon, 27 Jun 2005 16:28:43 -0700 Subject: [PATCH] pcmcia id_table for sl811.cs Catch up with some PCMCIA API changes: - Docs say that as of 2.6.11 the PCMCIA IRQInfo2 field is ignored, but it's not yet removed from the API; stop using it anyway. - As of 2.6.13 PCMCIA finally hotplugs and does driver binding without "cardmgr"; add a MODULE_DEVICE_TABLE to support this. Signed-off-by: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/usb/host/sl811_cs.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c index 6e173265095..269d8ef0145 100644 --- a/drivers/usb/host/sl811_cs.c +++ b/drivers/usb/host/sl811_cs.c @@ -68,13 +68,6 @@ static const char driver_name[DEV_NAME_LEN] = "sl811_cs"; static dev_link_t *dev_list = NULL; -static int irq_list[4] = { -1 }; -static int irq_list_count; - -module_param_array(irq_list, int, &irq_list_count, 0444); - -INT_MODULE_PARM(irq_mask, 0xdeb8); - typedef struct local_info_t { dev_link_t link; dev_node_t node; @@ -373,7 +366,7 @@ static dev_link_t *sl811_cs_attach(void) local_info_t *local; dev_link_t *link; client_reg_t client_reg; - int ret, i; + int ret; local = kmalloc(sizeof(local_info_t), GFP_KERNEL); if (!local) @@ -385,11 +378,6 @@ static dev_link_t *sl811_cs_attach(void) /* Initialize */ link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; link->irq.IRQInfo1 = IRQ_INFO2_VALID|IRQ_LEVEL_ID; - if (irq_list[0] == -1) - link->irq.IRQInfo2 = irq_mask; - else - for (i = 0; i < irq_list_count; i++) - link->irq.IRQInfo2 |= 1 << irq_list[i]; link->irq.Handler = NULL; link->conf.Attributes = 0; @@ -418,6 +406,12 @@ static dev_link_t *sl811_cs_attach(void) return link; } +static struct pcmcia_device_id sl811_ids[] = { + PCMCIA_DEVICE_MANF_CARD(0xc015, 0x0001), /* RATOC USB HOST CF+ Card */ + PCMCIA_DEVICE_NULL, +}; +MODULE_DEVICE_TABLE(pcmcia, sl811_ids); + static struct pcmcia_driver sl811_cs_driver = { .owner = THIS_MODULE, .drv = { @@ -425,6 +419,7 @@ static struct pcmcia_driver sl811_cs_driver = { }, .attach = sl811_cs_attach, .detach = sl811_cs_detach, + .id_table = sl811_ids, }; /*====================================================================*/ -- cgit v1.2.3 From f4d7510d3d3b4501c94b4b00cf42fd58d49aeddd Mon Sep 17 00:00:00 2001 From: Jun Komuro Date: Mon, 27 Jun 2005 16:28:44 -0700 Subject: [PATCH] pcmcia: more IDs for TDK multifunction cards Add new pcmcia id_table for fmvj18x_cs and serial_cs. (TDK multi-function card (NetPartner9610 and MobileNetworker3200)) Signed-off-by: Jun Komuro Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/pcmcia/fmvj18x_cs.c | 6 +++++- drivers/serial/serial_cs.c | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index b17aedd5e5a..917adbbf0b5 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c @@ -435,7 +435,9 @@ static void fmvj18x_config(dev_link_t *link) pcmcia_get_status(handle, &status); if (status.CardState & CS_EVENT_3VCARD) link->conf.Vcc = 33; /* inserted in 3.3V slot */ - } else if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410) { + } else if (le16_to_cpu(buf[1]) == PRODID_TDK_GN3410 + || le16_to_cpu(buf[1]) == PRODID_TDK_NP9610 + || le16_to_cpu(buf[1]) == PRODID_TDK_MN3200) { /* MultiFunction Card */ link->conf.ConfigBase = 0x800; link->conf.ConfigIndex = 0x47; @@ -783,6 +785,8 @@ static struct pcmcia_device_id fmvj18x_ids[] = { PCMCIA_DEVICE_PROD_ID1("PCMCIA MBH10302", 0x8f4005da), PCMCIA_DEVICE_PROD_ID1("UBKK,V2.0", 0x90888080), PCMCIA_PFC_DEVICE_PROD_ID12(0, "TDK", "GlobalNetworker 3410/3412", 0x1eae9475, 0xd9a93bed), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0x0d0a), + PCMCIA_PFC_DEVICE_MANF_CARD(0, 0x0105, 0x0e0a), PCMCIA_DEVICE_NULL, }; MODULE_DEVICE_TABLE(pcmcia, fmvj18x_ids); diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c index ca86f1f668f..73a34b18866 100644 --- a/drivers/serial/serial_cs.c +++ b/drivers/serial/serial_cs.c @@ -785,6 +785,8 @@ static struct pcmcia_device_id serial_ids[] = { PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x016c, 0x0081), PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x021b, 0x0101), PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x08a1, 0xc0ab), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0d0a), + PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0105, 0x0e0a), PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3288", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x04cd2988, 0x46a52d63), PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "CC/XJEM3336", "DATA/FAX/CELL ETHERNET MODEM", 0xf510db04, 0x0143b773, 0x46a52d63), PCMCIA_PFC_DEVICE_PROD_ID123(1, "MEGAHERTZ", "EM1144T", "PCMCIA MODEM", 0xf510db04, 0x856d66c8, 0xbd6c43ef), -- cgit v1.2.3 From 5085cb26503a662a5cfdf53ce96fd606c1fbe9ba Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:45 -0700 Subject: [PATCH] pcmcia: add some Documentation Add some information useful for PCMCIA device driver authors to Documentation/pcmcia/, and reference it in dmesg in case of hash mismatches. Also add a reference to pcmciautils to Documentation/Changes. With recent changes, you don't need to concern yourself with pcmcia-cs even if you have PCMCIA hardware, so the example above the list needed to be adapted as well. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index bde9b0513d9..2c3c3da5368 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -262,8 +262,6 @@ void cs_error(client_handle_t handle, int func, int ret) } EXPORT_SYMBOL(cs_error); -#ifdef CONFIG_PCMCIA_DEBUG - static void pcmcia_check_driver(struct pcmcia_driver *p_drv) { @@ -284,6 +282,9 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv) "product string \"%s\": is 0x%x, should " "be 0x%x\n", p_drv->drv.name, did->prod_id[i], did->prod_id_hash[i], hash); + printk(KERN_DEBUG "pcmcia: see " + "Documentation/pcmcia/devicetable.txt for " + "details\n"); } did++; } @@ -291,12 +292,6 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv) return; } -#else -static inline void pcmcia_check_driver(struct pcmcia_driver *p_drv) { - return; -} -#endif - #ifdef CONFIG_PCMCIA_LOAD_CIS -- cgit v1.2.3 From 22916638b124e859b595099bd0c86a1e09e767fb Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:46 -0700 Subject: [PATCH] pcmcia: update resource database adjust routines to use unsigned long values Make adjust_io and adjust_memory independent of adjust_t to allow for IO resources > x86's IO_SPACE_LIMIT. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/rsrc_nonstatic.c | 89 ++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 51 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 9a0b835d612..6b463609a3a 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -683,27 +683,23 @@ static struct resource * nonstatic_find_mem_region(u_long base, u_long num, } -static int adjust_memory(struct pcmcia_socket *s, adjust_t *adj) +static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned long start, unsigned long end) { - u_long base, num; struct socket_data *data = s->resource_data; - int ret; - - base = adj->resource.memory.Base; - num = adj->resource.memory.Size; - if ((num == 0) || (base+num-1 < base)) - return CS_BAD_SIZE; + unsigned long size = end - start + 1; + int ret = 0; - ret = CS_SUCCESS; + if (end <= start) + return -EINVAL; down(&rsrc_sem); - switch (adj->Action) { + switch (action) { case ADD_MANAGED_RESOURCE: - ret = add_interval(&data->mem_db, base, num); + ret = add_interval(&data->mem_db, start, size); break; case REMOVE_MANAGED_RESOURCE: - ret = sub_interval(&data->mem_db, base, num); - if (ret == CS_SUCCESS) { + ret = sub_interval(&data->mem_db, start, size); + if (!ret) { struct pcmcia_socket *socket; down_read(&pcmcia_socket_list_rwsem); list_for_each_entry(socket, &pcmcia_socket_list, socket_list) @@ -712,7 +708,7 @@ static int adjust_memory(struct pcmcia_socket *s, adjust_t *adj) } break; default: - ret = CS_UNSUPPORTED_FUNCTION; + ret = -EINVAL; } up(&rsrc_sem); @@ -720,36 +716,35 @@ static int adjust_memory(struct pcmcia_socket *s, adjust_t *adj) } -static int adjust_io(struct pcmcia_socket *s, adjust_t *adj) +static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long start, unsigned long end) { struct socket_data *data = s->resource_data; - kio_addr_t base, num; - int ret = CS_SUCCESS; + unsigned long size = end - start + 1; + int ret = 0; - base = adj->resource.io.BasePort; - num = adj->resource.io.NumPorts; - if ((base < 0) || (base > 0xffff)) - return CS_BAD_BASE; - if ((num <= 0) || (base+num > 0x10000) || (base+num <= base)) - return CS_BAD_SIZE; + if (end <= start) + return -EINVAL; + + if (end > IO_SPACE_LIMIT) + return -EINVAL; down(&rsrc_sem); - switch (adj->Action) { + switch (action) { case ADD_MANAGED_RESOURCE: - if (add_interval(&data->io_db, base, num) != 0) { - ret = CS_IN_USE; + if (add_interval(&data->io_db, start, size) != 0) { + ret = -EBUSY; break; } #ifdef CONFIG_PCMCIA_PROBE if (probe_io) - do_io_probe(s, base, num); + do_io_probe(s, start, size); #endif break; case REMOVE_MANAGED_RESOURCE: - sub_interval(&data->io_db, base, num); + sub_interval(&data->io_db, start, size); break; default: - ret = CS_UNSUPPORTED_FUNCTION; + ret = -EINVAL; break; } up(&rsrc_sem); @@ -760,11 +755,15 @@ static int adjust_io(struct pcmcia_socket *s, adjust_t *adj) static int nonstatic_adjust_resource_info(struct pcmcia_socket *s, adjust_t *adj) { + unsigned long end; + switch (adj->Resource) { case RES_MEMORY_RANGE: - return adjust_memory(s, adj); + end = adj->resource.memory.Base + adj->resource.memory.Size - 1; + return adjust_memory(s, adj->Action, adj->resource.memory.Base, end); case RES_IO_RANGE: - return adjust_io(s, adj); + end = adj->resource.io.BasePort + adj->resource.io.NumPorts - 1; + return adjust_io(s, adj->Action, adj->resource.io.BasePort, end); } return CS_UNSUPPORTED_FUNCTION; } @@ -845,17 +844,16 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size { struct pcmcia_socket *s = class_get_devdata(class_dev); unsigned long start_addr, end_addr; - unsigned int add = 1; - adjust_t adj; + unsigned int add = ADD_MANAGED_RESOURCE; ssize_t ret = 0; ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr); if (ret != 2) { ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr); - add = 0; + add = REMOVE_MANAGED_RESOURCE; if (ret != 2) { ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr); - add = 1; + add = ADD_MANAGED_RESOURCE; if (ret != 2) return -EINVAL; } @@ -863,12 +861,7 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size if (end_addr <= start_addr) return -EINVAL; - adj.Action = add ? ADD_MANAGED_RESOURCE : REMOVE_MANAGED_RESOURCE; - adj.Resource = RES_IO_RANGE; - adj.resource.io.BasePort = start_addr; - adj.resource.io.NumPorts = end_addr - start_addr + 1; - - ret = adjust_io(s, &adj); + ret = adjust_io(s, add, start_addr, end_addr); return ret ? ret : count; } @@ -901,17 +894,16 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz { struct pcmcia_socket *s = class_get_devdata(class_dev); unsigned long start_addr, end_addr; - unsigned int add = 1; - adjust_t adj; + unsigned int add = ADD_MANAGED_RESOURCE; ssize_t ret = 0; ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr); if (ret != 2) { ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr); - add = 0; + add = REMOVE_MANAGED_RESOURCE; if (ret != 2) { ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, &end_addr); - add = 1; + add = ADD_MANAGED_RESOURCE; if (ret != 2) return -EINVAL; } @@ -919,12 +911,7 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz if (end_addr <= start_addr) return -EINVAL; - adj.Action = add ? ADD_MANAGED_RESOURCE : REMOVE_MANAGED_RESOURCE; - adj.Resource = RES_MEMORY_RANGE; - adj.resource.memory.Base = start_addr; - adj.resource.memory.Size = end_addr - start_addr + 1; - - ret = adjust_memory(s, &adj); + ret = adjust_memory(s, add, start_addr, end_addr); return ret ? ret : count; } -- cgit v1.2.3 From 3c29976a6469b81a7858812dc2d4b8430d74004a Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:46 -0700 Subject: [PATCH] pcmcia: mark parent bridge windows as resources available for PCMCIA devices Automatically mark the parent PCI-PCI bridge windows as resources available for PCMCIA usage. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/rsrc_mgr.c | 2 +- drivers/pcmcia/rsrc_nonstatic.c | 58 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c index b6843f8d300..b9269e66281 100644 --- a/drivers/pcmcia/rsrc_mgr.c +++ b/drivers/pcmcia/rsrc_mgr.c @@ -72,7 +72,7 @@ int pcmcia_adjust_resource_info(adjust_t *adj) /* you can't use the old interface if the new * one was used before */ spin_lock_irqsave(&s->lock, flags); - if ((s->resource_setup_done) && + if ((s->resource_setup_new) && !(s->resource_setup_old)) { spin_unlock_irqrestore(&s->lock, flags); continue; diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 6b463609a3a..c8f21796c59 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -768,6 +768,58 @@ static int nonstatic_adjust_resource_info(struct pcmcia_socket *s, adjust_t *adj return CS_UNSUPPORTED_FUNCTION; } +#ifdef CONFIG_PCI +static int nonstatic_autoadd_resources(struct pcmcia_socket *s) +{ + struct resource *res; + int i, done = 0; + + if (!s->cb_dev || !s->cb_dev->bus) + return -ENODEV; + + for (i=0; i < PCI_BUS_NUM_RESOURCES; i++) { + res = s->cb_dev->bus->resource[i]; + if (!res) + continue; + + if (res->flags & IORESOURCE_IO) { + if (res == &ioport_resource) + continue; + printk(KERN_INFO "pcmcia: parent PCI bridge I/O window: 0x%lx - 0x%lx\n", + res->start, res->end); + if (!adjust_io(s, ADD_MANAGED_RESOURCE, res->start, res->end)) + done |= IORESOURCE_IO; + + } + + if (res->flags & IORESOURCE_MEM) { + if (res == &iomem_resource) + continue; + printk(KERN_INFO "pcmcia: parent PCI bridge Memory window: 0x%lx - 0x%lx\n", + res->start, res->end); + if (!adjust_memory(s, ADD_MANAGED_RESOURCE, res->start, res->end)) + done |= IORESOURCE_MEM; + } + } + + /* if we got at least one of IO, and one of MEM, we can be glad and + * activate the PCMCIA subsystem */ + if (done & (IORESOURCE_MEM | IORESOURCE_IO)) + s->resource_setup_done = 1; + + return 0; +} + +#else + +static inline int nonstatic_autoadd_resources(struct pcmcia_socket *s) +{ + return -ENODEV; +} + +#endif + + static int nonstatic_init(struct pcmcia_socket *s) { struct socket_data *data; @@ -782,6 +834,8 @@ static int nonstatic_init(struct pcmcia_socket *s) s->resource_data = (void *) data; + nonstatic_autoadd_resources(s); + return 0; } @@ -862,6 +916,8 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size return -EINVAL; ret = adjust_io(s, add, start_addr, end_addr); + if (!ret) + s->resource_setup_new = 1; return ret ? ret : count; } @@ -912,6 +968,8 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz return -EINVAL; ret = adjust_memory(s, add, start_addr, end_addr); + if (!ret) + s->resource_setup_new = 1; return ret ? ret : count; } -- cgit v1.2.3 From 9a5555b81fde402119a6b4f2b38d3373d272ff69 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:47 -0700 Subject: [PATCH] pcmcia: add a config option for the PCMICA ioctl Add a new config option to control the building of the PCMCIA IOCTL. Currently, it is not yet made public, though the help text is there already. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/Kconfig | 28 ++++++++++++++++++++-------- drivers/pcmcia/ds.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 11 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 22f7e8ca658..85af1fb2a30 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -14,8 +14,8 @@ config PCCARD Say Y here if you want to attach PCMCIA- or PC-cards to your Linux computer. These are credit-card size devices such as network cards, modems or hard drives often used with laptops computers. There are - actually two varieties of these cards: the older 16 bit PCMCIA cards - and the newer 32 bit CardBus cards. + actually two varieties of these cards: 16 bit PCMCIA and 32 bit + CardBus cards. To compile this driver as modules, choose M here: the module will be called pcmcia_core. @@ -48,10 +48,9 @@ config PCMCIA PC-cards are such 16-bit PCMCIA cards, so unless you know you're only using 32-bit CardBus cards, say Y or M here. - To use 16-bit PCMCIA cards, you will need supporting software from - David Hinds' pcmcia-cs package (see the file - for location). Please also read the PCMCIA-HOWTO, available from - . + To use 16-bit PCMCIA cards, you will need supporting software in + most cases. (see the file for + location and details). To compile this driver as modules, choose M here: the module will be called pcmcia. @@ -72,6 +71,21 @@ config PCMCIA_LOAD_CIS If unsure, say Y. +config PCMCIA_IOCTL + bool + depends on PCMCIA + default y + help + If you say Y here, the deprecated ioctl interface to the PCMCIA + subsystem will be built. It is needed by cardmgr and cardctl + (pcmcia-cs) to function properly. + + If you do not use the new pcmciautils package, and have a + yenta, Cirrus PD6729, i82092, i82365 or tcic compatible bridge, + you need to say Y here to be able to use 16-bit PCMCIA cards. + + If unsure, say Y. + config CARDBUS bool "32-bit CardBus support" depends on PCI @@ -91,8 +105,6 @@ comment "PC-card bridges" config YENTA tristate "CardBus yenta-compatible bridge support" - depends on PCI -#fixme: remove dependendcy on CARDBUS depends on CARDBUS select PCCARD_NONSTATIC ---help--- diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 2c3c3da5368..0c7dc5b3875 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -116,8 +116,13 @@ static struct bus_type pcmcia_bus_type; #define DS_SOCKET_DEAD 0x80 /*====================================================================*/ +#ifdef CONFIG_PCMCIA_IOCTL static int major_dev = -1; +static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr); +static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); + +#endif static int unbind_request(struct pcmcia_bus_socket *s); @@ -356,8 +361,6 @@ static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filenam /*======================================================================*/ -static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); -static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr); static void pcmcia_release_bus_socket(struct kref *refcount) { @@ -411,6 +414,7 @@ void pcmcia_unregister_driver(struct pcmcia_driver *driver) } EXPORT_SYMBOL(pcmcia_unregister_driver); +#ifdef CONFIG_PCMCIA_IOCTL #ifdef CONFIG_PROC_FS static struct proc_dir_entry *proc_pccard = NULL; @@ -443,6 +447,7 @@ static int proc_read_drivers(char *buf, char **start, off_t pos, return (p - buf); } #endif +#endif /* pcmcia_device handling */ @@ -998,6 +1003,8 @@ static struct device_attribute pcmcia_dev_attrs[] = { ======================================================================*/ +#ifdef CONFIG_PCMCIA_IOCTL + static int queue_empty(user_info_t *user) { return (user->event_head == user->event_tail); @@ -1024,6 +1031,11 @@ static void handle_event(struct pcmcia_bus_socket *s, event_t event) queue_event(user, event); wake_up_interruptible(&s->queue); } +#else +static inline void handle_event(struct pcmcia_bus_socket *s, event_t event) { return; } +static inline int handle_request(struct pcmcia_bus_socket *s, event_t event) { return CS_SUCCESS; } +#endif + /*====================================================================== @@ -1142,6 +1154,8 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) ======================================================================*/ +#ifdef CONFIG_PCMCIA_IOCTL + static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info) { struct pcmcia_driver *p_drv; @@ -1237,6 +1251,8 @@ rescan: return (ret); } /* bind_request */ +#endif + int pcmcia_register_client(client_handle_t *handle, client_reg_t *req) { @@ -1334,6 +1350,7 @@ EXPORT_SYMBOL(pcmcia_register_client); /*====================================================================*/ +#ifdef CONFIG_PCMCIA_IOCTL extern struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s); @@ -1422,6 +1439,8 @@ static int get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info, return (ret); } /* get_device_info */ +#endif + /*====================================================================*/ /* unbind _all_ devices attached to a given pcmcia_bus_socket. The @@ -1495,6 +1514,8 @@ EXPORT_SYMBOL(pcmcia_deregister_client); ======================================================================*/ +#ifdef CONFIG_PCMCIA_IOCTL + static int ds_open(struct inode *inode, struct file *file) { socket_t i = iminor(inode); @@ -1855,6 +1876,8 @@ static struct file_operations ds_fops = { .poll = ds_poll, }; +#endif + static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) { struct pcmcia_socket *socket = class_get_devdata(class_dev); @@ -1939,13 +1962,16 @@ static struct bus_type pcmcia_bus_type = { static int __init init_pcmcia_bus(void) { +#ifdef CONFIG_PCMCIA_IOCTL int i; +#endif spin_lock_init(&pcmcia_dev_list_lock); bus_register(&pcmcia_bus_type); class_interface_register(&pcmcia_bus_interface); +#ifdef CONFIG_PCMCIA_IOCTL /* Set up character device for user mode clients */ i = register_chrdev(0, "pcmcia", &ds_fops); if (i < 0) @@ -1958,6 +1984,7 @@ static int __init init_pcmcia_bus(void) proc_pccard = proc_mkdir("pccard", proc_bus); if (proc_pccard) create_proc_read_entry("drivers",0,proc_pccard,proc_read_drivers,NULL); +#endif #endif return 0; @@ -1970,6 +1997,7 @@ static void __exit exit_pcmcia_bus(void) { class_interface_unregister(&pcmcia_bus_interface); +#ifdef CONFIG_PCMCIA_IOCTL #ifdef CONFIG_PROC_FS if (proc_pccard) { remove_proc_entry("drivers", proc_pccard); @@ -1978,6 +2006,7 @@ static void __exit exit_pcmcia_bus(void) #endif if (major_dev != -1) unregister_chrdev(major_dev, "pcmcia"); +#endif bus_unregister(&pcmcia_bus_type); } @@ -1986,7 +2015,7 @@ module_exit(exit_pcmcia_bus); /* helpers for backwards-compatible functions */ - +#ifdef CONFIG_PCMCIA_IOCTL static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr) { struct pcmcia_socket * s = pcmcia_get_socket_by_nr(nr); @@ -2011,5 +2040,6 @@ static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) return (p_drv); } +#endif MODULE_ALIAS("ds"); -- cgit v1.2.3 From e7a480d229461e54a0b3b0439b2bf0e652545e3d Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:47 -0700 Subject: [PATCH] pcmcia: move PCMCIA ioctl to a separate file Move all PCMCIA_IOCTL-related code to a different file. Signed-off-by: Dominik Brodowski From: Richard Purdie The pcmcia-move-pcmcia-ioctl-to-a-separate-file patch was corrupted in -mm2 causing this problem. Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/Makefile | 1 + drivers/pcmcia/ds.c | 795 +----------------------------------------- drivers/pcmcia/ds_internal.h | 55 +++ drivers/pcmcia/pcmcia_ioctl.c | 779 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 850 insertions(+), 780 deletions(-) create mode 100644 drivers/pcmcia/ds_internal.h create mode 100644 drivers/pcmcia/pcmcia_ioctl.c (limited to 'drivers') diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 50c29361bc5..195e8104ae6 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -11,6 +11,7 @@ pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o obj-$(CONFIG_PCCARD) += pcmcia_core.o pcmcia-y += ds.o pcmcia_compat.o +pcmcia-$(CONFIG_PCMCIA_IOCTL) += pcmcia_ioctl.o obj-$(CONFIG_PCMCIA) += pcmcia.o obj-$(CONFIG_PCCARD_NONSTATIC) += rsrc_nonstatic.o diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 0c7dc5b3875..80b34b65511 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -50,6 +50,7 @@ #include #include "cs_internal.h" +#include "ds_internal.h" /*====================================================================*/ @@ -60,7 +61,7 @@ MODULE_DESCRIPTION("PCMCIA Driver Services"); MODULE_LICENSE("GPL"); #ifdef DEBUG -static int ds_pc_debug; +int ds_pc_debug; module_param_named(pc_debug, ds_pc_debug, int, 0644); @@ -72,57 +73,7 @@ module_param_named(pc_debug, ds_pc_debug, int, 0644); #define ds_dbg(lvl, fmt, arg...) do { } while (0) #endif -/*====================================================================*/ - -/* Device user information */ -#define MAX_EVENTS 32 -#define USER_MAGIC 0x7ea4 -#define CHECK_USER(u) \ - (((u) == NULL) || ((u)->user_magic != USER_MAGIC)) -typedef struct user_info_t { - u_int user_magic; - int event_head, event_tail; - event_t event[MAX_EVENTS]; - struct user_info_t *next; - struct pcmcia_bus_socket *socket; -} user_info_t; - -/* Socket state information */ -struct pcmcia_bus_socket { - struct kref refcount; - struct pcmcia_callback callback; - int state; - user_info_t *user; - wait_queue_head_t queue; - struct pcmcia_socket *parent; - - /* the PCMCIA devices connected to this socket (normally one, more - * for multifunction devices: */ - struct list_head devices_list; - u8 device_count; /* the number of devices, used - * only internally and subject - * to incorrectness and change */ - - u8 device_add_pending; - struct work_struct device_add; -}; -static spinlock_t pcmcia_dev_list_lock; - -static struct bus_type pcmcia_bus_type; - -#define DS_SOCKET_PRESENT 0x01 -#define DS_SOCKET_BUSY 0x02 -#define DS_SOCKET_REMOVAL_PENDING 0x10 -#define DS_SOCKET_DEAD 0x80 - -/*====================================================================*/ -#ifdef CONFIG_PCMCIA_IOCTL - -static int major_dev = -1; -static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr); -static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info); - -#endif +spinlock_t pcmcia_dev_list_lock; static int unbind_request(struct pcmcia_bus_socket *s); @@ -362,19 +313,19 @@ static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filenam /*======================================================================*/ -static void pcmcia_release_bus_socket(struct kref *refcount) +void pcmcia_release_bus_socket(struct kref *refcount) { struct pcmcia_bus_socket *s = container_of(refcount, struct pcmcia_bus_socket, refcount); pcmcia_put_socket(s->parent); kfree(s); } -static void pcmcia_put_bus_socket(struct pcmcia_bus_socket *s) +void pcmcia_put_bus_socket(struct pcmcia_bus_socket *s) { kref_put(&s->refcount, pcmcia_release_bus_socket); } -static struct pcmcia_bus_socket *pcmcia_get_bus_socket(struct pcmcia_bus_socket *s) +struct pcmcia_bus_socket *pcmcia_get_bus_socket(struct pcmcia_bus_socket *s) { kref_get(&s->refcount); return (s); @@ -414,44 +365,10 @@ void pcmcia_unregister_driver(struct pcmcia_driver *driver) } EXPORT_SYMBOL(pcmcia_unregister_driver); -#ifdef CONFIG_PCMCIA_IOCTL -#ifdef CONFIG_PROC_FS -static struct proc_dir_entry *proc_pccard = NULL; - -static int proc_read_drivers_callback(struct device_driver *driver, void *d) -{ - char **p = d; - struct pcmcia_driver *p_drv = container_of(driver, - struct pcmcia_driver, drv); - - *p += sprintf(*p, "%-24.24s 1 %d\n", p_drv->drv.name, -#ifdef CONFIG_MODULE_UNLOAD - (p_drv->owner) ? module_refcount(p_drv->owner) : 1 -#else - 1 -#endif - ); - d = (void *) p; - - return 0; -} - -static int proc_read_drivers(char *buf, char **start, off_t pos, - int count, int *eof, void *data) -{ - char *p = buf; - - bus_for_each_drv(&pcmcia_bus_type, NULL, - (void *) &p, proc_read_drivers_callback); - - return (p - buf); -} -#endif -#endif /* pcmcia_device handling */ -static struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev) +struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev) { struct device *tmp_dev; tmp_dev = get_device(&p_dev->dev); @@ -460,7 +377,7 @@ static struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev) return to_pcmcia_dev(tmp_dev); } -static void pcmcia_put_dev(struct pcmcia_device *p_dev) +void pcmcia_put_dev(struct pcmcia_device *p_dev) { if (p_dev) put_device(&p_dev->dev); @@ -605,7 +522,7 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) */ static DECLARE_MUTEX(device_add_lock); -static struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, unsigned int function) +struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, unsigned int function) { struct pcmcia_device *p_dev; unsigned long flags; @@ -997,47 +914,6 @@ static struct device_attribute pcmcia_dev_attrs[] = { }; -/*====================================================================== - - These manage a ring buffer of events pending for one user process - -======================================================================*/ - -#ifdef CONFIG_PCMCIA_IOCTL - -static int queue_empty(user_info_t *user) -{ - return (user->event_head == user->event_tail); -} - -static event_t get_queued_event(user_info_t *user) -{ - user->event_tail = (user->event_tail+1) % MAX_EVENTS; - return user->event[user->event_tail]; -} - -static void queue_event(user_info_t *user, event_t event) -{ - user->event_head = (user->event_head+1) % MAX_EVENTS; - if (user->event_head == user->event_tail) - user->event_tail = (user->event_tail+1) % MAX_EVENTS; - user->event[user->event_head] = event; -} - -static void handle_event(struct pcmcia_bus_socket *s, event_t event) -{ - user_info_t *user; - for (user = s->user; user; user = user->next) - queue_event(user, event); - wake_up_interruptible(&s->queue); -} -#else -static inline void handle_event(struct pcmcia_bus_socket *s, event_t event) { return; } -static inline int handle_request(struct pcmcia_bus_socket *s, event_t event) { return CS_SUCCESS; } -#endif - - - /*====================================================================== The card status event handler. @@ -1131,128 +1007,6 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) } /* ds_event */ -/*====================================================================== - - bind_request() and bind_device() are merged by now. Register_client() - is called right at the end of bind_request(), during the driver's - ->attach() call. Individual descriptions: - - bind_request() connects a socket to a particular client driver. - It looks up the specified device ID in the list of registered - drivers, binds it to the socket, and tries to create an instance - of the device. unbind_request() deletes a driver instance. - - Bind_device() associates a device driver with a particular socket. - It is normally called by Driver Services after it has identified - a newly inserted card. An instance of that driver will then be - eligible to register as a client of this socket. - - Register_client() uses the dev_info_t handle to match the - caller with a socket. The driver must have already been bound - to a socket with bind_device() -- in fact, bind_device() - allocates the client structure that will be used. - -======================================================================*/ - -#ifdef CONFIG_PCMCIA_IOCTL - -static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info) -{ - struct pcmcia_driver *p_drv; - struct pcmcia_device *p_dev; - int ret = 0; - unsigned long flags; - - s = pcmcia_get_bus_socket(s); - if (!s) - return -EINVAL; - - ds_dbg(2, "bind_request(%d, '%s')\n", s->parent->sock, - (char *)bind_info->dev_info); - - p_drv = get_pcmcia_driver(&bind_info->dev_info); - if (!p_drv) { - ret = -EINVAL; - goto err_put; - } - - if (!try_module_get(p_drv->owner)) { - ret = -EINVAL; - goto err_put_driver; - } - - spin_lock_irqsave(&pcmcia_dev_list_lock, flags); - list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { - if (p_dev->func == bind_info->function) { - if ((p_dev->dev.driver == &p_drv->drv)) { - if (p_dev->cardmgr) { - /* if there's already a device - * registered, and it was registered - * by userspace before, we need to - * return the "instance". */ - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - bind_info->instance = p_dev->instance; - ret = -EBUSY; - goto err_put_module; - } else { - /* the correct driver managed to bind - * itself magically to the correct - * device. */ - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - p_dev->cardmgr = p_drv; - ret = 0; - goto err_put_module; - } - } else if (!p_dev->dev.driver) { - /* there's already a device available where - * no device has been bound to yet. So we don't - * need to register a device! */ - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - goto rescan; - } - } - } - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - - p_dev = pcmcia_device_add(s, bind_info->function); - if (!p_dev) { - ret = -EIO; - goto err_put_module; - } - -rescan: - p_dev->cardmgr = p_drv; - - /* if a driver is already running, we can abort */ - if (p_dev->dev.driver) - goto err_put_module; - - /* - * Prevent this racing with a card insertion. - */ - down(&s->parent->skt_sem); - bus_rescan_devices(&pcmcia_bus_type); - up(&s->parent->skt_sem); - - /* check whether the driver indeed matched. I don't care if this - * is racy or not, because it can only happen on cardmgr access - * paths... - */ - if (!(p_dev->dev.driver == &p_drv->drv)) - p_dev->cardmgr = NULL; - - err_put_module: - module_put(p_drv->owner); - err_put_driver: - put_driver(&p_drv->drv); - err_put: - pcmcia_put_bus_socket(s); - - return (ret); -} /* bind_request */ - -#endif - int pcmcia_register_client(client_handle_t *handle, client_reg_t *req) { @@ -1349,100 +1103,6 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req) EXPORT_SYMBOL(pcmcia_register_client); -/*====================================================================*/ -#ifdef CONFIG_PCMCIA_IOCTL - -extern struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s); - -static int get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info, int first) -{ - dev_node_t *node; - struct pcmcia_device *p_dev; - unsigned long flags; - int ret = 0; - -#ifdef CONFIG_CARDBUS - /* - * Some unbelievably ugly code to associate the PCI cardbus - * device and its driver with the PCMCIA "bind" information. - */ - { - struct pci_bus *bus; - - bus = pcmcia_lookup_bus(s->parent); - if (bus) { - struct list_head *list; - struct pci_dev *dev = NULL; - - list = bus->devices.next; - while (list != &bus->devices) { - struct pci_dev *pdev = pci_dev_b(list); - list = list->next; - - if (first) { - dev = pdev; - break; - } - - /* Try to handle "next" here some way? */ - } - if (dev && dev->driver) { - strlcpy(bind_info->name, dev->driver->name, DEV_NAME_LEN); - bind_info->major = 0; - bind_info->minor = 0; - bind_info->next = NULL; - return 0; - } - } - } -#endif - - spin_lock_irqsave(&pcmcia_dev_list_lock, flags); - list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { - if (p_dev->func == bind_info->function) { - p_dev = pcmcia_get_dev(p_dev); - if (!p_dev) - continue; - goto found; - } - } - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - return -ENODEV; - - found: - spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - - if ((!p_dev->instance) || - (p_dev->instance->state & DEV_CONFIG_PENDING)) { - ret = -EAGAIN; - goto err_put; - } - - if (first) - node = p_dev->instance->dev; - else - for (node = p_dev->instance->dev; node; node = node->next) - if (node == bind_info->next) - break; - if (!node) { - ret = -ENODEV; - goto err_put; - } - - strlcpy(bind_info->name, node->dev_name, DEV_NAME_LEN); - bind_info->major = node->major; - bind_info->minor = node->minor; - bind_info->next = node->next; - - err_put: - pcmcia_put_dev(p_dev); - return (ret); -} /* get_device_info */ - -#endif - -/*====================================================================*/ - /* unbind _all_ devices attached to a given pcmcia_bus_socket. The * drivers have been called with EVENT_CARD_REMOVAL before. */ @@ -1507,377 +1167,6 @@ int pcmcia_deregister_client(client_handle_t handle) } /* deregister_client */ EXPORT_SYMBOL(pcmcia_deregister_client); - -/*====================================================================== - - The user-mode PC Card device interface - -======================================================================*/ - -#ifdef CONFIG_PCMCIA_IOCTL - -static int ds_open(struct inode *inode, struct file *file) -{ - socket_t i = iminor(inode); - struct pcmcia_bus_socket *s; - user_info_t *user; - - ds_dbg(0, "ds_open(socket %d)\n", i); - - s = get_socket_info_by_nr(i); - if (!s) - return -ENODEV; - s = pcmcia_get_bus_socket(s); - if (!s) - return -ENODEV; - - if ((file->f_flags & O_ACCMODE) != O_RDONLY) { - if (s->state & DS_SOCKET_BUSY) { - pcmcia_put_bus_socket(s); - return -EBUSY; - } - else - s->state |= DS_SOCKET_BUSY; - } - - user = kmalloc(sizeof(user_info_t), GFP_KERNEL); - if (!user) { - pcmcia_put_bus_socket(s); - return -ENOMEM; - } - user->event_tail = user->event_head = 0; - user->next = s->user; - user->user_magic = USER_MAGIC; - user->socket = s; - s->user = user; - file->private_data = user; - - if (s->state & DS_SOCKET_PRESENT) - queue_event(user, CS_EVENT_CARD_INSERTION); - return 0; -} /* ds_open */ - -/*====================================================================*/ - -static int ds_release(struct inode *inode, struct file *file) -{ - struct pcmcia_bus_socket *s; - user_info_t *user, **link; - - ds_dbg(0, "ds_release(socket %d)\n", iminor(inode)); - - user = file->private_data; - if (CHECK_USER(user)) - goto out; - - s = user->socket; - - /* Unlink user data structure */ - if ((file->f_flags & O_ACCMODE) != O_RDONLY) { - s->state &= ~DS_SOCKET_BUSY; - } - file->private_data = NULL; - for (link = &s->user; *link; link = &(*link)->next) - if (*link == user) break; - if (link == NULL) - goto out; - *link = user->next; - user->user_magic = 0; - kfree(user); - pcmcia_put_bus_socket(s); -out: - return 0; -} /* ds_release */ - -/*====================================================================*/ - -static ssize_t ds_read(struct file *file, char __user *buf, - size_t count, loff_t *ppos) -{ - struct pcmcia_bus_socket *s; - user_info_t *user; - int ret; - - ds_dbg(2, "ds_read(socket %d)\n", iminor(file->f_dentry->d_inode)); - - if (count < 4) - return -EINVAL; - - user = file->private_data; - if (CHECK_USER(user)) - return -EIO; - - s = user->socket; - if (s->state & DS_SOCKET_DEAD) - return -EIO; - - ret = wait_event_interruptible(s->queue, !queue_empty(user)); - if (ret == 0) - ret = put_user(get_queued_event(user), (int __user *)buf) ? -EFAULT : 4; - - return ret; -} /* ds_read */ - -/*====================================================================*/ - -static ssize_t ds_write(struct file *file, const char __user *buf, - size_t count, loff_t *ppos) -{ - ds_dbg(2, "ds_write(socket %d)\n", iminor(file->f_dentry->d_inode)); - - if (count != 4) - return -EINVAL; - if ((file->f_flags & O_ACCMODE) == O_RDONLY) - return -EBADF; - - return -EIO; -} /* ds_write */ - -/*====================================================================*/ - -/* No kernel lock - fine */ -static u_int ds_poll(struct file *file, poll_table *wait) -{ - struct pcmcia_bus_socket *s; - user_info_t *user; - - ds_dbg(2, "ds_poll(socket %d)\n", iminor(file->f_dentry->d_inode)); - - user = file->private_data; - if (CHECK_USER(user)) - return POLLERR; - s = user->socket; - /* - * We don't check for a dead socket here since that - * will send cardmgr into an endless spin. - */ - poll_wait(file, &s->queue, wait); - if (!queue_empty(user)) - return POLLIN | POLLRDNORM; - return 0; -} /* ds_poll */ - -/*====================================================================*/ - -extern int pcmcia_adjust_resource_info(adjust_t *adj); - -static int ds_ioctl(struct inode * inode, struct file * file, - u_int cmd, u_long arg) -{ - struct pcmcia_bus_socket *s; - void __user *uarg = (char __user *)arg; - u_int size; - int ret, err; - ds_ioctl_arg_t *buf; - user_info_t *user; - - ds_dbg(2, "ds_ioctl(socket %d, %#x, %#lx)\n", iminor(inode), cmd, arg); - - user = file->private_data; - if (CHECK_USER(user)) - return -EIO; - - s = user->socket; - if (s->state & DS_SOCKET_DEAD) - return -EIO; - - size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; - if (size > sizeof(ds_ioctl_arg_t)) return -EINVAL; - - /* Permission check */ - if (!(cmd & IOC_OUT) && !capable(CAP_SYS_ADMIN)) - return -EPERM; - - if (cmd & IOC_IN) { - if (!access_ok(VERIFY_READ, uarg, size)) { - ds_dbg(3, "ds_ioctl(): verify_read = %d\n", -EFAULT); - return -EFAULT; - } - } - if (cmd & IOC_OUT) { - if (!access_ok(VERIFY_WRITE, uarg, size)) { - ds_dbg(3, "ds_ioctl(): verify_write = %d\n", -EFAULT); - return -EFAULT; - } - } - buf = kmalloc(sizeof(ds_ioctl_arg_t), GFP_KERNEL); - if (!buf) - return -ENOMEM; - - err = ret = 0; - - if (cmd & IOC_IN) __copy_from_user((char *)buf, uarg, size); - - switch (cmd) { - case DS_ADJUST_RESOURCE_INFO: - ret = pcmcia_adjust_resource_info(&buf->adjust); - break; - case DS_GET_CARD_SERVICES_INFO: - ret = pcmcia_get_card_services_info(&buf->servinfo); - break; - case DS_GET_CONFIGURATION_INFO: - if (buf->config.Function && - (buf->config.Function >= s->parent->functions)) - ret = CS_BAD_ARGS; - else - ret = pccard_get_configuration_info(s->parent, - buf->config.Function, &buf->config); - break; - case DS_GET_FIRST_TUPLE: - down(&s->parent->skt_sem); - pcmcia_validate_mem(s->parent); - up(&s->parent->skt_sem); - ret = pccard_get_first_tuple(s->parent, BIND_FN_ALL, &buf->tuple); - break; - case DS_GET_NEXT_TUPLE: - ret = pccard_get_next_tuple(s->parent, BIND_FN_ALL, &buf->tuple); - break; - case DS_GET_TUPLE_DATA: - buf->tuple.TupleData = buf->tuple_parse.data; - buf->tuple.TupleDataMax = sizeof(buf->tuple_parse.data); - ret = pccard_get_tuple_data(s->parent, &buf->tuple); - break; - case DS_PARSE_TUPLE: - buf->tuple.TupleData = buf->tuple_parse.data; - ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); - break; - case DS_RESET_CARD: - ret = pccard_reset_card(s->parent); - break; - case DS_GET_STATUS: - if (buf->status.Function && - (buf->status.Function >= s->parent->functions)) - ret = CS_BAD_ARGS; - else - ret = pccard_get_status(s->parent, buf->status.Function, &buf->status); - break; - case DS_VALIDATE_CIS: - down(&s->parent->skt_sem); - pcmcia_validate_mem(s->parent); - up(&s->parent->skt_sem); - ret = pccard_validate_cis(s->parent, BIND_FN_ALL, &buf->cisinfo); - break; - case DS_SUSPEND_CARD: - ret = pcmcia_suspend_card(s->parent); - break; - case DS_RESUME_CARD: - ret = pcmcia_resume_card(s->parent); - break; - case DS_EJECT_CARD: - err = pcmcia_eject_card(s->parent); - break; - case DS_INSERT_CARD: - err = pcmcia_insert_card(s->parent); - break; - case DS_ACCESS_CONFIGURATION_REGISTER: - if ((buf->conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN)) { - err = -EPERM; - goto free_out; - } - if (buf->conf_reg.Function && - (buf->conf_reg.Function >= s->parent->functions)) - ret = CS_BAD_ARGS; - else - ret = pccard_access_configuration_register(s->parent, - buf->conf_reg.Function, &buf->conf_reg); - break; - case DS_GET_FIRST_REGION: - case DS_GET_NEXT_REGION: - case DS_BIND_MTD: - if (!capable(CAP_SYS_ADMIN)) { - err = -EPERM; - goto free_out; - } else { - static int printed = 0; - if (!printed) { - printk(KERN_WARNING "2.6. kernels use pcmciamtd instead of memory_cs.c and do not require special\n"); - printk(KERN_WARNING "MTD handling any more.\n"); - printed++; - } - } - err = -EINVAL; - goto free_out; - break; - case DS_GET_FIRST_WINDOW: - ret = pcmcia_get_window(s->parent, &buf->win_info.handle, 0, - &buf->win_info.window); - break; - case DS_GET_NEXT_WINDOW: - ret = pcmcia_get_window(s->parent, &buf->win_info.handle, - buf->win_info.handle->index + 1, &buf->win_info.window); - break; - case DS_GET_MEM_PAGE: - ret = pcmcia_get_mem_page(buf->win_info.handle, - &buf->win_info.map); - break; - case DS_REPLACE_CIS: - ret = pcmcia_replace_cis(s->parent, &buf->cisdump); - break; - case DS_BIND_REQUEST: - if (!capable(CAP_SYS_ADMIN)) { - err = -EPERM; - goto free_out; - } - err = bind_request(s, &buf->bind_info); - break; - case DS_GET_DEVICE_INFO: - err = get_device_info(s, &buf->bind_info, 1); - break; - case DS_GET_NEXT_DEVICE: - err = get_device_info(s, &buf->bind_info, 0); - break; - case DS_UNBIND_REQUEST: - err = 0; - break; - default: - err = -EINVAL; - } - - if ((err == 0) && (ret != CS_SUCCESS)) { - ds_dbg(2, "ds_ioctl: ret = %d\n", ret); - switch (ret) { - case CS_BAD_SOCKET: case CS_NO_CARD: - err = -ENODEV; break; - case CS_BAD_ARGS: case CS_BAD_ATTRIBUTE: case CS_BAD_IRQ: - case CS_BAD_TUPLE: - err = -EINVAL; break; - case CS_IN_USE: - err = -EBUSY; break; - case CS_OUT_OF_RESOURCE: - err = -ENOSPC; break; - case CS_NO_MORE_ITEMS: - err = -ENODATA; break; - case CS_UNSUPPORTED_FUNCTION: - err = -ENOSYS; break; - default: - err = -EIO; break; - } - } - - if (cmd & IOC_OUT) { - if (__copy_to_user(uarg, (char *)buf, size)) - err = -EFAULT; - } - -free_out: - kfree(buf); - return err; -} /* ds_ioctl */ - -/*====================================================================*/ - -static struct file_operations ds_fops = { - .owner = THIS_MODULE, - .open = ds_open, - .release = ds_release, - .ioctl = ds_ioctl, - .read = ds_read, - .write = ds_write, - .poll = ds_poll, -}; - -#endif - static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) { struct pcmcia_socket *socket = class_get_devdata(class_dev); @@ -1905,7 +1194,9 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) */ msleep(250); +#ifdef CONFIG_PCMCIA_IOCTL init_waitqueue_head(&s->queue); +#endif INIT_LIST_HEAD(&s->devices_list); INIT_WORK(&s->device_add, pcmcia_delayed_add_pseudo_device, s); @@ -1952,7 +1243,7 @@ static struct class_interface pcmcia_bus_interface = { }; -static struct bus_type pcmcia_bus_type = { +struct bus_type pcmcia_bus_type = { .name = "pcmcia", .hotplug = pcmcia_bus_hotplug, .match = pcmcia_bus_match, @@ -1962,30 +1253,12 @@ static struct bus_type pcmcia_bus_type = { static int __init init_pcmcia_bus(void) { -#ifdef CONFIG_PCMCIA_IOCTL - int i; -#endif - spin_lock_init(&pcmcia_dev_list_lock); bus_register(&pcmcia_bus_type); class_interface_register(&pcmcia_bus_interface); -#ifdef CONFIG_PCMCIA_IOCTL - /* Set up character device for user mode clients */ - i = register_chrdev(0, "pcmcia", &ds_fops); - if (i < 0) - printk(KERN_NOTICE "unable to find a free device # for " - "Driver Services (error=%d)\n", i); - else - major_dev = i; - -#ifdef CONFIG_PROC_FS - proc_pccard = proc_mkdir("pccard", proc_bus); - if (proc_pccard) - create_proc_read_entry("drivers",0,proc_pccard,proc_read_drivers,NULL); -#endif -#endif + pcmcia_setup_ioctl(); return 0; } @@ -1995,51 +1268,13 @@ fs_initcall(init_pcmcia_bus); /* one level after subsys_initcall so that static void __exit exit_pcmcia_bus(void) { - class_interface_unregister(&pcmcia_bus_interface); + pcmcia_cleanup_ioctl(); -#ifdef CONFIG_PCMCIA_IOCTL -#ifdef CONFIG_PROC_FS - if (proc_pccard) { - remove_proc_entry("drivers", proc_pccard); - remove_proc_entry("pccard", proc_bus); - } -#endif - if (major_dev != -1) - unregister_chrdev(major_dev, "pcmcia"); -#endif + class_interface_unregister(&pcmcia_bus_interface); bus_unregister(&pcmcia_bus_type); } module_exit(exit_pcmcia_bus); - -/* helpers for backwards-compatible functions */ -#ifdef CONFIG_PCMCIA_IOCTL -static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr) -{ - struct pcmcia_socket * s = pcmcia_get_socket_by_nr(nr); - if (s && s->pcmcia) - return s->pcmcia; - else - return NULL; -} - -/* backwards-compatible accessing of driver --- by name! */ - -static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) -{ - struct device_driver *drv; - struct pcmcia_driver *p_drv; - - drv = driver_find((char *) dev_info, &pcmcia_bus_type); - if (!drv) - return NULL; - - p_drv = container_of(drv, struct pcmcia_driver, drv); - - return (p_drv); -} -#endif - MODULE_ALIAS("ds"); diff --git a/drivers/pcmcia/ds_internal.h b/drivers/pcmcia/ds_internal.h new file mode 100644 index 00000000000..0de90e5e67a --- /dev/null +++ b/drivers/pcmcia/ds_internal.h @@ -0,0 +1,55 @@ +/* ds_internal.h - internal header for 16-bit PCMCIA devices management */ + +struct user_info_t; + +/* Socket state information */ +struct pcmcia_bus_socket { + struct kref refcount; + struct pcmcia_callback callback; + int state; + struct pcmcia_socket *parent; + + /* the PCMCIA devices connected to this socket (normally one, more + * for multifunction devices: */ + struct list_head devices_list; + u8 device_count; /* the number of devices, used + * only internally and subject + * to incorrectness and change */ + + u8 device_add_pending; + struct work_struct device_add; + + +#ifdef CONFIG_PCMCIA_IOCTL + struct user_info_t *user; + wait_queue_head_t queue; +#endif +}; +extern spinlock_t pcmcia_dev_list_lock; + +extern struct bus_type pcmcia_bus_type; + + +#define DS_SOCKET_PRESENT 0x01 +#define DS_SOCKET_BUSY 0x02 +#define DS_SOCKET_DEAD 0x80 + +extern struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev); +extern void pcmcia_put_dev(struct pcmcia_device *p_dev); + +struct pcmcia_bus_socket *pcmcia_get_bus_socket(struct pcmcia_bus_socket *s); +void pcmcia_put_bus_socket(struct pcmcia_bus_socket *s); + +struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, unsigned int function); + +#ifdef CONFIG_PCMCIA_IOCTL +extern void __init pcmcia_setup_ioctl(void); +extern void __exit pcmcia_cleanup_ioctl(void); +extern void handle_event(struct pcmcia_bus_socket *s, event_t event); +extern int handle_request(struct pcmcia_bus_socket *s, event_t event); +#else +static inline void __init pcmcia_setup_ioctl(void) { return; } +static inline void __init pcmcia_cleanup_ioctl(void) { return; } +static inline void handle_event(struct pcmcia_bus_socket *s, event_t event) { return; } +static inline int handle_request(struct pcmcia_bus_socket *s, event_t event) { return CS_SUCCESS; } +#endif diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c new file mode 100644 index 00000000000..e8d2c95db1c --- /dev/null +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -0,0 +1,779 @@ +/* + * pcmcia_ioctl.c -- ioctl interface for cardmgr and cardctl + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * The initial developer of the original code is David A. Hinds + * . Portions created by David A. Hinds + * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + * + * (C) 1999 David A. Hinds + * (C) 2003 - 2004 Dominik Brodowski + */ + +/* + * This file will go away soon. + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define IN_CARD_SERVICES +#include +#include +#include +#include +#include +#include +#include + +#include "cs_internal.h" +#include "ds_internal.h" + +static int major_dev = -1; + + +/* Device user information */ +#define MAX_EVENTS 32 +#define USER_MAGIC 0x7ea4 +#define CHECK_USER(u) \ + (((u) == NULL) || ((u)->user_magic != USER_MAGIC)) + +typedef struct user_info_t { + u_int user_magic; + int event_head, event_tail; + event_t event[MAX_EVENTS]; + struct user_info_t *next; + struct pcmcia_bus_socket *socket; +} user_info_t; + + +#ifdef DEBUG +extern int ds_pc_debug; +#define cs_socket_name(skt) ((skt)->dev.class_id) + +#define ds_dbg(lvl, fmt, arg...) do { \ + if (ds_pc_debug >= lvl) \ + printk(KERN_DEBUG "ds: " fmt , ## arg); \ +} while (0) +#else +#define ds_dbg(lvl, fmt, arg...) do { } while (0) +#endif + + +static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr) +{ + struct pcmcia_socket * s = pcmcia_get_socket_by_nr(nr); + if (s && s->pcmcia) + return s->pcmcia; + else + return NULL; +} + +/* backwards-compatible accessing of driver --- by name! */ + +static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) +{ + struct device_driver *drv; + struct pcmcia_driver *p_drv; + + drv = driver_find((char *) dev_info, &pcmcia_bus_type); + if (!drv) + return NULL; + + p_drv = container_of(drv, struct pcmcia_driver, drv); + + return (p_drv); +} + + +#ifdef CONFIG_PROC_FS +static struct proc_dir_entry *proc_pccard = NULL; + +static int proc_read_drivers_callback(struct device_driver *driver, void *d) +{ + char **p = d; + struct pcmcia_driver *p_drv = container_of(driver, + struct pcmcia_driver, drv); + + *p += sprintf(*p, "%-24.24s 1 %d\n", p_drv->drv.name, +#ifdef CONFIG_MODULE_UNLOAD + (p_drv->owner) ? module_refcount(p_drv->owner) : 1 +#else + 1 +#endif + ); + d = (void *) p; + + return 0; +} + +static int proc_read_drivers(char *buf, char **start, off_t pos, + int count, int *eof, void *data) +{ + char *p = buf; + + bus_for_each_drv(&pcmcia_bus_type, NULL, + (void *) &p, proc_read_drivers_callback); + + return (p - buf); +} +#endif + +/*====================================================================== + + These manage a ring buffer of events pending for one user process + +======================================================================*/ + + +static int queue_empty(user_info_t *user) +{ + return (user->event_head == user->event_tail); +} + +static event_t get_queued_event(user_info_t *user) +{ + user->event_tail = (user->event_tail+1) % MAX_EVENTS; + return user->event[user->event_tail]; +} + +static void queue_event(user_info_t *user, event_t event) +{ + user->event_head = (user->event_head+1) % MAX_EVENTS; + if (user->event_head == user->event_tail) + user->event_tail = (user->event_tail+1) % MAX_EVENTS; + user->event[user->event_head] = event; +} + +void handle_event(struct pcmcia_bus_socket *s, event_t event) +{ + user_info_t *user; + for (user = s->user; user; user = user->next) + queue_event(user, event); + wake_up_interruptible(&s->queue); +} + + +/*====================================================================== + + bind_request() and bind_device() are merged by now. Register_client() + is called right at the end of bind_request(), during the driver's + ->attach() call. Individual descriptions: + + bind_request() connects a socket to a particular client driver. + It looks up the specified device ID in the list of registered + drivers, binds it to the socket, and tries to create an instance + of the device. unbind_request() deletes a driver instance. + + Bind_device() associates a device driver with a particular socket. + It is normally called by Driver Services after it has identified + a newly inserted card. An instance of that driver will then be + eligible to register as a client of this socket. + + Register_client() uses the dev_info_t handle to match the + caller with a socket. The driver must have already been bound + to a socket with bind_device() -- in fact, bind_device() + allocates the client structure that will be used. + +======================================================================*/ + +static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info) +{ + struct pcmcia_driver *p_drv; + struct pcmcia_device *p_dev; + int ret = 0; + unsigned long flags; + + s = pcmcia_get_bus_socket(s); + if (!s) + return -EINVAL; + + ds_dbg(2, "bind_request(%d, '%s')\n", s->parent->sock, + (char *)bind_info->dev_info); + + p_drv = get_pcmcia_driver(&bind_info->dev_info); + if (!p_drv) { + ret = -EINVAL; + goto err_put; + } + + if (!try_module_get(p_drv->owner)) { + ret = -EINVAL; + goto err_put_driver; + } + + spin_lock_irqsave(&pcmcia_dev_list_lock, flags); + list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { + if (p_dev->func == bind_info->function) { + if ((p_dev->dev.driver == &p_drv->drv)) { + if (p_dev->cardmgr) { + /* if there's already a device + * registered, and it was registered + * by userspace before, we need to + * return the "instance". */ + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + bind_info->instance = p_dev->instance; + ret = -EBUSY; + goto err_put_module; + } else { + /* the correct driver managed to bind + * itself magically to the correct + * device. */ + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + p_dev->cardmgr = p_drv; + ret = 0; + goto err_put_module; + } + } else if (!p_dev->dev.driver) { + /* there's already a device available where + * no device has been bound to yet. So we don't + * need to register a device! */ + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + goto rescan; + } + } + } + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + + p_dev = pcmcia_device_add(s, bind_info->function); + if (!p_dev) { + ret = -EIO; + goto err_put_module; + } + +rescan: + p_dev->cardmgr = p_drv; + + /* if a driver is already running, we can abort */ + if (p_dev->dev.driver) + goto err_put_module; + + /* + * Prevent this racing with a card insertion. + */ + down(&s->parent->skt_sem); + bus_rescan_devices(&pcmcia_bus_type); + up(&s->parent->skt_sem); + + /* check whether the driver indeed matched. I don't care if this + * is racy or not, because it can only happen on cardmgr access + * paths... + */ + if (!(p_dev->dev.driver == &p_drv->drv)) + p_dev->cardmgr = NULL; + + err_put_module: + module_put(p_drv->owner); + err_put_driver: + put_driver(&p_drv->drv); + err_put: + pcmcia_put_bus_socket(s); + + return (ret); +} /* bind_request */ + + +extern struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s); + +static int get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info, int first) +{ + dev_node_t *node; + struct pcmcia_device *p_dev; + unsigned long flags; + int ret = 0; + +#ifdef CONFIG_CARDBUS + /* + * Some unbelievably ugly code to associate the PCI cardbus + * device and its driver with the PCMCIA "bind" information. + */ + { + struct pci_bus *bus; + + bus = pcmcia_lookup_bus(s->parent); + if (bus) { + struct list_head *list; + struct pci_dev *dev = NULL; + + list = bus->devices.next; + while (list != &bus->devices) { + struct pci_dev *pdev = pci_dev_b(list); + list = list->next; + + if (first) { + dev = pdev; + break; + } + + /* Try to handle "next" here some way? */ + } + if (dev && dev->driver) { + strlcpy(bind_info->name, dev->driver->name, DEV_NAME_LEN); + bind_info->major = 0; + bind_info->minor = 0; + bind_info->next = NULL; + return 0; + } + } + } +#endif + + spin_lock_irqsave(&pcmcia_dev_list_lock, flags); + list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { + if (p_dev->func == bind_info->function) { + p_dev = pcmcia_get_dev(p_dev); + if (!p_dev) + continue; + goto found; + } + } + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + return -ENODEV; + + found: + spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); + + if ((!p_dev->instance) || + (p_dev->instance->state & DEV_CONFIG_PENDING)) { + ret = -EAGAIN; + goto err_put; + } + + if (first) + node = p_dev->instance->dev; + else + for (node = p_dev->instance->dev; node; node = node->next) + if (node == bind_info->next) + break; + if (!node) { + ret = -ENODEV; + goto err_put; + } + + strlcpy(bind_info->name, node->dev_name, DEV_NAME_LEN); + bind_info->major = node->major; + bind_info->minor = node->minor; + bind_info->next = node->next; + + err_put: + pcmcia_put_dev(p_dev); + return (ret); +} /* get_device_info */ + + +static int ds_open(struct inode *inode, struct file *file) +{ + socket_t i = iminor(inode); + struct pcmcia_bus_socket *s; + user_info_t *user; + + ds_dbg(0, "ds_open(socket %d)\n", i); + + s = get_socket_info_by_nr(i); + if (!s) + return -ENODEV; + s = pcmcia_get_bus_socket(s); + if (!s) + return -ENODEV; + + if ((file->f_flags & O_ACCMODE) != O_RDONLY) { + if (s->state & DS_SOCKET_BUSY) { + pcmcia_put_bus_socket(s); + return -EBUSY; + } + else + s->state |= DS_SOCKET_BUSY; + } + + user = kmalloc(sizeof(user_info_t), GFP_KERNEL); + if (!user) { + pcmcia_put_bus_socket(s); + return -ENOMEM; + } + user->event_tail = user->event_head = 0; + user->next = s->user; + user->user_magic = USER_MAGIC; + user->socket = s; + s->user = user; + file->private_data = user; + + if (s->state & DS_SOCKET_PRESENT) + queue_event(user, CS_EVENT_CARD_INSERTION); + return 0; +} /* ds_open */ + +/*====================================================================*/ + +static int ds_release(struct inode *inode, struct file *file) +{ + struct pcmcia_bus_socket *s; + user_info_t *user, **link; + + ds_dbg(0, "ds_release(socket %d)\n", iminor(inode)); + + user = file->private_data; + if (CHECK_USER(user)) + goto out; + + s = user->socket; + + /* Unlink user data structure */ + if ((file->f_flags & O_ACCMODE) != O_RDONLY) { + s->state &= ~DS_SOCKET_BUSY; + } + file->private_data = NULL; + for (link = &s->user; *link; link = &(*link)->next) + if (*link == user) break; + if (link == NULL) + goto out; + *link = user->next; + user->user_magic = 0; + kfree(user); + pcmcia_put_bus_socket(s); +out: + return 0; +} /* ds_release */ + +/*====================================================================*/ + +static ssize_t ds_read(struct file *file, char __user *buf, + size_t count, loff_t *ppos) +{ + struct pcmcia_bus_socket *s; + user_info_t *user; + int ret; + + ds_dbg(2, "ds_read(socket %d)\n", iminor(file->f_dentry->d_inode)); + + if (count < 4) + return -EINVAL; + + user = file->private_data; + if (CHECK_USER(user)) + return -EIO; + + s = user->socket; + if (s->state & DS_SOCKET_DEAD) + return -EIO; + + ret = wait_event_interruptible(s->queue, !queue_empty(user)); + if (ret == 0) + ret = put_user(get_queued_event(user), (int __user *)buf) ? -EFAULT : 4; + + return ret; +} /* ds_read */ + +/*====================================================================*/ + +static ssize_t ds_write(struct file *file, const char __user *buf, + size_t count, loff_t *ppos) +{ + ds_dbg(2, "ds_write(socket %d)\n", iminor(file->f_dentry->d_inode)); + + if (count != 4) + return -EINVAL; + if ((file->f_flags & O_ACCMODE) == O_RDONLY) + return -EBADF; + + return -EIO; +} /* ds_write */ + +/*====================================================================*/ + +/* No kernel lock - fine */ +static u_int ds_poll(struct file *file, poll_table *wait) +{ + struct pcmcia_bus_socket *s; + user_info_t *user; + + ds_dbg(2, "ds_poll(socket %d)\n", iminor(file->f_dentry->d_inode)); + + user = file->private_data; + if (CHECK_USER(user)) + return POLLERR; + s = user->socket; + /* + * We don't check for a dead socket here since that + * will send cardmgr into an endless spin. + */ + poll_wait(file, &s->queue, wait); + if (!queue_empty(user)) + return POLLIN | POLLRDNORM; + return 0; +} /* ds_poll */ + +/*====================================================================*/ + +extern int pcmcia_adjust_resource_info(adjust_t *adj); + +static int ds_ioctl(struct inode * inode, struct file * file, + u_int cmd, u_long arg) +{ + struct pcmcia_bus_socket *s; + void __user *uarg = (char __user *)arg; + u_int size; + int ret, err; + ds_ioctl_arg_t *buf; + user_info_t *user; + + ds_dbg(2, "ds_ioctl(socket %d, %#x, %#lx)\n", iminor(inode), cmd, arg); + + user = file->private_data; + if (CHECK_USER(user)) + return -EIO; + + s = user->socket; + if (s->state & DS_SOCKET_DEAD) + return -EIO; + + size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; + if (size > sizeof(ds_ioctl_arg_t)) return -EINVAL; + + /* Permission check */ + if (!(cmd & IOC_OUT) && !capable(CAP_SYS_ADMIN)) + return -EPERM; + + if (cmd & IOC_IN) { + if (!access_ok(VERIFY_READ, uarg, size)) { + ds_dbg(3, "ds_ioctl(): verify_read = %d\n", -EFAULT); + return -EFAULT; + } + } + if (cmd & IOC_OUT) { + if (!access_ok(VERIFY_WRITE, uarg, size)) { + ds_dbg(3, "ds_ioctl(): verify_write = %d\n", -EFAULT); + return -EFAULT; + } + } + buf = kmalloc(sizeof(ds_ioctl_arg_t), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + err = ret = 0; + + if (cmd & IOC_IN) __copy_from_user((char *)buf, uarg, size); + + switch (cmd) { + case DS_ADJUST_RESOURCE_INFO: + ret = pcmcia_adjust_resource_info(&buf->adjust); + break; + case DS_GET_CARD_SERVICES_INFO: + ret = pcmcia_get_card_services_info(&buf->servinfo); + break; + case DS_GET_CONFIGURATION_INFO: + if (buf->config.Function && + (buf->config.Function >= s->parent->functions)) + ret = CS_BAD_ARGS; + else + ret = pccard_get_configuration_info(s->parent, + buf->config.Function, &buf->config); + break; + case DS_GET_FIRST_TUPLE: + down(&s->parent->skt_sem); + pcmcia_validate_mem(s->parent); + up(&s->parent->skt_sem); + ret = pccard_get_first_tuple(s->parent, BIND_FN_ALL, &buf->tuple); + break; + case DS_GET_NEXT_TUPLE: + ret = pccard_get_next_tuple(s->parent, BIND_FN_ALL, &buf->tuple); + break; + case DS_GET_TUPLE_DATA: + buf->tuple.TupleData = buf->tuple_parse.data; + buf->tuple.TupleDataMax = sizeof(buf->tuple_parse.data); + ret = pccard_get_tuple_data(s->parent, &buf->tuple); + break; + case DS_PARSE_TUPLE: + buf->tuple.TupleData = buf->tuple_parse.data; + ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); + break; + case DS_RESET_CARD: + ret = pccard_reset_card(s->parent); + break; + case DS_GET_STATUS: + if (buf->status.Function && + (buf->status.Function >= s->parent->functions)) + ret = CS_BAD_ARGS; + else + ret = pccard_get_status(s->parent, buf->status.Function, &buf->status); + break; + case DS_VALIDATE_CIS: + down(&s->parent->skt_sem); + pcmcia_validate_mem(s->parent); + up(&s->parent->skt_sem); + ret = pccard_validate_cis(s->parent, BIND_FN_ALL, &buf->cisinfo); + break; + case DS_SUSPEND_CARD: + ret = pcmcia_suspend_card(s->parent); + break; + case DS_RESUME_CARD: + ret = pcmcia_resume_card(s->parent); + break; + case DS_EJECT_CARD: + err = pcmcia_eject_card(s->parent); + break; + case DS_INSERT_CARD: + err = pcmcia_insert_card(s->parent); + break; + case DS_ACCESS_CONFIGURATION_REGISTER: + if ((buf->conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN)) { + err = -EPERM; + goto free_out; + } + if (buf->conf_reg.Function && + (buf->conf_reg.Function >= s->parent->functions)) + ret = CS_BAD_ARGS; + else + ret = pccard_access_configuration_register(s->parent, + buf->conf_reg.Function, &buf->conf_reg); + break; + case DS_GET_FIRST_REGION: + case DS_GET_NEXT_REGION: + case DS_BIND_MTD: + if (!capable(CAP_SYS_ADMIN)) { + err = -EPERM; + goto free_out; + } else { + static int printed = 0; + if (!printed) { + printk(KERN_WARNING "2.6. kernels use pcmciamtd instead of memory_cs.c and do not require special\n"); + printk(KERN_WARNING "MTD handling any more.\n"); + printed++; + } + } + err = -EINVAL; + goto free_out; + break; + case DS_GET_FIRST_WINDOW: + ret = pcmcia_get_window(s->parent, &buf->win_info.handle, 0, + &buf->win_info.window); + break; + case DS_GET_NEXT_WINDOW: + ret = pcmcia_get_window(s->parent, &buf->win_info.handle, + buf->win_info.handle->index + 1, &buf->win_info.window); + break; + case DS_GET_MEM_PAGE: + ret = pcmcia_get_mem_page(buf->win_info.handle, + &buf->win_info.map); + break; + case DS_REPLACE_CIS: + ret = pcmcia_replace_cis(s->parent, &buf->cisdump); + break; + case DS_BIND_REQUEST: + if (!capable(CAP_SYS_ADMIN)) { + err = -EPERM; + goto free_out; + } + err = bind_request(s, &buf->bind_info); + break; + case DS_GET_DEVICE_INFO: + err = get_device_info(s, &buf->bind_info, 1); + break; + case DS_GET_NEXT_DEVICE: + err = get_device_info(s, &buf->bind_info, 0); + break; + case DS_UNBIND_REQUEST: + err = 0; + break; + default: + err = -EINVAL; + } + + if ((err == 0) && (ret != CS_SUCCESS)) { + ds_dbg(2, "ds_ioctl: ret = %d\n", ret); + switch (ret) { + case CS_BAD_SOCKET: case CS_NO_CARD: + err = -ENODEV; break; + case CS_BAD_ARGS: case CS_BAD_ATTRIBUTE: case CS_BAD_IRQ: + case CS_BAD_TUPLE: + err = -EINVAL; break; + case CS_IN_USE: + err = -EBUSY; break; + case CS_OUT_OF_RESOURCE: + err = -ENOSPC; break; + case CS_NO_MORE_ITEMS: + err = -ENODATA; break; + case CS_UNSUPPORTED_FUNCTION: + err = -ENOSYS; break; + default: + err = -EIO; break; + } + } + + if (cmd & IOC_OUT) { + if (__copy_to_user(uarg, (char *)buf, size)) + err = -EFAULT; + } + +free_out: + kfree(buf); + return err; +} /* ds_ioctl */ + +/*====================================================================*/ + +static struct file_operations ds_fops = { + .owner = THIS_MODULE, + .open = ds_open, + .release = ds_release, + .ioctl = ds_ioctl, + .read = ds_read, + .write = ds_write, + .poll = ds_poll, +}; + +void __init pcmcia_setup_ioctl(void) { + int i; + + /* Set up character device for user mode clients */ + i = register_chrdev(0, "pcmcia", &ds_fops); + if (i == -EBUSY) + printk(KERN_NOTICE "unable to find a free device # for " + "Driver Services\n"); + else + major_dev = i; + +#ifdef CONFIG_PROC_FS + proc_pccard = proc_mkdir("pccard", proc_bus); + if (proc_pccard) + create_proc_read_entry("drivers",0,proc_pccard,proc_read_drivers,NULL); +#endif +} + + +void __exit pcmcia_cleanup_ioctl(void) { +#ifdef CONFIG_PROC_FS + if (proc_pccard) { + remove_proc_entry("drivers", proc_pccard); + remove_proc_entry("pccard", proc_bus); + } +#endif + if (major_dev != -1) + unregister_chrdev(major_dev, "pcmcia"); +} -- cgit v1.2.3 From 90c6cdd1fa8dd4d69af792541a37b38576aa9b5a Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:49 -0700 Subject: [PATCH] pcmcia: clean up cs ds callback struct pcmcia_callback isn't needed for each socket, one is enough for all sockets. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 12 +++++++----- drivers/pcmcia/ds_internal.h | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 80b34b65511..54068f451ee 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -1167,6 +1167,12 @@ int pcmcia_deregister_client(client_handle_t handle) } /* deregister_client */ EXPORT_SYMBOL(pcmcia_deregister_client); +static struct pcmcia_callback pcmcia_bus_callback = { + .owner = THIS_MODULE, + .event = ds_event, + .requery = pcmcia_bus_rescan, +}; + static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) { struct pcmcia_socket *socket = class_get_devdata(class_dev); @@ -1201,12 +1207,9 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) INIT_WORK(&s->device_add, pcmcia_delayed_add_pseudo_device, s); /* Set up hotline to Card Services */ - s->callback.owner = THIS_MODULE; - s->callback.event = &ds_event; - s->callback.requery = &pcmcia_bus_rescan; socket->pcmcia = s; - ret = pccard_register_pcmcia(socket, &s->callback); + ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback); if (ret) { printk(KERN_ERR "PCMCIA registration PCCard core failed for socket %p\n", socket); pcmcia_put_bus_socket(s); @@ -1217,7 +1220,6 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) return 0; } - static void pcmcia_bus_remove_socket(struct class_device *class_dev) { struct pcmcia_socket *socket = class_get_devdata(class_dev); diff --git a/drivers/pcmcia/ds_internal.h b/drivers/pcmcia/ds_internal.h index 0de90e5e67a..b05bc39d9cd 100644 --- a/drivers/pcmcia/ds_internal.h +++ b/drivers/pcmcia/ds_internal.h @@ -5,7 +5,6 @@ struct user_info_t; /* Socket state information */ struct pcmcia_bus_socket { struct kref refcount; - struct pcmcia_callback callback; int state; struct pcmcia_socket *parent; -- cgit v1.2.3 From b5e43913cfe95a18ad8929585a0bb58e46cf3390 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:50 -0700 Subject: [PATCH] pcmcia: make PCMCIA status a bitfield make pcmcia_bus_socket->state a bitfield, and rename it pcmcia_state to prepare for struct pcmcia_bus_socket integration into struct pcmcia_socket. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 12 ++++++------ drivers/pcmcia/ds_internal.h | 14 ++++++++------ drivers/pcmcia/pcmcia_ioctl.c | 12 ++++++------ 3 files changed, 20 insertions(+), 18 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 54068f451ee..85e2cb2b9e9 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -622,14 +622,14 @@ static void pcmcia_delayed_add_pseudo_device(void *data) { struct pcmcia_bus_socket *s = data; pcmcia_device_add(s, 0); - s->device_add_pending = 0; + s->pcmcia_state.device_add_pending = 0; } static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s) { - if (!s->device_add_pending) { + if (!s->pcmcia_state.device_add_pending) { schedule_work(&s->device_add); - s->device_add_pending = 1; + s->pcmcia_state.device_add_pending = 1; } return; } @@ -981,14 +981,14 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) switch (event) { case CS_EVENT_CARD_REMOVAL: - s->state &= ~DS_SOCKET_PRESENT; + s->pcmcia_state.present = 0; send_event(skt, event, priority); unbind_request(s); handle_event(s, event); break; case CS_EVENT_CARD_INSERTION: - s->state |= DS_SOCKET_PRESENT; + s->pcmcia_state.present = 1; pcmcia_card_add(skt); handle_event(s, event); break; @@ -1229,7 +1229,7 @@ static void pcmcia_bus_remove_socket(struct class_device *class_dev) pccard_register_pcmcia(socket, NULL); - socket->pcmcia->state |= DS_SOCKET_DEAD; + socket->pcmcia->pcmcia_state.dead = 1; pcmcia_put_bus_socket(socket->pcmcia); socket->pcmcia = NULL; diff --git a/drivers/pcmcia/ds_internal.h b/drivers/pcmcia/ds_internal.h index b05bc39d9cd..2c3bb189dec 100644 --- a/drivers/pcmcia/ds_internal.h +++ b/drivers/pcmcia/ds_internal.h @@ -5,7 +5,6 @@ struct user_info_t; /* Socket state information */ struct pcmcia_bus_socket { struct kref refcount; - int state; struct pcmcia_socket *parent; /* the PCMCIA devices connected to this socket (normally one, more @@ -15,7 +14,14 @@ struct pcmcia_bus_socket { * only internally and subject * to incorrectness and change */ - u8 device_add_pending; + struct { + u8 present:1, + busy:1, + dead:1, + device_add_pending:1, + reserved:4; + } pcmcia_state; + struct work_struct device_add; @@ -29,10 +35,6 @@ extern spinlock_t pcmcia_dev_list_lock; extern struct bus_type pcmcia_bus_type; -#define DS_SOCKET_PRESENT 0x01 -#define DS_SOCKET_BUSY 0x02 -#define DS_SOCKET_DEAD 0x80 - extern struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev); extern void pcmcia_put_dev(struct pcmcia_device *p_dev); diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index e8d2c95db1c..b223f5235de 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -404,12 +404,12 @@ static int ds_open(struct inode *inode, struct file *file) return -ENODEV; if ((file->f_flags & O_ACCMODE) != O_RDONLY) { - if (s->state & DS_SOCKET_BUSY) { + if (s->pcmcia_state.busy) { pcmcia_put_bus_socket(s); return -EBUSY; } else - s->state |= DS_SOCKET_BUSY; + s->pcmcia_state.busy = 1; } user = kmalloc(sizeof(user_info_t), GFP_KERNEL); @@ -424,7 +424,7 @@ static int ds_open(struct inode *inode, struct file *file) s->user = user; file->private_data = user; - if (s->state & DS_SOCKET_PRESENT) + if (s->pcmcia_state.present) queue_event(user, CS_EVENT_CARD_INSERTION); return 0; } /* ds_open */ @@ -446,7 +446,7 @@ static int ds_release(struct inode *inode, struct file *file) /* Unlink user data structure */ if ((file->f_flags & O_ACCMODE) != O_RDONLY) { - s->state &= ~DS_SOCKET_BUSY; + s->pcmcia_state.busy = 0; } file->private_data = NULL; for (link = &s->user; *link; link = &(*link)->next) @@ -480,7 +480,7 @@ static ssize_t ds_read(struct file *file, char __user *buf, return -EIO; s = user->socket; - if (s->state & DS_SOCKET_DEAD) + if (s->pcmcia_state.dead) return -EIO; ret = wait_event_interruptible(s->queue, !queue_empty(user)); @@ -550,7 +550,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, return -EIO; s = user->socket; - if (s->state & DS_SOCKET_DEAD) + if (s->pcmcia_state.dead) return -EIO; size = (cmd & IOCSIZE_MASK) >> IOCSIZE_SHIFT; -- cgit v1.2.3 From dc109497bd5799770fedfc6503119808497b3677 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:50 -0700 Subject: [PATCH] pcmcia: merge struct pcmcia_bus_socket into struct pcmcia_socket Merge struct pcmcia_bus_socket into struct pcmcia_socket. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 123 ++++++++++++++---------------------------- drivers/pcmcia/ds_internal.h | 45 ++-------------- drivers/pcmcia/pcmcia_ioctl.c | 97 +++++++++++++++------------------ 3 files changed, 90 insertions(+), 175 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index 85e2cb2b9e9..f796dcd64dc 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -75,7 +75,7 @@ module_param_named(pc_debug, ds_pc_debug, int, 0644); spinlock_t pcmcia_dev_list_lock; -static int unbind_request(struct pcmcia_bus_socket *s); +static int unbind_request(struct pcmcia_socket *s); /*====================================================================*/ @@ -313,24 +313,6 @@ static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filenam /*======================================================================*/ -void pcmcia_release_bus_socket(struct kref *refcount) -{ - struct pcmcia_bus_socket *s = container_of(refcount, struct pcmcia_bus_socket, refcount); - pcmcia_put_socket(s->parent); - kfree(s); -} - -void pcmcia_put_bus_socket(struct pcmcia_bus_socket *s) -{ - kref_put(&s->refcount, pcmcia_release_bus_socket); -} - -struct pcmcia_bus_socket *pcmcia_get_bus_socket(struct pcmcia_bus_socket *s) -{ - kref_get(&s->refcount); - return (s); -} - /** * pcmcia_register_driver - register a PCMCIA driver with the bus core * @@ -387,7 +369,7 @@ static void pcmcia_release_dev(struct device *dev) { struct pcmcia_device *p_dev = to_pcmcia_dev(dev); ds_dbg(1, "releasing dev %p\n", p_dev); - pcmcia_put_bus_socket(p_dev->socket->pcmcia); + pcmcia_put_socket(p_dev->socket); kfree(p_dev); } @@ -522,12 +504,12 @@ static int pcmcia_device_query(struct pcmcia_device *p_dev) */ static DECLARE_MUTEX(device_add_lock); -struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, unsigned int function) +struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function) { struct pcmcia_device *p_dev; unsigned long flags; - s = pcmcia_get_bus_socket(s); + s = pcmcia_get_socket(s); if (!s) return NULL; @@ -542,18 +524,18 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, unsigned i goto err_put; memset(p_dev, 0, sizeof(struct pcmcia_device)); - p_dev->socket = s->parent; + p_dev->socket = s; p_dev->device_no = (s->device_count++); p_dev->func = function; p_dev->dev.bus = &pcmcia_bus_type; - p_dev->dev.parent = s->parent->dev.dev; + p_dev->dev.parent = s->dev.dev; p_dev->dev.release = pcmcia_release_dev; sprintf (p_dev->dev.bus_id, "%d.%d", p_dev->socket->sock, p_dev->device_no); /* compat */ p_dev->client.client_magic = CLIENT_MAGIC; - p_dev->client.Socket = s->parent; + p_dev->client.Socket = s; p_dev->client.Function = function; p_dev->client.state = CLIENT_UNBOUND; @@ -581,7 +563,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, unsigned i s->device_count--; err_put: up(&device_add_lock); - pcmcia_put_bus_socket(s); + pcmcia_put_socket(s); return NULL; } @@ -612,7 +594,7 @@ static int pcmcia_card_add(struct pcmcia_socket *s) /* this doesn't handle multifunction devices on one pcmcia function * yet. */ for (i=0; i < no_funcs; i++) - pcmcia_device_add(s->pcmcia, i); + pcmcia_device_add(s, i); return (ret); } @@ -620,12 +602,12 @@ static int pcmcia_card_add(struct pcmcia_socket *s) static void pcmcia_delayed_add_pseudo_device(void *data) { - struct pcmcia_bus_socket *s = data; + struct pcmcia_socket *s = data; pcmcia_device_add(s, 0); s->pcmcia_state.device_add_pending = 0; } -static inline void pcmcia_add_pseudo_device(struct pcmcia_bus_socket *s) +static inline void pcmcia_add_pseudo_device(struct pcmcia_socket *s) { if (!s->pcmcia_state.device_add_pending) { schedule_work(&s->device_add); @@ -650,7 +632,7 @@ static void pcmcia_bus_rescan(struct pcmcia_socket *skt) /* must be called with skt_sem held */ spin_lock_irqsave(&pcmcia_dev_list_lock, flags); - if (list_empty(&skt->pcmcia->devices_list)) + if (list_empty(&skt->devices_list)) no_devices=1; spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); @@ -727,7 +709,7 @@ static inline int pcmcia_devmatch(struct pcmcia_device *dev, * pseudo devices, and if not, add the second one. */ if (dev->device_no == 0) - pcmcia_add_pseudo_device(dev->socket->pcmcia); + pcmcia_add_pseudo_device(dev->socket); if (dev->device_no != did->device_no) return 0; @@ -947,21 +929,13 @@ static int send_event_callback(struct device *dev, void * _data) static int send_event(struct pcmcia_socket *s, event_t event, int priority) { - int ret = 0; struct send_event_data private; - struct pcmcia_bus_socket *skt = pcmcia_get_bus_socket(s->pcmcia); - - if (!skt) - return 0; private.skt = s; private.event = event; private.priority = priority; - ret = bus_for_each_dev(&pcmcia_bus_type, NULL, &private, send_event_callback); - - pcmcia_put_bus_socket(skt); - return ret; + return bus_for_each_dev(&pcmcia_bus_type, NULL, &private, send_event_callback); } /* send_event */ @@ -972,25 +946,25 @@ static int send_event(struct pcmcia_socket *s, event_t event, int priority) static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) { - struct pcmcia_bus_socket *s = skt->pcmcia; + struct pcmcia_socket *s = pcmcia_get_socket(skt); int ret = 0; ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n", - event, priority, s); + event, priority, skt); switch (event) { case CS_EVENT_CARD_REMOVAL: s->pcmcia_state.present = 0; send_event(skt, event, priority); - unbind_request(s); - handle_event(s, event); + unbind_request(skt); + handle_event(skt, event); break; case CS_EVENT_CARD_INSERTION: s->pcmcia_state.present = 1; pcmcia_card_add(skt); - handle_event(s, event); + handle_event(skt, event); break; case CS_EVENT_EJECTION_REQUEST: @@ -998,11 +972,13 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) break; default: - handle_event(s, event); + handle_event(skt, event); send_event(skt, event, priority); break; } + pcmcia_put_socket(s); + return 0; } /* ds_event */ @@ -1011,8 +987,7 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) int pcmcia_register_client(client_handle_t *handle, client_reg_t *req) { client_t *client = NULL; - struct pcmcia_socket *s; - struct pcmcia_bus_socket *skt = NULL; + struct pcmcia_socket *s = NULL; struct pcmcia_device *p_dev = NULL; /* Look for unbound client with matching dev_info */ @@ -1023,14 +998,11 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req) if (s->state & SOCKET_CARDBUS) continue; - skt = s->pcmcia; - if (!skt) - continue; - skt = pcmcia_get_bus_socket(skt); - if (!skt) + s = pcmcia_get_socket(s); + if (!s) continue; spin_lock_irqsave(&pcmcia_dev_list_lock, flags); - list_for_each_entry(p_dev, &skt->devices_list, socket_device_list) { + list_for_each_entry(p_dev, &s->devices_list, socket_device_list) { struct pcmcia_driver *p_drv; p_dev = pcmcia_get_dev(p_dev); if (!p_dev) @@ -1049,14 +1021,14 @@ int pcmcia_register_client(client_handle_t *handle, client_reg_t *req) pcmcia_put_dev(p_dev); } spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); - pcmcia_put_bus_socket(skt); + pcmcia_put_socket(s); } found: up_read(&pcmcia_socket_list_rwsem); if (!p_dev || !client) return -ENODEV; - pcmcia_put_bus_socket(skt); /* safe, as we already hold a reference from bind_device */ + pcmcia_put_socket(s); /* safe, as we already hold a reference from bind_device */ *handle = client; client->state &= ~CLIENT_UNBOUND; @@ -1106,12 +1078,12 @@ EXPORT_SYMBOL(pcmcia_register_client); /* unbind _all_ devices attached to a given pcmcia_bus_socket. The * drivers have been called with EVENT_CARD_REMOVAL before. */ -static int unbind_request(struct pcmcia_bus_socket *s) +static int unbind_request(struct pcmcia_socket *s) { struct pcmcia_device *p_dev; unsigned long flags; - ds_dbg(2, "unbind_request(%d)\n", s->parent->sock); + ds_dbg(2, "unbind_request(%d)\n", s->sock); s->device_count = 0; @@ -1176,24 +1148,14 @@ static struct pcmcia_callback pcmcia_bus_callback = { static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) { struct pcmcia_socket *socket = class_get_devdata(class_dev); - struct pcmcia_bus_socket *s; int ret; - s = kmalloc(sizeof(struct pcmcia_bus_socket), GFP_KERNEL); - if(!s) - return -ENOMEM; - memset(s, 0, sizeof(struct pcmcia_bus_socket)); - - /* get reference to parent socket */ - s->parent = pcmcia_get_socket(socket); - if (!s->parent) { + socket = pcmcia_get_socket(socket); + if (!socket) { printk(KERN_ERR "PCMCIA obtaining reference to socket %p failed\n", socket); - kfree (s); return -ENODEV; } - kref_init(&s->refcount); - /* * Ugly. But we want to wait for the socket threads to have started up. * We really should let the drivers themselves drive some of this.. @@ -1201,19 +1163,17 @@ static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev) msleep(250); #ifdef CONFIG_PCMCIA_IOCTL - init_waitqueue_head(&s->queue); + init_waitqueue_head(&socket->queue); #endif - INIT_LIST_HEAD(&s->devices_list); - INIT_WORK(&s->device_add, pcmcia_delayed_add_pseudo_device, s); - - /* Set up hotline to Card Services */ - socket->pcmcia = s; + INIT_LIST_HEAD(&socket->devices_list); + INIT_WORK(&socket->device_add, pcmcia_delayed_add_pseudo_device, socket); + memset(&socket->pcmcia_state, 0, sizeof(u8)); + socket->device_count = 0; ret = pccard_register_pcmcia(socket, &pcmcia_bus_callback); if (ret) { printk(KERN_ERR "PCMCIA registration PCCard core failed for socket %p\n", socket); - pcmcia_put_bus_socket(s); - socket->pcmcia = NULL; + pcmcia_put_socket(socket); return (ret); } @@ -1224,14 +1184,13 @@ static void pcmcia_bus_remove_socket(struct class_device *class_dev) { struct pcmcia_socket *socket = class_get_devdata(class_dev); - if (!socket || !socket->pcmcia) + if (!socket) return; + socket->pcmcia_state.dead = 1; pccard_register_pcmcia(socket, NULL); - socket->pcmcia->pcmcia_state.dead = 1; - pcmcia_put_bus_socket(socket->pcmcia); - socket->pcmcia = NULL; + pcmcia_put_socket(socket); return; } diff --git a/drivers/pcmcia/ds_internal.h b/drivers/pcmcia/ds_internal.h index 2c3bb189dec..d359bd25a51 100644 --- a/drivers/pcmcia/ds_internal.h +++ b/drivers/pcmcia/ds_internal.h @@ -1,56 +1,21 @@ /* ds_internal.h - internal header for 16-bit PCMCIA devices management */ -struct user_info_t; - -/* Socket state information */ -struct pcmcia_bus_socket { - struct kref refcount; - struct pcmcia_socket *parent; - - /* the PCMCIA devices connected to this socket (normally one, more - * for multifunction devices: */ - struct list_head devices_list; - u8 device_count; /* the number of devices, used - * only internally and subject - * to incorrectness and change */ - - struct { - u8 present:1, - busy:1, - dead:1, - device_add_pending:1, - reserved:4; - } pcmcia_state; - - struct work_struct device_add; - - -#ifdef CONFIG_PCMCIA_IOCTL - struct user_info_t *user; - wait_queue_head_t queue; -#endif -}; extern spinlock_t pcmcia_dev_list_lock; - extern struct bus_type pcmcia_bus_type; - extern struct pcmcia_device * pcmcia_get_dev(struct pcmcia_device *p_dev); extern void pcmcia_put_dev(struct pcmcia_device *p_dev); -struct pcmcia_bus_socket *pcmcia_get_bus_socket(struct pcmcia_bus_socket *s); -void pcmcia_put_bus_socket(struct pcmcia_bus_socket *s); - -struct pcmcia_device * pcmcia_device_add(struct pcmcia_bus_socket *s, unsigned int function); +struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int function); #ifdef CONFIG_PCMCIA_IOCTL extern void __init pcmcia_setup_ioctl(void); extern void __exit pcmcia_cleanup_ioctl(void); -extern void handle_event(struct pcmcia_bus_socket *s, event_t event); -extern int handle_request(struct pcmcia_bus_socket *s, event_t event); +extern void handle_event(struct pcmcia_socket *s, event_t event); +extern int handle_request(struct pcmcia_socket *s, event_t event); #else static inline void __init pcmcia_setup_ioctl(void) { return; } static inline void __init pcmcia_cleanup_ioctl(void) { return; } -static inline void handle_event(struct pcmcia_bus_socket *s, event_t event) { return; } -static inline int handle_request(struct pcmcia_bus_socket *s, event_t event) { return CS_SUCCESS; } +static inline void handle_event(struct pcmcia_socket *s, event_t event) { return; } +static inline int handle_request(struct pcmcia_socket *s, event_t event) { return CS_SUCCESS; } #endif diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index b223f5235de..0bebfdbdc27 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -70,7 +70,7 @@ typedef struct user_info_t { int event_head, event_tail; event_t event[MAX_EVENTS]; struct user_info_t *next; - struct pcmcia_bus_socket *socket; + struct pcmcia_socket *socket; } user_info_t; @@ -87,15 +87,6 @@ extern int ds_pc_debug; #endif -static struct pcmcia_bus_socket * get_socket_info_by_nr(unsigned int nr) -{ - struct pcmcia_socket * s = pcmcia_get_socket_by_nr(nr); - if (s && s->pcmcia) - return s->pcmcia; - else - return NULL; -} - /* backwards-compatible accessing of driver --- by name! */ static struct pcmcia_driver * get_pcmcia_driver (dev_info_t *dev_info) @@ -172,7 +163,7 @@ static void queue_event(user_info_t *user, event_t event) user->event[user->event_head] = event; } -void handle_event(struct pcmcia_bus_socket *s, event_t event) +void handle_event(struct pcmcia_socket *s, event_t event) { user_info_t *user; for (user = s->user; user; user = user->next) @@ -204,18 +195,18 @@ void handle_event(struct pcmcia_bus_socket *s, event_t event) ======================================================================*/ -static int bind_request(struct pcmcia_bus_socket *s, bind_info_t *bind_info) +static int bind_request(struct pcmcia_socket *s, bind_info_t *bind_info) { struct pcmcia_driver *p_drv; struct pcmcia_device *p_dev; int ret = 0; unsigned long flags; - s = pcmcia_get_bus_socket(s); + s = pcmcia_get_socket(s); if (!s) return -EINVAL; - ds_dbg(2, "bind_request(%d, '%s')\n", s->parent->sock, + ds_dbg(2, "bind_request(%d, '%s')\n", s->sock, (char *)bind_info->dev_info); p_drv = get_pcmcia_driver(&bind_info->dev_info); @@ -278,9 +269,9 @@ rescan: /* * Prevent this racing with a card insertion. */ - down(&s->parent->skt_sem); + down(&s->skt_sem); bus_rescan_devices(&pcmcia_bus_type); - up(&s->parent->skt_sem); + up(&s->skt_sem); /* check whether the driver indeed matched. I don't care if this * is racy or not, because it can only happen on cardmgr access @@ -294,7 +285,7 @@ rescan: err_put_driver: put_driver(&p_drv->drv); err_put: - pcmcia_put_bus_socket(s); + pcmcia_put_socket(s); return (ret); } /* bind_request */ @@ -302,7 +293,7 @@ rescan: extern struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s); -static int get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info, int first) +static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int first) { dev_node_t *node; struct pcmcia_device *p_dev; @@ -317,7 +308,7 @@ static int get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info, { struct pci_bus *bus; - bus = pcmcia_lookup_bus(s->parent); + bus = pcmcia_lookup_bus(s); if (bus) { struct list_head *list; struct pci_dev *dev = NULL; @@ -391,21 +382,21 @@ static int get_device_info(struct pcmcia_bus_socket *s, bind_info_t *bind_info, static int ds_open(struct inode *inode, struct file *file) { socket_t i = iminor(inode); - struct pcmcia_bus_socket *s; + struct pcmcia_socket *s; user_info_t *user; ds_dbg(0, "ds_open(socket %d)\n", i); - s = get_socket_info_by_nr(i); + s = pcmcia_get_socket_by_nr(i); if (!s) return -ENODEV; - s = pcmcia_get_bus_socket(s); + s = pcmcia_get_socket(s); if (!s) return -ENODEV; if ((file->f_flags & O_ACCMODE) != O_RDONLY) { if (s->pcmcia_state.busy) { - pcmcia_put_bus_socket(s); + pcmcia_put_socket(s); return -EBUSY; } else @@ -414,7 +405,7 @@ static int ds_open(struct inode *inode, struct file *file) user = kmalloc(sizeof(user_info_t), GFP_KERNEL); if (!user) { - pcmcia_put_bus_socket(s); + pcmcia_put_socket(s); return -ENOMEM; } user->event_tail = user->event_head = 0; @@ -433,7 +424,7 @@ static int ds_open(struct inode *inode, struct file *file) static int ds_release(struct inode *inode, struct file *file) { - struct pcmcia_bus_socket *s; + struct pcmcia_socket *s; user_info_t *user, **link; ds_dbg(0, "ds_release(socket %d)\n", iminor(inode)); @@ -456,7 +447,7 @@ static int ds_release(struct inode *inode, struct file *file) *link = user->next; user->user_magic = 0; kfree(user); - pcmcia_put_bus_socket(s); + pcmcia_put_socket(s); out: return 0; } /* ds_release */ @@ -466,7 +457,7 @@ out: static ssize_t ds_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - struct pcmcia_bus_socket *s; + struct pcmcia_socket *s; user_info_t *user; int ret; @@ -510,7 +501,7 @@ static ssize_t ds_write(struct file *file, const char __user *buf, /* No kernel lock - fine */ static u_int ds_poll(struct file *file, poll_table *wait) { - struct pcmcia_bus_socket *s; + struct pcmcia_socket *s; user_info_t *user; ds_dbg(2, "ds_poll(socket %d)\n", iminor(file->f_dentry->d_inode)); @@ -536,7 +527,7 @@ extern int pcmcia_adjust_resource_info(adjust_t *adj); static int ds_ioctl(struct inode * inode, struct file * file, u_int cmd, u_long arg) { - struct pcmcia_bus_socket *s; + struct pcmcia_socket *s; void __user *uarg = (char __user *)arg; u_int size; int ret, err; @@ -589,57 +580,57 @@ static int ds_ioctl(struct inode * inode, struct file * file, break; case DS_GET_CONFIGURATION_INFO: if (buf->config.Function && - (buf->config.Function >= s->parent->functions)) + (buf->config.Function >= s->functions)) ret = CS_BAD_ARGS; else - ret = pccard_get_configuration_info(s->parent, + ret = pccard_get_configuration_info(s, buf->config.Function, &buf->config); break; case DS_GET_FIRST_TUPLE: - down(&s->parent->skt_sem); - pcmcia_validate_mem(s->parent); - up(&s->parent->skt_sem); - ret = pccard_get_first_tuple(s->parent, BIND_FN_ALL, &buf->tuple); + down(&s->skt_sem); + pcmcia_validate_mem(s); + up(&s->skt_sem); + ret = pccard_get_first_tuple(s, BIND_FN_ALL, &buf->tuple); break; case DS_GET_NEXT_TUPLE: - ret = pccard_get_next_tuple(s->parent, BIND_FN_ALL, &buf->tuple); + ret = pccard_get_next_tuple(s, BIND_FN_ALL, &buf->tuple); break; case DS_GET_TUPLE_DATA: buf->tuple.TupleData = buf->tuple_parse.data; buf->tuple.TupleDataMax = sizeof(buf->tuple_parse.data); - ret = pccard_get_tuple_data(s->parent, &buf->tuple); + ret = pccard_get_tuple_data(s, &buf->tuple); break; case DS_PARSE_TUPLE: buf->tuple.TupleData = buf->tuple_parse.data; ret = pccard_parse_tuple(&buf->tuple, &buf->tuple_parse.parse); break; case DS_RESET_CARD: - ret = pccard_reset_card(s->parent); + ret = pccard_reset_card(s); break; case DS_GET_STATUS: if (buf->status.Function && - (buf->status.Function >= s->parent->functions)) + (buf->status.Function >= s->functions)) ret = CS_BAD_ARGS; else - ret = pccard_get_status(s->parent, buf->status.Function, &buf->status); + ret = pccard_get_status(s, buf->status.Function, &buf->status); break; case DS_VALIDATE_CIS: - down(&s->parent->skt_sem); - pcmcia_validate_mem(s->parent); - up(&s->parent->skt_sem); - ret = pccard_validate_cis(s->parent, BIND_FN_ALL, &buf->cisinfo); + down(&s->skt_sem); + pcmcia_validate_mem(s); + up(&s->skt_sem); + ret = pccard_validate_cis(s, BIND_FN_ALL, &buf->cisinfo); break; case DS_SUSPEND_CARD: - ret = pcmcia_suspend_card(s->parent); + ret = pcmcia_suspend_card(s); break; case DS_RESUME_CARD: - ret = pcmcia_resume_card(s->parent); + ret = pcmcia_resume_card(s); break; case DS_EJECT_CARD: - err = pcmcia_eject_card(s->parent); + err = pcmcia_eject_card(s); break; case DS_INSERT_CARD: - err = pcmcia_insert_card(s->parent); + err = pcmcia_insert_card(s); break; case DS_ACCESS_CONFIGURATION_REGISTER: if ((buf->conf_reg.Action == CS_WRITE) && !capable(CAP_SYS_ADMIN)) { @@ -647,10 +638,10 @@ static int ds_ioctl(struct inode * inode, struct file * file, goto free_out; } if (buf->conf_reg.Function && - (buf->conf_reg.Function >= s->parent->functions)) + (buf->conf_reg.Function >= s->functions)) ret = CS_BAD_ARGS; else - ret = pccard_access_configuration_register(s->parent, + ret = pccard_access_configuration_register(s, buf->conf_reg.Function, &buf->conf_reg); break; case DS_GET_FIRST_REGION: @@ -671,11 +662,11 @@ static int ds_ioctl(struct inode * inode, struct file * file, goto free_out; break; case DS_GET_FIRST_WINDOW: - ret = pcmcia_get_window(s->parent, &buf->win_info.handle, 0, + ret = pcmcia_get_window(s, &buf->win_info.handle, 0, &buf->win_info.window); break; case DS_GET_NEXT_WINDOW: - ret = pcmcia_get_window(s->parent, &buf->win_info.handle, + ret = pcmcia_get_window(s, &buf->win_info.handle, buf->win_info.handle->index + 1, &buf->win_info.window); break; case DS_GET_MEM_PAGE: @@ -683,7 +674,7 @@ static int ds_ioctl(struct inode * inode, struct file * file, &buf->win_info.map); break; case DS_REPLACE_CIS: - ret = pcmcia_replace_cis(s->parent, &buf->cisdump); + ret = pcmcia_replace_cis(s, &buf->cisdump); break; case DS_BIND_REQUEST: if (!capable(CAP_SYS_ADMIN)) { -- cgit v1.2.3 From 3b659fb862db02c77ea7e6db7e70b6e888681579 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:51 -0700 Subject: [PATCH] pcmcia: remove unneeded includes in ds.c Remove unnecessary includes in ds.c and pcmcia_ioctl.c Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 22 ++-------------------- drivers/pcmcia/pcmcia_ioctl.c | 17 +---------------- 2 files changed, 3 insertions(+), 36 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index f796dcd64dc..f018d26f181 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -10,41 +10,23 @@ * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. * * (C) 1999 David A. Hinds - * (C) 2003 - 2004 Dominik Brodowski + * (C) 2003 - 2005 Dominik Brodowski */ #include +#include #include -#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include -#include #include #include #include -#include - #define IN_CARD_SERVICES -#include #include #include -#include #include #include #include diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 0bebfdbdc27..7aa2e7f20d5 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -19,36 +19,21 @@ #include +#include #include -#include #include -#include #include -#include #include -#include -#include -#include -#include -#include -#include #include #include #include #include -#include -#include -#include #include -#include - -#include #define IN_CARD_SERVICES #include #include #include -#include #include #include #include -- cgit v1.2.3 From e6ea0b9ec5131ac360581d6924fed536758bd024 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:52 -0700 Subject: [PATCH] pcmcia: rename some functions Rename some functions in drivers/pcmcia/ to show they belong to the PCMCIA subsystem. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cistpl.c | 14 +++++++------- drivers/pcmcia/cs.c | 32 ++++++++++++++++---------------- drivers/pcmcia/cs_internal.h | 11 +++++------ drivers/pcmcia/rsrc_mgr.c | 6 +++--- 4 files changed, 31 insertions(+), 32 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index e29a6ddf2fd..af4ff08d6dc 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -90,7 +90,7 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag { pccard_mem_map *mem = &s->cis_mem; if (!(s->features & SS_CAP_STATIC_MAP) && mem->res == NULL) { - mem->res = find_mem_region(0, s->map_size, s->map_size, 0, s); + mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s); if (mem->res == NULL) { printk(KERN_NOTICE "cs: unable to map card memory!\n"); return NULL; @@ -119,13 +119,13 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag #define IS_ATTR 1 #define IS_INDIRECT 8 -int read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, +int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr) { void __iomem *sys, *end; unsigned char *buf = ptr; - cs_dbg(s, 3, "read_cis_mem(%d, %#x, %u)\n", attr, addr, len); + cs_dbg(s, 3, "pcmcia_read_cis_mem(%d, %#x, %u)\n", attr, addr, len); if (attr & IS_INDIRECT) { /* Indirect accesses use a bunch of special registers at fixed @@ -183,13 +183,13 @@ int read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, return 0; } -void write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, +void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr) { void __iomem *sys, *end; unsigned char *buf = ptr; - cs_dbg(s, 3, "write_cis_mem(%d, %#x, %u)\n", attr, addr, len); + cs_dbg(s, 3, "pcmcia_write_cis_mem(%d, %#x, %u)\n", attr, addr, len); if (attr & IS_INDIRECT) { /* Indirect accesses use a bunch of special registers at fixed @@ -274,7 +274,7 @@ static void read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr, ret = read_cb_mem(s, attr, addr, len, ptr); else #endif - ret = read_cis_mem(s, attr, addr, len, ptr); + ret = pcmcia_read_cis_mem(s, attr, addr, len, ptr); if (ret == 0) { /* Copy data into the cache */ @@ -348,7 +348,7 @@ int verify_cis_cache(struct pcmcia_socket *s) read_cb_mem(s, cis->attr, cis->addr, len, buf); else #endif - read_cis_mem(s, cis->attr, cis->addr, len, buf); + pcmcia_read_cis_mem(s, cis->attr, cis->addr, len, buf); if (memcmp(buf, cis->cache, len) != 0) { kfree(buf); diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index fec9e030473..574706e7479 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -787,7 +787,7 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base, return 1; for (i = 0; i < MAX_IO_WIN; i++) { if (s->io[i].NumPorts == 0) { - s->io[i].res = find_io_region(*base, num, align, s); + s->io[i].res = pcmcia_find_io_region(*base, num, align, s); if (s->io[i].res) { s->io[i].Attributes = attr; s->io[i].BasePort = *base = s->io[i].res->start; @@ -800,7 +800,7 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base, /* Try to extend top of window */ try = s->io[i].BasePort + s->io[i].NumPorts; if ((*base == 0) || (*base == try)) - if (adjust_io_region(s->io[i].res, s->io[i].res->start, + if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start, s->io[i].res->end + num, s) == 0) { *base = try; s->io[i].NumPorts += num; @@ -810,7 +810,7 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base, /* Try to extend bottom of window */ try = s->io[i].BasePort - num; if ((*base == 0) || (*base == try)) - if (adjust_io_region(s->io[i].res, s->io[i].res->start - num, + if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start - num, s->io[i].res->end, s) == 0) { s->io[i].BasePort = *base = try; s->io[i].NumPorts += num; @@ -872,12 +872,12 @@ int pccard_access_configuration_register(struct pcmcia_socket *s, switch (reg->Action) { case CS_READ: - read_cis_mem(s, 1, addr, 1, &val); + pcmcia_read_cis_mem(s, 1, addr, 1, &val); reg->Value = val; break; case CS_WRITE: val = reg->Value; - write_cis_mem(s, 1, addr, 1, &val); + pcmcia_write_cis_mem(s, 1, addr, 1, &val); break; default: return CS_BAD_ARGS; @@ -1050,7 +1050,7 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_ (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) { u_char reg; if (c->Present & PRESENT_PIN_REPLACE) { - read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, ®); + pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, ®); status->CardState |= (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0; status->CardState |= @@ -1064,7 +1064,7 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_ status->CardState |= CS_EVENT_READY_CHANGE; } if (c->Present & PRESENT_EXT_STATUS) { - read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, ®); + pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, ®); status->CardState |= (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; } @@ -1401,7 +1401,7 @@ int pcmcia_request_configuration(client_handle_t handle, c->Present = c->CardValues = req->Present; if (req->Present & PRESENT_COPY) { c->Copy = req->Copy; - write_cis_mem(s, 1, (base + CISREG_SCR)>>1, 1, &c->Copy); + pcmcia_write_cis_mem(s, 1, (base + CISREG_SCR)>>1, 1, &c->Copy); } if (req->Present & PRESENT_OPTION) { if (s->functions == 1) { @@ -1415,30 +1415,30 @@ int pcmcia_request_configuration(client_handle_t handle, if (c->state & CONFIG_IRQ_REQ) if (!(c->irq.Attributes & IRQ_FORCED_PULSE)) c->Option |= COR_LEVEL_REQ; - write_cis_mem(s, 1, (base + CISREG_COR)>>1, 1, &c->Option); + pcmcia_write_cis_mem(s, 1, (base + CISREG_COR)>>1, 1, &c->Option); mdelay(40); } if (req->Present & PRESENT_STATUS) { c->Status = req->Status; - write_cis_mem(s, 1, (base + CISREG_CCSR)>>1, 1, &c->Status); + pcmcia_write_cis_mem(s, 1, (base + CISREG_CCSR)>>1, 1, &c->Status); } if (req->Present & PRESENT_PIN_REPLACE) { c->Pin = req->Pin; - write_cis_mem(s, 1, (base + CISREG_PRR)>>1, 1, &c->Pin); + pcmcia_write_cis_mem(s, 1, (base + CISREG_PRR)>>1, 1, &c->Pin); } if (req->Present & PRESENT_EXT_STATUS) { c->ExtStatus = req->ExtStatus; - write_cis_mem(s, 1, (base + CISREG_ESR)>>1, 1, &c->ExtStatus); + pcmcia_write_cis_mem(s, 1, (base + CISREG_ESR)>>1, 1, &c->ExtStatus); } if (req->Present & PRESENT_IOBASE_0) { u_char b = c->io.BasePort1 & 0xff; - write_cis_mem(s, 1, (base + CISREG_IOBASE_0)>>1, 1, &b); + pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_0)>>1, 1, &b); b = (c->io.BasePort1 >> 8) & 0xff; - write_cis_mem(s, 1, (base + CISREG_IOBASE_1)>>1, 1, &b); + pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_1)>>1, 1, &b); } if (req->Present & PRESENT_IOSIZE) { u_char b = c->io.NumPorts1 + c->io.NumPorts2 - 1; - write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &b); + pcmcia_write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &b); } /* Configure I/O windows */ @@ -1678,7 +1678,7 @@ int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle win->sock = s; if (!(s->features & SS_CAP_STATIC_MAP)) { - win->ctl.res = find_mem_region(req->Base, req->Size, align, + win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, (req->Attributes & WIN_MAP_BELOW_1MB), s); if (!win->ctl.res) return CS_IN_USE; diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h index 7830d7e42ea..0b4c18edfa4 100644 --- a/drivers/pcmcia/cs_internal.h +++ b/drivers/pcmcia/cs_internal.h @@ -123,9 +123,9 @@ void cb_free(struct pcmcia_socket *s); int read_cb_mem(struct pcmcia_socket *s, int space, u_int addr, u_int len, void *ptr); /* In cistpl.c */ -int read_cis_mem(struct pcmcia_socket *s, int attr, +int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr); -void write_cis_mem(struct pcmcia_socket *s, int attr, +void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr); void release_cis_mem(struct pcmcia_socket *s); void destroy_cis_cache(struct pcmcia_socket *s); @@ -134,13 +134,12 @@ int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t /* In rsrc_mgr */ void pcmcia_validate_mem(struct pcmcia_socket *s); -struct resource *find_io_region(unsigned long base, int num, unsigned long align, +struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align, struct pcmcia_socket *s); -int adjust_io_region(struct resource *res, unsigned long r_start, +int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start, unsigned long r_end, struct pcmcia_socket *s); -struct resource *find_mem_region(u_long base, u_long num, u_long align, +struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align, int low, struct pcmcia_socket *s); -int adjust_resource_info(client_handle_t handle, adjust_t *adj); void release_resource_db(struct pcmcia_socket *s); /* In socket_sysfs.c */ diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c index b9269e66281..fca10a1a56d 100644 --- a/drivers/pcmcia/rsrc_mgr.c +++ b/drivers/pcmcia/rsrc_mgr.c @@ -105,7 +105,7 @@ void pcmcia_validate_mem(struct pcmcia_socket *s) } EXPORT_SYMBOL(pcmcia_validate_mem); -int adjust_io_region(struct resource *res, unsigned long r_start, +int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start, unsigned long r_end, struct pcmcia_socket *s) { if (s->resource_ops->adjust_io_region) @@ -113,7 +113,7 @@ int adjust_io_region(struct resource *res, unsigned long r_start, return -ENOMEM; } -struct resource *find_io_region(unsigned long base, int num, +struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align, struct pcmcia_socket *s) { if (s->resource_ops->find_io) @@ -121,7 +121,7 @@ struct resource *find_io_region(unsigned long base, int num, return NULL; } -struct resource *find_mem_region(u_long base, u_long num, u_long align, +struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align, int low, struct pcmcia_socket *s) { if (s->resource_ops->find_mem) -- cgit v1.2.3 From 1a8d46631e166a3c79fe1466ce8cfc4721fdf780 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:53 -0700 Subject: [PATCH] pcmcia: move pcmcia resource handling out of cs.c Move the 16-bit PCMICA resource handling from pcmcia_core.o to pcmcia.o. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/Makefile | 2 +- drivers/pcmcia/cistpl.c | 4 + drivers/pcmcia/cs.c | 935 ------------------------------------ drivers/pcmcia/pcmcia_resource.c | 989 +++++++++++++++++++++++++++++++++++++++ drivers/pcmcia/rsrc_mgr.c | 3 + 5 files changed, 997 insertions(+), 936 deletions(-) create mode 100644 drivers/pcmcia/pcmcia_resource.c (limited to 'drivers') diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile index 195e8104ae6..ef694c74dfb 100644 --- a/drivers/pcmcia/Makefile +++ b/drivers/pcmcia/Makefile @@ -10,7 +10,7 @@ pcmcia_core-y += cs.o cistpl.o rsrc_mgr.o socket_sysfs.o pcmcia_core-$(CONFIG_CARDBUS) += cardbus.o obj-$(CONFIG_PCCARD) += pcmcia_core.o -pcmcia-y += ds.o pcmcia_compat.o +pcmcia-y += ds.o pcmcia_compat.o pcmcia_resource.o pcmcia-$(CONFIG_PCMCIA_IOCTL) += pcmcia_ioctl.o obj-$(CONFIG_PCMCIA) += pcmcia.o diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index af4ff08d6dc..a8aa7b9cf64 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -182,6 +182,8 @@ int pcmcia_read_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, *(u_char *)(ptr+2), *(u_char *)(ptr+3)); return 0; } +EXPORT_SYMBOL(pcmcia_read_cis_mem); + void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, u_int len, void *ptr) @@ -239,6 +241,8 @@ void pcmcia_write_cis_mem(struct pcmcia_socket *s, int attr, u_int addr, } } } +EXPORT_SYMBOL(pcmcia_write_cis_mem); + /*====================================================================== diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 574706e7479..6a35a4a9f93 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -89,9 +89,6 @@ INT_MODULE_PARM(unreset_limit, 30); /* unreset_check's */ /* Access speed for attribute memory windows */ INT_MODULE_PARM(cis_speed, 300); /* ns */ -/* Access speed for IO windows */ -INT_MODULE_PARM(io_speed, 0); /* ns */ - #ifdef DEBUG static int pc_debug; @@ -117,11 +114,6 @@ EXPORT_SYMBOL(pcmcia_socket_list); EXPORT_SYMBOL(pcmcia_socket_list_rwsem); -#ifdef CONFIG_PCMCIA_PROBE -/* mask ofIRQs already reserved by other cards, we should avoid using them */ -static u8 pcmcia_used_irq[NR_IRQS]; -#endif - /*==================================================================== Low-level PC Card interface drivers need to register with Card @@ -748,260 +740,6 @@ void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) } /* pcmcia_parse_events */ -/*====================================================================== - - Special stuff for managing IO windows, because they are scarce. - -======================================================================*/ - -static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base, - ioaddr_t num, u_int lines) -{ - int i; - kio_addr_t try, align; - - align = (*base) ? (lines ? 1<features & SS_CAP_STATIC_MAP) && s->io_offset) { - *base = s->io_offset | (*base & 0x0fff); - return 0; - } - /* Check for an already-allocated window that must conflict with - what was asked for. It is a hack because it does not catch all - potential conflicts, just the most obvious ones. */ - for (i = 0; i < MAX_IO_WIN; i++) - if ((s->io[i].NumPorts != 0) && - ((s->io[i].BasePort & (align-1)) == *base)) - return 1; - for (i = 0; i < MAX_IO_WIN; i++) { - if (s->io[i].NumPorts == 0) { - s->io[i].res = pcmcia_find_io_region(*base, num, align, s); - if (s->io[i].res) { - s->io[i].Attributes = attr; - s->io[i].BasePort = *base = s->io[i].res->start; - s->io[i].NumPorts = s->io[i].InUse = num; - break; - } else - return 1; - } else if (s->io[i].Attributes != attr) - continue; - /* Try to extend top of window */ - try = s->io[i].BasePort + s->io[i].NumPorts; - if ((*base == 0) || (*base == try)) - if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start, - s->io[i].res->end + num, s) == 0) { - *base = try; - s->io[i].NumPorts += num; - s->io[i].InUse += num; - break; - } - /* Try to extend bottom of window */ - try = s->io[i].BasePort - num; - if ((*base == 0) || (*base == try)) - if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start - num, - s->io[i].res->end, s) == 0) { - s->io[i].BasePort = *base = try; - s->io[i].NumPorts += num; - s->io[i].InUse += num; - break; - } - } - return (i == MAX_IO_WIN); -} /* alloc_io_space */ - -static void release_io_space(struct pcmcia_socket *s, ioaddr_t base, - ioaddr_t num) -{ - int i; - - for (i = 0; i < MAX_IO_WIN; i++) { - if ((s->io[i].BasePort <= base) && - (s->io[i].BasePort+s->io[i].NumPorts >= base+num)) { - s->io[i].InUse -= num; - /* Free the window if no one else is using it */ - if (s->io[i].InUse == 0) { - s->io[i].NumPorts = 0; - release_resource(s->io[i].res); - kfree(s->io[i].res); - s->io[i].res = NULL; - } - } - } -} - -/*====================================================================== - - Access_configuration_register() reads and writes configuration - registers in attribute memory. Memory window 0 is reserved for - this and the tuple reading services. - -======================================================================*/ - -int pccard_access_configuration_register(struct pcmcia_socket *s, - unsigned int function, - conf_reg_t *reg) -{ - config_t *c; - int addr; - u_char val; - - if (!s || !s->config) - return CS_NO_CARD; - - c = &s->config[function]; - - if (c == NULL) - return CS_NO_CARD; - - if (!(c->state & CONFIG_LOCKED)) - return CS_CONFIGURATION_LOCKED; - - addr = (c->ConfigBase + reg->Offset) >> 1; - - switch (reg->Action) { - case CS_READ: - pcmcia_read_cis_mem(s, 1, addr, 1, &val); - reg->Value = val; - break; - case CS_WRITE: - val = reg->Value; - pcmcia_write_cis_mem(s, 1, addr, 1, &val); - break; - default: - return CS_BAD_ARGS; - break; - } - return CS_SUCCESS; -} /* access_configuration_register */ -EXPORT_SYMBOL(pccard_access_configuration_register); - - -/*====================================================================*/ - -int pccard_get_configuration_info(struct pcmcia_socket *s, - unsigned int function, - config_info_t *config) -{ - config_t *c; - - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - - config->Function = function; - -#ifdef CONFIG_CARDBUS - if (s->state & SOCKET_CARDBUS) { - memset(config, 0, sizeof(config_info_t)); - config->Vcc = s->socket.Vcc; - config->Vpp1 = config->Vpp2 = s->socket.Vpp; - config->Option = s->cb_dev->subordinate->number; - if (s->state & SOCKET_CARDBUS_CONFIG) { - config->Attributes = CONF_VALID_CLIENT; - config->IntType = INT_CARDBUS; - config->AssignedIRQ = s->irq.AssignedIRQ; - if (config->AssignedIRQ) - config->Attributes |= CONF_ENABLE_IRQ; - config->BasePort1 = s->io[0].BasePort; - config->NumPorts1 = s->io[0].NumPorts; - } - return CS_SUCCESS; - } -#endif - - c = (s->config != NULL) ? &s->config[function] : NULL; - - if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { - config->Attributes = 0; - config->Vcc = s->socket.Vcc; - config->Vpp1 = config->Vpp2 = s->socket.Vpp; - return CS_SUCCESS; - } - - /* !!! This is a hack !!! */ - memcpy(&config->Attributes, &c->Attributes, sizeof(config_t)); - config->Attributes |= CONF_VALID_CLIENT; - config->CardValues = c->CardValues; - config->IRQAttributes = c->irq.Attributes; - config->AssignedIRQ = s->irq.AssignedIRQ; - config->BasePort1 = c->io.BasePort1; - config->NumPorts1 = c->io.NumPorts1; - config->Attributes1 = c->io.Attributes1; - config->BasePort2 = c->io.BasePort2; - config->NumPorts2 = c->io.NumPorts2; - config->Attributes2 = c->io.Attributes2; - config->IOAddrLines = c->io.IOAddrLines; - - return CS_SUCCESS; -} /* get_configuration_info */ -EXPORT_SYMBOL(pccard_get_configuration_info); - -/*====================================================================== - - Return information about this version of Card Services. - -======================================================================*/ - -int pcmcia_get_card_services_info(servinfo_t *info) -{ - unsigned int socket_count = 0; - struct list_head *tmp; - info->Signature[0] = 'C'; - info->Signature[1] = 'S'; - down_read(&pcmcia_socket_list_rwsem); - list_for_each(tmp, &pcmcia_socket_list) - socket_count++; - up_read(&pcmcia_socket_list_rwsem); - info->Count = socket_count; - info->Revision = CS_RELEASE_CODE; - info->CSLevel = 0x0210; - info->VendorString = (char *)release; - return CS_SUCCESS; -} /* get_card_services_info */ - - -/*====================================================================*/ - -int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, int idx, win_req_t *req) -{ - window_t *win; - int w; - - if (!s || !(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - for (w = idx; w < MAX_WIN; w++) - if (s->state & SOCKET_WIN_REQ(w)) break; - if (w == MAX_WIN) - return CS_NO_MORE_ITEMS; - win = &s->win[w]; - req->Base = win->ctl.res->start; - req->Size = win->ctl.res->end - win->ctl.res->start + 1; - req->AccessSpeed = win->ctl.speed; - req->Attributes = 0; - if (win->ctl.flags & MAP_ATTRIB) - req->Attributes |= WIN_MEMORY_TYPE_AM; - if (win->ctl.flags & MAP_ACTIVE) - req->Attributes |= WIN_ENABLE; - if (win->ctl.flags & MAP_16BIT) - req->Attributes |= WIN_DATA_WIDTH_16; - if (win->ctl.flags & MAP_USE_WAIT) - req->Attributes |= WIN_USE_WAIT; - *handle = win; - return CS_SUCCESS; -} /* get_window */ -EXPORT_SYMBOL(pcmcia_get_window); - /*===================================================================== Return the PCI device associated with a card.. @@ -1022,143 +760,6 @@ EXPORT_SYMBOL(pcmcia_lookup_bus); #endif -/*====================================================================== - - Get the current socket state bits. We don't support the latched - SocketState yet: I haven't seen any point for it. - -======================================================================*/ - -int pccard_get_status(struct pcmcia_socket *s, unsigned int function, cs_status_t *status) -{ - config_t *c; - int val; - - s->ops->get_status(s, &val); - status->CardState = status->SocketState = 0; - status->CardState |= (val & SS_DETECT) ? CS_EVENT_CARD_DETECT : 0; - status->CardState |= (val & SS_CARDBUS) ? CS_EVENT_CB_DETECT : 0; - status->CardState |= (val & SS_3VCARD) ? CS_EVENT_3VCARD : 0; - status->CardState |= (val & SS_XVCARD) ? CS_EVENT_XVCARD : 0; - if (s->state & SOCKET_SUSPEND) - status->CardState |= CS_EVENT_PM_SUSPEND; - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - - c = (s->config != NULL) ? &s->config[function] : NULL; - if ((c != NULL) && (c->state & CONFIG_LOCKED) && - (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) { - u_char reg; - if (c->Present & PRESENT_PIN_REPLACE) { - pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, ®); - status->CardState |= - (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0; - status->CardState |= - (reg & PRR_READY_STATUS) ? CS_EVENT_READY_CHANGE : 0; - status->CardState |= - (reg & PRR_BVD2_STATUS) ? CS_EVENT_BATTERY_LOW : 0; - status->CardState |= - (reg & PRR_BVD1_STATUS) ? CS_EVENT_BATTERY_DEAD : 0; - } else { - /* No PRR? Then assume we're always ready */ - status->CardState |= CS_EVENT_READY_CHANGE; - } - if (c->Present & PRESENT_EXT_STATUS) { - pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, ®); - status->CardState |= - (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; - } - return CS_SUCCESS; - } - status->CardState |= - (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0; - status->CardState |= - (val & SS_BATDEAD) ? CS_EVENT_BATTERY_DEAD : 0; - status->CardState |= - (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0; - status->CardState |= - (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0; - return CS_SUCCESS; -} /* get_status */ -EXPORT_SYMBOL(pccard_get_status); - -/*====================================================================== - - Change the card address of an already open memory window. - -======================================================================*/ - -int pcmcia_get_mem_page(window_handle_t win, memreq_t *req) -{ - if ((win == NULL) || (win->magic != WINDOW_MAGIC)) - return CS_BAD_HANDLE; - req->Page = 0; - req->CardOffset = win->ctl.card_start; - return CS_SUCCESS; -} /* get_mem_page */ - -int pcmcia_map_mem_page(window_handle_t win, memreq_t *req) -{ - struct pcmcia_socket *s; - if ((win == NULL) || (win->magic != WINDOW_MAGIC)) - return CS_BAD_HANDLE; - if (req->Page != 0) - return CS_BAD_PAGE; - s = win->sock; - win->ctl.card_start = req->CardOffset; - if (s->ops->set_mem_map(s, &win->ctl) != 0) - return CS_BAD_OFFSET; - return CS_SUCCESS; -} /* map_mem_page */ - -/*====================================================================== - - Modify a locked socket configuration - -======================================================================*/ - -int pcmcia_modify_configuration(client_handle_t handle, - modconf_t *mod) -{ - struct pcmcia_socket *s; - config_t *c; - - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); c = CONFIG(handle); - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - if (!(c->state & CONFIG_LOCKED)) - return CS_CONFIGURATION_LOCKED; - - if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { - if (mod->Attributes & CONF_ENABLE_IRQ) { - c->Attributes |= CONF_ENABLE_IRQ; - s->socket.io_irq = s->irq.AssignedIRQ; - } else { - c->Attributes &= ~CONF_ENABLE_IRQ; - s->socket.io_irq = 0; - } - s->ops->set_socket(s, &s->socket); - } - - if (mod->Attributes & CONF_VCC_CHANGE_VALID) - return CS_BAD_VCC; - - /* We only allow changing Vpp1 and Vpp2 to the same value */ - if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && - (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { - if (mod->Vpp1 != mod->Vpp2) - return CS_BAD_VPP; - c->Vpp1 = c->Vpp2 = s->socket.Vpp = mod->Vpp1; - if (s->ops->set_socket(s, &s->socket)) - return CS_BAD_VPP; - } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || - (mod->Attributes & CONF_VPP2_CHANGE_VALID)) - return CS_BAD_VPP; - - return CS_SUCCESS; -} /* modify_configuration */ /* register pcmcia_callback */ int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c) @@ -1188,530 +789,6 @@ int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c) } EXPORT_SYMBOL(pccard_register_pcmcia); -/*====================================================================*/ - -int pcmcia_release_configuration(client_handle_t handle) -{ - pccard_io_map io = { 0, 0, 0, 0, 1 }; - struct pcmcia_socket *s; - int i; - - if (CHECK_HANDLE(handle) || - !(handle->state & CLIENT_CONFIG_LOCKED)) - return CS_BAD_HANDLE; - handle->state &= ~CLIENT_CONFIG_LOCKED; - s = SOCKET(handle); - -#ifdef CONFIG_CARDBUS - if (handle->state & CLIENT_CARDBUS) - return CS_SUCCESS; -#endif - - if (!(handle->state & CLIENT_STALE)) { - config_t *c = CONFIG(handle); - if (--(s->lock_count) == 0) { - s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ - s->socket.Vpp = 0; - s->socket.io_irq = 0; - s->ops->set_socket(s, &s->socket); - } - if (c->state & CONFIG_IO_REQ) - for (i = 0; i < MAX_IO_WIN; i++) { - if (s->io[i].NumPorts == 0) - continue; - s->io[i].Config--; - if (s->io[i].Config != 0) - continue; - io.map = i; - s->ops->set_io_map(s, &io); - } - c->state &= ~CONFIG_LOCKED; - } - - return CS_SUCCESS; -} /* release_configuration */ - -/*====================================================================== - - Release_io() releases the I/O ranges allocated by a client. This - may be invoked some time after a card ejection has already dumped - the actual socket configuration, so if the client is "stale", we - don't bother checking the port ranges against the current socket - values. - -======================================================================*/ - -int pcmcia_release_io(client_handle_t handle, io_req_t *req) -{ - struct pcmcia_socket *s; - - if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IO_REQ)) - return CS_BAD_HANDLE; - handle->state &= ~CLIENT_IO_REQ; - s = SOCKET(handle); - -#ifdef CONFIG_CARDBUS - if (handle->state & CLIENT_CARDBUS) - return CS_SUCCESS; -#endif - - if (!(handle->state & CLIENT_STALE)) { - config_t *c = CONFIG(handle); - if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; - if ((c->io.BasePort1 != req->BasePort1) || - (c->io.NumPorts1 != req->NumPorts1) || - (c->io.BasePort2 != req->BasePort2) || - (c->io.NumPorts2 != req->NumPorts2)) - return CS_BAD_ARGS; - c->state &= ~CONFIG_IO_REQ; - } - - release_io_space(s, req->BasePort1, req->NumPorts1); - if (req->NumPorts2) - release_io_space(s, req->BasePort2, req->NumPorts2); - - return CS_SUCCESS; -} /* release_io */ - -/*====================================================================*/ - -int pcmcia_release_irq(client_handle_t handle, irq_req_t *req) -{ - struct pcmcia_socket *s; - if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IRQ_REQ)) - return CS_BAD_HANDLE; - handle->state &= ~CLIENT_IRQ_REQ; - s = SOCKET(handle); - - if (!(handle->state & CLIENT_STALE)) { - config_t *c = CONFIG(handle); - if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; - if (c->irq.Attributes != req->Attributes) - return CS_BAD_ATTRIBUTE; - if (s->irq.AssignedIRQ != req->AssignedIRQ) - return CS_BAD_IRQ; - if (--s->irq.Config == 0) { - c->state &= ~CONFIG_IRQ_REQ; - s->irq.AssignedIRQ = 0; - } - } - - if (req->Attributes & IRQ_HANDLE_PRESENT) { - free_irq(req->AssignedIRQ, req->Instance); - } - -#ifdef CONFIG_PCMCIA_PROBE - pcmcia_used_irq[req->AssignedIRQ]--; -#endif - - return CS_SUCCESS; -} /* cs_release_irq */ - -/*====================================================================*/ - -int pcmcia_release_window(window_handle_t win) -{ - struct pcmcia_socket *s; - - if ((win == NULL) || (win->magic != WINDOW_MAGIC)) - return CS_BAD_HANDLE; - s = win->sock; - if (!(win->handle->state & CLIENT_WIN_REQ(win->index))) - return CS_BAD_HANDLE; - - /* Shut down memory window */ - win->ctl.flags &= ~MAP_ACTIVE; - s->ops->set_mem_map(s, &win->ctl); - s->state &= ~SOCKET_WIN_REQ(win->index); - - /* Release system memory */ - if (win->ctl.res) { - release_resource(win->ctl.res); - kfree(win->ctl.res); - win->ctl.res = NULL; - } - win->handle->state &= ~CLIENT_WIN_REQ(win->index); - - win->magic = 0; - - return CS_SUCCESS; -} /* release_window */ - -/*====================================================================*/ - -int pcmcia_request_configuration(client_handle_t handle, - config_req_t *req) -{ - int i; - u_int base; - struct pcmcia_socket *s; - config_t *c; - pccard_io_map iomap; - - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - -#ifdef CONFIG_CARDBUS - if (handle->state & CLIENT_CARDBUS) - return CS_UNSUPPORTED_MODE; -#endif - - if (req->IntType & INT_CARDBUS) - return CS_UNSUPPORTED_MODE; - c = CONFIG(handle); - if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; - - /* Do power control. We don't allow changes in Vcc. */ - if (s->socket.Vcc != req->Vcc) - return CS_BAD_VCC; - if (req->Vpp1 != req->Vpp2) - return CS_BAD_VPP; - s->socket.Vpp = req->Vpp1; - if (s->ops->set_socket(s, &s->socket)) - return CS_BAD_VPP; - - c->Vcc = req->Vcc; c->Vpp1 = c->Vpp2 = req->Vpp1; - - /* Pick memory or I/O card, DMA mode, interrupt */ - c->IntType = req->IntType; - c->Attributes = req->Attributes; - if (req->IntType & INT_MEMORY_AND_IO) - s->socket.flags |= SS_IOCARD; - if (req->IntType & INT_ZOOMED_VIDEO) - s->socket.flags |= SS_ZVCARD | SS_IOCARD; - if (req->Attributes & CONF_ENABLE_DMA) - s->socket.flags |= SS_DMA_MODE; - if (req->Attributes & CONF_ENABLE_SPKR) - s->socket.flags |= SS_SPKR_ENA; - if (req->Attributes & CONF_ENABLE_IRQ) - s->socket.io_irq = s->irq.AssignedIRQ; - else - s->socket.io_irq = 0; - s->ops->set_socket(s, &s->socket); - s->lock_count++; - - /* Set up CIS configuration registers */ - base = c->ConfigBase = req->ConfigBase; - c->Present = c->CardValues = req->Present; - if (req->Present & PRESENT_COPY) { - c->Copy = req->Copy; - pcmcia_write_cis_mem(s, 1, (base + CISREG_SCR)>>1, 1, &c->Copy); - } - if (req->Present & PRESENT_OPTION) { - if (s->functions == 1) { - c->Option = req->ConfigIndex & COR_CONFIG_MASK; - } else { - c->Option = req->ConfigIndex & COR_MFC_CONFIG_MASK; - c->Option |= COR_FUNC_ENA|COR_IREQ_ENA; - if (req->Present & PRESENT_IOBASE_0) - c->Option |= COR_ADDR_DECODE; - } - if (c->state & CONFIG_IRQ_REQ) - if (!(c->irq.Attributes & IRQ_FORCED_PULSE)) - c->Option |= COR_LEVEL_REQ; - pcmcia_write_cis_mem(s, 1, (base + CISREG_COR)>>1, 1, &c->Option); - mdelay(40); - } - if (req->Present & PRESENT_STATUS) { - c->Status = req->Status; - pcmcia_write_cis_mem(s, 1, (base + CISREG_CCSR)>>1, 1, &c->Status); - } - if (req->Present & PRESENT_PIN_REPLACE) { - c->Pin = req->Pin; - pcmcia_write_cis_mem(s, 1, (base + CISREG_PRR)>>1, 1, &c->Pin); - } - if (req->Present & PRESENT_EXT_STATUS) { - c->ExtStatus = req->ExtStatus; - pcmcia_write_cis_mem(s, 1, (base + CISREG_ESR)>>1, 1, &c->ExtStatus); - } - if (req->Present & PRESENT_IOBASE_0) { - u_char b = c->io.BasePort1 & 0xff; - pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_0)>>1, 1, &b); - b = (c->io.BasePort1 >> 8) & 0xff; - pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_1)>>1, 1, &b); - } - if (req->Present & PRESENT_IOSIZE) { - u_char b = c->io.NumPorts1 + c->io.NumPorts2 - 1; - pcmcia_write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &b); - } - - /* Configure I/O windows */ - if (c->state & CONFIG_IO_REQ) { - iomap.speed = io_speed; - for (i = 0; i < MAX_IO_WIN; i++) - if (s->io[i].NumPorts != 0) { - iomap.map = i; - iomap.flags = MAP_ACTIVE; - switch (s->io[i].Attributes & IO_DATA_PATH_WIDTH) { - case IO_DATA_PATH_WIDTH_16: - iomap.flags |= MAP_16BIT; break; - case IO_DATA_PATH_WIDTH_AUTO: - iomap.flags |= MAP_AUTOSZ; break; - default: - break; - } - iomap.start = s->io[i].BasePort; - iomap.stop = iomap.start + s->io[i].NumPorts - 1; - s->ops->set_io_map(s, &iomap); - s->io[i].Config++; - } - } - - c->state |= CONFIG_LOCKED; - handle->state |= CLIENT_CONFIG_LOCKED; - return CS_SUCCESS; -} /* request_configuration */ - -/*====================================================================== - - Request_io() reserves ranges of port addresses for a socket. - I have not implemented range sharing or alias addressing. - -======================================================================*/ - -int pcmcia_request_io(client_handle_t handle, io_req_t *req) -{ - struct pcmcia_socket *s; - config_t *c; - - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - - if (handle->state & CLIENT_CARDBUS) { -#ifdef CONFIG_CARDBUS - handle->state |= CLIENT_IO_REQ; - return CS_SUCCESS; -#else - return CS_UNSUPPORTED_FUNCTION; -#endif - } - - if (!req) - return CS_UNSUPPORTED_MODE; - c = CONFIG(handle); - if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; - if (c->state & CONFIG_IO_REQ) - return CS_IN_USE; - if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) - return CS_BAD_ATTRIBUTE; - if ((req->NumPorts2 > 0) && - (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) - return CS_BAD_ATTRIBUTE; - - if (alloc_io_space(s, req->Attributes1, &req->BasePort1, - req->NumPorts1, req->IOAddrLines)) - return CS_IN_USE; - - if (req->NumPorts2) { - if (alloc_io_space(s, req->Attributes2, &req->BasePort2, - req->NumPorts2, req->IOAddrLines)) { - release_io_space(s, req->BasePort1, req->NumPorts1); - return CS_IN_USE; - } - } - - c->io = *req; - c->state |= CONFIG_IO_REQ; - handle->state |= CLIENT_IO_REQ; - return CS_SUCCESS; -} /* request_io */ - -/*====================================================================== - - Request_irq() reserves an irq for this client. - - Also, since Linux only reserves irq's when they are actually - hooked, we don't guarantee that an irq will still be available - when the configuration is locked. Now that I think about it, - there might be a way to fix this using a dummy handler. - -======================================================================*/ - -#ifdef CONFIG_PCMCIA_PROBE -static irqreturn_t test_action(int cpl, void *dev_id, struct pt_regs *regs) -{ - return IRQ_NONE; -} -#endif - -int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) -{ - struct pcmcia_socket *s; - config_t *c; - int ret = CS_IN_USE, irq = 0; - struct pcmcia_device *p_dev = handle_to_pdev(handle); - - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - c = CONFIG(handle); - if (c->state & CONFIG_LOCKED) - return CS_CONFIGURATION_LOCKED; - if (c->state & CONFIG_IRQ_REQ) - return CS_IN_USE; - -#ifdef CONFIG_PCMCIA_PROBE - if (s->irq.AssignedIRQ != 0) { - /* If the interrupt is already assigned, it must be the same */ - irq = s->irq.AssignedIRQ; - } else { - int try; - u32 mask = s->irq_mask; - void *data = NULL; - - for (try = 0; try < 64; try++) { - irq = try % 32; - - /* marked as available by driver, and not blocked by userspace? */ - if (!((mask >> irq) & 1)) - continue; - - /* avoid an IRQ which is already used by a PCMCIA card */ - if ((try < 32) && pcmcia_used_irq[irq]) - continue; - - /* register the correct driver, if possible, of check whether - * registering a dummy handle works, i.e. if the IRQ isn't - * marked as used by the kernel resource management core */ - ret = request_irq(irq, - (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Handler : test_action, - ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || - (s->functions > 1) || - (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, - (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data); - if (!ret) { - if (!(req->Attributes & IRQ_HANDLE_PRESENT)) - free_irq(irq, data); - break; - } - } - } -#endif - if (ret) { - if (!s->pci_irq) - return ret; - irq = s->pci_irq; - } - - if (ret && req->Attributes & IRQ_HANDLE_PRESENT) { - if (request_irq(irq, req->Handler, - ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || - (s->functions > 1) || - (irq == s->pci_irq)) ? SA_SHIRQ : 0, - p_dev->dev.bus_id, req->Instance)) - return CS_IN_USE; - } - - c->irq.Attributes = req->Attributes; - s->irq.AssignedIRQ = req->AssignedIRQ = irq; - s->irq.Config++; - - c->state |= CONFIG_IRQ_REQ; - handle->state |= CLIENT_IRQ_REQ; - -#ifdef CONFIG_PCMCIA_PROBE - pcmcia_used_irq[irq]++; -#endif - - return CS_SUCCESS; -} /* pcmcia_request_irq */ - -/*====================================================================== - - Request_window() establishes a mapping between card memory space - and system memory space. - -======================================================================*/ - -int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle_t *wh) -{ - struct pcmcia_socket *s; - window_t *win; - u_long align; - int w; - - if (CHECK_HANDLE(*handle)) - return CS_BAD_HANDLE; - s = (*handle)->Socket; - if (!(s->state & SOCKET_PRESENT)) - return CS_NO_CARD; - if (req->Attributes & (WIN_PAGED | WIN_SHARED)) - return CS_BAD_ATTRIBUTE; - - /* Window size defaults to smallest available */ - if (req->Size == 0) - req->Size = s->map_size; - align = (((s->features & SS_CAP_MEM_ALIGN) || - (req->Attributes & WIN_STRICT_ALIGN)) ? - req->Size : s->map_size); - if (req->Size & (s->map_size-1)) - return CS_BAD_SIZE; - if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || - (req->Base & (align-1))) - return CS_BAD_BASE; - if (req->Base) - align = 0; - - /* Allocate system memory window */ - for (w = 0; w < MAX_WIN; w++) - if (!(s->state & SOCKET_WIN_REQ(w))) break; - if (w == MAX_WIN) - return CS_OUT_OF_RESOURCE; - - win = &s->win[w]; - win->magic = WINDOW_MAGIC; - win->index = w; - win->handle = *handle; - win->sock = s; - - if (!(s->features & SS_CAP_STATIC_MAP)) { - win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, - (req->Attributes & WIN_MAP_BELOW_1MB), s); - if (!win->ctl.res) - return CS_IN_USE; - } - (*handle)->state |= CLIENT_WIN_REQ(w); - - /* Configure the socket controller */ - win->ctl.map = w+1; - win->ctl.flags = 0; - win->ctl.speed = req->AccessSpeed; - if (req->Attributes & WIN_MEMORY_TYPE) - win->ctl.flags |= MAP_ATTRIB; - if (req->Attributes & WIN_ENABLE) - win->ctl.flags |= MAP_ACTIVE; - if (req->Attributes & WIN_DATA_WIDTH_16) - win->ctl.flags |= MAP_16BIT; - if (req->Attributes & WIN_USE_WAIT) - win->ctl.flags |= MAP_USE_WAIT; - win->ctl.card_start = 0; - if (s->ops->set_mem_map(s, &win->ctl) != 0) - return CS_BAD_ARGS; - s->state |= SOCKET_WIN_REQ(w); - - /* Return window handle */ - if (s->features & SS_CAP_STATIC_MAP) { - req->Base = win->ctl.static_start; - } else { - req->Base = win->ctl.res->start; - } - *wh = win; - - return CS_SUCCESS; -} /* request_window */ /*====================================================================== @@ -1888,20 +965,8 @@ static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, ======================================================================*/ /* in alpha order */ EXPORT_SYMBOL(pcmcia_eject_card); -EXPORT_SYMBOL(pcmcia_get_card_services_info); -EXPORT_SYMBOL(pcmcia_get_mem_page); EXPORT_SYMBOL(pcmcia_insert_card); -EXPORT_SYMBOL(pcmcia_map_mem_page); -EXPORT_SYMBOL(pcmcia_modify_configuration); -EXPORT_SYMBOL(pcmcia_release_configuration); -EXPORT_SYMBOL(pcmcia_release_io); -EXPORT_SYMBOL(pcmcia_release_irq); -EXPORT_SYMBOL(pcmcia_release_window); EXPORT_SYMBOL(pcmcia_replace_cis); -EXPORT_SYMBOL(pcmcia_request_configuration); -EXPORT_SYMBOL(pcmcia_request_io); -EXPORT_SYMBOL(pcmcia_request_irq); -EXPORT_SYMBOL(pcmcia_request_window); EXPORT_SYMBOL(pcmcia_resume_card); EXPORT_SYMBOL(pcmcia_suspend_card); diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c new file mode 100644 index 00000000000..cf66b997894 --- /dev/null +++ b/drivers/pcmcia/pcmcia_resource.c @@ -0,0 +1,989 @@ +/* + * PCMCIA 16-bit resource management functions + * + * The initial developer of the original code is David A. Hinds + * . Portions created by David A. Hinds + * are Copyright (C) 1999 David A. Hinds. All Rights Reserved. + * + * Copyright (C) 1999 David A. Hinds + * Copyright (C) 2004-2005 Dominik Brodowski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +#define IN_CARD_SERVICES +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cs_internal.h" +#include "ds_internal.h" + + +static const char *release = "Linux Kernel Card Services"; + +/* Access speed for IO windows */ +static int io_speed = 0; +module_param(io_speed, int, 0444); + + +#ifdef CONFIG_PCMCIA_PROBE +/* mask of IRQs already reserved by other cards, we should avoid using them */ +static u8 pcmcia_used_irq[NR_IRQS]; +#endif + + +#ifdef DEBUG +extern int ds_pc_debug; +#define cs_socket_name(skt) ((skt)->dev.class_id) + +#define ds_dbg(skt, lvl, fmt, arg...) do { \ + if (ds_pc_debug >= lvl) \ + printk(KERN_DEBUG "pcmcia_resource: %s: " fmt, \ + cs_socket_name(skt) , ## arg); \ +} while (0) +#else +#define ds_dbg(lvl, fmt, arg...) do { } while (0) +#endif + + + +/** alloc_io_space + * + * Special stuff for managing IO windows, because they are scarce + */ + +static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base, + ioaddr_t num, u_int lines) +{ + int i; + kio_addr_t try, align; + + align = (*base) ? (lines ? 1<features & SS_CAP_STATIC_MAP) && s->io_offset) { + *base = s->io_offset | (*base & 0x0fff); + return 0; + } + /* Check for an already-allocated window that must conflict with + * what was asked for. It is a hack because it does not catch all + * potential conflicts, just the most obvious ones. + */ + for (i = 0; i < MAX_IO_WIN; i++) + if ((s->io[i].NumPorts != 0) && + ((s->io[i].BasePort & (align-1)) == *base)) + return 1; + for (i = 0; i < MAX_IO_WIN; i++) { + if (s->io[i].NumPorts == 0) { + s->io[i].res = pcmcia_find_io_region(*base, num, align, s); + if (s->io[i].res) { + s->io[i].Attributes = attr; + s->io[i].BasePort = *base = s->io[i].res->start; + s->io[i].NumPorts = s->io[i].InUse = num; + break; + } else + return 1; + } else if (s->io[i].Attributes != attr) + continue; + /* Try to extend top of window */ + try = s->io[i].BasePort + s->io[i].NumPorts; + if ((*base == 0) || (*base == try)) + if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start, + s->io[i].res->end + num, s) == 0) { + *base = try; + s->io[i].NumPorts += num; + s->io[i].InUse += num; + break; + } + /* Try to extend bottom of window */ + try = s->io[i].BasePort - num; + if ((*base == 0) || (*base == try)) + if (pcmcia_adjust_io_region(s->io[i].res, s->io[i].res->start - num, + s->io[i].res->end, s) == 0) { + s->io[i].BasePort = *base = try; + s->io[i].NumPorts += num; + s->io[i].InUse += num; + break; + } + } + return (i == MAX_IO_WIN); +} /* alloc_io_space */ + + +static void release_io_space(struct pcmcia_socket *s, ioaddr_t base, + ioaddr_t num) +{ + int i; + + for (i = 0; i < MAX_IO_WIN; i++) { + if ((s->io[i].BasePort <= base) && + (s->io[i].BasePort+s->io[i].NumPorts >= base+num)) { + s->io[i].InUse -= num; + /* Free the window if no one else is using it */ + if (s->io[i].InUse == 0) { + s->io[i].NumPorts = 0; + release_resource(s->io[i].res); + kfree(s->io[i].res); + s->io[i].res = NULL; + } + } + } +} /* release_io_space */ + + +/** pccard_access_configuration_register + * + * Access_configuration_register() reads and writes configuration + * registers in attribute memory. Memory window 0 is reserved for + * this and the tuple reading services. + */ + +int pccard_access_configuration_register(struct pcmcia_socket *s, + unsigned int function, + conf_reg_t *reg) +{ + config_t *c; + int addr; + u_char val; + + if (!s || !s->config) + return CS_NO_CARD; + + c = &s->config[function]; + + if (c == NULL) + return CS_NO_CARD; + + if (!(c->state & CONFIG_LOCKED)) + return CS_CONFIGURATION_LOCKED; + + addr = (c->ConfigBase + reg->Offset) >> 1; + + switch (reg->Action) { + case CS_READ: + pcmcia_read_cis_mem(s, 1, addr, 1, &val); + reg->Value = val; + break; + case CS_WRITE: + val = reg->Value; + pcmcia_write_cis_mem(s, 1, addr, 1, &val); + break; + default: + return CS_BAD_ARGS; + break; + } + return CS_SUCCESS; +} /* pccard_access_configuration_register */ +EXPORT_SYMBOL(pccard_access_configuration_register); + + +int pccard_get_configuration_info(struct pcmcia_socket *s, + unsigned int function, + config_info_t *config) +{ + config_t *c; + + if (!(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + + config->Function = function; + +#ifdef CONFIG_CARDBUS + if (s->state & SOCKET_CARDBUS) { + memset(config, 0, sizeof(config_info_t)); + config->Vcc = s->socket.Vcc; + config->Vpp1 = config->Vpp2 = s->socket.Vpp; + config->Option = s->cb_dev->subordinate->number; + if (s->state & SOCKET_CARDBUS_CONFIG) { + config->Attributes = CONF_VALID_CLIENT; + config->IntType = INT_CARDBUS; + config->AssignedIRQ = s->irq.AssignedIRQ; + if (config->AssignedIRQ) + config->Attributes |= CONF_ENABLE_IRQ; + config->BasePort1 = s->io[0].BasePort; + config->NumPorts1 = s->io[0].NumPorts; + } + return CS_SUCCESS; + } +#endif + + c = (s->config != NULL) ? &s->config[function] : NULL; + + if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { + config->Attributes = 0; + config->Vcc = s->socket.Vcc; + config->Vpp1 = config->Vpp2 = s->socket.Vpp; + return CS_SUCCESS; + } + + /* !!! This is a hack !!! */ + memcpy(&config->Attributes, &c->Attributes, sizeof(config_t)); + config->Attributes |= CONF_VALID_CLIENT; + config->CardValues = c->CardValues; + config->IRQAttributes = c->irq.Attributes; + config->AssignedIRQ = s->irq.AssignedIRQ; + config->BasePort1 = c->io.BasePort1; + config->NumPorts1 = c->io.NumPorts1; + config->Attributes1 = c->io.Attributes1; + config->BasePort2 = c->io.BasePort2; + config->NumPorts2 = c->io.NumPorts2; + config->Attributes2 = c->io.Attributes2; + config->IOAddrLines = c->io.IOAddrLines; + + return CS_SUCCESS; +} /* pccard_get_configuration_info */ +EXPORT_SYMBOL(pccard_get_configuration_info); + + +/** pcmcia_get_card_services_info + * + * Return information about this version of Card Services + */ + +int pcmcia_get_card_services_info(servinfo_t *info) +{ + unsigned int socket_count = 0; + struct list_head *tmp; + info->Signature[0] = 'C'; + info->Signature[1] = 'S'; + down_read(&pcmcia_socket_list_rwsem); + list_for_each(tmp, &pcmcia_socket_list) + socket_count++; + up_read(&pcmcia_socket_list_rwsem); + info->Count = socket_count; + info->Revision = CS_RELEASE_CODE; + info->CSLevel = 0x0210; + info->VendorString = (char *)release; + return CS_SUCCESS; +} /* get_card_services_info */ +EXPORT_SYMBOL(pcmcia_get_card_services_info); + + +/** pcmcia_get_window + */ +int pcmcia_get_window(struct pcmcia_socket *s, window_handle_t *handle, + int idx, win_req_t *req) +{ + window_t *win; + int w; + + if (!s || !(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + for (w = idx; w < MAX_WIN; w++) + if (s->state & SOCKET_WIN_REQ(w)) + break; + if (w == MAX_WIN) + return CS_NO_MORE_ITEMS; + win = &s->win[w]; + req->Base = win->ctl.res->start; + req->Size = win->ctl.res->end - win->ctl.res->start + 1; + req->AccessSpeed = win->ctl.speed; + req->Attributes = 0; + if (win->ctl.flags & MAP_ATTRIB) + req->Attributes |= WIN_MEMORY_TYPE_AM; + if (win->ctl.flags & MAP_ACTIVE) + req->Attributes |= WIN_ENABLE; + if (win->ctl.flags & MAP_16BIT) + req->Attributes |= WIN_DATA_WIDTH_16; + if (win->ctl.flags & MAP_USE_WAIT) + req->Attributes |= WIN_USE_WAIT; + *handle = win; + return CS_SUCCESS; +} /* pcmcia_get_window */ +EXPORT_SYMBOL(pcmcia_get_window); + + +/** pccard_get_status + * + * Get the current socket state bits. We don't support the latched + * SocketState yet: I haven't seen any point for it. + */ + +int pccard_get_status(struct pcmcia_socket *s, unsigned int function, + cs_status_t *status) +{ + config_t *c; + int val; + + s->ops->get_status(s, &val); + status->CardState = status->SocketState = 0; + status->CardState |= (val & SS_DETECT) ? CS_EVENT_CARD_DETECT : 0; + status->CardState |= (val & SS_CARDBUS) ? CS_EVENT_CB_DETECT : 0; + status->CardState |= (val & SS_3VCARD) ? CS_EVENT_3VCARD : 0; + status->CardState |= (val & SS_XVCARD) ? CS_EVENT_XVCARD : 0; + if (s->state & SOCKET_SUSPEND) + status->CardState |= CS_EVENT_PM_SUSPEND; + if (!(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + + c = (s->config != NULL) ? &s->config[function] : NULL; + if ((c != NULL) && (c->state & CONFIG_LOCKED) && + (c->IntType & (INT_MEMORY_AND_IO | INT_ZOOMED_VIDEO))) { + u_char reg; + if (c->Present & PRESENT_PIN_REPLACE) { + pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_PRR)>>1, 1, ®); + status->CardState |= + (reg & PRR_WP_STATUS) ? CS_EVENT_WRITE_PROTECT : 0; + status->CardState |= + (reg & PRR_READY_STATUS) ? CS_EVENT_READY_CHANGE : 0; + status->CardState |= + (reg & PRR_BVD2_STATUS) ? CS_EVENT_BATTERY_LOW : 0; + status->CardState |= + (reg & PRR_BVD1_STATUS) ? CS_EVENT_BATTERY_DEAD : 0; + } else { + /* No PRR? Then assume we're always ready */ + status->CardState |= CS_EVENT_READY_CHANGE; + } + if (c->Present & PRESENT_EXT_STATUS) { + pcmcia_read_cis_mem(s, 1, (c->ConfigBase+CISREG_ESR)>>1, 1, ®); + status->CardState |= + (reg & ESR_REQ_ATTN) ? CS_EVENT_REQUEST_ATTENTION : 0; + } + return CS_SUCCESS; + } + status->CardState |= + (val & SS_WRPROT) ? CS_EVENT_WRITE_PROTECT : 0; + status->CardState |= + (val & SS_BATDEAD) ? CS_EVENT_BATTERY_DEAD : 0; + status->CardState |= + (val & SS_BATWARN) ? CS_EVENT_BATTERY_LOW : 0; + status->CardState |= + (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0; + return CS_SUCCESS; +} /* pccard_get_status */ +EXPORT_SYMBOL(pccard_get_status); + + +/** pcmcia_get_mem_page + * + * Change the card address of an already open memory window. + */ +int pcmcia_get_mem_page(window_handle_t win, memreq_t *req) +{ + if ((win == NULL) || (win->magic != WINDOW_MAGIC)) + return CS_BAD_HANDLE; + req->Page = 0; + req->CardOffset = win->ctl.card_start; + return CS_SUCCESS; +} /* pcmcia_get_mem_page */ +EXPORT_SYMBOL(pcmcia_get_mem_page); + + +int pcmcia_map_mem_page(window_handle_t win, memreq_t *req) +{ + struct pcmcia_socket *s; + if ((win == NULL) || (win->magic != WINDOW_MAGIC)) + return CS_BAD_HANDLE; + if (req->Page != 0) + return CS_BAD_PAGE; + s = win->sock; + win->ctl.card_start = req->CardOffset; + if (s->ops->set_mem_map(s, &win->ctl) != 0) + return CS_BAD_OFFSET; + return CS_SUCCESS; +} /* pcmcia_map_mem_page */ +EXPORT_SYMBOL(pcmcia_map_mem_page); + + +/** pcmcia_modify_configuration + * + * Modify a locked socket configuration + */ +int pcmcia_modify_configuration(client_handle_t handle, + modconf_t *mod) +{ + struct pcmcia_socket *s; + config_t *c; + + if (CHECK_HANDLE(handle)) + return CS_BAD_HANDLE; + s = SOCKET(handle); + c = CONFIG(handle); + if (!(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + if (!(c->state & CONFIG_LOCKED)) + return CS_CONFIGURATION_LOCKED; + + if (mod->Attributes & CONF_IRQ_CHANGE_VALID) { + if (mod->Attributes & CONF_ENABLE_IRQ) { + c->Attributes |= CONF_ENABLE_IRQ; + s->socket.io_irq = s->irq.AssignedIRQ; + } else { + c->Attributes &= ~CONF_ENABLE_IRQ; + s->socket.io_irq = 0; + } + s->ops->set_socket(s, &s->socket); + } + + if (mod->Attributes & CONF_VCC_CHANGE_VALID) + return CS_BAD_VCC; + + /* We only allow changing Vpp1 and Vpp2 to the same value */ + if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) && + (mod->Attributes & CONF_VPP2_CHANGE_VALID)) { + if (mod->Vpp1 != mod->Vpp2) + return CS_BAD_VPP; + c->Vpp1 = c->Vpp2 = s->socket.Vpp = mod->Vpp1; + if (s->ops->set_socket(s, &s->socket)) + return CS_BAD_VPP; + } else if ((mod->Attributes & CONF_VPP1_CHANGE_VALID) || + (mod->Attributes & CONF_VPP2_CHANGE_VALID)) + return CS_BAD_VPP; + + return CS_SUCCESS; +} /* modify_configuration */ +EXPORT_SYMBOL(pcmcia_modify_configuration); + + +int pcmcia_release_configuration(client_handle_t handle) +{ + pccard_io_map io = { 0, 0, 0, 0, 1 }; + struct pcmcia_socket *s; + int i; + + if (CHECK_HANDLE(handle) || + !(handle->state & CLIENT_CONFIG_LOCKED)) + return CS_BAD_HANDLE; + handle->state &= ~CLIENT_CONFIG_LOCKED; + s = SOCKET(handle); + +#ifdef CONFIG_CARDBUS + if (handle->state & CLIENT_CARDBUS) + return CS_SUCCESS; +#endif + + if (!(handle->state & CLIENT_STALE)) { + config_t *c = CONFIG(handle); + if (--(s->lock_count) == 0) { + s->socket.flags = SS_OUTPUT_ENA; /* Is this correct? */ + s->socket.Vpp = 0; + s->socket.io_irq = 0; + s->ops->set_socket(s, &s->socket); + } + if (c->state & CONFIG_IO_REQ) + for (i = 0; i < MAX_IO_WIN; i++) { + if (s->io[i].NumPorts == 0) + continue; + s->io[i].Config--; + if (s->io[i].Config != 0) + continue; + io.map = i; + s->ops->set_io_map(s, &io); + } + c->state &= ~CONFIG_LOCKED; + } + + return CS_SUCCESS; +} /* pcmcia_release_configuration */ +EXPORT_SYMBOL(pcmcia_release_configuration); + + +/** pcmcia_release_io + * + * Release_io() releases the I/O ranges allocated by a client. This + * may be invoked some time after a card ejection has already dumped + * the actual socket configuration, so if the client is "stale", we + * don't bother checking the port ranges against the current socket + * values. + */ +int pcmcia_release_io(client_handle_t handle, io_req_t *req) +{ + struct pcmcia_socket *s; + + if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IO_REQ)) + return CS_BAD_HANDLE; + handle->state &= ~CLIENT_IO_REQ; + s = SOCKET(handle); + +#ifdef CONFIG_CARDBUS + if (handle->state & CLIENT_CARDBUS) + return CS_SUCCESS; +#endif + + if (!(handle->state & CLIENT_STALE)) { + config_t *c = CONFIG(handle); + if (c->state & CONFIG_LOCKED) + return CS_CONFIGURATION_LOCKED; + if ((c->io.BasePort1 != req->BasePort1) || + (c->io.NumPorts1 != req->NumPorts1) || + (c->io.BasePort2 != req->BasePort2) || + (c->io.NumPorts2 != req->NumPorts2)) + return CS_BAD_ARGS; + c->state &= ~CONFIG_IO_REQ; + } + + release_io_space(s, req->BasePort1, req->NumPorts1); + if (req->NumPorts2) + release_io_space(s, req->BasePort2, req->NumPorts2); + + return CS_SUCCESS; +} /* pcmcia_release_io */ +EXPORT_SYMBOL(pcmcia_release_io); + + +int pcmcia_release_irq(client_handle_t handle, irq_req_t *req) +{ + struct pcmcia_socket *s; + if (CHECK_HANDLE(handle) || !(handle->state & CLIENT_IRQ_REQ)) + return CS_BAD_HANDLE; + handle->state &= ~CLIENT_IRQ_REQ; + s = SOCKET(handle); + + if (!(handle->state & CLIENT_STALE)) { + config_t *c = CONFIG(handle); + if (c->state & CONFIG_LOCKED) + return CS_CONFIGURATION_LOCKED; + if (c->irq.Attributes != req->Attributes) + return CS_BAD_ATTRIBUTE; + if (s->irq.AssignedIRQ != req->AssignedIRQ) + return CS_BAD_IRQ; + if (--s->irq.Config == 0) { + c->state &= ~CONFIG_IRQ_REQ; + s->irq.AssignedIRQ = 0; + } + } + + if (req->Attributes & IRQ_HANDLE_PRESENT) { + free_irq(req->AssignedIRQ, req->Instance); + } + +#ifdef CONFIG_PCMCIA_PROBE + pcmcia_used_irq[req->AssignedIRQ]--; +#endif + + return CS_SUCCESS; +} /* pcmcia_release_irq */ +EXPORT_SYMBOL(pcmcia_release_irq); + + +int pcmcia_release_window(window_handle_t win) +{ + struct pcmcia_socket *s; + + if ((win == NULL) || (win->magic != WINDOW_MAGIC)) + return CS_BAD_HANDLE; + s = win->sock; + if (!(win->handle->state & CLIENT_WIN_REQ(win->index))) + return CS_BAD_HANDLE; + + /* Shut down memory window */ + win->ctl.flags &= ~MAP_ACTIVE; + s->ops->set_mem_map(s, &win->ctl); + s->state &= ~SOCKET_WIN_REQ(win->index); + + /* Release system memory */ + if (win->ctl.res) { + release_resource(win->ctl.res); + kfree(win->ctl.res); + win->ctl.res = NULL; + } + win->handle->state &= ~CLIENT_WIN_REQ(win->index); + + win->magic = 0; + + return CS_SUCCESS; +} /* pcmcia_release_window */ +EXPORT_SYMBOL(pcmcia_release_window); + + +int pcmcia_request_configuration(client_handle_t handle, + config_req_t *req) +{ + int i; + u_int base; + struct pcmcia_socket *s; + config_t *c; + pccard_io_map iomap; + + if (CHECK_HANDLE(handle)) + return CS_BAD_HANDLE; + s = SOCKET(handle); + if (!(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + +#ifdef CONFIG_CARDBUS + if (handle->state & CLIENT_CARDBUS) + return CS_UNSUPPORTED_MODE; +#endif + + if (req->IntType & INT_CARDBUS) + return CS_UNSUPPORTED_MODE; + c = CONFIG(handle); + if (c->state & CONFIG_LOCKED) + return CS_CONFIGURATION_LOCKED; + + /* Do power control. We don't allow changes in Vcc. */ + if (s->socket.Vcc != req->Vcc) + return CS_BAD_VCC; + if (req->Vpp1 != req->Vpp2) + return CS_BAD_VPP; + s->socket.Vpp = req->Vpp1; + if (s->ops->set_socket(s, &s->socket)) + return CS_BAD_VPP; + + c->Vcc = req->Vcc; c->Vpp1 = c->Vpp2 = req->Vpp1; + + /* Pick memory or I/O card, DMA mode, interrupt */ + c->IntType = req->IntType; + c->Attributes = req->Attributes; + if (req->IntType & INT_MEMORY_AND_IO) + s->socket.flags |= SS_IOCARD; + if (req->IntType & INT_ZOOMED_VIDEO) + s->socket.flags |= SS_ZVCARD | SS_IOCARD; + if (req->Attributes & CONF_ENABLE_DMA) + s->socket.flags |= SS_DMA_MODE; + if (req->Attributes & CONF_ENABLE_SPKR) + s->socket.flags |= SS_SPKR_ENA; + if (req->Attributes & CONF_ENABLE_IRQ) + s->socket.io_irq = s->irq.AssignedIRQ; + else + s->socket.io_irq = 0; + s->ops->set_socket(s, &s->socket); + s->lock_count++; + + /* Set up CIS configuration registers */ + base = c->ConfigBase = req->ConfigBase; + c->Present = c->CardValues = req->Present; + if (req->Present & PRESENT_COPY) { + c->Copy = req->Copy; + pcmcia_write_cis_mem(s, 1, (base + CISREG_SCR)>>1, 1, &c->Copy); + } + if (req->Present & PRESENT_OPTION) { + if (s->functions == 1) { + c->Option = req->ConfigIndex & COR_CONFIG_MASK; + } else { + c->Option = req->ConfigIndex & COR_MFC_CONFIG_MASK; + c->Option |= COR_FUNC_ENA|COR_IREQ_ENA; + if (req->Present & PRESENT_IOBASE_0) + c->Option |= COR_ADDR_DECODE; + } + if (c->state & CONFIG_IRQ_REQ) + if (!(c->irq.Attributes & IRQ_FORCED_PULSE)) + c->Option |= COR_LEVEL_REQ; + pcmcia_write_cis_mem(s, 1, (base + CISREG_COR)>>1, 1, &c->Option); + mdelay(40); + } + if (req->Present & PRESENT_STATUS) { + c->Status = req->Status; + pcmcia_write_cis_mem(s, 1, (base + CISREG_CCSR)>>1, 1, &c->Status); + } + if (req->Present & PRESENT_PIN_REPLACE) { + c->Pin = req->Pin; + pcmcia_write_cis_mem(s, 1, (base + CISREG_PRR)>>1, 1, &c->Pin); + } + if (req->Present & PRESENT_EXT_STATUS) { + c->ExtStatus = req->ExtStatus; + pcmcia_write_cis_mem(s, 1, (base + CISREG_ESR)>>1, 1, &c->ExtStatus); + } + if (req->Present & PRESENT_IOBASE_0) { + u_char b = c->io.BasePort1 & 0xff; + pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_0)>>1, 1, &b); + b = (c->io.BasePort1 >> 8) & 0xff; + pcmcia_write_cis_mem(s, 1, (base + CISREG_IOBASE_1)>>1, 1, &b); + } + if (req->Present & PRESENT_IOSIZE) { + u_char b = c->io.NumPorts1 + c->io.NumPorts2 - 1; + pcmcia_write_cis_mem(s, 1, (base + CISREG_IOSIZE)>>1, 1, &b); + } + + /* Configure I/O windows */ + if (c->state & CONFIG_IO_REQ) { + iomap.speed = io_speed; + for (i = 0; i < MAX_IO_WIN; i++) + if (s->io[i].NumPorts != 0) { + iomap.map = i; + iomap.flags = MAP_ACTIVE; + switch (s->io[i].Attributes & IO_DATA_PATH_WIDTH) { + case IO_DATA_PATH_WIDTH_16: + iomap.flags |= MAP_16BIT; break; + case IO_DATA_PATH_WIDTH_AUTO: + iomap.flags |= MAP_AUTOSZ; break; + default: + break; + } + iomap.start = s->io[i].BasePort; + iomap.stop = iomap.start + s->io[i].NumPorts - 1; + s->ops->set_io_map(s, &iomap); + s->io[i].Config++; + } + } + + c->state |= CONFIG_LOCKED; + handle->state |= CLIENT_CONFIG_LOCKED; + return CS_SUCCESS; +} /* pcmcia_request_configuration */ +EXPORT_SYMBOL(pcmcia_request_configuration); + + +/** pcmcia_request_io + * + * Request_io() reserves ranges of port addresses for a socket. + * I have not implemented range sharing or alias addressing. + */ +int pcmcia_request_io(client_handle_t handle, io_req_t *req) +{ + struct pcmcia_socket *s; + config_t *c; + + if (CHECK_HANDLE(handle)) + return CS_BAD_HANDLE; + s = SOCKET(handle); + if (!(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + + if (handle->state & CLIENT_CARDBUS) { +#ifdef CONFIG_CARDBUS + handle->state |= CLIENT_IO_REQ; + return CS_SUCCESS; +#else + return CS_UNSUPPORTED_FUNCTION; +#endif + } + + if (!req) + return CS_UNSUPPORTED_MODE; + c = CONFIG(handle); + if (c->state & CONFIG_LOCKED) + return CS_CONFIGURATION_LOCKED; + if (c->state & CONFIG_IO_REQ) + return CS_IN_USE; + if (req->Attributes1 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS)) + return CS_BAD_ATTRIBUTE; + if ((req->NumPorts2 > 0) && + (req->Attributes2 & (IO_SHARED | IO_FORCE_ALIAS_ACCESS))) + return CS_BAD_ATTRIBUTE; + + if (alloc_io_space(s, req->Attributes1, &req->BasePort1, + req->NumPorts1, req->IOAddrLines)) + return CS_IN_USE; + + if (req->NumPorts2) { + if (alloc_io_space(s, req->Attributes2, &req->BasePort2, + req->NumPorts2, req->IOAddrLines)) { + release_io_space(s, req->BasePort1, req->NumPorts1); + return CS_IN_USE; + } + } + + c->io = *req; + c->state |= CONFIG_IO_REQ; + handle->state |= CLIENT_IO_REQ; + return CS_SUCCESS; +} /* pcmcia_request_io */ +EXPORT_SYMBOL(pcmcia_request_io); + + +/** pcmcia_request_irq + * + * Request_irq() reserves an irq for this client. + * + * Also, since Linux only reserves irq's when they are actually + * hooked, we don't guarantee that an irq will still be available + * when the configuration is locked. Now that I think about it, + * there might be a way to fix this using a dummy handler. + */ + +#ifdef CONFIG_PCMCIA_PROBE +static irqreturn_t test_action(int cpl, void *dev_id, struct pt_regs *regs) +{ + return IRQ_NONE; +} +#endif + +int pcmcia_request_irq(client_handle_t handle, irq_req_t *req) +{ + struct pcmcia_socket *s; + config_t *c; + int ret = CS_IN_USE, irq = 0; + struct pcmcia_device *p_dev = handle_to_pdev(handle); + + if (CHECK_HANDLE(handle)) + return CS_BAD_HANDLE; + s = SOCKET(handle); + if (!(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + c = CONFIG(handle); + if (c->state & CONFIG_LOCKED) + return CS_CONFIGURATION_LOCKED; + if (c->state & CONFIG_IRQ_REQ) + return CS_IN_USE; + +#ifdef CONFIG_PCMCIA_PROBE + if (s->irq.AssignedIRQ != 0) { + /* If the interrupt is already assigned, it must be the same */ + irq = s->irq.AssignedIRQ; + } else { + int try; + u32 mask = s->irq_mask; + void *data = NULL; + + for (try = 0; try < 64; try++) { + irq = try % 32; + + /* marked as available by driver, and not blocked by userspace? */ + if (!((mask >> irq) & 1)) + continue; + + /* avoid an IRQ which is already used by a PCMCIA card */ + if ((try < 32) && pcmcia_used_irq[irq]) + continue; + + /* register the correct driver, if possible, of check whether + * registering a dummy handle works, i.e. if the IRQ isn't + * marked as used by the kernel resource management core */ + ret = request_irq(irq, + (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Handler : test_action, + ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || + (s->functions > 1) || + (irq == s->pci_irq)) ? SA_SHIRQ : 0, + p_dev->dev.bus_id, + (req->Attributes & IRQ_HANDLE_PRESENT) ? req->Instance : data); + if (!ret) { + if (!(req->Attributes & IRQ_HANDLE_PRESENT)) + free_irq(irq, data); + break; + } + } + } +#endif + if (ret) { + if (!s->pci_irq) + return ret; + irq = s->pci_irq; + } + + if (ret && req->Attributes & IRQ_HANDLE_PRESENT) { + if (request_irq(irq, req->Handler, + ((req->Attributes & IRQ_TYPE_DYNAMIC_SHARING) || + (s->functions > 1) || + (irq == s->pci_irq)) ? SA_SHIRQ : 0, + p_dev->dev.bus_id, req->Instance)) + return CS_IN_USE; + } + + c->irq.Attributes = req->Attributes; + s->irq.AssignedIRQ = req->AssignedIRQ = irq; + s->irq.Config++; + + c->state |= CONFIG_IRQ_REQ; + handle->state |= CLIENT_IRQ_REQ; + +#ifdef CONFIG_PCMCIA_PROBE + pcmcia_used_irq[irq]++; +#endif + + return CS_SUCCESS; +} /* pcmcia_request_irq */ +EXPORT_SYMBOL(pcmcia_request_irq); + + +/** pcmcia_request_window + * + * Request_window() establishes a mapping between card memory space + * and system memory space. + */ +int pcmcia_request_window(client_handle_t *handle, win_req_t *req, window_handle_t *wh) +{ + struct pcmcia_socket *s; + window_t *win; + u_long align; + int w; + + if (CHECK_HANDLE(*handle)) + return CS_BAD_HANDLE; + s = (*handle)->Socket; + if (!(s->state & SOCKET_PRESENT)) + return CS_NO_CARD; + if (req->Attributes & (WIN_PAGED | WIN_SHARED)) + return CS_BAD_ATTRIBUTE; + + /* Window size defaults to smallest available */ + if (req->Size == 0) + req->Size = s->map_size; + align = (((s->features & SS_CAP_MEM_ALIGN) || + (req->Attributes & WIN_STRICT_ALIGN)) ? + req->Size : s->map_size); + if (req->Size & (s->map_size-1)) + return CS_BAD_SIZE; + if ((req->Base && (s->features & SS_CAP_STATIC_MAP)) || + (req->Base & (align-1))) + return CS_BAD_BASE; + if (req->Base) + align = 0; + + /* Allocate system memory window */ + for (w = 0; w < MAX_WIN; w++) + if (!(s->state & SOCKET_WIN_REQ(w))) break; + if (w == MAX_WIN) + return CS_OUT_OF_RESOURCE; + + win = &s->win[w]; + win->magic = WINDOW_MAGIC; + win->index = w; + win->handle = *handle; + win->sock = s; + + if (!(s->features & SS_CAP_STATIC_MAP)) { + win->ctl.res = pcmcia_find_mem_region(req->Base, req->Size, align, + (req->Attributes & WIN_MAP_BELOW_1MB), s); + if (!win->ctl.res) + return CS_IN_USE; + } + (*handle)->state |= CLIENT_WIN_REQ(w); + + /* Configure the socket controller */ + win->ctl.map = w+1; + win->ctl.flags = 0; + win->ctl.speed = req->AccessSpeed; + if (req->Attributes & WIN_MEMORY_TYPE) + win->ctl.flags |= MAP_ATTRIB; + if (req->Attributes & WIN_ENABLE) + win->ctl.flags |= MAP_ACTIVE; + if (req->Attributes & WIN_DATA_WIDTH_16) + win->ctl.flags |= MAP_16BIT; + if (req->Attributes & WIN_USE_WAIT) + win->ctl.flags |= MAP_USE_WAIT; + win->ctl.card_start = 0; + if (s->ops->set_mem_map(s, &win->ctl) != 0) + return CS_BAD_ARGS; + s->state |= SOCKET_WIN_REQ(w); + + /* Return window handle */ + if (s->features & SS_CAP_STATIC_MAP) { + req->Base = win->ctl.static_start; + } else { + req->Base = win->ctl.res->start; + } + *wh = win; + + return CS_SUCCESS; +} /* pcmcia_request_window */ +EXPORT_SYMBOL(pcmcia_request_window); diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c index fca10a1a56d..0668384ebc8 100644 --- a/drivers/pcmcia/rsrc_mgr.c +++ b/drivers/pcmcia/rsrc_mgr.c @@ -112,6 +112,7 @@ int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start, return s->resource_ops->adjust_io_region(res, r_start, r_end, s); return -ENOMEM; } +EXPORT_SYMBOL(pcmcia_adjust_io_region); struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align, struct pcmcia_socket *s) @@ -120,6 +121,7 @@ struct resource *pcmcia_find_io_region(unsigned long base, int num, return s->resource_ops->find_io(base, num, align, s); return NULL; } +EXPORT_SYMBOL(pcmcia_find_io_region); struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align, int low, struct pcmcia_socket *s) @@ -128,6 +130,7 @@ struct resource *pcmcia_find_mem_region(u_long base, u_long num, u_long align, return s->resource_ops->find_mem(base, num, align, low, s); return NULL; } +EXPORT_SYMBOL(pcmcia_find_mem_region); void release_resource_db(struct pcmcia_socket *s) { -- cgit v1.2.3 From 33519ddd43f4adc221ee7b2801dedd19ac97540b Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:53 -0700 Subject: [PATCH] pcmcia: cs.c cleanup Clean up cs.c Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cistpl.c | 1 + drivers/pcmcia/cs.c | 209 +++++++++++++----------------------------- drivers/pcmcia/pcmcia_ioctl.c | 10 +- 3 files changed, 76 insertions(+), 144 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index a8aa7b9cf64..8567f4fad50 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -385,6 +385,7 @@ int pcmcia_replace_cis(struct pcmcia_socket *s, cisdump_t *cis) memcpy(s->fake_cis, cis->Data, cis->Length); return CS_SUCCESS; } +EXPORT_SYMBOL(pcmcia_replace_cis); /*====================================================================== diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 6a35a4a9f93..0ff4d6ec8b7 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -43,36 +43,11 @@ #include #include "cs_internal.h" -#ifdef CONFIG_PCI -#define PCI_OPT " [pci]" -#else -#define PCI_OPT "" -#endif -#ifdef CONFIG_CARDBUS -#define CB_OPT " [cardbus]" -#else -#define CB_OPT "" -#endif -#ifdef CONFIG_PM -#define PM_OPT " [pm]" -#else -#define PM_OPT "" -#endif -#if !defined(CONFIG_CARDBUS) && !defined(CONFIG_PCI) && !defined(CONFIG_PM) -#define OPTIONS " none" -#else -#define OPTIONS PCI_OPT CB_OPT PM_OPT -#endif - -static const char *release = "Linux Kernel Card Services"; -static const char *options = "options: " OPTIONS; - -/*====================================================================*/ /* Module parameters */ MODULE_AUTHOR("David Hinds "); -MODULE_DESCRIPTION("Linux Kernel Card Services\noptions:" OPTIONS); +MODULE_DESCRIPTION("Linux Kernel Card Services"); MODULE_LICENSE("GPL"); #define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444) @@ -100,29 +75,26 @@ int cs_debug_level(int level) } #endif -/*====================================================================*/ socket_state_t dead_socket = { .csc_mask = SS_DETECT, }; +EXPORT_SYMBOL(dead_socket); /* List of all sockets, protected by a rwsem */ LIST_HEAD(pcmcia_socket_list); -DECLARE_RWSEM(pcmcia_socket_list_rwsem); EXPORT_SYMBOL(pcmcia_socket_list); -EXPORT_SYMBOL(pcmcia_socket_list_rwsem); +DECLARE_RWSEM(pcmcia_socket_list_rwsem); +EXPORT_SYMBOL(pcmcia_socket_list_rwsem); -/*==================================================================== - - Low-level PC Card interface drivers need to register with Card - Services using these calls. - -======================================================================*/ /** - * socket drivers are expected to use the following callbacks in their + * Low-level PCMCIA socket drivers need to register with the PCCard + * core using pcmcia_register_socket. + * + * socket drivers are expected to use the following callbacks in their * .drv struct: * - pcmcia_socket_dev_suspend * - pcmcia_socket_dev_resume @@ -222,8 +194,8 @@ int pcmcia_register_socket(struct pcmcia_socket *socket) } /* try to obtain a socket number [yes, it gets ugly if we - * register more than 2^sizeof(unsigned int) pcmcia - * sockets... but the socket number is deprecated + * register more than 2^sizeof(unsigned int) pcmcia + * sockets... but the socket number is deprecated * anyways, so I don't care] */ down_write(&pcmcia_socket_list_rwsem); if (list_empty(&pcmcia_socket_list)) @@ -332,54 +304,49 @@ struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr) EXPORT_SYMBOL(pcmcia_get_socket_by_nr); -/*====================================================================== - - socket_setup() and shutdown_socket() are called by the main event - handler when card insertion and removal events are received. - socket_setup() turns on socket power and resets the socket, in two stages. - shutdown_socket() unconfigures a socket and turns off socket power. - -======================================================================*/ - +/** + * socket_setup() and shutdown_socket() are called by the main event + * handler when card insertion and removal events are received. + * socket_setup() turns on socket power and resets the socket, in two stages. + * shutdown_socket() unconfigures a socket and turns off socket power. + */ static void shutdown_socket(struct pcmcia_socket *s) { - cs_dbg(s, 1, "shutdown_socket\n"); - - /* Blank out the socket state */ - s->socket = dead_socket; - s->ops->init(s); - s->ops->set_socket(s, &s->socket); - s->irq.AssignedIRQ = s->irq.Config = 0; - s->lock_count = 0; - destroy_cis_cache(s); + cs_dbg(s, 1, "shutdown_socket\n"); + + /* Blank out the socket state */ + s->socket = dead_socket; + s->ops->init(s); + s->ops->set_socket(s, &s->socket); + s->irq.AssignedIRQ = s->irq.Config = 0; + s->lock_count = 0; + destroy_cis_cache(s); #ifdef CONFIG_CARDBUS - cb_free(s); + cb_free(s); #endif - s->functions = 0; - if (s->config) { - kfree(s->config); - s->config = NULL; - } - - { - int status; - s->ops->get_status(s, &status); - if (status & SS_POWERON) { - printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); + s->functions = 0; + if (s->config) { + kfree(s->config); + s->config = NULL; } - } -} /* shutdown_socket */ -/*====================================================================== + { + int status; + s->ops->get_status(s, &status); + if (status & SS_POWERON) { + printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s); + } + } +} /* shutdown_socket */ - The central event handler. Send_event() sends an event to the - 16-bit subsystem, which then calls the relevant device drivers. - Parse_events() interprets the event bits from - a card status change report. Do_shutdown() handles the high - priority stuff associated with a card removal. - -======================================================================*/ +/** + * The central event handler. Send_event() sends an event to the + * 16-bit subsystem, which then calls the relevant device drivers. + * Parse_events() interprets the event bits from + * a card status change report. Do_shutdown() handles the high + * priority stuff associated with a card removal. + */ /* NOTE: send_event needs to be called with skt->sem held. */ @@ -738,27 +705,7 @@ void pcmcia_parse_events(struct pcmcia_socket *s, u_int events) wake_up(&s->thread_wait); } } /* pcmcia_parse_events */ - - -/*===================================================================== - - Return the PCI device associated with a card.. - -======================================================================*/ - -#ifdef CONFIG_CARDBUS - -struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s) -{ - if (!s || !(s->state & SOCKET_CARDBUS)) - return NULL; - - return s->cb_dev->subordinate; -} - -EXPORT_SYMBOL(pcmcia_lookup_bus); - -#endif +EXPORT_SYMBOL(pcmcia_parse_events); /* register pcmcia_callback */ @@ -790,18 +737,15 @@ int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c) EXPORT_SYMBOL(pccard_register_pcmcia); -/*====================================================================== - - I'm not sure which "reset" function this is supposed to use, - but for now, it uses the low-level interface's reset, not the - CIS register. - -======================================================================*/ +/* I'm not sure which "reset" function this is supposed to use, + * but for now, it uses the low-level interface's reset, not the + * CIS register. + */ int pccard_reset_card(struct pcmcia_socket *skt) { int ret; - + cs_dbg(skt, 1, "resetting socket\n"); down(&skt->skt_sem); @@ -834,17 +778,14 @@ int pccard_reset_card(struct pcmcia_socket *skt) } /* reset_card */ EXPORT_SYMBOL(pccard_reset_card); -/*====================================================================== - - These shut down or wake up a socket. They are sort of user - initiated versions of the APM suspend and resume actions. - -======================================================================*/ +/* These shut down or wake up a socket. They are sort of user + * initiated versions of the APM suspend and resume actions. + */ int pcmcia_suspend_card(struct pcmcia_socket *skt) { int ret; - + cs_dbg(skt, 1, "suspending socket\n"); down(&skt->skt_sem); @@ -863,6 +804,8 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt) return ret; } /* suspend_card */ +EXPORT_SYMBOL(pcmcia_suspend_card); + int pcmcia_resume_card(struct pcmcia_socket *skt) { @@ -886,13 +829,10 @@ int pcmcia_resume_card(struct pcmcia_socket *skt) return ret; } /* resume_card */ +EXPORT_SYMBOL(pcmcia_resume_card); -/*====================================================================== - - These handle user requests to eject or insert a card. - -======================================================================*/ +/* These handle user requests to eject or insert a card. */ int pcmcia_eject_card(struct pcmcia_socket *skt) { int ret; @@ -919,6 +859,8 @@ int pcmcia_eject_card(struct pcmcia_socket *skt) return ret; } /* eject_card */ +EXPORT_SYMBOL(pcmcia_eject_card); + int pcmcia_insert_card(struct pcmcia_socket *skt) { @@ -942,6 +884,8 @@ int pcmcia_insert_card(struct pcmcia_socket *skt) return ret; } /* insert_card */ +EXPORT_SYMBOL(pcmcia_insert_card); + static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, int num_envp, char *buffer, int buffer_size) @@ -958,20 +902,6 @@ static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, return 0; } -/*====================================================================== - - OS-specific module glue goes here - -======================================================================*/ -/* in alpha order */ -EXPORT_SYMBOL(pcmcia_eject_card); -EXPORT_SYMBOL(pcmcia_insert_card); -EXPORT_SYMBOL(pcmcia_replace_cis); -EXPORT_SYMBOL(pcmcia_resume_card); -EXPORT_SYMBOL(pcmcia_suspend_card); - -EXPORT_SYMBOL(dead_socket); -EXPORT_SYMBOL(pcmcia_parse_events); struct class pcmcia_socket_class = { .name = "pcmcia_socket", @@ -983,11 +913,7 @@ EXPORT_SYMBOL(pcmcia_socket_class); static int __init init_pcmcia_cs(void) { - int ret; - printk(KERN_INFO "%s\n", release); - printk(KERN_INFO " %s\n", options); - - ret = class_register(&pcmcia_socket_class); + int ret = class_register(&pcmcia_socket_class); if (ret) return (ret); return class_interface_register(&pccard_sysfs_interface); @@ -995,13 +921,10 @@ static int __init init_pcmcia_cs(void) static void __exit exit_pcmcia_cs(void) { - printk(KERN_INFO "unloading Kernel Card Services\n"); - class_interface_unregister(&pccard_sysfs_interface); - class_unregister(&pcmcia_socket_class); + class_interface_unregister(&pccard_sysfs_interface); + class_unregister(&pcmcia_socket_class); } subsys_initcall(init_pcmcia_cs); module_exit(exit_pcmcia_cs); -/*====================================================================*/ - diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 7aa2e7f20d5..fa2a79d29e1 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -275,8 +275,16 @@ rescan: return (ret); } /* bind_request */ +#ifdef CONFIG_CARDBUS + +static struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s) +{ + if (!s || !(s->state & SOCKET_CARDBUS)) + return NULL; -extern struct pci_bus *pcmcia_lookup_bus(struct pcmcia_socket *s); + return s->cb_dev->subordinate; +} +#endif static int get_device_info(struct pcmcia_socket *s, bind_info_t *bind_info, int first) { -- cgit v1.2.3 From 3448139b41b9e3b8799eed7d427cd50789dadc3e Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:54 -0700 Subject: [PATCH] pcmcia: ds.c cleanup Clean up ds.c Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/pcmcia_compat.c | 34 ---------------------- drivers/pcmcia/pcmcia_ioctl.c | 23 +++++++++++++++ drivers/pcmcia/pcmcia_resource.c | 62 +++++++++++++++++++++++----------------- 3 files changed, 58 insertions(+), 61 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/pcmcia_compat.c b/drivers/pcmcia/pcmcia_compat.c index 68b80084f83..1cc83317e7e 100644 --- a/drivers/pcmcia/pcmcia_compat.c +++ b/drivers/pcmcia/pcmcia_compat.c @@ -74,19 +74,6 @@ int pcmcia_validate_cis(client_handle_t handle, cisinfo_t *info) } EXPORT_SYMBOL(pcmcia_validate_cis); -int pcmcia_get_configuration_info(client_handle_t handle, - config_info_t *config) -{ - struct pcmcia_socket *s; - - if ((CHECK_HANDLE(handle)) || !config) - return CS_BAD_HANDLE; - s = SOCKET(handle); - if (!s) - return CS_BAD_HANDLE; - return pccard_get_configuration_info(s, handle->Function, config); -} -EXPORT_SYMBOL(pcmcia_get_configuration_info); int pcmcia_reset_card(client_handle_t handle, client_req_t *req) { @@ -102,24 +89,3 @@ int pcmcia_reset_card(client_handle_t handle, client_req_t *req) } EXPORT_SYMBOL(pcmcia_reset_card); -int pcmcia_get_status(client_handle_t handle, cs_status_t *status) -{ - struct pcmcia_socket *s; - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); - return pccard_get_status(s, handle->Function, status); -} -EXPORT_SYMBOL(pcmcia_get_status); - -int pcmcia_access_configuration_register(client_handle_t handle, - conf_reg_t *reg) -{ - struct pcmcia_socket *s; - if (CHECK_HANDLE(handle)) - return CS_BAD_HANDLE; - s = SOCKET(handle); - return pccard_access_configuration_register(s, handle->Function, reg); -} -EXPORT_SYMBOL(pcmcia_access_configuration_register); - diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index fa2a79d29e1..3084d8a3ba4 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -71,6 +71,29 @@ extern int ds_pc_debug; #define ds_dbg(lvl, fmt, arg...) do { } while (0) #endif +static const char *release = "Linux Kernel Card Services"; + +/** pcmcia_get_card_services_info + * + * Return information about this version of Card Services + */ +static int pcmcia_get_card_services_info(servinfo_t *info) +{ + unsigned int socket_count = 0; + struct list_head *tmp; + info->Signature[0] = 'C'; + info->Signature[1] = 'S'; + down_read(&pcmcia_socket_list_rwsem); + list_for_each(tmp, &pcmcia_socket_list) + socket_count++; + up_read(&pcmcia_socket_list_rwsem); + info->Count = socket_count; + info->Revision = CS_RELEASE_CODE; + info->CSLevel = 0x0210; + info->VendorString = (char *)release; + return CS_SUCCESS; +} /* get_card_services_info */ + /* backwards-compatible accessing of driver --- by name! */ diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index cf66b997894..9ed3d4a9b99 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -36,8 +36,6 @@ #include "ds_internal.h" -static const char *release = "Linux Kernel Card Services"; - /* Access speed for IO windows */ static int io_speed = 0; module_param(io_speed, int, 0444); @@ -202,7 +200,18 @@ int pccard_access_configuration_register(struct pcmcia_socket *s, } return CS_SUCCESS; } /* pccard_access_configuration_register */ -EXPORT_SYMBOL(pccard_access_configuration_register); + +int pcmcia_access_configuration_register(client_handle_t handle, + conf_reg_t *reg) +{ + struct pcmcia_socket *s; + if (CHECK_HANDLE(handle)) + return CS_BAD_HANDLE; + s = SOCKET(handle); + return pccard_access_configuration_register(s, handle->Function, reg); +} +EXPORT_SYMBOL(pcmcia_access_configuration_register); + int pccard_get_configuration_info(struct pcmcia_socket *s, @@ -260,31 +269,20 @@ int pccard_get_configuration_info(struct pcmcia_socket *s, return CS_SUCCESS; } /* pccard_get_configuration_info */ -EXPORT_SYMBOL(pccard_get_configuration_info); - -/** pcmcia_get_card_services_info - * - * Return information about this version of Card Services - */ - -int pcmcia_get_card_services_info(servinfo_t *info) +int pcmcia_get_configuration_info(client_handle_t handle, + config_info_t *config) { - unsigned int socket_count = 0; - struct list_head *tmp; - info->Signature[0] = 'C'; - info->Signature[1] = 'S'; - down_read(&pcmcia_socket_list_rwsem); - list_for_each(tmp, &pcmcia_socket_list) - socket_count++; - up_read(&pcmcia_socket_list_rwsem); - info->Count = socket_count; - info->Revision = CS_RELEASE_CODE; - info->CSLevel = 0x0210; - info->VendorString = (char *)release; - return CS_SUCCESS; -} /* get_card_services_info */ -EXPORT_SYMBOL(pcmcia_get_card_services_info); + struct pcmcia_socket *s; + + if ((CHECK_HANDLE(handle)) || !config) + return CS_BAD_HANDLE; + s = SOCKET(handle); + if (!s) + return CS_BAD_HANDLE; + return pccard_get_configuration_info(s, handle->Function, config); +} +EXPORT_SYMBOL(pcmcia_get_configuration_info); /** pcmcia_get_window @@ -379,7 +377,17 @@ int pccard_get_status(struct pcmcia_socket *s, unsigned int function, (val & SS_READY) ? CS_EVENT_READY_CHANGE : 0; return CS_SUCCESS; } /* pccard_get_status */ -EXPORT_SYMBOL(pccard_get_status); + +int pcmcia_get_status(client_handle_t handle, cs_status_t *status) +{ + struct pcmcia_socket *s; + if (CHECK_HANDLE(handle)) + return CS_BAD_HANDLE; + s = SOCKET(handle); + return pccard_get_status(s, handle->Function, status); +} +EXPORT_SYMBOL(pcmcia_get_status); + /** pcmcia_get_mem_page -- cgit v1.2.3 From 378a33a686d457fa5a38d6ad134f5385a9cc7860 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:54 -0700 Subject: [PATCH] pcmcia: release_class Properly wait for the class refcount to reach zero. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cs.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c index 0ff4d6ec8b7..e82859d3227 100644 --- a/drivers/pcmcia/cs.c +++ b/drivers/pcmcia/cs.c @@ -903,17 +903,29 @@ static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, } +static struct completion pcmcia_unload; + +static void pcmcia_release_socket_class(struct class *data) +{ + complete(&pcmcia_unload); +} + + struct class pcmcia_socket_class = { .name = "pcmcia_socket", .hotplug = pcmcia_socket_hotplug, .release = pcmcia_release_socket, + .class_release = pcmcia_release_socket_class, }; EXPORT_SYMBOL(pcmcia_socket_class); static int __init init_pcmcia_cs(void) { - int ret = class_register(&pcmcia_socket_class); + int ret; + + init_completion(&pcmcia_unload); + ret = class_register(&pcmcia_socket_class); if (ret) return (ret); return class_interface_register(&pccard_sysfs_interface); @@ -923,6 +935,8 @@ static void __exit exit_pcmcia_cs(void) { class_interface_unregister(&pccard_sysfs_interface); class_unregister(&pcmcia_socket_class); + + wait_for_completion(&pcmcia_unload); } subsys_initcall(init_pcmcia_cs); -- cgit v1.2.3 From f354942cb301fed273f423fb5c4f57bde3efc5b2 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:55 -0700 Subject: [PATCH] pcmcia: use request_region in i82365 randy_dunlap Convert deprecated check_region() calls to request/release region. Add return value check on one request_region(). I suspect that it may do an extra release_region(), which should generate a warning message from the kernel. Signed-off-by: randy_dunlap Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/i82365.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index 90a335a5d9f..d72f9a35c8b 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c @@ -669,11 +669,13 @@ static int __init is_alive(u_short sock) if ((stat & I365_CS_DETECT) && (stat & I365_CS_POWERON) && (i365_get(sock, I365_INTCTL) & I365_PC_IOCARD) && (i365_get(sock, I365_ADDRWIN) & I365_ENA_IO(0)) && - (check_region(start, stop-start+1) != 0) && - ((start & 0xfeef) != 0x02e8)) - return 1; - else - return 0; + ((start & 0xfeef) != 0x02e8)) { + if (!request_region(start, stop-start+1, "i82365")) + return 1; + release_region(start, stop-start+1); + } + + return 0; } /*====================================================================*/ @@ -696,7 +698,13 @@ static void __init add_pcic(int ns, int type) struct i82365_socket *t = &socket[sockets-ns]; base = sockets-ns; - if (t->ioaddr > 0) request_region(t->ioaddr, 2, "i82365"); + if (t->ioaddr > 0) { + if (!request_region(t->ioaddr, 2, "i82365")) { + printk(KERN_ERR "i82365: IO region conflict at %#lx, not available\n", + t->ioaddr); + return; + } + } if (base == 0) printk("\n"); printk(KERN_INFO " %s", pcic[type].name); @@ -803,7 +811,7 @@ static void __init isa_probe(void) } #endif - if (check_region(i365_base, 2) != 0) { + if (!request_region(i365_base, 2, "i82365")) { if (sockets == 0) printk("port conflict at %#lx\n", i365_base); return; @@ -1441,6 +1449,7 @@ static void __exit exit_i82365(void) i365_set(i, I365_CSCINT, 0); release_region(socket[i].ioaddr, 2); } + release_region(i365_base, 2); #ifdef CONFIG_PNP if (i82365_pnpdev) pnp_disable_dev(i82365_pnpdev); -- cgit v1.2.3 From 0c7ab67602e65b3ba7aaa81f023b034cd7458ec6 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:56 -0700 Subject: [PATCH] pcmcia: synclink_cs IRQ_INFO2_INFO is gone Remove the IRQ_INFO2_VALID flag in synclink_cs -- I overlooked it when removing all other users in PCMCIA drivers for 2.6.11. Thanks to Marcelo Tosatti for noticing it. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/char/pcmcia/synclink_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index f2ca4fffa21..8f36b1758eb 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c @@ -581,7 +581,7 @@ static dev_link_t *mgslpc_attach(void) /* Interrupt setup */ link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; - link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_LEVEL_ID; + link->irq.IRQInfo1 = IRQ_LEVEL_ID; link->irq.Handler = NULL; link->conf.Attributes = 0; -- cgit v1.2.3 From f861bd23076efc4c86063721b9021d82481fd6b2 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:57 -0700 Subject: [PATCH] pcmcia: select crc32 in Kconfig for PCMCIA PCMCIA needs CRC32. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index 85af1fb2a30..52ea3459436 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig @@ -42,6 +42,7 @@ config PCMCIA_DEBUG config PCMCIA tristate "16-bit PCMCIA support" + select CRC32 default y ---help--- This option enables support for 16-bit PCMCIA cards. Most older -- cgit v1.2.3 From 2ad0a0a793cbd87a87488d59abc744374669498f Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:28:58 -0700 Subject: [PATCH] pcmcia: resource handling fixes - properly bail out in set_cis_map if call to socket driver's set_mem_map failed - don't abort do_mem_probe cycle if one entry failed (!CONFIG_PCMCIA_PROBE) - don't do iomem probing in chunks larger than 0x800000 (1 << 23) as yenta_socket and vrc4173_cardu.c fail to set_mem_map for windows equal to or larger than (1 << 24). Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/cistpl.c | 9 ++++++++- drivers/pcmcia/rsrc_nonstatic.c | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 8567f4fad50..dd7651ff5b4 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c @@ -89,6 +89,8 @@ static void __iomem * set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flags) { pccard_mem_map *mem = &s->cis_mem; + int ret; + if (!(s->features & SS_CAP_STATIC_MAP) && mem->res == NULL) { mem->res = pcmcia_find_mem_region(0, s->map_size, s->map_size, 0, s); if (mem->res == NULL) { @@ -99,7 +101,12 @@ set_cis_map(struct pcmcia_socket *s, unsigned int card_offset, unsigned int flag } mem->card_start = card_offset; mem->flags = flags; - s->ops->set_mem_map(s, mem); + ret = s->ops->set_mem_map(s, mem); + if (ret) { + iounmap(s->cis_virt); + return NULL; + } + if (s->features & SS_CAP_STATIC_MAP) { if (s->cis_virt) iounmap(s->cis_virt); diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index c8f21796c59..51aa04b7ecc 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -372,6 +372,9 @@ static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s) base, base+num-1); bad = fail = 0; step = (num < 0x20000) ? 0x2000 : ((num>>4) & ~0x1fff); + /* don't allow too large steps */ + if (step > 0x800000) + step = 0x800000; /* cis_readable wants to map 2x map_size */ if (step < 2 * s->map_size) step = 2 * s->map_size; @@ -465,8 +468,7 @@ static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) { mm = *m; - if (do_mem_probe(mm.base, mm.num, s)) - break; + do_mem_probe(mm.base, mm.num, s); } } -- cgit v1.2.3 From 1a8ceafce5f1e68c28c7ba52fd7e72ab0008eb46 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:29:00 -0700 Subject: [PATCH] pcmcia: properly handle all errors of register_chrdev register_chrdev() can return errors (negative) other then -EBUSY, so check for any negative error code. Signed-off-by: Randy Dunlap Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/pcmcia_ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index 3084d8a3ba4..b883bc151ed 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c @@ -760,9 +760,9 @@ void __init pcmcia_setup_ioctl(void) { /* Set up character device for user mode clients */ i = register_chrdev(0, "pcmcia", &ds_fops); - if (i == -EBUSY) + if (i < 0) printk(KERN_NOTICE "unable to find a free device # for " - "Driver Services\n"); + "Driver Services (error=%d)\n", i); else major_dev = i; -- cgit v1.2.3 From 57b6281cea59639cce995745f1dc42fe9da2c533 Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:29:01 -0700 Subject: [PATCH] pcmcia: 8 and 16 bit access for static_map The PCMCIA card services layer is never setting the i/o map attributes when SS_CAP_STATIC_MAP is specified. Net result, sockets' set_io_map() calls always see requests with most flags clear, meaning 8 bit access. For hardware that always autosizes, that won't matter; and all current STATIC_MAP drivers ignore those attributes. A new driver (for at91rm9200) suffers badly from this, since this forces everything into 8 bit mode and that breaks both (a) cards requiring 16 bit access, and (b) ide-cs; but of course 8-bit cards work OK (as does accessing card attributes). So this patch arranges to pass the attributes down, matching the behavior for non-static mappings (using the first/only I/O window). Signed-off-by: David Brownell Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/pcmcia_resource.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 9ed3d4a9b99..c01dc6bf152 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c @@ -89,6 +89,7 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base, } if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) { *base = s->io_offset | (*base & 0x0fff); + s->io[0].Attributes = attr; return 0; } /* Check for an already-allocated window that must conflict with -- cgit v1.2.3 From 3248ff43f86493368b321376d447d84fa9a2737d Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:29:01 -0700 Subject: [PATCH] pcmcia: export modalias in sysfs Provide a "modalias" entry in sysfs for PCMCIA devices. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/ds.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index f018d26f181..cabddd49f6f 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c @@ -847,9 +847,29 @@ pcmcia_device_stringattr(prod_id2, prod_id[1]); pcmcia_device_stringattr(prod_id3, prod_id[2]); pcmcia_device_stringattr(prod_id4, prod_id[3]); +static ssize_t modalias_show(struct device *dev, char *buf) +{ + struct pcmcia_device *p_dev = to_pcmcia_dev(dev); + int i; + u32 hash[4] = { 0, 0, 0, 0}; + + /* calculate hashes */ + for (i=0; i<4; i++) { + if (!p_dev->prod_id[i]) + continue; + hash[i] = crc32(0,p_dev->prod_id[i],strlen(p_dev->prod_id[i])); + } + return sprintf(buf, "pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" + "pa%08Xpb%08Xpc%08Xpd%08X\n", + p_dev->has_manf_id ? p_dev->manf_id : 0, + p_dev->has_card_id ? p_dev->card_id : 0, + p_dev->has_func_id ? p_dev->func_id : 0, + p_dev->func, p_dev->device_no, + hash[0], hash[1], hash[2], hash[3]); +} -static ssize_t pcmcia_store_allow_func_id_match (struct device * dev, struct device_attribute *attr, - const char * buf, size_t count) +static ssize_t pcmcia_store_allow_func_id_match(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) { struct pcmcia_device *p_dev = to_pcmcia_dev(dev); if (!count) @@ -873,6 +893,7 @@ static struct device_attribute pcmcia_dev_attrs[] = { __ATTR_RO(prod_id2), __ATTR_RO(prod_id3), __ATTR_RO(prod_id4), + __ATTR_RO(modalias), __ATTR(allow_func_id_match, 0200, NULL, pcmcia_store_allow_func_id_match), __ATTR_NULL, }; -- cgit v1.2.3 From b6d00f0de9e932e2884b3b7af8e43c0a61a271ee Mon Sep 17 00:00:00 2001 From: Dominik Brodowski Date: Mon, 27 Jun 2005 16:29:02 -0700 Subject: [PATCH] ACPI-based PCI resources: PCMCIA bugfix, but resources missing in trees Don't auto-configure yenta sockets for PCMCIA devices if it is connected to the root PCI bus on the x86 or x86_64 architectures. Previously, this was handled by the "ioport_resource"/"iomem_resource" check a few lines below, but with the new ACPI-based resource handling this doesn't catch all cases any longer. pci-yenta-cardbus-fix.patch and this patch should solve the initialization time trouble. However, the ACPI-based PCI resource handling is badly broken, IMHO: - many resources of devices don't show up in the resource trees ( /proc/iomem and /proc/ioports) any longer. This means that PCMCIA, but also possibly other subsystems (ISA, PnP, ...) do not know which resources it cannot use. - verify_root_windows() should fail if there are no iomem _or_ ioport resources, not only if there are no iomem _and_ ioport resources. Signed-off-by: Dominik Brodowski Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/pcmcia/rsrc_nonstatic.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers') diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index 51aa04b7ecc..c42455d20eb 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c @@ -779,6 +779,17 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s) if (!s->cb_dev || !s->cb_dev->bus) return -ENODEV; +#if defined(CONFIG_X86) || defined(CONFIG_X86_64) + /* If this is the root bus, the risk of hitting + * some strange system devices which aren't protected + * by either ACPI resource tables or properly requested + * resources is too big. Therefore, don't do auto-adding + * of resources at the moment. + */ + if (s->cb_dev->bus->number == 0) + return -EINVAL; +#endif + for (i=0; i < PCI_BUS_NUM_RESOURCES; i++) { res = s->cb_dev->bus->resource[i]; if (!res) -- cgit v1.2.3 From 99f95e5286df2f69edab8a04c7080d986ee4233b Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 27 Jun 2005 20:14:05 -0700 Subject: [PATCH] cfq build fix drivers/block/cfq-iosched.c: In function 'cfq_put_queue': drivers/block/cfq-iosched.c:303: sorry, unimplemented: inlining failed in call to 'cfq_pending_requests': function body not available drivers/block/cfq-iosched.c:1080: sorry, unimplemented: called from here drivers/block/cfq-iosched.c: In function '__cfq_may_queue': drivers/block/cfq-iosched.c:1955: warning: the address of 'cfq_cfqq_must_alloc_slice', will always evaluate as 'true' make[1]: *** [drivers/block/cfq-iosched.o] Error 1 make: *** [drivers/block/cfq-iosched.o] Error 2 Cc: Jeff Garzik Cc: Jens Axboe Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/block/cfq-iosched.c | 49 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'drivers') diff --git a/drivers/block/cfq-iosched.c b/drivers/block/cfq-iosched.c index ff1cc968f96..de5746e38af 100644 --- a/drivers/block/cfq-iosched.c +++ b/drivers/block/cfq-iosched.c @@ -300,7 +300,6 @@ CFQ_CRQ_FNS(requeued); static struct cfq_queue *cfq_find_cfq_hash(struct cfq_data *, unsigned int, unsigned short); static void cfq_dispatch_sort(request_queue_t *, struct cfq_rq *); static void cfq_put_cfqd(struct cfq_data *cfqd); -static inline int cfq_pending_requests(struct cfq_data *cfqd); #define process_sync(tsk) ((tsk)->flags & PF_SYNCWRITE) @@ -348,6 +347,28 @@ static struct request *cfq_find_rq_hash(struct cfq_data *cfqd, sector_t offset) return NULL; } +static inline int cfq_pending_requests(struct cfq_data *cfqd) +{ + return !list_empty(&cfqd->queue->queue_head) || cfqd->busy_queues; +} + +/* + * scheduler run of queue, if there are requests pending and no one in the + * driver that will restart queueing + */ +static inline void cfq_schedule_dispatch(struct cfq_data *cfqd) +{ + if (!cfqd->rq_in_driver && cfq_pending_requests(cfqd)) + kblockd_schedule_work(&cfqd->unplug_work); +} + +static int cfq_queue_empty(request_queue_t *q) +{ + struct cfq_data *cfqd = q->elevator->elevator_data; + + return !cfq_pending_requests(cfqd); +} + /* * Lifted from AS - choose which of crq1 and crq2 that is best served now. * We choose the request that is closest to the head right now. Distance @@ -1071,16 +1092,6 @@ cfq_prio_to_maxrq(struct cfq_data *cfqd, struct cfq_queue *cfqq) return 2 * (base_rq + base_rq * (CFQ_PRIO_LISTS - 1 - cfqq->ioprio)); } -/* - * scheduler run of queue, if there are requests pending and no one in the - * driver that will restart queueing - */ -static inline void cfq_schedule_dispatch(struct cfq_data *cfqd) -{ - if (!cfqd->rq_in_driver && cfq_pending_requests(cfqd)) - kblockd_schedule_work(&cfqd->unplug_work); -} - /* * get next queue for service */ @@ -1846,18 +1857,6 @@ cfq_insert_request(request_queue_t *q, struct request *rq, int where) } } -static inline int cfq_pending_requests(struct cfq_data *cfqd) -{ - return !list_empty(&cfqd->queue->queue_head) || cfqd->busy_queues; -} - -static int cfq_queue_empty(request_queue_t *q) -{ - struct cfq_data *cfqd = q->elevator->elevator_data; - - return !cfq_pending_requests(cfqd); -} - static void cfq_completed_request(request_queue_t *q, struct request *rq) { struct cfq_rq *crq = RQ_DATA(rq); @@ -1952,7 +1951,7 @@ __cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq, { #if 1 if ((cfq_cfqq_wait_request(cfqq) || cfq_cfqq_must_alloc(cfqq)) && - !cfq_cfqq_must_alloc_slice) { + !cfq_cfqq_must_alloc_slice(cfqq)) { cfq_mark_cfqq_must_alloc_slice(cfqq); return ELV_MQUEUE_MUST; } @@ -1969,7 +1968,7 @@ __cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq, * only allow 1 ELV_MQUEUE_MUST per slice, otherwise we * can quickly flood the queue with writes from a single task */ - if (rw == READ || !cfq_cfqq_must_alloc_slice) { + if (rw == READ || !cfq_cfqq_must_alloc_slice(cfqq)) { cfq_mark_cfqq_must_alloc_slice(cfqq); return ELV_MQUEUE_MUST; } -- cgit v1.2.3