Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363382
b: refs/heads/master
c: e125f75
h: refs/heads/master
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Mar 11, 2013
1 parent 6ea94b8 commit b4acabd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 47 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2ccdb96442fb94342eedb9dbc7a7a180e05dbde7
refs/heads/master: e125f75374830aa004ba24ce5375e850856a2731
76 changes: 30 additions & 46 deletions trunk/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 b4acabd

Please sign in to comment.