Introduce a new subdevice flag, SDF_FREE_SPRIV, to allow the comedi core to automatically free the subdevice private data during the cleanup_device() stage of the detach. Currently the s->private is only allocated by the 8255, addi_watchdog, amplc_dio200_common, and ni_65xx drivers. All users of those drivers can them have the comedi_spriv_free() calls removed and in many cases the (*detach) can then simply be the appropriate comedi core provided function. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/comedi.h | 2 ++ drivers/staging/comedi/comedidev.h | 2 -- drivers/staging/comedi/drivers.c | 14 ++--------- drivers/staging/comedi/drivers/8255.c | 3 +-- drivers/staging/comedi/drivers/8255_pci.c | 2 -- drivers/staging/comedi/drivers/addi_apci_1516.c | 1 - drivers/staging/comedi/drivers/addi_apci_2032.c | 1 - drivers/staging/comedi/drivers/addi_apci_2200.c | 1 - drivers/staging/comedi/drivers/addi_watchdog.c | 2 +- drivers/staging/comedi/drivers/adv_pci_dio.c | 6 ----- drivers/staging/comedi/drivers/aio_aio12_8.c | 8 +------ .../staging/comedi/drivers/amplc_dio200_common.c | 27 +++++----------------- drivers/staging/comedi/drivers/amplc_pc236.c | 1 - drivers/staging/comedi/drivers/amplc_pci230.c | 1 - drivers/staging/comedi/drivers/cb_pcidas.c | 1 - drivers/staging/comedi/drivers/cb_pcidas64.c | 1 - drivers/staging/comedi/drivers/cb_pcidda.c | 9 +------- drivers/staging/comedi/drivers/cb_pcimdda.c | 8 +------ drivers/staging/comedi/drivers/daqboard2000.c | 1 - drivers/staging/comedi/drivers/das08.c | 6 ----- drivers/staging/comedi/drivers/das08.h | 1 - drivers/staging/comedi/drivers/das08_cs.c | 8 +------ drivers/staging/comedi/drivers/das08_isa.c | 8 +------ drivers/staging/comedi/drivers/das08_pci.c | 8 +------ drivers/staging/comedi/drivers/das16.c | 1 - drivers/staging/comedi/drivers/das16m1.c | 1 - drivers/staging/comedi/drivers/ni_65xx.c | 5 ++-- drivers/staging/comedi/drivers/ni_atmio16d.c | 1 - drivers/staging/comedi/drivers/ni_daq_dio24.c | 8 +------ drivers/staging/comedi/drivers/ni_labpc.c | 8 ------- drivers/staging/comedi/drivers/ni_labpc.h | 1 - drivers/staging/comedi/drivers/ni_labpc_cs.c | 8 +------ drivers/staging/comedi/drivers/ni_labpc_pci.c | 2 -- drivers/staging/comedi/drivers/ni_mio_common.c | 1 - drivers/staging/comedi/drivers/pcl724.c | 11 +-------- drivers/staging/comedi/drivers/pcm3724.c | 11 +-------- 36 files changed, 25 insertions(+), 155 deletions(-) diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h index 6bbbe5b..3a284434 100644 --- a/drivers/staging/comedi/comedi.h +++ b/drivers/staging/comedi/comedi.h @@ -211,6 +211,8 @@ #define SDF_PWM_COUNTER SDF_MODE0 /* PWM can automatically switch off */ #define SDF_PWM_HBRIDGE SDF_MODE1 /* PWM is signed (H-bridge) */ +#define SDF_FREE_SPRIV 0x80000000 /* free s->private on detach */ + /* subdevice types */ enum comedi_subdevice_type { diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 57deabf..6731109 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -356,8 +356,6 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, int comedi_alloc_subdevices(struct comedi_device *, int); -void comedi_spriv_free(struct comedi_device *, int subdev_num); - int comedi_load_firmware(struct comedi_device *, struct device *, const char *name, int (*cb)(struct comedi_device *, diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index f3e57fd..61be3de 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -83,18 +83,6 @@ int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices) } EXPORT_SYMBOL_GPL(comedi_alloc_subdevices); -void comedi_spriv_free(struct comedi_device *dev, int subdev_num) -{ - struct comedi_subdevice *s; - - if (dev->subdevices && subdev_num < dev->n_subdevices) { - s = &dev->subdevices[subdev_num]; - kfree(s->private); - s->private = NULL; - } -} -EXPORT_SYMBOL_GPL(comedi_spriv_free); - static void cleanup_device(struct comedi_device *dev) { int i; @@ -103,6 +91,8 @@ static void cleanup_device(struct comedi_device *dev) if (dev->subdevices) { for (i = 0; i < dev->n_subdevices; i++) { s = &dev->subdevices[i]; + if (s->subdev_flags & SDF_FREE_SPRIV) + kfree(s->private); comedi_free_subdevice_minor(s); if (s->async) { comedi_buf_alloc(dev, s, 0); diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c index 1a1c2da..8862405 100644 --- a/drivers/staging/comedi/drivers/8255.c +++ b/drivers/staging/comedi/drivers/8255.c @@ -295,7 +295,7 @@ int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s, s->private = spriv; s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_FREE_SPRIV; s->n_chan = 24; s->range_table = &range_digital; s->maxdata = 1; @@ -386,7 +386,6 @@ static void dev_8255_detach(struct comedi_device *dev) spriv = s->private; release_region(spriv->iobase, _8255_SIZE); } - comedi_spriv_free(dev, i); } } diff --git a/drivers/staging/comedi/drivers/8255_pci.c b/drivers/staging/comedi/drivers/8255_pci.c index 1117b61..21a3fa4 100644 --- a/drivers/staging/comedi/drivers/8255_pci.c +++ b/drivers/staging/comedi/drivers/8255_pci.c @@ -240,8 +240,6 @@ static void pci_8255_detach(struct comedi_device *dev) struct pci_8255_private *devpriv = dev->private; int i; - for (i = 0; i < dev->n_subdevices; i++) - comedi_spriv_free(dev, i); if (devpriv && devpriv->mmio_base) iounmap(devpriv->mmio_base); comedi_pci_disable(dev); diff --git a/drivers/staging/comedi/drivers/addi_apci_1516.c b/drivers/staging/comedi/drivers/addi_apci_1516.c index 5bf6bb1..b626738 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1516.c +++ b/drivers/staging/comedi/drivers/addi_apci_1516.c @@ -196,7 +196,6 @@ static void apci1516_detach(struct comedi_device *dev) { if (dev->iobase) apci1516_reset(dev); - comedi_spriv_free(dev, 2); comedi_pci_disable(dev); } diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index c0d83d8..89ead8e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -347,7 +347,6 @@ static void apci2032_detach(struct comedi_device *dev) free_irq(dev->irq, dev); if (dev->read_subdev) kfree(dev->read_subdev->private); - comedi_spriv_free(dev, 1); comedi_pci_disable(dev); } diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index 060620e..ca1bd92 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -123,7 +123,6 @@ static void apci2200_detach(struct comedi_device *dev) { if (dev->iobase) apci2200_reset(dev); - comedi_spriv_free(dev, 2); comedi_pci_disable(dev); } diff --git a/drivers/staging/comedi/drivers/addi_watchdog.c b/drivers/staging/comedi/drivers/addi_watchdog.c index 2c21a16..1626c85 100644 --- a/drivers/staging/comedi/drivers/addi_watchdog.c +++ b/drivers/staging/comedi/drivers/addi_watchdog.c @@ -135,7 +135,7 @@ int addi_watchdog_init(struct comedi_subdevice *s, unsigned long iobase) s->private = spriv; s->type = COMEDI_SUBD_TIMER; - s->subdev_flags = SDF_WRITEABLE; + s->subdev_flags = SDF_WRITEABLE | SDF_FREE_SPRIV; s->n_chan = 1; s->maxdata = 0xff; s->insn_config = addi_watchdog_insn_config; diff --git a/drivers/staging/comedi/drivers/adv_pci_dio.c b/drivers/staging/comedi/drivers/adv_pci_dio.c index f70c6747..1e393b5 100644 --- a/drivers/staging/comedi/drivers/adv_pci_dio.c +++ b/drivers/staging/comedi/drivers/adv_pci_dio.c @@ -1180,12 +1180,6 @@ static void pci_dio_detach(struct comedi_device *dev) if (devpriv->valid) pci_dio_reset(dev); } - for (i = 0; i < dev->n_subdevices; i++) { - s = &dev->subdevices[i]; - if (s->type == COMEDI_SUBD_DIO) - comedi_spriv_free(dev, i); - s->private = NULL; /* some private data is static */ - } comedi_pci_disable(dev); } diff --git a/drivers/staging/comedi/drivers/aio_aio12_8.c b/drivers/staging/comedi/drivers/aio_aio12_8.c index 77c92cb..279dfe8 100644 --- a/drivers/staging/comedi/drivers/aio_aio12_8.c +++ b/drivers/staging/comedi/drivers/aio_aio12_8.c @@ -255,17 +255,11 @@ static int aio_aio12_8_attach(struct comedi_device *dev, return 0; } -static void aio_aio12_8_detach(struct comedi_device *dev) -{ - comedi_spriv_free(dev, 2); - comedi_legacy_detach(dev); -} - static struct comedi_driver aio_aio12_8_driver = { .driver_name = "aio_aio12_8", .module = THIS_MODULE, .attach = aio_aio12_8_attach, - .detach = aio_aio12_8_detach, + .detach = comedi_legacy_detach, .board_name = &board_types[0].name, .num_names = ARRAY_SIZE(board_types), .offset = sizeof(struct aio12_8_boardtype), diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 81d6ee4..8697096 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -569,8 +569,9 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s, dio200_write8(dev, subpriv->ofs, 0); s->private = subpriv; + s->type = COMEDI_SUBD_DI; - s->subdev_flags = SDF_READABLE | SDF_CMD_READ; + s->subdev_flags = SDF_READABLE | SDF_CMD_READ | SDF_FREE_SPRIV; if (layout->has_int_sce) { s->n_chan = DIO200_MAX_ISNS; s->len_chanlist = DIO200_MAX_ISNS; @@ -886,10 +887,10 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s, subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL); if (!subpriv) return -ENOMEM; - s->private = subpriv; + s->type = COMEDI_SUBD_COUNTER; - s->subdev_flags = SDF_WRITABLE | SDF_READABLE; + s->subdev_flags = SDF_WRITABLE | SDF_READABLE | SDF_FREE_SPRIV; s->n_chan = 3; s->maxdata = 0xFFFF; s->insn_read = dio200_subdev_8254_read; @@ -1024,8 +1025,9 @@ static int dio200_subdev_8255_init(struct comedi_device *dev, return -ENOMEM; subpriv->ofs = offset; s->private = subpriv; + s->type = COMEDI_SUBD_DIO; - s->subdev_flags = SDF_READABLE | SDF_WRITABLE; + s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_FREE_SPRIV; s->n_chan = 24; s->range_table = &range_digital; s->maxdata = 1; @@ -1225,28 +1227,11 @@ void amplc_dio200_common_detach(struct comedi_device *dev) { const struct dio200_board *thisboard = comedi_board(dev); struct dio200_private *devpriv = dev->private; - const struct dio200_layout *layout; - unsigned n; if (!thisboard || !devpriv) return; if (dev->irq) free_irq(dev->irq, dev); - if (dev->subdevices) { - layout = dio200_board_layout(thisboard); - for (n = 0; n < dev->n_subdevices; n++) { - switch (layout->sdtype[n]) { - case sd_8254: - case sd_8255: - case sd_intr: - comedi_spriv_free(dev, n); - break; - case sd_timer: - default: - break; - } - } - } } EXPORT_SYMBOL_GPL(amplc_dio200_common_detach); diff --git a/drivers/staging/comedi/drivers/amplc_pc236.c b/drivers/staging/comedi/drivers/amplc_pc236.c index 179d25e..4e889b8 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.c +++ b/drivers/staging/comedi/drivers/amplc_pc236.c @@ -538,7 +538,6 @@ static void pc236_detach(struct comedi_device *dev) return; if (dev->iobase) pc236_intr_disable(dev); - comedi_spriv_free(dev, 0); if (is_isa_board(thisboard)) { comedi_legacy_detach(dev); } else if (is_pci_board(thisboard)) { diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 08ff128..846d644 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2830,7 +2830,6 @@ static void pci230_detach(struct comedi_device *dev) { struct pci_dev *pcidev = comedi_to_pci_dev(dev); - comedi_spriv_free(dev, 2); if (dev->irq) free_irq(dev->irq, dev); comedi_pci_disable(dev); diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 172f459..58bca18 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -1602,7 +1602,6 @@ static void cb_pcidas_detach(struct comedi_device *dev) } if (dev->irq) free_irq(dev->irq, dev); - comedi_spriv_free(dev, 2); comedi_pci_disable(dev); } diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 11f8101..43c0bf5 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -4158,7 +4158,6 @@ static void detach(struct comedi_device *dev) devpriv->ao_dma_desc_bus_addr); } } - comedi_spriv_free(dev, 4); comedi_pci_disable(dev); } diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index b74d4c3..2d3e920 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -393,18 +393,11 @@ static int cb_pcidda_auto_attach(struct comedi_device *dev, return 0; } -static void cb_pcidda_detach(struct comedi_device *dev) -{ - comedi_spriv_free(dev, 1); - comedi_spriv_free(dev, 2); - comedi_pci_disable(dev); -} - static struct comedi_driver cb_pcidda_driver = { .driver_name = "cb_pcidda", .module = THIS_MODULE, .auto_attach = cb_pcidda_auto_attach, - .detach = cb_pcidda_detach, + .detach = comedi_pci_disable, }; static int cb_pcidda_pci_probe(struct pci_dev *dev, diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index d3a796e..406cba8c 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -192,17 +192,11 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev, return 1; } -static void cb_pcimdda_detach(struct comedi_device *dev) -{ - comedi_spriv_free(dev, 1); - comedi_pci_disable(dev); -} - static struct comedi_driver cb_pcimdda_driver = { .driver_name = "cb_pcimdda", .module = THIS_MODULE, .auto_attach = cb_pcimdda_auto_attach, - .detach = cb_pcimdda_detach, + .detach = comedi_pci_disable, }; static int cb_pcimdda_pci_probe(struct pci_dev *dev, diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index f5aa386..44c912b 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -747,7 +747,6 @@ static void daqboard2000_detach(struct comedi_device *dev) { struct daqboard2000_private *devpriv = dev->private; - comedi_spriv_free(dev, 2); if (dev->irq) free_irq(dev->irq, dev); if (devpriv) { diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c index 64807ea..2e7e3e2 100644 --- a/drivers/staging/comedi/drivers/das08.c +++ b/drivers/staging/comedi/drivers/das08.c @@ -560,12 +560,6 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase) } EXPORT_SYMBOL_GPL(das08_common_attach); -void das08_common_detach(struct comedi_device *dev) -{ - comedi_spriv_free(dev, 4); -} -EXPORT_SYMBOL_GPL(das08_common_detach); - static int __init das08_init(void) { return 0; diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index c312870..cce1b58 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -47,6 +47,5 @@ struct das08_private_struct { }; int das08_common_attach(struct comedi_device *dev, unsigned long iobase); -void das08_common_detach(struct comedi_device *dev); #endif /* _DAS08_H */ diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c index 3625b3e..885fb17 100644 --- a/drivers/staging/comedi/drivers/das08_cs.c +++ b/drivers/staging/comedi/drivers/das08_cs.c @@ -86,17 +86,11 @@ static int das08_cs_auto_attach(struct comedi_device *dev, return das08_common_attach(dev, iobase); } -static void das08_cs_detach(struct comedi_device *dev) -{ - das08_common_detach(dev); - comedi_pcmcia_disable(dev); -} - static struct comedi_driver driver_das08_cs = { .driver_name = "das08_cs", .module = THIS_MODULE, .auto_attach = das08_cs_auto_attach, - .detach = das08_cs_detach, + .detach = comedi_pcmcia_disable, }; static int das08_pcmcia_attach(struct pcmcia_device *link) diff --git a/drivers/staging/comedi/drivers/das08_isa.c b/drivers/staging/comedi/drivers/das08_isa.c index 10e96e9..21a9438 100644 --- a/drivers/staging/comedi/drivers/das08_isa.c +++ b/drivers/staging/comedi/drivers/das08_isa.c @@ -189,17 +189,11 @@ static int das08_isa_attach(struct comedi_device *dev, return das08_common_attach(dev, dev->iobase); } -static void das08_isa_detach(struct comedi_device *dev) -{ - das08_common_detach(dev); - comedi_legacy_detach(dev); -} - static struct comedi_driver das08_isa_driver = { .driver_name = "isa-das08", .module = THIS_MODULE, .attach = das08_isa_attach, - .detach = das08_isa_detach, + .detach = comedi_legacy_detach, .board_name = &das08_isa_boards[0].name, .num_names = ARRAY_SIZE(das08_isa_boards), .offset = sizeof(das08_isa_boards[0]), diff --git a/drivers/staging/comedi/drivers/das08_pci.c b/drivers/staging/comedi/drivers/das08_pci.c index 351fbc6..9c5d234 100644 --- a/drivers/staging/comedi/drivers/das08_pci.c +++ b/drivers/staging/comedi/drivers/das08_pci.c @@ -75,17 +75,11 @@ static int das08_pci_auto_attach(struct comedi_device *dev, return das08_common_attach(dev, dev->iobase); } -static void das08_pci_detach(struct comedi_device *dev) -{ - das08_common_detach(dev); - comedi_pci_disable(dev); -} - static struct comedi_driver das08_pci_comedi_driver = { .driver_name = "pci-das08", .module = THIS_MODULE, .auto_attach = das08_pci_auto_attach, - .detach = das08_pci_detach, + .detach = comedi_pci_disable, }; static int das08_pci_probe(struct pci_dev *dev, diff --git a/drivers/staging/comedi/drivers/das16.c b/drivers/staging/comedi/drivers/das16.c index dab7647..dbec3ba 100644 --- a/drivers/staging/comedi/drivers/das16.c +++ b/drivers/staging/comedi/drivers/das16.c @@ -1333,7 +1333,6 @@ static void das16_detach(struct comedi_device *dev) struct das16_private_struct *devpriv = dev->private; das16_reset(dev); - comedi_spriv_free(dev, 4); if (devpriv) { int i; for (i = 0; i < 2; i++) { diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index e7ae2ff..0b33808 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -666,7 +666,6 @@ static void das16m1_detach(struct comedi_device *dev) { struct das16m1_private_struct *devpriv = dev->private; - comedi_spriv_free(dev, 3); if (devpriv && devpriv->extra_iobase) release_region(devpriv->extra_iobase, DAS16M1_SIZE2); comedi_legacy_detach(dev); diff --git a/drivers/staging/comedi/drivers/ni_65xx.c b/drivers/staging/comedi/drivers/ni_65xx.c index 6a89e5c..7fcabdc 100644 --- a/drivers/staging/comedi/drivers/ni_65xx.c +++ b/drivers/staging/comedi/drivers/ni_65xx.c @@ -635,6 +635,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev, s->private = ni_65xx_alloc_subdevice_private(); if (s->private == NULL) return -ENOMEM; + s->subdev_flags |= SDF_FREE_SPRIV; sprivate(s)->base_port = 0; } else { s->type = COMEDI_SUBD_UNUSED; @@ -652,6 +653,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev, s->private = ni_65xx_alloc_subdevice_private(); if (s->private == NULL) return -ENOMEM; + s->subdev_flags |= SDF_FREE_SPRIV; sprivate(s)->base_port = board->num_di_ports; } else { s->type = COMEDI_SUBD_UNUSED; @@ -670,6 +672,7 @@ static int ni_65xx_auto_attach(struct comedi_device *dev, s->private = ni_65xx_alloc_subdevice_private(); if (s->private == NULL) return -ENOMEM; + s->subdev_flags |= SDF_FREE_SPRIV; sprivate(s)->base_port = 0; for (i = 0; i < board->num_dio_ports; ++i) { /* configure all ports for input */ @@ -734,8 +737,6 @@ static void ni_65xx_detach(struct comedi_device *dev) } if (dev->irq) free_irq(dev->irq, dev); - for (i = 0; i < dev->n_subdevices; ++i) - comedi_spriv_free(dev, i); if (devpriv) { if (devpriv->mite) { mite_unsetup(devpriv->mite); diff --git a/drivers/staging/comedi/drivers/ni_atmio16d.c b/drivers/staging/comedi/drivers/ni_atmio16d.c index d280332..da7396f 100644 --- a/drivers/staging/comedi/drivers/ni_atmio16d.c +++ b/drivers/staging/comedi/drivers/ni_atmio16d.c @@ -762,7 +762,6 @@ static int atmio16d_attach(struct comedi_device *dev, static void atmio16d_detach(struct comedi_device *dev) { - comedi_spriv_free(dev, 3); reset_atmio16d(dev); comedi_legacy_detach(dev); } diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c index 6ff1526..d3d4eb9 100644 --- a/drivers/staging/comedi/drivers/ni_daq_dio24.c +++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c @@ -65,17 +65,11 @@ static int dio24_auto_attach(struct comedi_device *dev, return 0; } -static void dio24_detach(struct comedi_device *dev) -{ - comedi_spriv_free(dev, 0); - comedi_pcmcia_disable(dev); -} - static struct comedi_driver driver_dio24 = { .driver_name = "ni_daq_dio24", .module = THIS_MODULE, .auto_attach = dio24_auto_attach, - .detach = dio24_detach, + .detach = comedi_pcmcia_disable, }; static int dio24_cs_attach(struct pcmcia_device *link) diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index a918b7f..f161e70 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -1689,12 +1689,6 @@ int labpc_common_attach(struct comedi_device *dev, } EXPORT_SYMBOL_GPL(labpc_common_attach); -void labpc_common_detach(struct comedi_device *dev) -{ - comedi_spriv_free(dev, 2); -} -EXPORT_SYMBOL_GPL(labpc_common_detach); - #if IS_ENABLED(CONFIG_COMEDI_NI_LABPC_ISA) static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) { @@ -1747,8 +1741,6 @@ static void labpc_detach(struct comedi_device *dev) { struct labpc_private *devpriv = dev->private; - labpc_common_detach(dev); - if (devpriv) { kfree(devpriv->dma_buffer); if (devpriv->dma_chan) diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index aa5c4d8..486589f 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -86,6 +86,5 @@ struct labpc_private { int labpc_common_attach(struct comedi_device *dev, unsigned int irq, unsigned long isr_flags); -void labpc_common_detach(struct comedi_device *dev); #endif /* _NI_LABPC_H */ diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index 883581e..ce67f4b 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -104,17 +104,11 @@ static int labpc_auto_attach(struct comedi_device *dev, return labpc_common_attach(dev, link->irq, IRQF_SHARED); } -static void labpc_detach(struct comedi_device *dev) -{ - labpc_common_detach(dev); - comedi_pcmcia_disable(dev); -} - static struct comedi_driver driver_labpc_cs = { .driver_name = "ni_labpc_cs", .module = THIS_MODULE, .auto_attach = labpc_auto_attach, - .detach = labpc_detach, + .detach = comedi_pcmcia_disable, }; static int labpc_cs_attach(struct pcmcia_device *link) diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/staging/comedi/drivers/ni_labpc_pci.c index 1f80711..6c79237 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_pci.c +++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c @@ -92,8 +92,6 @@ static void labpc_pci_detach(struct comedi_device *dev) { struct labpc_private *devpriv = dev->private; - labpc_common_detach(dev); - if (devpriv && devpriv->mite) { mite_unsetup(devpriv->mite); mite_free(devpriv->mite); diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 1e78198..3e9f544 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -4072,7 +4072,6 @@ static void mio_common_detach(struct comedi_device *dev) ni_gpct_device_destroy(devpriv->counter_dev); } } - comedi_spriv_free(dev, NI_8255_DIO_SUBDEV); } static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s) diff --git a/drivers/staging/comedi/drivers/pcl724.c b/drivers/staging/comedi/drivers/pcl724.c index 1bcabb89..cea657c 100644 --- a/drivers/staging/comedi/drivers/pcl724.c +++ b/drivers/staging/comedi/drivers/pcl724.c @@ -136,20 +136,11 @@ static int pcl724_attach(struct comedi_device *dev, return 0; } -static void pcl724_detach(struct comedi_device *dev) -{ - int i; - - for (i = 0; i < dev->n_subdevices; i++) - comedi_spriv_free(dev, i); - comedi_legacy_detach(dev); -} - static struct comedi_driver pcl724_driver = { .driver_name = "pcl724", .module = THIS_MODULE, .attach = pcl724_attach, - .detach = pcl724_detach, + .detach = comedi_legacy_detach, .board_name = &boardtypes[0].name, .num_names = ARRAY_SIZE(boardtypes), .offset = sizeof(struct pcl724_board), diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index 4ef0df3..5a9cd38 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -250,20 +250,11 @@ static int pcm3724_attach(struct comedi_device *dev, return 0; } -static void pcm3724_detach(struct comedi_device *dev) -{ - int i; - - for (i = 0; i < dev->n_subdevices; i++) - comedi_spriv_free(dev, i); - comedi_legacy_detach(dev); -} - static struct comedi_driver pcm3724_driver = { .driver_name = "pcm3724", .module = THIS_MODULE, .attach = pcm3724_attach, - .detach = pcm3724_detach, + .detach = comedi_legacy_detach, }; module_comedi_driver(pcm3724_driver); -- 1.8.1.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel