Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363405
b: refs/heads/master
c: 2fdecdb
h: refs/heads/master
i:
  363403: ccadbfc
v: v3
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Mar 11, 2013
1 parent 6fa8adc commit 2cc9bb4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 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: 151df466b681181bc1b0543df79620d4e805e531
refs/heads/master: 2fdecdbedbe08957155e68946b1eb87848364d8d
59 changes: 24 additions & 35 deletions trunk/drivers/staging/comedi/drivers/skel.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,27 @@ Configuration Options:
* boards in this way is optional, and completely driver-dependent.
* Some drivers use arrays such as this, other do not.
*/
enum skel_boardid {
BOARD_SKEL100,
BOARD_SKEL200,
};

struct skel_board {
const char *name;
unsigned int devid;
int ai_chans;
int ai_bits;
int have_dio;
};

static const struct skel_board skel_boards[] = {
{
[BOARD_SKEL100] = {
.name = "skel-100",
.devid = 0x100,
.ai_chans = 16,
.ai_bits = 12,
.have_dio = 1,
},
{
[BOARD_SKEL200] = {
.name = "skel-200",
.devid = 0x200,
.ai_chans = 8,
.ai_bits = 16,
.have_dio = 0,
Expand Down Expand Up @@ -394,22 +396,6 @@ static int skel_dio_insn_config(struct comedi_device *dev,
return insn->n;
}

static const struct skel_board *skel_find_pci_board(struct pci_dev *pcidev)
{
unsigned int i;

/*
* This example code assumes all the entries in skel_boards[] are PCI boards
* and all use the same PCI vendor ID. If skel_boards[] contains a mixture
* of PCI and non-PCI boards, this loop should skip over the non-PCI boards.
*/
for (i = 0; i < ARRAY_SIZE(skel_boards); i++)
if (/* skel_boards[i].bustype == pci_bustype && */
pcidev->device == skel_boards[i].devid)
return &skel_boards[i];
return NULL;
}

/*
* Handle common part of skel_attach() and skel_auto_attach().
*/
Expand Down Expand Up @@ -541,29 +527,32 @@ static int skel_attach(struct comedi_device *dev, struct comedi_devconfig *it)
* comedi_usb_auto_config(), etc.) to handle devices that can be attached
* to the Comedi core automatically without the COMEDI_DEVCONFIG ioctl.
*
* The context parameter is usually unused, but if the driver called
* comedi_auto_config() directly instead of the comedi_pci_auto_config()
* wrapper function, this will be a copy of the context passed to
* comedi_auto_config().
* The context parameter is driver dependent.
*/
static int skel_auto_attach(struct comedi_device *dev,
unsigned long context)
unsigned long context)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct skel_board *thisboard;
const struct skel_board *thisboard = NULL;
struct skel_private *devpriv;
int ret;

/* Hack to allow unused code to be optimized out. */
if (!IS_ENABLED(CONFIG_COMEDI_PCI_DRIVERS))
return -EINVAL;

/* Find a matching board in skel_boards[]. */
thisboard = skel_find_pci_board(pcidev);
if (!thisboard) {
dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
return -EINVAL;
}
/*
* In this example, the _auto_attach is for a PCI device.
*
* The 'context' passed to this function is the id->driver_data
* associated with the PCI device found in the id_table during
* the modprobe. This 'context' is the index of the entry in
* skel_boards[i] that contains the boardinfo for the PCI device.
*/
if (context < ARRAY_SIZE(skel_boards))
thisboard = &skel_boards[context];
if (!thisboard)
return -ENODEV;

/*
* Point the struct comedi_device to the matching board info
Expand Down Expand Up @@ -706,8 +695,8 @@ static int skel_pci_probe(struct pci_dev *dev,
* Should only be used for PCI and ISA-PnP devices
*/
static DEFINE_PCI_DEVICE_TABLE(skel_pci_table) = {
{ PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0100) },
{ PCI_DEVICE(PCI_VENDOR_ID_SKEL, 0x0200) },
{ PCI_VDEVICE(SKEL, 0x0100), BOARD_SKEL100 },
{ PCI_VDEVICE(SKEL, 0x0200), BOARD_SKEL200 },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, skel_pci_table);
Expand Down

0 comments on commit 2cc9bb4

Please sign in to comment.