unsigned short IDIFiltrHigh[8]; /* IDI's filter value high signal */
};
-#define devpriv ((struct pci_dio_private *)dev->private)
-#define this_board ((const struct dio_boardtype *)dev->board_ptr)
-
/*
==============================================================================
*/
struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
+ struct pci_dio_private *devpriv = dev->private;
int ret;
unsigned char chan = CR_CHAN(insn->chanspec) & 0x07;
unsigned char bitmask = 1 << chan;
*/
static int pci1760_reset(struct comedi_device *dev)
{
+ struct pci_dio_private *devpriv = dev->private;
int i;
unsigned char omb[4] = { 0x00, 0x00, 0x00, 0x00 };
unsigned char imb[4];
*/
static int pci_dio_reset(struct comedi_device *dev)
{
+ const struct dio_boardtype *this_board = comedi_board(dev);
+
switch (this_board->cardtype) {
case TYPE_PCI1730:
outb(0, dev->iobase + PCI1730_DO); /* clear outputs */
static int pci_dio_add_di(struct comedi_device *dev, struct comedi_subdevice *s,
const struct diosubd_data *d, int subdev)
{
+ const struct dio_boardtype *this_board = comedi_board(dev);
+
s->type = COMEDI_SUBD_DI;
s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_COMMON | d->specflags;
if (d->chans > 16)
static int pci_dio_add_do(struct comedi_device *dev, struct comedi_subdevice *s,
const struct diosubd_data *d, int subdev)
{
+ const struct dio_boardtype *this_board = comedi_board(dev);
+
s->type = COMEDI_SUBD_DO;
s->subdev_flags = SDF_WRITABLE | SDF_GROUND | SDF_COMMON;
if (d->chans > 16)
static int pci_dio_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
+ const struct dio_boardtype *this_board;
+ struct pci_dio_private *devpriv;
struct pci_dev *pcidev;
struct comedi_subdevice *s;
int ret, subdev, n_subdevices, i, j;
- ret = alloc_private(dev, sizeof(struct pci_dio_private));
+ ret = alloc_private(dev, sizeof(*devpriv));
if (ret < 0)
- return -ENOMEM;
+ return ret;
+ devpriv = dev->private;
pcidev = pci_dio_find_pci_dev(dev, it);
if (!pcidev)
return -EIO;
comedi_set_hw_dev(dev, &pcidev->dev);
+ this_board = comedi_board(dev);
+ dev->board_name = this_board->name;
- if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
- dev_err(dev->class_dev,
- "Error: Can't enable PCI device and request regions!\n");
- return -EIO;
- }
+ ret = comedi_pci_enable(pcidev, dev->board_name);
+ if (ret)
+ return ret;
dev->iobase = pci_resource_start(pcidev, this_board->main_pci_region);
- dev->board_name = this_board->name;
if (this_board->cardtype == TYPE_PCI1760) {
n_subdevices = 4; /* 8 IDI, 8 IDO, 2 PWM, 8 CNT */
static void pci_dio_detach(struct comedi_device *dev)
{
+ const struct dio_boardtype *this_board = comedi_board(dev);
+ struct pci_dio_private *devpriv = dev->private;
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
int i, j;
struct comedi_subdevice *s;
int subdev;
- if (dev->private) {
+ if (devpriv) {
if (devpriv->valid)
pci_dio_reset(dev);
subdev = 0;