提交 3d1fe3f7 编写于 作者: H H Hartley Sweeten 提交者: Greg Kroah-Hartman

staging: comedi: drivers: free_irq() in comedi_legacy_detach()

All the legacy comedi drivers now call comedi_legacy_detach()
either directly or as part of their (*detach). Move the free_irq()
into comedi_legacy_detach() so that the drivers don't have to
deal with it.

For drivers that then only call comedi_legacy_detach() in their
private (*detach), remove the private function and use the helper
directly for the (*detach).

The amplc_pc236 and ni_labpc drivers are hybrid legacy/PCI drivers.
In the detach of a PCI board free_irq() still needs to be handled
by the driver.

The pcl724 and pcl726 drivers currently have the free_irq() #ifdef'ed
out. The comedi_legacy_detach() function sanity checks that the irq
has been requested before freeing it so they are safe to convert.

For aesthetic reasons, move the #ifdef unused chunk in the pcl816
driver up to the previous #ifdef unused block.

The pcmio and pcmuio drivers request multiple irqs and handle the
freeing of them. Remove the 'dev->irq = irq[0]' in those drivers
so that comedi_legacy_detach() does not attempt to free the irq.
Signed-off-by: NH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: NIan Abbott <abbotti@mev.co.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 a32c6d00
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/interrupt.h>
#include "comedidev.h" #include "comedidev.h"
#include "comedi_internal.h" #include "comedi_internal.h"
...@@ -403,6 +404,10 @@ EXPORT_SYMBOL_GPL(comedi_request_region); ...@@ -403,6 +404,10 @@ EXPORT_SYMBOL_GPL(comedi_request_region);
*/ */
void comedi_legacy_detach(struct comedi_device *dev) void comedi_legacy_detach(struct comedi_device *dev)
{ {
if (dev->irq) {
free_irq(dev->irq, dev);
dev->irq = 0;
}
if (dev->iobase && dev->iolen) { if (dev->iobase && dev->iolen) {
release_region(dev->iobase, dev->iolen); release_region(dev->iobase, dev->iolen);
dev->iobase = 0; dev->iobase = 0;
......
...@@ -543,13 +543,13 @@ static void pc236_detach(struct comedi_device *dev) ...@@ -543,13 +543,13 @@ static void pc236_detach(struct comedi_device *dev)
return; return;
if (dev->iobase) if (dev->iobase)
pc236_intr_disable(dev); pc236_intr_disable(dev);
if (dev->irq)
free_irq(dev->irq, dev);
comedi_spriv_free(dev, 0); comedi_spriv_free(dev, 0);
if (is_isa_board(thisboard)) { if (is_isa_board(thisboard)) {
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
} else if (is_pci_board(thisboard)) { } else if (is_pci_board(thisboard)) {
struct pci_dev *pcidev = comedi_to_pci_dev(dev); struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (dev->irq)
free_irq(dev->irq, dev);
comedi_pci_disable(dev); comedi_pci_disable(dev);
if (pcidev) if (pcidev)
pci_dev_put(pcidev); pci_dev_put(pcidev);
......
...@@ -338,18 +338,11 @@ static int parport_attach(struct comedi_device *dev, ...@@ -338,18 +338,11 @@ static int parport_attach(struct comedi_device *dev,
return 0; return 0;
} }
static void parport_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev);
}
static struct comedi_driver parport_driver = { static struct comedi_driver parport_driver = {
.driver_name = "comedi_parport", .driver_name = "comedi_parport",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = parport_attach, .attach = parport_attach,
.detach = parport_detach, .detach = comedi_legacy_detach,
}; };
module_comedi_driver(parport_driver); module_comedi_driver(parport_driver);
......
...@@ -1354,8 +1354,6 @@ static void das16_detach(struct comedi_device *dev) ...@@ -1354,8 +1354,6 @@ static void das16_detach(struct comedi_device *dev)
kfree(devpriv->user_ai_range_table); kfree(devpriv->user_ai_range_table);
kfree(devpriv->user_ao_range_table); kfree(devpriv->user_ao_range_table);
} }
if (dev->irq)
free_irq(dev->irq, dev);
if (devpriv->extra_iobase) if (devpriv->extra_iobase)
release_region(devpriv->extra_iobase, board->size & 0x3ff); release_region(devpriv->extra_iobase, board->size & 0x3ff);
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
......
...@@ -673,8 +673,6 @@ static void das16m1_detach(struct comedi_device *dev) ...@@ -673,8 +673,6 @@ static void das16m1_detach(struct comedi_device *dev)
struct das16m1_private_struct *devpriv = dev->private; struct das16m1_private_struct *devpriv = dev->private;
comedi_spriv_free(dev, 3); comedi_spriv_free(dev, 3);
if (dev->irq)
free_irq(dev->irq, dev);
if (devpriv && devpriv->extra_iobase) if (devpriv && devpriv->extra_iobase)
release_region(devpriv->extra_iobase, DAS16M1_SIZE2); release_region(devpriv->extra_iobase, DAS16M1_SIZE2);
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
......
...@@ -1668,8 +1668,6 @@ static void das1800_detach(struct comedi_device *dev) ...@@ -1668,8 +1668,6 @@ static void das1800_detach(struct comedi_device *dev)
{ {
struct das1800_private *devpriv = dev->private; struct das1800_private *devpriv = dev->private;
if (dev->irq)
free_irq(dev->irq, dev);
if (devpriv) { if (devpriv) {
if (devpriv->dma0) if (devpriv->dma0)
free_dma(devpriv->dma0); free_dma(devpriv->dma0);
......
...@@ -324,18 +324,11 @@ static int das6402_attach(struct comedi_device *dev, ...@@ -324,18 +324,11 @@ static int das6402_attach(struct comedi_device *dev,
return 0; return 0;
} }
static void das6402_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev);
}
static struct comedi_driver das6402_driver = { static struct comedi_driver das6402_driver = {
.driver_name = "das6402", .driver_name = "das6402",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = das6402_attach, .attach = das6402_attach,
.detach = das6402_detach, .detach = comedi_legacy_detach,
}; };
module_comedi_driver(das6402_driver) module_comedi_driver(das6402_driver)
......
...@@ -230,14 +230,13 @@ struct das800_private { ...@@ -230,14 +230,13 @@ struct das800_private {
static int das800_attach(struct comedi_device *dev, static int das800_attach(struct comedi_device *dev,
struct comedi_devconfig *it); struct comedi_devconfig *it);
static void das800_detach(struct comedi_device *dev);
static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s); static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s);
static struct comedi_driver driver_das800 = { static struct comedi_driver driver_das800 = {
.driver_name = "das800", .driver_name = "das800",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = das800_attach, .attach = das800_attach,
.detach = das800_detach, .detach = comedi_legacy_detach,
.num_names = ARRAY_SIZE(das800_boards), .num_names = ARRAY_SIZE(das800_boards),
.board_name = &das800_boards[0].name, .board_name = &das800_boards[0].name,
.offset = sizeof(struct das800_board), .offset = sizeof(struct das800_board),
...@@ -522,13 +521,6 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -522,13 +521,6 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0; return 0;
}; };
static void das800_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev);
}
static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{ {
struct das800_private *devpriv = dev->private; struct das800_private *devpriv = dev->private;
......
...@@ -820,18 +820,11 @@ static int dmm32at_attach(struct comedi_device *dev, ...@@ -820,18 +820,11 @@ static int dmm32at_attach(struct comedi_device *dev,
} }
static void dmm32at_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev);
}
static struct comedi_driver dmm32at_driver = { static struct comedi_driver dmm32at_driver = {
.driver_name = "dmm32at", .driver_name = "dmm32at",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = dmm32at_attach, .attach = dmm32at_attach,
.detach = dmm32at_detach, .detach = comedi_legacy_detach,
}; };
module_comedi_driver(dmm32at_driver); module_comedi_driver(dmm32at_driver);
......
...@@ -556,13 +556,6 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -556,13 +556,6 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0; return 0;
} }
static void dt2811_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev);
}
static const struct dt2811_board boardtypes[] = { static const struct dt2811_board boardtypes[] = {
{ {
.name = "dt2811-pgh", .name = "dt2811-pgh",
...@@ -581,7 +574,7 @@ static struct comedi_driver dt2811_driver = { ...@@ -581,7 +574,7 @@ static struct comedi_driver dt2811_driver = {
.driver_name = "dt2811", .driver_name = "dt2811",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = dt2811_attach, .attach = dt2811_attach,
.detach = dt2811_detach, .detach = comedi_legacy_detach,
.board_name = &boardtypes[0].name, .board_name = &boardtypes[0].name,
.num_names = ARRAY_SIZE(boardtypes), .num_names = ARRAY_SIZE(boardtypes),
.offset = sizeof(struct dt2811_board), .offset = sizeof(struct dt2811_board),
......
...@@ -323,18 +323,11 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -323,18 +323,11 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0; return 0;
} }
static void dt2814_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev);
}
static struct comedi_driver dt2814_driver = { static struct comedi_driver dt2814_driver = {
.driver_name = "dt2814", .driver_name = "dt2814",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = dt2814_attach, .attach = dt2814_attach,
.detach = dt2814_detach, .detach = comedi_legacy_detach,
}; };
module_comedi_driver(dt2814_driver); module_comedi_driver(dt2814_driver);
......
...@@ -1271,8 +1271,6 @@ static void dt282x_detach(struct comedi_device *dev) ...@@ -1271,8 +1271,6 @@ static void dt282x_detach(struct comedi_device *dev)
{ {
struct dt282x_private *devpriv = dev->private; struct dt282x_private *devpriv = dev->private;
if (dev->irq)
free_irq(dev->irq, dev);
if (dev->private) { if (dev->private) {
if (devpriv->dma[0].chan) if (devpriv->dma[0].chan)
free_dma(devpriv->dma[0].chan); free_dma(devpriv->dma[0].chan);
......
...@@ -829,8 +829,6 @@ static void a2150_detach(struct comedi_device *dev) ...@@ -829,8 +829,6 @@ static void a2150_detach(struct comedi_device *dev)
if (dev->iobase) if (dev->iobase)
outw(APD_BIT | DPD_BIT, dev->iobase + CONFIG_REG); outw(APD_BIT | DPD_BIT, dev->iobase + CONFIG_REG);
if (dev->irq)
free_irq(dev->irq, dev);
if (devpriv) { if (devpriv) {
if (devpriv->dma) if (devpriv->dma)
free_dma(devpriv->dma); free_dma(devpriv->dma);
......
...@@ -499,8 +499,6 @@ static void ni_atmio_detach(struct comedi_device *dev) ...@@ -499,8 +499,6 @@ static void ni_atmio_detach(struct comedi_device *dev)
struct ni_private *devpriv = dev->private; struct ni_private *devpriv = dev->private;
mio_common_detach(dev); mio_common_detach(dev);
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
if (devpriv->isapnp_dev) if (devpriv->isapnp_dev)
pnp_device_detach(devpriv->isapnp_dev); pnp_device_detach(devpriv->isapnp_dev);
......
...@@ -768,8 +768,6 @@ static int atmio16d_attach(struct comedi_device *dev, ...@@ -768,8 +768,6 @@ static int atmio16d_attach(struct comedi_device *dev,
static void atmio16d_detach(struct comedi_device *dev) static void atmio16d_detach(struct comedi_device *dev)
{ {
comedi_spriv_free(dev, 3); comedi_spriv_free(dev, 3);
if (dev->irq)
free_irq(dev->irq, dev);
reset_atmio16d(dev); reset_atmio16d(dev);
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
} }
......
...@@ -1870,8 +1870,6 @@ void labpc_common_detach(struct comedi_device *dev) ...@@ -1870,8 +1870,6 @@ void labpc_common_detach(struct comedi_device *dev)
if (devpriv->dma_chan) if (devpriv->dma_chan)
free_dma(devpriv->dma_chan); free_dma(devpriv->dma_chan);
#endif #endif
if (dev->irq)
free_irq(dev->irq, dev);
if (board->bustype == isa_bustype) if (board->bustype == isa_bustype)
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
#ifdef CONFIG_COMEDI_PCI_DRIVERS #ifdef CONFIG_COMEDI_PCI_DRIVERS
...@@ -1879,8 +1877,11 @@ void labpc_common_detach(struct comedi_device *dev) ...@@ -1879,8 +1877,11 @@ void labpc_common_detach(struct comedi_device *dev)
mite_unsetup(devpriv->mite); mite_unsetup(devpriv->mite);
mite_free(devpriv->mite); mite_free(devpriv->mite);
} }
if (board->bustype == pci_bustype) if (board->bustype == pci_bustype) {
if (dev->irq)
free_irq(dev->irq, dev);
comedi_pci_disable(dev); comedi_pci_disable(dev);
}
#endif #endif
} }
EXPORT_SYMBOL_GPL(labpc_common_detach); EXPORT_SYMBOL_GPL(labpc_common_detach);
......
...@@ -550,13 +550,6 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -550,13 +550,6 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0; return 0;
} }
static void pcl711_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev);
}
static const struct pcl711_board boardtypes[] = { static const struct pcl711_board boardtypes[] = {
{ "pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5 }, { "pcl711", 0, 0, 0, 5, 8, 1, 0, &range_bipolar5 },
{ "pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai }, { "pcl711b", 1, 0, 0, 5, 8, 1, 7, &range_pcl711b_ai },
...@@ -568,7 +561,7 @@ static struct comedi_driver pcl711_driver = { ...@@ -568,7 +561,7 @@ static struct comedi_driver pcl711_driver = {
.driver_name = "pcl711", .driver_name = "pcl711",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = pcl711_attach, .attach = pcl711_attach,
.detach = pcl711_detach, .detach = comedi_legacy_detach,
.board_name = &boardtypes[0].name, .board_name = &boardtypes[0].name,
.num_names = ARRAY_SIZE(boardtypes), .num_names = ARRAY_SIZE(boardtypes),
.offset = sizeof(struct pcl711_board), .offset = sizeof(struct pcl711_board),
......
...@@ -173,10 +173,6 @@ static void pcl724_detach(struct comedi_device *dev) ...@@ -173,10 +173,6 @@ static void pcl724_detach(struct comedi_device *dev)
for (i = 0; i < dev->n_subdevices; i++) for (i = 0; i < dev->n_subdevices; i++)
comedi_spriv_free(dev, i); comedi_spriv_free(dev, i);
#ifdef PCL724_IRQ
if (dev->irq)
free_irq(dev->irq, dev);
#endif
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
} }
......
...@@ -335,20 +335,11 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -335,20 +335,11 @@ static int pcl726_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0; return 0;
} }
static void pcl726_detach(struct comedi_device *dev)
{
#ifdef ACL6126_IRQ
if (dev->irq)
free_irq(dev->irq, dev);
#endif
comedi_legacy_detach(dev);
}
static struct comedi_driver pcl726_driver = { static struct comedi_driver pcl726_driver = {
.driver_name = "pcl726", .driver_name = "pcl726",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = pcl726_attach, .attach = pcl726_attach,
.detach = pcl726_detach, .detach = comedi_legacy_detach,
.board_name = &boardtypes[0].name, .board_name = &boardtypes[0].name,
.num_names = ARRAY_SIZE(boardtypes), .num_names = ARRAY_SIZE(boardtypes),
.offset = sizeof(struct pcl726_board), .offset = sizeof(struct pcl726_board),
......
...@@ -1438,8 +1438,6 @@ static void pcl812_detach(struct comedi_device *dev) ...@@ -1438,8 +1438,6 @@ static void pcl812_detach(struct comedi_device *dev)
if (devpriv->dma) if (devpriv->dma)
free_dma(devpriv->dma); free_dma(devpriv->dma);
} }
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
} }
......
...@@ -1214,14 +1214,10 @@ static void pcl816_detach(struct comedi_device *dev) ...@@ -1214,14 +1214,10 @@ static void pcl816_detach(struct comedi_device *dev)
release_region(devpriv->rtc_iobase, release_region(devpriv->rtc_iobase,
devpriv->rtc_iosize); devpriv->rtc_iosize);
} }
#endif
}
if (dev->irq)
free_irq(dev->irq, dev);
#ifdef unused
if (devpriv->dma_rtc) if (devpriv->dma_rtc)
RTC_lock--; RTC_lock--;
#endif #endif
}
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
} }
......
...@@ -1898,8 +1898,6 @@ static void pcl818_detach(struct comedi_device *dev) ...@@ -1898,8 +1898,6 @@ static void pcl818_detach(struct comedi_device *dev)
RTC_lock--; RTC_lock--;
#endif #endif
} }
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev); comedi_legacy_detach(dev);
} }
......
...@@ -133,13 +133,6 @@ static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -133,13 +133,6 @@ static int pcmad_attach(struct comedi_device *dev, struct comedi_devconfig *it)
return 0; return 0;
} }
static void pcmad_detach(struct comedi_device *dev)
{
if (dev->irq)
free_irq(dev->irq, dev);
comedi_legacy_detach(dev);
}
static const struct pcmad_board_struct pcmad_boards[] = { static const struct pcmad_board_struct pcmad_boards[] = {
{ {
.name = "pcmad12", .name = "pcmad12",
...@@ -153,7 +146,7 @@ static struct comedi_driver pcmad_driver = { ...@@ -153,7 +146,7 @@ static struct comedi_driver pcmad_driver = {
.driver_name = "pcmad", .driver_name = "pcmad",
.module = THIS_MODULE, .module = THIS_MODULE,
.attach = pcmad_attach, .attach = pcmad_attach,
.detach = pcmad_detach, .detach = comedi_legacy_detach,
.board_name = &pcmad_boards[0].name, .board_name = &pcmad_boards[0].name,
.num_names = ARRAY_SIZE(pcmad_boards), .num_names = ARRAY_SIZE(pcmad_boards),
.offset = sizeof(pcmad_boards[0]), .offset = sizeof(pcmad_boards[0]),
......
...@@ -1193,11 +1193,6 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -1193,11 +1193,6 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->asics[asic].irq = irq[asic]; devpriv->asics[asic].irq = irq[asic];
} }
dev->irq = irq[0]; /*
* grr.. wish comedi dev struct supported
* multiple irqs..
*/
return 1; return 1;
} }
......
...@@ -917,9 +917,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it) ...@@ -917,9 +917,6 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)
devpriv->asics[asic].irq = irq[asic]; devpriv->asics[asic].irq = irq[asic];
} }
dev->irq = irq[0]; /* grr.. wish comedi dev struct supported multiple
irqs.. */
if (irq[0]) { if (irq[0]) {
dev_dbg(dev->class_dev, "irq: %u\n", irq[0]); dev_dbg(dev->class_dev, "irq: %u\n", irq[0]);
if (irq[1] && board->num_asics == 2) if (irq[1] && board->num_asics == 2)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册