Commit 76212bf3 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: amplc_dio200: remove private data

The private data in this driver only has one member, 'intr_sd', which is
the index to the interrupt subdevice.

This member is initialized during the attach of the driver when the sd_intr
subdevice is detected in the boadinfo 'layout'. The member is then used in
the interrupt handler to get the pointer to the subdevice.

This member is not necessary. The comedi_device 'read_subdev' is also
initialized during the attach. This can be used in the interrupt handler
to get the subdevice pointer.

Refactor the code to not require the private data and remove the struct
and its allocations.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fe10bdbd
...@@ -265,16 +265,11 @@ static const struct dio200_board dio200_isa_boards[] = { ...@@ -265,16 +265,11 @@ static const struct dio200_board dio200_isa_boards[] = {
static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
{ {
const struct dio200_board *thisboard = comedi_board(dev); const struct dio200_board *thisboard = comedi_board(dev);
struct dio200_private *devpriv;
unsigned int irq; unsigned int irq;
int ret; int ret;
irq = it->options[1]; irq = it->options[1];
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
ret = comedi_request_region(dev, it->options[0], thisboard->mainsize); ret = comedi_request_region(dev, it->options[0], thisboard->mainsize);
if (ret) if (ret)
return ret; return ret;
......
...@@ -59,13 +59,6 @@ struct dio200_board { ...@@ -59,13 +59,6 @@ struct dio200_board {
unsigned int mainsize; unsigned int mainsize;
}; };
/*
* Comedi device private data.
*/
struct dio200_private {
int intr_sd;
};
int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq,
unsigned long req_irq_flags); unsigned long req_irq_flags);
......
...@@ -574,19 +574,13 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s, ...@@ -574,19 +574,13 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
static irqreturn_t dio200_interrupt(int irq, void *d) static irqreturn_t dio200_interrupt(int irq, void *d)
{ {
struct comedi_device *dev = d; struct comedi_device *dev = d;
struct dio200_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev;
struct comedi_subdevice *s;
int handled; int handled;
if (!dev->attached) if (!dev->attached)
return IRQ_NONE; return IRQ_NONE;
if (devpriv->intr_sd >= 0) {
s = &dev->subdevices[devpriv->intr_sd];
handled = dio200_handle_read_intr(dev, s); handled = dio200_handle_read_intr(dev, s);
} else {
handled = 0;
}
return IRQ_RETVAL(handled); return IRQ_RETVAL(handled);
} }
...@@ -1122,15 +1116,11 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, ...@@ -1122,15 +1116,11 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq,
unsigned long req_irq_flags) unsigned long req_irq_flags)
{ {
const struct dio200_board *thisboard = comedi_board(dev); const struct dio200_board *thisboard = comedi_board(dev);
struct dio200_private *devpriv = dev->private;
const struct dio200_layout *layout = dio200_board_layout(thisboard); const struct dio200_layout *layout = dio200_board_layout(thisboard);
struct comedi_subdevice *s; struct comedi_subdevice *s;
int sdx;
unsigned int n; unsigned int n;
int ret; int ret;
devpriv->intr_sd = -1;
ret = comedi_alloc_subdevices(dev, layout->n_subdevs); ret = comedi_alloc_subdevices(dev, layout->n_subdevs);
if (ret) if (ret)
return ret; return ret;
...@@ -1154,14 +1144,14 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, ...@@ -1154,14 +1144,14 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq,
break; break;
case sd_intr: case sd_intr:
/* 'INTERRUPT' subdevice */ /* 'INTERRUPT' subdevice */
if (irq) { if (irq && !dev->read_subdev) {
ret = dio200_subdev_intr_init(dev, s, ret = dio200_subdev_intr_init(dev, s,
DIO200_INT_SCE, DIO200_INT_SCE,
layout->sdinfo[n] layout->sdinfo[n]
); );
if (ret < 0) if (ret < 0)
return ret; return ret;
devpriv->intr_sd = n; dev->read_subdev = s;
} else { } else {
s->type = COMEDI_SUBD_UNUSED; s->type = COMEDI_SUBD_UNUSED;
} }
...@@ -1176,10 +1166,8 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, ...@@ -1176,10 +1166,8 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq,
break; break;
} }
} }
sdx = devpriv->intr_sd;
if (sdx >= 0 && sdx < dev->n_subdevices) if (irq && dev->read_subdev) {
dev->read_subdev = &dev->subdevices[sdx];
if (irq) {
if (request_irq(irq, dio200_interrupt, req_irq_flags, if (request_irq(irq, dio200_interrupt, req_irq_flags,
dev->board_name, dev) >= 0) { dev->board_name, dev) >= 0) {
dev->irq = irq; dev->irq = irq;
......
...@@ -359,7 +359,6 @@ static int dio200_pci_auto_attach(struct comedi_device *dev, ...@@ -359,7 +359,6 @@ static int dio200_pci_auto_attach(struct comedi_device *dev,
{ {
struct pci_dev *pci_dev = comedi_to_pci_dev(dev); struct pci_dev *pci_dev = comedi_to_pci_dev(dev);
const struct dio200_board *thisboard = NULL; const struct dio200_board *thisboard = NULL;
struct dio200_private *devpriv;
unsigned int bar; unsigned int bar;
int ret; int ret;
...@@ -373,10 +372,6 @@ static int dio200_pci_auto_attach(struct comedi_device *dev, ...@@ -373,10 +372,6 @@ static int dio200_pci_auto_attach(struct comedi_device *dev,
dev_info(dev->class_dev, "%s: attach pci %s (%s)\n", dev_info(dev->class_dev, "%s: attach pci %s (%s)\n",
dev->driver->driver_name, pci_name(pci_dev), dev->board_name); dev->driver->driver_name, pci_name(pci_dev), dev->board_name);
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
return -ENOMEM;
ret = comedi_pci_enable(dev); ret = comedi_pci_enable(dev);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment