Default the dev->board_name to the dev->driver->driver_name before calling the comedi driver (*attach) or (*auto_attach). This way drivers without additional boardinfo do not have to set the dev->board_name pointer. This also ensures that dev->board_name is always initialized before PCI drivers call comedi_pci_enable(). Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/comedi_pci.c | 4 +--- drivers/staging/comedi/drivers.c | 8 ++++++-- drivers/staging/comedi/drivers/addi_apci_1032.c | 2 -- drivers/staging/comedi/drivers/addi_apci_1710.c | 2 -- drivers/staging/comedi/drivers/addi_apci_2032.c | 2 -- drivers/staging/comedi/drivers/addi_apci_2200.c | 2 -- drivers/staging/comedi/drivers/addi_apci_3501.c | 2 -- drivers/staging/comedi/drivers/adl_pci8164.c | 2 -- drivers/staging/comedi/drivers/adl_pci9111.c | 2 -- drivers/staging/comedi/drivers/adq12b.c | 2 -- drivers/staging/comedi/drivers/adv_pci1723.c | 2 -- drivers/staging/comedi/drivers/adv_pci1724.c | 2 -- drivers/staging/comedi/drivers/aio_iiro_16.c | 2 -- drivers/staging/comedi/drivers/cb_pcimdas.c | 2 -- drivers/staging/comedi/drivers/cb_pcimdda.c | 2 -- drivers/staging/comedi/drivers/comedi_parport.c | 2 -- drivers/staging/comedi/drivers/comedi_test.c | 2 -- drivers/staging/comedi/drivers/contec_pci_dio.c | 2 -- drivers/staging/comedi/drivers/das16m1.c | 2 -- drivers/staging/comedi/drivers/dmm32at.c | 2 -- drivers/staging/comedi/drivers/dyna_pci10xx.c | 2 -- drivers/staging/comedi/drivers/icp_multi.c | 2 -- drivers/staging/comedi/drivers/jr3_pci.c | 1 - drivers/staging/comedi/drivers/ke_counter.c | 2 -- drivers/staging/comedi/drivers/ni_daq_700.c | 2 -- drivers/staging/comedi/drivers/ni_daq_dio24.c | 2 -- drivers/staging/comedi/drivers/pcm3724.c | 2 -- drivers/staging/comedi/drivers/pcmda12.c | 2 -- drivers/staging/comedi/drivers/pcmmio.c | 2 -- drivers/staging/comedi/drivers/quatech_daqp_cs.c | 2 -- drivers/staging/comedi/drivers/s526.c | 2 -- drivers/staging/comedi/drivers/s626.c | 2 -- drivers/staging/comedi/drivers/serial2002.c | 1 - drivers/staging/comedi/drivers/ssv_dnp.c | 2 -- 34 files changed, 7 insertions(+), 67 deletions(-) diff --git a/drivers/staging/comedi/comedi_pci.c b/drivers/staging/comedi/comedi_pci.c index 8169487..9b0854a 100644 --- a/drivers/staging/comedi/comedi_pci.c +++ b/drivers/staging/comedi/comedi_pci.c @@ -51,9 +51,7 @@ int comedi_pci_enable(struct comedi_device *dev, int main_pcibar) if (rc < 0) return rc; - rc = pci_request_regions(pcidev, dev->board_name - ? dev->board_name - : dev->driver->driver_name); + rc = pci_request_regions(pcidev, dev->board_name); if (rc < 0) { pci_disable_device(pcidev); return rc; diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index 64be7c5..da36eb3 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -390,9 +390,12 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it) module_put(driv->module); return -ENOSYS; } - /* initialize dev->driver here so - * comedi_error() can be called from attach */ + /* + * initialize dev->driver and dev->board_name here so + * comedi_error() can be called from attach + */ dev->driver = driv; + dev->board_name = dev->driver->driver_name; ret = driv->attach(dev, it); if (ret < 0) { module_put(dev->driver->module); @@ -430,6 +433,7 @@ int comedi_auto_config(struct device *hardware_device, else { comedi_set_hw_dev(comedi_dev, hardware_device); comedi_dev->driver = driver; + comedi_dev->board_name = comedi_dev->driver->driver_name; ret = driver->auto_attach(comedi_dev, context); if (ret < 0) { module_put(driver->module); diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c index c1d8b59..23cbbf8 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1032.c +++ b/drivers/staging/comedi/drivers/addi_apci_1032.c @@ -296,8 +296,6 @@ static int apci1032_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/addi_apci_1710.c b/drivers/staging/comedi/drivers/addi_apci_1710.c index 0526ec4..1f4de7a 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1710.c +++ b/drivers/staging/comedi/drivers/addi_apci_1710.c @@ -35,8 +35,6 @@ static int apci1710_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/addi_apci_2032.c b/drivers/staging/comedi/drivers/addi_apci_2032.c index 1a6e85f..b1f9e4e 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2032.c +++ b/drivers/staging/comedi/drivers/addi_apci_2032.c @@ -287,8 +287,6 @@ static int apci2032_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(dev, 1); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/addi_apci_2200.c b/drivers/staging/comedi/drivers/addi_apci_2200.c index f817b49..7938ec6 100644 --- a/drivers/staging/comedi/drivers/addi_apci_2200.c +++ b/drivers/staging/comedi/drivers/addi_apci_2200.c @@ -87,8 +87,6 @@ static int apci2200_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(dev, 1); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index 352d862..97170e6 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -339,8 +339,6 @@ static int apci3501_auto_attach(struct comedi_device *dev, int ao_n_chan; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/adl_pci8164.c b/drivers/staging/comedi/drivers/adl_pci8164.c index 41b3181..e6dc7d4 100644 --- a/drivers/staging/comedi/drivers/adl_pci8164.c +++ b/drivers/staging/comedi/drivers/adl_pci8164.c @@ -77,8 +77,6 @@ static int adl_pci8164_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(dev, 2); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/adl_pci9111.c b/drivers/staging/comedi/drivers/adl_pci9111.c index 88af984..5578123 100644 --- a/drivers/staging/comedi/drivers/adl_pci9111.c +++ b/drivers/staging/comedi/drivers/adl_pci9111.c @@ -865,8 +865,6 @@ static int pci9111_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - dev_private = kzalloc(sizeof(*dev_private), GFP_KERNEL); if (!dev_private) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/adq12b.c b/drivers/staging/comedi/drivers/adq12b.c index f7950df..dd31597 100644 --- a/drivers/staging/comedi/drivers/adq12b.c +++ b/drivers/staging/comedi/drivers/adq12b.c @@ -217,8 +217,6 @@ static int adq12b_attach(struct comedi_device *dev, struct comedi_devconfig *it) int unipolar, differential; int ret; - dev->board_name = dev->driver->driver_name; - iobase = it->options[0]; unipolar = it->options[1]; differential = it->options[2]; diff --git a/drivers/staging/comedi/drivers/adv_pci1723.c b/drivers/staging/comedi/drivers/adv_pci1723.c index af61fe2..f7cc788 100644 --- a/drivers/staging/comedi/drivers/adv_pci1723.c +++ b/drivers/staging/comedi/drivers/adv_pci1723.c @@ -241,8 +241,6 @@ static int pci1723_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/adv_pci1724.c b/drivers/staging/comedi/drivers/adv_pci1724.c index d3f8b4e..2c0e15d 100644 --- a/drivers/staging/comedi/drivers/adv_pci1724.c +++ b/drivers/staging/comedi/drivers/adv_pci1724.c @@ -358,8 +358,6 @@ static int adv_pci1724_auto_attach(struct comedi_device *dev, devpriv->gain_value[i] = -1; } - dev->board_name = dev->driver->driver_name; - retval = comedi_pci_enable(dev, 2); if (retval) return retval; diff --git a/drivers/staging/comedi/drivers/aio_iiro_16.c b/drivers/staging/comedi/drivers/aio_iiro_16.c index 64c1ae5..29aba2b 100644 --- a/drivers/staging/comedi/drivers/aio_iiro_16.c +++ b/drivers/staging/comedi/drivers/aio_iiro_16.c @@ -83,8 +83,6 @@ static int aio_iiro_16_attach(struct comedi_device *dev, printk(KERN_INFO "comedi%d: aio_iiro_16: ", dev->minor); - dev->board_name = dev->driver->driver_name; - iobase = it->options[0]; if (!request_region(iobase, AIO_IIRO_16_SIZE, dev->board_name)) { diff --git a/drivers/staging/comedi/drivers/cb_pcimdas.c b/drivers/staging/comedi/drivers/cb_pcimdas.c index 348c17e..c6dfcc6 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdas.c +++ b/drivers/staging/comedi/drivers/cb_pcimdas.c @@ -215,8 +215,6 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev, unsigned long iobase_8255; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c index 4ab2903..d2c7df5 100644 --- a/drivers/staging/comedi/drivers/cb_pcimdda.c +++ b/drivers/staging/comedi/drivers/cb_pcimdda.c @@ -160,8 +160,6 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/comedi_parport.c b/drivers/staging/comedi/drivers/comedi_parport.c index 76d59dc..e392f68 100644 --- a/drivers/staging/comedi/drivers/comedi_parport.c +++ b/drivers/staging/comedi/drivers/comedi_parport.c @@ -266,8 +266,6 @@ static int parport_attach(struct comedi_device *dev, unsigned long iobase; struct comedi_subdevice *s; - dev->board_name = dev->driver->driver_name; - iobase = it->options[0]; if (!request_region(iobase, PARPORT_SIZE, dev->board_name)) { dev_err(dev->class_dev, "I/O port conflict\n"); diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c index 270fea5..c1d8e86 100644 --- a/drivers/staging/comedi/drivers/comedi_test.c +++ b/drivers/staging/comedi/drivers/comedi_test.c @@ -384,8 +384,6 @@ static int waveform_attach(struct comedi_device *dev, int i; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/contec_pci_dio.c b/drivers/staging/comedi/drivers/contec_pci_dio.c index f79c46c..465287b 100644 --- a/drivers/staging/comedi/drivers/contec_pci_dio.c +++ b/drivers/staging/comedi/drivers/contec_pci_dio.c @@ -76,8 +76,6 @@ static int contec_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(dev, 0); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c index b0a861a..0cc3d04 100644 --- a/drivers/staging/comedi/drivers/das16m1.c +++ b/drivers/staging/comedi/drivers/das16m1.c @@ -573,8 +573,6 @@ static int das16m1_attach(struct comedi_device *dev, unsigned int irq; unsigned long iobase; - dev->board_name = dev->driver->driver_name; - iobase = it->options[0]; devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c index 9e21241..ca07e54 100644 --- a/drivers/staging/comedi/drivers/dmm32at.c +++ b/drivers/staging/comedi/drivers/dmm32at.c @@ -698,8 +698,6 @@ static int dmm32at_attach(struct comedi_device *dev, unsigned long iobase; unsigned int irq; - dev->board_name = dev->driver->driver_name; - iobase = it->options[0]; irq = it->options[1]; diff --git a/drivers/staging/comedi/drivers/dyna_pci10xx.c b/drivers/staging/comedi/drivers/dyna_pci10xx.c index d771a04..5d1e30e 100644 --- a/drivers/staging/comedi/drivers/dyna_pci10xx.c +++ b/drivers/staging/comedi/drivers/dyna_pci10xx.c @@ -187,8 +187,6 @@ static int dyna_pci10xx_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index 98becd3..b45a9bc 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -503,8 +503,6 @@ static int icp_multi_auto_attach(struct comedi_device *dev, resource_size_t iobase; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c index 98eb5b9..e93b7f3 100644 --- a/drivers/staging/comedi/drivers/jr3_pci.c +++ b/drivers/staging/comedi/drivers/jr3_pci.c @@ -700,7 +700,6 @@ static int jr3_pci_auto_attach(struct comedi_device *dev, return -EINVAL; break; } - dev->board_name = "jr3_pci"; result = comedi_pci_enable(dev, -1); if (result) diff --git a/drivers/staging/comedi/drivers/ke_counter.c b/drivers/staging/comedi/drivers/ke_counter.c index b634517..ff2badc 100644 --- a/drivers/staging/comedi/drivers/ke_counter.c +++ b/drivers/staging/comedi/drivers/ke_counter.c @@ -95,8 +95,6 @@ static int cnt_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - ret = comedi_pci_enable(dev, 0); if (ret) return ret; diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 9cc6092..d067ef7 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -202,8 +202,6 @@ static int daq700_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - link->config_flags |= CONF_AUTO_SET_IO; ret = comedi_pcmcia_enable(dev, NULL); if (ret) diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c index e1cc9d0..c17ffe3 100644 --- a/drivers/staging/comedi/drivers/ni_daq_dio24.c +++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c @@ -52,8 +52,6 @@ static int dio24_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - link->config_flags |= CONF_AUTO_SET_IO; ret = comedi_pcmcia_enable(dev, NULL); if (ret) diff --git a/drivers/staging/comedi/drivers/pcm3724.c b/drivers/staging/comedi/drivers/pcm3724.c index 5f062df..d78aeeb 100644 --- a/drivers/staging/comedi/drivers/pcm3724.c +++ b/drivers/staging/comedi/drivers/pcm3724.c @@ -230,8 +230,6 @@ static int pcm3724_attach(struct comedi_device *dev, unsigned int iorange; int ret, i; - dev->board_name = dev->driver->driver_name; - iobase = it->options[0]; iorange = PCM3724_SIZE; diff --git a/drivers/staging/comedi/drivers/pcmda12.c b/drivers/staging/comedi/drivers/pcmda12.c index 13f79f4..64b76e4 100644 --- a/drivers/staging/comedi/drivers/pcmda12.c +++ b/drivers/staging/comedi/drivers/pcmda12.c @@ -168,8 +168,6 @@ static int pcmda12_attach(struct comedi_device *dev, } dev->iobase = iobase; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/pcmmio.c b/drivers/staging/comedi/drivers/pcmmio.c index 5fa1fe0..a342e37 100644 --- a/drivers/staging/comedi/drivers/pcmmio.c +++ b/drivers/staging/comedi/drivers/pcmmio.c @@ -1038,8 +1038,6 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it) unsigned int irq[MAX_ASICS]; int ret; - dev->board_name = dev->driver->driver_name; - iobase = it->options[0]; irq[0] = it->options[1]; diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c index 911eb6b..e092ce8 100644 --- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c +++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c @@ -715,8 +715,6 @@ static int daqp_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/s526.c b/drivers/staging/comedi/drivers/s526.c index 39232b35..b490b47 100644 --- a/drivers/staging/comedi/drivers/s526.c +++ b/drivers/staging/comedi/drivers/s526.c @@ -555,8 +555,6 @@ static int s526_attach(struct comedi_device *dev, struct comedi_devconfig *it) int iobase; int ret; - dev->board_name = dev->driver->driver_name; - iobase = it->options[0]; if (!iobase || !request_region(iobase, S526_IOSIZE, dev->board_name)) { comedi_error(dev, "I/O port conflict"); diff --git a/drivers/staging/comedi/drivers/s626.c b/drivers/staging/comedi/drivers/s626.c index 7dc28aa..6f6ea63 100644 --- a/drivers/staging/comedi/drivers/s626.c +++ b/drivers/staging/comedi/drivers/s626.c @@ -2666,8 +2666,6 @@ static int s626_auto_attach(struct comedi_device *dev, struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) return -ENOMEM; diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c index e6177b4..4d6b4e6 100644 --- a/drivers/staging/comedi/drivers/serial2002.c +++ b/drivers/staging/comedi/drivers/serial2002.c @@ -786,7 +786,6 @@ static int serial2002_attach(struct comedi_device *dev, int ret; dev_dbg(dev->class_dev, "serial2002: attach\n"); - dev->board_name = dev->driver->driver_name; devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL); if (!devpriv) diff --git a/drivers/staging/comedi/drivers/ssv_dnp.c b/drivers/staging/comedi/drivers/ssv_dnp.c index afa4016..a76df09 100644 --- a/drivers/staging/comedi/drivers/ssv_dnp.c +++ b/drivers/staging/comedi/drivers/ssv_dnp.c @@ -167,8 +167,6 @@ static int dnp_attach(struct comedi_device *dev, struct comedi_devconfig *it) struct comedi_subdevice *s; int ret; - dev->board_name = dev->driver->driver_name; - ret = comedi_alloc_subdevices(dev, 1); if (ret) return ret; -- 1.8.1.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel