Commit 9b315bcb authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: cb_pcidas: use the pci id_table 'driver_data'

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.

This allows removing the 'device_id' data from the boardinfo as well
the search function that was used to locate the boardinfo for the PCI
device.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c0a0e0ca
...@@ -231,9 +231,19 @@ enum trimpot_model { ...@@ -231,9 +231,19 @@ enum trimpot_model {
AD8402, AD8402,
}; };
enum cb_pcidas_boardid {
BOARD_PCIDAS1602_16,
BOARD_PCIDAS1200,
BOARD_PCIDAS1602_12,
BOARD_PCIDAS1200_JR,
BOARD_PCIDAS1602_16_JR,
BOARD_PCIDAS1000,
BOARD_PCIDAS1001,
BOARD_PCIDAS1002,
};
struct cb_pcidas_board { struct cb_pcidas_board {
const char *name; const char *name;
unsigned short device_id;
int ai_nchan; /* Inputs in single-ended mode */ int ai_nchan; /* Inputs in single-ended mode */
int ai_bits; /* analog input resolution */ int ai_bits; /* analog input resolution */
int ai_speed; /* fastest conversion period in ns */ int ai_speed; /* fastest conversion period in ns */
...@@ -248,9 +258,8 @@ struct cb_pcidas_board { ...@@ -248,9 +258,8 @@ struct cb_pcidas_board {
}; };
static const struct cb_pcidas_board cb_pcidas_boards[] = { static const struct cb_pcidas_board cb_pcidas_boards[] = {
{ [BOARD_PCIDAS1602_16] = {
.name = "pci-das1602/16", .name = "pci-das1602/16",
.device_id = 0x1,
.ai_nchan = 16, .ai_nchan = 16,
.ai_bits = 16, .ai_bits = 16,
.ai_speed = 5000, .ai_speed = 5000,
...@@ -262,9 +271,9 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -262,9 +271,9 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.trimpot = AD8402, .trimpot = AD8402,
.has_dac08 = 1, .has_dac08 = 1,
.is_1602 = 1, .is_1602 = 1,
}, { },
[BOARD_PCIDAS1200] = {
.name = "pci-das1200", .name = "pci-das1200",
.device_id = 0xF,
.ai_nchan = 16, .ai_nchan = 16,
.ai_bits = 12, .ai_bits = 12,
.ai_speed = 3200, .ai_speed = 3200,
...@@ -272,9 +281,9 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -272,9 +281,9 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.fifo_size = 1024, .fifo_size = 1024,
.ranges = &cb_pcidas_ranges, .ranges = &cb_pcidas_ranges,
.trimpot = AD7376, .trimpot = AD7376,
}, { },
[BOARD_PCIDAS1602_12] = {
.name = "pci-das1602/12", .name = "pci-das1602/12",
.device_id = 0x10,
.ai_nchan = 16, .ai_nchan = 16,
.ai_bits = 12, .ai_bits = 12,
.ai_speed = 3200, .ai_speed = 3200,
...@@ -285,18 +294,18 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -285,18 +294,18 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.ranges = &cb_pcidas_ranges, .ranges = &cb_pcidas_ranges,
.trimpot = AD7376, .trimpot = AD7376,
.is_1602 = 1, .is_1602 = 1,
}, { },
[BOARD_PCIDAS1200_JR] = {
.name = "pci-das1200/jr", .name = "pci-das1200/jr",
.device_id = 0x19,
.ai_nchan = 16, .ai_nchan = 16,
.ai_bits = 12, .ai_bits = 12,
.ai_speed = 3200, .ai_speed = 3200,
.fifo_size = 1024, .fifo_size = 1024,
.ranges = &cb_pcidas_ranges, .ranges = &cb_pcidas_ranges,
.trimpot = AD7376, .trimpot = AD7376,
}, { },
[BOARD_PCIDAS1602_16_JR] = {
.name = "pci-das1602/16/jr", .name = "pci-das1602/16/jr",
.device_id = 0x1C,
.ai_nchan = 16, .ai_nchan = 16,
.ai_bits = 16, .ai_bits = 16,
.ai_speed = 5000, .ai_speed = 5000,
...@@ -305,18 +314,18 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -305,18 +314,18 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.trimpot = AD8402, .trimpot = AD8402,
.has_dac08 = 1, .has_dac08 = 1,
.is_1602 = 1, .is_1602 = 1,
}, { },
[BOARD_PCIDAS1000] = {
.name = "pci-das1000", .name = "pci-das1000",
.device_id = 0x4C,
.ai_nchan = 16, .ai_nchan = 16,
.ai_bits = 12, .ai_bits = 12,
.ai_speed = 4000, .ai_speed = 4000,
.fifo_size = 1024, .fifo_size = 1024,
.ranges = &cb_pcidas_ranges, .ranges = &cb_pcidas_ranges,
.trimpot = AD7376, .trimpot = AD7376,
}, { },
[BOARD_PCIDAS1001] = {
.name = "pci-das1001", .name = "pci-das1001",
.device_id = 0x1a,
.ai_nchan = 16, .ai_nchan = 16,
.ai_bits = 12, .ai_bits = 12,
.ai_speed = 6800, .ai_speed = 6800,
...@@ -324,9 +333,9 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = { ...@@ -324,9 +333,9 @@ static const struct cb_pcidas_board cb_pcidas_boards[] = {
.fifo_size = 1024, .fifo_size = 1024,
.ranges = &cb_pcidas_alt_ranges, .ranges = &cb_pcidas_alt_ranges,
.trimpot = AD7376, .trimpot = AD7376,
}, { },
[BOARD_PCIDAS1002] = {
.name = "pci-das1002", .name = "pci-das1002",
.device_id = 0x1b,
.ai_nchan = 16, .ai_nchan = 16,
.ai_bits = 12, .ai_bits = 12,
.ai_speed = 6800, .ai_speed = 6800,
...@@ -1424,31 +1433,18 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d) ...@@ -1424,31 +1433,18 @@ static irqreturn_t cb_pcidas_interrupt(int irq, void *d)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static const void *cb_pcidas_find_boardinfo(struct comedi_device *dev,
struct pci_dev *pcidev)
{
const struct cb_pcidas_board *thisboard;
int i;
for (i = 0; i < ARRAY_SIZE(cb_pcidas_boards); i++) {
thisboard = &cb_pcidas_boards[i];
if (thisboard->device_id == pcidev->device)
return thisboard;
}
return NULL;
}
static int cb_pcidas_auto_attach(struct comedi_device *dev, static int cb_pcidas_auto_attach(struct comedi_device *dev,
unsigned long context_unused) unsigned long context)
{ {
struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct cb_pcidas_board *thisboard; const struct cb_pcidas_board *thisboard = NULL;
struct cb_pcidas_private *devpriv; struct cb_pcidas_private *devpriv;
struct comedi_subdevice *s; struct comedi_subdevice *s;
int i; int i;
int ret; int ret;
thisboard = cb_pcidas_find_boardinfo(dev, pcidev); if (context < ARRAY_SIZE(cb_pcidas_boards))
thisboard = &cb_pcidas_boards[context];
if (!thisboard) if (!thisboard)
return -ENODEV; return -ENODEV;
dev->board_ptr = thisboard; dev->board_ptr = thisboard;
...@@ -1636,14 +1632,14 @@ static int cb_pcidas_pci_probe(struct pci_dev *dev, ...@@ -1636,14 +1632,14 @@ static int cb_pcidas_pci_probe(struct pci_dev *dev,
} }
static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = { static DEFINE_PCI_DEVICE_TABLE(cb_pcidas_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0001) }, { PCI_VDEVICE(CB, 0x0001), BOARD_PCIDAS1602_16 },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x000f) }, { PCI_VDEVICE(CB, 0x000f), BOARD_PCIDAS1200 },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0010) }, { PCI_VDEVICE(CB, 0x0010), BOARD_PCIDAS1602_12 },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x0019) }, { PCI_VDEVICE(CB, 0x0019), BOARD_PCIDAS1200_JR },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001c) }, { PCI_VDEVICE(CB, 0x001c), BOARD_PCIDAS1602_16_JR },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x004c) }, { PCI_VDEVICE(CB, 0x004c), BOARD_PCIDAS1000 },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001a) }, { PCI_VDEVICE(CB, 0x001a), BOARD_PCIDAS1001 },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, 0x001b) }, { PCI_VDEVICE(CB, 0x001b), BOARD_PCIDAS1002 },
{ 0 } { 0 }
}; };
MODULE_DEVICE_TABLE(pci, cb_pcidas_pci_table); MODULE_DEVICE_TABLE(pci, cb_pcidas_pci_table);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment