Skip to content

Commit

Permalink
staging: comedi: cb_pcidda: use the pci id_table 'driver_data'
Browse files Browse the repository at this point in the history
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.

Since the PCI device ids are now only used in the id_table, remove the
defines and open code the device ids.

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>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Mar 11, 2013
1 parent 2ccdb96 commit e125f75
Showing 1 changed file with 30 additions and 46 deletions.
76 changes: 30 additions & 46 deletions drivers/staging/comedi/drivers/cb_pcidda.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@
#include "comedi_fc.h"
#include "8255.h"

/*
* ComputerBoards PCI Device ID's supported by this driver
*/
#define PCI_DEVICE_ID_DDA02_12 0x0020
#define PCI_DEVICE_ID_DDA04_12 0x0021
#define PCI_DEVICE_ID_DDA08_12 0x0022
#define PCI_DEVICE_ID_DDA02_16 0x0023
#define PCI_DEVICE_ID_DDA04_16 0x0024
#define PCI_DEVICE_ID_DDA08_16 0x0025

#define EEPROM_SIZE 128 /* number of entries in eeprom */
/* maximum number of ao channels for supported boards */
#define MAX_AO_CHANNELS 8
Expand Down Expand Up @@ -118,42 +108,49 @@ static const struct comedi_lrange cb_pcidda_ranges = {
}
};

enum cb_pcidda_boardid {
BOARD_DDA02_12,
BOARD_DDA04_12,
BOARD_DDA08_12,
BOARD_DDA02_16,
BOARD_DDA04_16,
BOARD_DDA08_16,
};

struct cb_pcidda_board {
const char *name;
unsigned short device_id;
int ao_chans;
int ao_bits;
};

static const struct cb_pcidda_board cb_pcidda_boards[] = {
{
[BOARD_DDA02_12] = {
.name = "pci-dda02/12",
.device_id = PCI_DEVICE_ID_DDA02_12,
.ao_chans = 2,
.ao_bits = 12,
}, {
},
[BOARD_DDA04_12] = {
.name = "pci-dda04/12",
.device_id = PCI_DEVICE_ID_DDA04_12,
.ao_chans = 4,
.ao_bits = 12,
}, {
},
[BOARD_DDA08_12] = {
.name = "pci-dda08/12",
.device_id = PCI_DEVICE_ID_DDA08_12,
.ao_chans = 8,
.ao_bits = 12,
}, {
},
[BOARD_DDA02_16] = {
.name = "pci-dda02/16",
.device_id = PCI_DEVICE_ID_DDA02_16,
.ao_chans = 2,
.ao_bits = 16,
}, {
},
[BOARD_DDA04_16] = {
.name = "pci-dda04/16",
.device_id = PCI_DEVICE_ID_DDA04_16,
.ao_chans = 4,
.ao_bits = 16,
}, {
},
[BOARD_DDA08_16] = {
.name = "pci-dda08/16",
.device_id = PCI_DEVICE_ID_DDA08_16,
.ao_chans = 8,
.ao_bits = 16,
},
Expand Down Expand Up @@ -337,32 +334,19 @@ static int cb_pcidda_ao_insn_write(struct comedi_device *dev,
return insn->n;
}

static const void *cb_pcidda_find_boardinfo(struct comedi_device *dev,
struct pci_dev *pcidev)
{
const struct cb_pcidda_board *thisboard;
int i;

for (i = 0; i < ARRAY_SIZE(cb_pcidda_boards); i++) {
thisboard = &cb_pcidda_boards[i];
if (thisboard->device_id != pcidev->device)
return thisboard;
}
return NULL;
}

static int cb_pcidda_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
unsigned long context)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct cb_pcidda_board *thisboard;
const struct cb_pcidda_board *thisboard = NULL;
struct cb_pcidda_private *devpriv;
struct comedi_subdevice *s;
unsigned long iobase_8255;
int i;
int ret;

thisboard = cb_pcidda_find_boardinfo(dev, pcidev);
if (context < ARRAY_SIZE(cb_pcidda_boards))
thisboard = &cb_pcidda_boards[context];
if (!thisboard)
return -ENODEV;
dev->board_ptr = thisboard;
Expand Down Expand Up @@ -442,12 +426,12 @@ static int cb_pcidda_pci_probe(struct pci_dev *dev,
}

static DEFINE_PCI_DEVICE_TABLE(cb_pcidda_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA02_12) },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA04_12) },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA08_12) },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA02_16) },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA04_16) },
{ PCI_DEVICE(PCI_VENDOR_ID_CB, PCI_DEVICE_ID_DDA08_16) },
{ PCI_VDEVICE(CB, 0x0020), BOARD_DDA02_12 },
{ PCI_VDEVICE(CB, 0x0021), BOARD_DDA04_12 },
{ PCI_VDEVICE(CB, 0x0022), BOARD_DDA08_12 },
{ PCI_VDEVICE(CB, 0x0023), BOARD_DDA02_16 },
{ PCI_VDEVICE(CB, 0x0024), BOARD_DDA04_16 },
{ PCI_VDEVICE(CB, 0x0025), BOARD_DDA08_16 },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, cb_pcidda_pci_table);
Expand Down

0 comments on commit e125f75

Please sign in to comment.