Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363387
b: refs/heads/master
c: 1787b7c
h: refs/heads/master
i:
  363385: 70cb6a5
  363383: 23074a6
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Mar 11, 2013
1 parent 11d0e5b commit 533a03f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 35 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: dcf9cfd3b1807a28fd46ca73489bc401827fd933
refs/heads/master: 1787b7c170a59f93a17f340b8956152a9aad8f37
56 changes: 22 additions & 34 deletions trunk/drivers/staging/comedi/drivers/ni_6527.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,24 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800
#define Rising_Edge_Detection_Enable(x) (0x018+(x))
#define Falling_Edge_Detection_Enable(x) (0x020+(x))

struct ni6527_board {
enum ni6527_boardid {
BOARD_PCI6527,
BOARD_PXI6527,
};

int dev_id;
struct ni6527_board {
const char *name;
};

static const struct ni6527_board ni6527_boards[] = {
{
.dev_id = 0x2b20,
.name = "pci-6527",
},
{
.dev_id = 0x2b10,
.name = "pxi-6527",
},
[BOARD_PCI6527] = {
.name = "pci-6527",
},
[BOARD_PXI6527] = {
.name = "pxi-6527",
},
};

#define this_board ((const struct ni6527_board *)dev->board_ptr)

struct ni6527_private {
struct mite_struct *mite;
unsigned int filter_interval;
Expand Down Expand Up @@ -321,37 +320,27 @@ static int ni6527_intr_insn_config(struct comedi_device *dev,
return 2;
}

static const struct ni6527_board *
ni6527_find_boardinfo(struct pci_dev *pcidev)
{
unsigned int dev_id = pcidev->device;
unsigned int n;

for (n = 0; n < ARRAY_SIZE(ni6527_boards); n++) {
const struct ni6527_board *board = &ni6527_boards[n];
if (board->dev_id == dev_id)
return board;
}
return NULL;
}

static int ni6527_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
unsigned long context)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct ni6527_board *board = NULL;
struct ni6527_private *devpriv;
struct comedi_subdevice *s;
int ret;

if (context < ARRAY_SIZE(ni6527_boards))
board = &ni6527_boards[context];
if (!board)
return -ENODEV;
dev->board_ptr = board;
dev->board_name = board->name;

devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
if (!devpriv)
return -ENOMEM;
dev->private = devpriv;

dev->board_ptr = ni6527_find_boardinfo(pcidev);
if (!dev->board_ptr)
return -ENODEV;

devpriv->mite = mite_alloc(pcidev);
if (!devpriv->mite)
return -ENOMEM;
Expand All @@ -362,7 +351,6 @@ static int ni6527_auto_attach(struct comedi_device *dev,
return ret;
}

dev->board_name = this_board->name;
dev_info(dev->class_dev, "board: %s, ID=0x%02x\n", dev->board_name,
readb(devpriv->mite->daq_io_addr + ID_Register));

Expand Down Expand Up @@ -447,8 +435,8 @@ static int ni6527_pci_probe(struct pci_dev *dev,
}

static DEFINE_PCI_DEVICE_TABLE(ni6527_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b10) },
{ PCI_DEVICE(PCI_VENDOR_ID_NI, 0x2b20) },
{ PCI_VDEVICE(NI, 0x2b10), BOARD_PXI6527 },
{ PCI_VDEVICE(NI, 0x2b20), BOARD_PCI6527 },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, ni6527_pci_table);
Expand Down

0 comments on commit 533a03f

Please sign in to comment.