From 76212bf32b92a62d7057159498b7d9475d7bf295 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Fri, 1 Aug 2014 13:06:59 -0700 Subject: [PATCH] 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: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200.c | 5 ---- drivers/staging/comedi/drivers/amplc_dio200.h | 7 ------ .../comedi/drivers/amplc_dio200_common.c | 24 +++++-------------- .../staging/comedi/drivers/amplc_dio200_pci.c | 5 ---- 4 files changed, 6 insertions(+), 35 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c index 17d2e20663cb..d605fd95cc50 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.c +++ b/drivers/staging/comedi/drivers/amplc_dio200.c @@ -265,16 +265,11 @@ static const struct dio200_board dio200_isa_boards[] = { static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it) { const struct dio200_board *thisboard = comedi_board(dev); - struct dio200_private *devpriv; unsigned int irq; int ret; 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); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/staging/comedi/drivers/amplc_dio200.h index e0afe2cee2d6..b21ed526a960 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.h +++ b/drivers/staging/comedi/drivers/amplc_dio200.h @@ -59,13 +59,6 @@ struct dio200_board { 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, unsigned long req_irq_flags); diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index f0d709e0dafc..775263c1471e 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -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) { struct comedi_device *dev = d; - struct dio200_private *devpriv = dev->private; - struct comedi_subdevice *s; + struct comedi_subdevice *s = dev->read_subdev; int handled; if (!dev->attached) return IRQ_NONE; - if (devpriv->intr_sd >= 0) { - s = &dev->subdevices[devpriv->intr_sd]; - handled = dio200_handle_read_intr(dev, s); - } else { - handled = 0; - } + handled = dio200_handle_read_intr(dev, s); return IRQ_RETVAL(handled); } @@ -1122,15 +1116,11 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, unsigned long req_irq_flags) { const struct dio200_board *thisboard = comedi_board(dev); - struct dio200_private *devpriv = dev->private; const struct dio200_layout *layout = dio200_board_layout(thisboard); struct comedi_subdevice *s; - int sdx; unsigned int n; int ret; - devpriv->intr_sd = -1; - ret = comedi_alloc_subdevices(dev, layout->n_subdevs); if (ret) return ret; @@ -1154,14 +1144,14 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, break; case sd_intr: /* 'INTERRUPT' subdevice */ - if (irq) { + if (irq && !dev->read_subdev) { ret = dio200_subdev_intr_init(dev, s, DIO200_INT_SCE, layout->sdinfo[n] ); if (ret < 0) return ret; - devpriv->intr_sd = n; + dev->read_subdev = s; } else { s->type = COMEDI_SUBD_UNUSED; } @@ -1176,10 +1166,8 @@ int amplc_dio200_common_attach(struct comedi_device *dev, unsigned int irq, break; } } - sdx = devpriv->intr_sd; - if (sdx >= 0 && sdx < dev->n_subdevices) - dev->read_subdev = &dev->subdevices[sdx]; - if (irq) { + + if (irq && dev->read_subdev) { if (request_irq(irq, dio200_interrupt, req_irq_flags, dev->board_name, dev) >= 0) { dev->irq = irq; diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c index fbf05687347f..f4170f899487 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c @@ -359,7 +359,6 @@ static int dio200_pci_auto_attach(struct comedi_device *dev, { struct pci_dev *pci_dev = comedi_to_pci_dev(dev); const struct dio200_board *thisboard = NULL; - struct dio200_private *devpriv; unsigned int bar; int ret; @@ -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->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); if (ret) return ret; -- 2.34.1