]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: comedi: addi_apci_3xxx: use the pci id_table 'driver_data'
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Tue, 5 Mar 2013 17:25:04 +0000 (10:25 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 11 Mar 2013 17:05:23 +0000 (10:05 -0700)
Create an enum to the boardinfo and pass that enum in the pci_driver
id_table as the driver_data.

Change the macro used to fill in the device table from PCI_DEVICE()
to PCI_VDEVICE(). This allows passing the enum as the next field.

Set the dev->board_ptr before calling addi_auto_attach(). This
removes the need for the common code to search for the boardinfo.

Since the search is not done we can remove the unnecessary board
information from the comedi_driver.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/addi_apci_3xxx.c

index 96ec65b2678edd49ad3882977327bf9d1ce3ed8b..5069fbdb27c341997b2dc4077a9f6c64fa08d572 100644 (file)
 #include "addi-data/hwdrv_apci3xxx.c"
 #include "addi-data/addi_common.c"
 
+enum apci3xxx_boardid {
+       BOARD_APCI3000_16,
+       BOARD_APCI3000_8,
+       BOARD_APCI3000_4,
+       BOARD_APCI3006_16,
+       BOARD_APCI3006_8,
+       BOARD_APCI3006_4,
+       BOARD_APCI3010_16,
+       BOARD_APCI3010_8,
+       BOARD_APCI3010_4,
+       BOARD_APCI3016_16,
+       BOARD_APCI3016_8,
+       BOARD_APCI3016_4,
+       BOARD_APCI3100_16_4,
+       BOARD_APCI3100_8_4,
+       BOARD_APCI3106_16_4,
+       BOARD_APCI3106_8_4,
+       BOARD_APCI3110_16_4,
+       BOARD_APCI3110_8_4,
+       BOARD_APCI3116_16_4,
+       BOARD_APCI3116_8_4,
+       BOARD_APCI3003,
+       BOARD_APCI3002_16,
+       BOARD_APCI3002_8,
+       BOARD_APCI3002_4,
+       BOARD_APCI3500,
+};
+
 static const struct addi_board apci3xxx_boardtypes[] = {
-       {
+       [BOARD_APCI3000_16] = {
                .pc_DriverName          = "apci3000-16",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3010,
@@ -37,7 +65,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3000_8] = {
                .pc_DriverName          = "apci3000-8",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x300F,
@@ -63,7 +92,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3000_4] = {
                .pc_DriverName          = "apci3000-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x300E,
@@ -89,7 +119,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3006_16] = {
                .pc_DriverName          = "apci3006-16",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3013,
@@ -115,7 +146,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3006_8] = {
                .pc_DriverName          = "apci3006-8",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3014,
@@ -141,7 +173,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3006_4] = {
                .pc_DriverName          = "apci3006-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3015,
@@ -167,7 +200,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3010_16] = {
                .pc_DriverName          = "apci3010-16",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3016,
@@ -198,7 +232,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3010_8] = {
                .pc_DriverName          = "apci3010-8",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3017,
@@ -229,7 +264,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3010_4] = {
                .pc_DriverName          = "apci3010-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3018,
@@ -260,7 +296,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3016_16] = {
                .pc_DriverName          = "apci3016-16",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3019,
@@ -291,7 +328,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3016_8] = {
                .pc_DriverName          = "apci3016-8",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x301A,
@@ -322,7 +360,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3016_4] = {
                .pc_DriverName          = "apci3016-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x301B,
@@ -353,7 +392,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3100_16_4] = {
                .pc_DriverName          = "apci3100-16-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x301C,
@@ -383,7 +423,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3100_8_4] = {
                .pc_DriverName          = "apci3100-8-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x301D,
@@ -413,7 +454,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3106_16_4] = {
                .pc_DriverName          = "apci3106-16-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x301E,
@@ -443,7 +485,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3106_8_4] = {
                .pc_DriverName          = "apci3106-8-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x301F,
@@ -473,7 +516,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3110_16_4] = {
                .pc_DriverName          = "apci3110-16-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3020,
@@ -508,7 +552,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3110_8_4] = {
                .pc_DriverName          = "apci3110-8-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3021,
@@ -543,7 +588,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3116_16_4] = {
                .pc_DriverName          = "apci3116-16-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3022,
@@ -578,7 +624,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3116_8_4] = {
                .pc_DriverName          = "apci3116-8-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3023,
@@ -613,7 +660,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ttl_bits               = i_APCI3XXX_InsnBitsTTLIO,
                .ttl_read               = i_APCI3XXX_InsnReadTTLIO,
                .ttl_write              = i_APCI3XXX_InsnWriteTTLIO,
-       }, {
+       },
+       [BOARD_APCI3003] = {
                .pc_DriverName          = "apci3003",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x300B,
@@ -638,7 +686,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
                .do_bits                = apci3xxx_do_insn_bits,
-       }, {
+       },
+       [BOARD_APCI3002_16] = {
                .pc_DriverName          = "apci3002-16",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3002,
@@ -663,7 +712,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
                .do_bits                = apci3xxx_do_insn_bits,
-       }, {
+       },
+       [BOARD_APCI3002_8] = {
                .pc_DriverName          = "apci3002-8",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3003,
@@ -688,7 +738,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
                .do_bits                = apci3xxx_do_insn_bits,
-       }, {
+       },
+       [BOARD_APCI3002_4] = {
                .pc_DriverName          = "apci3002-4",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3004,
@@ -713,7 +764,8 @@ static const struct addi_board apci3xxx_boardtypes[] = {
                .ai_read                = i_APCI3XXX_InsnReadAnalogInput,
                .di_bits                = apci3xxx_di_insn_bits,
                .do_bits                = apci3xxx_do_insn_bits,
-       }, {
+       },
+       [BOARD_APCI3500] = {
                .pc_DriverName          = "apci3500",
                .i_VendorId             = PCI_VENDOR_ID_ADDIDATA,
                .i_DeviceId             = 0x3024,
@@ -737,14 +789,25 @@ static const struct addi_board apci3xxx_boardtypes[] = {
        },
 };
 
+static int apci3xxx_auto_attach(struct comedi_device *dev,
+                               unsigned long context)
+{
+       const struct addi_board *board = NULL;
+
+       if (context < ARRAY_SIZE(apci3xxx_boardtypes))
+               board = &apci3xxx_boardtypes[context];
+       if (!board)
+               return -ENODEV;
+       dev->board_ptr = board;
+
+       return addi_auto_attach(dev, context);
+}
+
 static struct comedi_driver apci3xxx_driver = {
        .driver_name    = "addi_apci_3xxx",
        .module         = THIS_MODULE,
-       .auto_attach    = addi_auto_attach,
+       .auto_attach    = apci3xxx_auto_attach,
        .detach         = i_ADDI_Detach,
-       .num_names      = ARRAY_SIZE(apci3xxx_boardtypes),
-       .board_name     = &apci3xxx_boardtypes[0].pc_DriverName,
-       .offset         = sizeof(struct addi_board),
 };
 
 static int apci3xxx_pci_probe(struct pci_dev *dev,
@@ -754,31 +817,31 @@ static int apci3xxx_pci_probe(struct pci_dev *dev,
 }
 
 static DEFINE_PCI_DEVICE_TABLE(apci3xxx_pci_table) = {
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3010) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x300f) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x300e) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3013) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3014) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3015) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3016) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3017) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3018) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3019) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x301a) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x301b) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x301c) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x301d) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x301e) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x301f) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3020) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3021) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3022) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3023) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x300B) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3002) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3003) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3004) },
-       { PCI_DEVICE(PCI_VENDOR_ID_ADDIDATA, 0x3024) },
+       { PCI_VDEVICE(ADDIDATA, 0x3010), BOARD_APCI3000_16 },
+       { PCI_VDEVICE(ADDIDATA, 0x300f), BOARD_APCI3000_8 },
+       { PCI_VDEVICE(ADDIDATA, 0x300e), BOARD_APCI3000_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x3013), BOARD_APCI3006_16 },
+       { PCI_VDEVICE(ADDIDATA, 0x3014), BOARD_APCI3006_8 },
+       { PCI_VDEVICE(ADDIDATA, 0x3015), BOARD_APCI3006_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x3016), BOARD_APCI3010_16 },
+       { PCI_VDEVICE(ADDIDATA, 0x3017), BOARD_APCI3010_8 },
+       { PCI_VDEVICE(ADDIDATA, 0x3018), BOARD_APCI3010_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x3019), BOARD_APCI3016_16 },
+       { PCI_VDEVICE(ADDIDATA, 0x301a), BOARD_APCI3016_8 },
+       { PCI_VDEVICE(ADDIDATA, 0x301b), BOARD_APCI3016_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x301c), BOARD_APCI3100_16_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x301d), BOARD_APCI3100_8_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x301e), BOARD_APCI3106_16_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x301f), BOARD_APCI3106_8_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x3020), BOARD_APCI3110_16_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x3021), BOARD_APCI3110_8_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x3022), BOARD_APCI3116_16_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x3023), BOARD_APCI3116_8_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x300B), BOARD_APCI3003 },
+       { PCI_VDEVICE(ADDIDATA, 0x3002), BOARD_APCI3002_16 },
+       { PCI_VDEVICE(ADDIDATA, 0x3003), BOARD_APCI3002_8 },
+       { PCI_VDEVICE(ADDIDATA, 0x3004), BOARD_APCI3002_4 },
+       { PCI_VDEVICE(ADDIDATA, 0x3024), BOARD_APCI3500 },
        { 0 }
 };
 MODULE_DEVICE_TABLE(pci, apci3xxx_pci_table);