staging: comedi: addi_apci_16xx: redefine the boardinfo
Currently this driver uses the struct addi_board from the addi-data "common" code to define the boardinfo. This struct contains a lot of information that is not used in this driver. Introduce a private struct in the driver that just contains the needed information. 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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
875a9cb1bd
commit
2a2e63dd98
@@ -5,17 +5,24 @@
|
|||||||
|
|
||||||
#include "addi-data/hwdrv_apci16xx.c"
|
#include "addi-data/hwdrv_apci16xx.c"
|
||||||
|
|
||||||
static const struct addi_board apci16xx_boardtypes[] = {
|
struct apci16xx_boardinfo {
|
||||||
|
const char *name;
|
||||||
|
unsigned short vendor;
|
||||||
|
unsigned short device;
|
||||||
|
int n_chan;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct apci16xx_boardinfo apci16xx_boardtypes[] = {
|
||||||
{
|
{
|
||||||
.pc_DriverName = "apci1648",
|
.name = "apci1648",
|
||||||
.i_VendorId = PCI_VENDOR_ID_ADDIDATA,
|
.vendor = PCI_VENDOR_ID_ADDIDATA,
|
||||||
.i_DeviceId = 0x1009,
|
.device = 0x1009,
|
||||||
.i_NbrTTLChannel = 48,
|
.n_chan = 48,
|
||||||
}, {
|
}, {
|
||||||
.pc_DriverName = "apci1696",
|
.name = "apci1696",
|
||||||
.i_VendorId = PCI_VENDOR_ID_ADDIDATA,
|
.vendor = PCI_VENDOR_ID_ADDIDATA,
|
||||||
.i_DeviceId = 0x100A,
|
.device = 0x100A,
|
||||||
.i_NbrTTLChannel = 96,
|
.n_chan = 96,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,13 +30,13 @@ static const void *addi_find_boardinfo(struct comedi_device *dev,
|
|||||||
struct pci_dev *pcidev)
|
struct pci_dev *pcidev)
|
||||||
{
|
{
|
||||||
const void *p = dev->driver->board_name;
|
const void *p = dev->driver->board_name;
|
||||||
const struct addi_board *this_board;
|
const struct apci16xx_boardinfo *this_board;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < dev->driver->num_names; i++) {
|
for (i = 0; i < dev->driver->num_names; i++) {
|
||||||
this_board = p;
|
this_board = p;
|
||||||
if (this_board->i_VendorId == pcidev->vendor &&
|
if (this_board->vendor == pcidev->vendor &&
|
||||||
this_board->i_DeviceId == pcidev->device)
|
this_board->device == pcidev->device)
|
||||||
return this_board;
|
return this_board;
|
||||||
p += dev->driver->offset;
|
p += dev->driver->offset;
|
||||||
}
|
}
|
||||||
@@ -40,7 +47,7 @@ static int apci16xx_auto_attach(struct comedi_device *dev,
|
|||||||
unsigned long context_unused)
|
unsigned long context_unused)
|
||||||
{
|
{
|
||||||
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
||||||
const struct addi_board *this_board;
|
const struct apci16xx_boardinfo *this_board;
|
||||||
struct addi_private *devpriv;
|
struct addi_private *devpriv;
|
||||||
struct comedi_subdevice *s;
|
struct comedi_subdevice *s;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -49,7 +56,7 @@ static int apci16xx_auto_attach(struct comedi_device *dev,
|
|||||||
if (!this_board)
|
if (!this_board)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
dev->board_ptr = this_board;
|
dev->board_ptr = this_board;
|
||||||
dev->board_name = this_board->pc_DriverName;
|
dev->board_name = this_board->name;
|
||||||
|
|
||||||
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
|
devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
|
||||||
if (!devpriv)
|
if (!devpriv)
|
||||||
@@ -70,10 +77,10 @@ static int apci16xx_auto_attach(struct comedi_device *dev,
|
|||||||
s = &dev->subdevices[0];
|
s = &dev->subdevices[0];
|
||||||
s->type = COMEDI_SUBD_DIO;
|
s->type = COMEDI_SUBD_DIO;
|
||||||
s->subdev_flags = SDF_WRITEABLE | SDF_READABLE;
|
s->subdev_flags = SDF_WRITEABLE | SDF_READABLE;
|
||||||
s->n_chan = this_board->i_NbrTTLChannel;
|
s->n_chan = this_board->n_chan;
|
||||||
s->maxdata = 1;
|
s->maxdata = 1;
|
||||||
s->io_bits = 0; /* all bits input */
|
s->io_bits = 0; /* all bits input */
|
||||||
s->len_chanlist = this_board->i_NbrTTLChannel;
|
s->len_chanlist = this_board->n_chan;
|
||||||
s->range_table = &range_digital;
|
s->range_table = &range_digital;
|
||||||
s->insn_config = i_APCI16XX_InsnConfigInitTTLIO;
|
s->insn_config = i_APCI16XX_InsnConfigInitTTLIO;
|
||||||
s->insn_bits = i_APCI16XX_InsnBitsReadTTLIO;
|
s->insn_bits = i_APCI16XX_InsnBitsReadTTLIO;
|
||||||
@@ -99,8 +106,8 @@ static struct comedi_driver apci16xx_driver = {
|
|||||||
.auto_attach = apci16xx_auto_attach,
|
.auto_attach = apci16xx_auto_attach,
|
||||||
.detach = apci16xx_detach,
|
.detach = apci16xx_detach,
|
||||||
.num_names = ARRAY_SIZE(apci16xx_boardtypes),
|
.num_names = ARRAY_SIZE(apci16xx_boardtypes),
|
||||||
.board_name = &apci16xx_boardtypes[0].pc_DriverName,
|
.board_name = &apci16xx_boardtypes[0].name,
|
||||||
.offset = sizeof(struct addi_board),
|
.offset = sizeof(struct apci16xx_boardinfo),
|
||||||
};
|
};
|
||||||
|
|
||||||
static int apci16xx_pci_probe(struct pci_dev *dev,
|
static int apci16xx_pci_probe(struct pci_dev *dev,
|
||||||
|
Reference in New Issue
Block a user