mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:46:16 +00:00
comedi: comedi_8254: Replace comedi_8254_init() and comedi_8254_mm_init()
`comedi_8254_init()` and `comedi_8254_mm_init()` return `NULL` on failure, but the failure is not necessarily due to lack of memory. Change them to return an `ERR_PTR` value on failure and rename the functions to make it obvious the API has changed. `comedi_8254_init()` has been replaced with `comedi_8254_io_alloc()`, and `comedi_8254_mm_init()` has been replaced with `comedi_8254_mm_alloc()`. Cc: Arnd Bergmann <arnd@kernel.org> Cc: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Link: https://lore.kernel.org/r/20230913170712.111719-4-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c62f5032f7
commit
fade5e5b0b
@ -177,7 +177,8 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev)
|
||||
dev->n_subdevices = 0;
|
||||
}
|
||||
kfree(dev->private);
|
||||
kfree(dev->pacer);
|
||||
if (!IS_ERR(dev->pacer))
|
||||
kfree(dev->pacer);
|
||||
dev->private = NULL;
|
||||
dev->pacer = NULL;
|
||||
dev->driver = NULL;
|
||||
|
@ -647,10 +647,10 @@ static int pci9111_auto_attach(struct comedi_device *dev,
|
||||
dev->irq = pcidev->irq;
|
||||
}
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCI9111_8254_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO16, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + PCI9111_8254_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO16, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
|
@ -1524,10 +1524,10 @@ static int pci9118_common_attach(struct comedi_device *dev,
|
||||
devpriv->iobase_a = pci_resource_start(pcidev, 0);
|
||||
dev->iobase = pci_resource_start(pcidev, 2);
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCI9118_TIMER_BASE,
|
||||
I8254_OSC_BASE_4MHZ, I8254_IO32, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + PCI9118_TIMER_BASE,
|
||||
I8254_OSC_BASE_4MHZ, I8254_IO32, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
pci9118_reset(dev);
|
||||
|
||||
|
@ -767,10 +767,10 @@ static int pci1710_auto_attach(struct comedi_device *dev,
|
||||
return ret;
|
||||
dev->iobase = pci_resource_start(pcidev, 2);
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCI171X_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO16, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + PCI171X_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO16, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
n_subdevices = 1; /* all boards have analog inputs */
|
||||
if (board->has_ao)
|
||||
|
@ -664,11 +664,11 @@ static int pci_dio_auto_attach(struct comedi_device *dev,
|
||||
if (board->timer_regbase) {
|
||||
s = &dev->subdevices[subdev++];
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase +
|
||||
board->timer_regbase,
|
||||
0, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer =
|
||||
comedi_8254_io_alloc(dev->iobase + board->timer_regbase,
|
||||
0, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
comedi_8254_subdevice_init(s, dev->pacer);
|
||||
}
|
||||
|
@ -206,10 +206,10 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + AIO12_8_8254_BASE_REG,
|
||||
0, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + AIO12_8_8254_BASE_REG,
|
||||
0, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
|
@ -556,14 +556,14 @@ static int dio200_subdev_8254_init(struct comedi_device *dev,
|
||||
}
|
||||
|
||||
if (dev->mmio) {
|
||||
i8254 = comedi_8254_mm_init(dev->mmio + offset,
|
||||
0, I8254_IO8, regshift);
|
||||
i8254 = comedi_8254_mm_alloc(dev->mmio + offset,
|
||||
0, I8254_IO8, regshift);
|
||||
} else {
|
||||
i8254 = comedi_8254_init(dev->iobase + offset,
|
||||
0, I8254_IO8, regshift);
|
||||
i8254 = comedi_8254_io_alloc(dev->iobase + offset,
|
||||
0, I8254_IO8, regshift);
|
||||
}
|
||||
if (!i8254)
|
||||
return -ENOMEM;
|
||||
if (IS_ERR(i8254))
|
||||
return PTR_ERR(i8254);
|
||||
|
||||
comedi_8254_subdevice_init(s, i8254);
|
||||
|
||||
|
@ -1051,10 +1051,10 @@ pci224_auto_attach(struct comedi_device *dev, unsigned long context_model)
|
||||
outw(devpriv->daccon | PCI224_DACCON_FIFORESET,
|
||||
dev->iobase + PCI224_DACCON);
|
||||
|
||||
dev->pacer = comedi_8254_init(devpriv->iobase1 + PCI224_Z2_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(devpriv->iobase1 + PCI224_Z2_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 1);
|
||||
if (ret)
|
||||
|
@ -2475,10 +2475,10 @@ static int pci230_auto_attach(struct comedi_device *dev,
|
||||
dev->irq = pci_dev->irq;
|
||||
}
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCI230_Z2_CT_BASE,
|
||||
0, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + PCI230_Z2_CT_BASE,
|
||||
0, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
rc = comedi_alloc_subdevices(dev, 3);
|
||||
if (rc)
|
||||
|
@ -363,10 +363,10 @@ static int das16cs_auto_attach(struct comedi_device *dev,
|
||||
if (!devpriv)
|
||||
return -ENOMEM;
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + DAS16CS_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO16, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + DAS16CS_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO16, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
|
@ -1288,16 +1288,16 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev,
|
||||
}
|
||||
dev->irq = pcidev->irq;
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCIDAS_AI_8254_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + PCIDAS_AI_8254_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
devpriv->ao_pacer = comedi_8254_init(dev->iobase + PCIDAS_AO_8254_BASE,
|
||||
I8254_OSC_BASE_10MHZ,
|
||||
I8254_IO8, 0);
|
||||
if (!devpriv->ao_pacer)
|
||||
return -ENOMEM;
|
||||
devpriv->ao_pacer =
|
||||
comedi_8254_io_alloc(dev->iobase + PCIDAS_AO_8254_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(devpriv->ao_pacer))
|
||||
return PTR_ERR(devpriv->ao_pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 7);
|
||||
if (ret)
|
||||
@ -1453,7 +1453,8 @@ static void cb_pcidas_detach(struct comedi_device *dev)
|
||||
if (devpriv->amcc)
|
||||
outl(INTCSR_INBOX_INTR_STATUS,
|
||||
devpriv->amcc + AMCC_OP_REG_INTCSR);
|
||||
kfree(devpriv->ao_pacer);
|
||||
if (!IS_ERR(devpriv->ao_pacer))
|
||||
kfree(devpriv->ao_pacer);
|
||||
}
|
||||
comedi_pci_detach(dev);
|
||||
}
|
||||
|
@ -364,11 +364,11 @@ static int cb_pcimdas_auto_attach(struct comedi_device *dev,
|
||||
devpriv->BADR3 = pci_resource_start(pcidev, 3);
|
||||
dev->iobase = pci_resource_start(pcidev, 4);
|
||||
|
||||
dev->pacer = comedi_8254_init(devpriv->BADR3 + PCIMDAS_8254_BASE,
|
||||
cb_pcimdas_pacer_clk(dev),
|
||||
I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(devpriv->BADR3 + PCIMDAS_8254_BASE,
|
||||
cb_pcimdas_pacer_clk(dev),
|
||||
I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 6);
|
||||
if (ret)
|
||||
|
@ -24,14 +24,17 @@
|
||||
*
|
||||
* This module provides the following basic functions:
|
||||
*
|
||||
* comedi_8254_init() / comedi_8254_mm_init()
|
||||
* comedi_8254_io_alloc() / comedi_8254_mm_alloc()
|
||||
* Initializes this module to access the 8254 registers. The _mm version
|
||||
* sets up the module for MMIO register access the other for PIO access.
|
||||
* The pointer returned from these functions is normally stored in the
|
||||
* comedi_device dev->pacer and will be freed by the comedi core during
|
||||
* the driver (*detach). If a driver has multiple 8254 devices, they need
|
||||
* to be stored in the drivers private data and freed when the driver is
|
||||
* detached.
|
||||
* sets up the module for MMIO register access; the _io version sets it
|
||||
* up for PIO access. These functions return a pointer to a struct
|
||||
* comedi_8254 on success, or an ERR_PTR value on failure. The pointer
|
||||
* returned from these functions is normally stored in the comedi_device
|
||||
* dev->pacer and will be freed by the comedi core during the driver
|
||||
* (*detach). If a driver has multiple 8254 devices, they need to be
|
||||
* stored in the drivers private data and freed when the driver is
|
||||
* detached. If the ERR_PTR value is stored, code should check the
|
||||
* pointer value with !IS_ERR(pointer) before freeing.
|
||||
*
|
||||
* NOTE: The counters are reset by setting them to I8254_MODE0 as part of
|
||||
* this initialization.
|
||||
@ -621,14 +624,14 @@ static struct comedi_8254 *__i8254_init(comedi_8254_iocb_fn *iocb,
|
||||
/* sanity check that the iosize is valid */
|
||||
if (!(iosize == I8254_IO8 || iosize == I8254_IO16 ||
|
||||
iosize == I8254_IO32))
|
||||
return NULL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
if (!iocb)
|
||||
return NULL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
i8254 = kzalloc(sizeof(*i8254), GFP_KERNEL);
|
||||
if (!i8254)
|
||||
return NULL;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
i8254->iocb = iocb;
|
||||
i8254->context = context;
|
||||
@ -646,17 +649,19 @@ static struct comedi_8254 *__i8254_init(comedi_8254_iocb_fn *iocb,
|
||||
}
|
||||
|
||||
/**
|
||||
* comedi_8254_init - allocate and initialize the 8254 device for pio access
|
||||
* comedi_8254_io_alloc - allocate and initialize the 8254 device for pio access
|
||||
* @iobase: port I/O base address
|
||||
* @osc_base: base time of the counter in ns
|
||||
* OPTIONAL - only used by comedi_8254_cascade_ns_to_timer()
|
||||
* @iosize: I/O register size
|
||||
* @regshift: register gap shift
|
||||
*
|
||||
* Return: A pointer to a struct comedi_8254 or an ERR_PTR value.
|
||||
*/
|
||||
struct comedi_8254 *comedi_8254_init(unsigned long iobase,
|
||||
unsigned int osc_base,
|
||||
unsigned int iosize,
|
||||
unsigned int regshift)
|
||||
struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase,
|
||||
unsigned int osc_base,
|
||||
unsigned int iosize,
|
||||
unsigned int regshift)
|
||||
{
|
||||
comedi_8254_iocb_fn *iocb;
|
||||
|
||||
@ -671,24 +676,26 @@ struct comedi_8254 *comedi_8254_init(unsigned long iobase,
|
||||
iocb = i8254_io32_cb;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
return __i8254_init(iocb, iobase, osc_base, iosize, regshift);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(comedi_8254_init);
|
||||
EXPORT_SYMBOL_GPL(comedi_8254_io_alloc);
|
||||
|
||||
/**
|
||||
* comedi_8254_mm_init - allocate and initialize the 8254 device for mmio access
|
||||
* comedi_8254_mm_alloc - allocate and initialize the 8254 device for mmio access
|
||||
* @mmio: memory mapped I/O base address
|
||||
* @osc_base: base time of the counter in ns
|
||||
* OPTIONAL - only used by comedi_8254_cascade_ns_to_timer()
|
||||
* @iosize: I/O register size
|
||||
* @regshift: register gap shift
|
||||
*
|
||||
* Return: A pointer to a struct comedi_8254 or an ERR_PTR value.
|
||||
*/
|
||||
struct comedi_8254 *comedi_8254_mm_init(void __iomem *mmio,
|
||||
unsigned int osc_base,
|
||||
unsigned int iosize,
|
||||
unsigned int regshift)
|
||||
struct comedi_8254 *comedi_8254_mm_alloc(void __iomem *mmio,
|
||||
unsigned int osc_base,
|
||||
unsigned int iosize,
|
||||
unsigned int regshift)
|
||||
{
|
||||
comedi_8254_iocb_fn *iocb;
|
||||
|
||||
@ -703,11 +710,11 @@ struct comedi_8254 *comedi_8254_mm_init(void __iomem *mmio,
|
||||
iocb = i8254_mmio32_cb;
|
||||
break;
|
||||
default:
|
||||
return NULL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
return __i8254_init(iocb, (unsigned long)mmio, osc_base, iosize, regshift);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(comedi_8254_mm_init);
|
||||
EXPORT_SYMBOL_GPL(comedi_8254_mm_alloc);
|
||||
|
||||
static int __init comedi_8254_module_init(void)
|
||||
{
|
||||
|
@ -439,10 +439,11 @@ int das08_common_attach(struct comedi_device *dev, unsigned long iobase)
|
||||
/* Counter subdevice (8254) */
|
||||
s = &dev->subdevices[5];
|
||||
if (board->i8254_offset) {
|
||||
dev->pacer = comedi_8254_init(dev->iobase + board->i8254_offset,
|
||||
0, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer =
|
||||
comedi_8254_io_alloc(dev->iobase + board->i8254_offset,
|
||||
0, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
comedi_8254_subdevice_init(s, dev->pacer);
|
||||
} else {
|
||||
|
@ -1067,10 +1067,10 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
osc_base = I8254_OSC_BASE_1MHZ / it->options[3];
|
||||
}
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + DAS16_TIMER_BASE_REG,
|
||||
osc_base, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + DAS16_TIMER_BASE_REG,
|
||||
osc_base, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
das16_alloc_dma(dev, it->options[2]);
|
||||
|
||||
|
@ -529,15 +529,16 @@ static int das16m1_attach(struct comedi_device *dev,
|
||||
dev->irq = it->options[1];
|
||||
}
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + DAS16M1_8254_IOBASE2,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + DAS16M1_8254_IOBASE2,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
devpriv->counter = comedi_8254_init(dev->iobase + DAS16M1_8254_IOBASE1,
|
||||
0, I8254_IO8, 0);
|
||||
if (!devpriv->counter)
|
||||
return -ENOMEM;
|
||||
devpriv->counter =
|
||||
comedi_8254_io_alloc(dev->iobase + DAS16M1_8254_IOBASE1,
|
||||
0, I8254_IO8, 0);
|
||||
if (IS_ERR(devpriv->counter))
|
||||
return PTR_ERR(devpriv->counter);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
@ -603,7 +604,8 @@ static void das16m1_detach(struct comedi_device *dev)
|
||||
if (devpriv) {
|
||||
if (devpriv->extra_iobase)
|
||||
release_region(devpriv->extra_iobase, DAS16M1_SIZE2);
|
||||
kfree(devpriv->counter);
|
||||
if (!IS_ERR(devpriv->counter))
|
||||
kfree(devpriv->counter);
|
||||
}
|
||||
comedi_legacy_detach(dev);
|
||||
}
|
||||
|
@ -1233,10 +1233,10 @@ static int das1800_attach(struct comedi_device *dev,
|
||||
if (!devpriv->fifo_buf)
|
||||
return -ENOMEM;
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + DAS1800_COUNTER,
|
||||
I8254_OSC_BASE_5MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + DAS1800_COUNTER,
|
||||
I8254_OSC_BASE_5MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
|
@ -590,10 +590,10 @@ static int das6402_attach(struct comedi_device *dev,
|
||||
}
|
||||
}
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + DAS6402_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + DAS6402_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
|
@ -672,10 +672,10 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
dev->irq = irq;
|
||||
}
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + DAS800_8254,
|
||||
I8254_OSC_BASE_1MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + DAS800_8254,
|
||||
I8254_OSC_BASE_1MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 3);
|
||||
if (ret)
|
||||
|
@ -1209,9 +1209,9 @@ static int me4000_auto_attach(struct comedi_device *dev,
|
||||
if (!timer_base)
|
||||
return -ENODEV;
|
||||
|
||||
dev->pacer = comedi_8254_init(timer_base, 0, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(timer_base, 0, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
comedi_8254_subdevice_init(s, dev->pacer);
|
||||
} else {
|
||||
|
@ -707,10 +707,10 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
/* an IRQ and DMA are required to support async commands */
|
||||
a2150_alloc_irq_and_dma(dev, it);
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + I8253_BASE_REG,
|
||||
0, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + I8253_BASE_REG,
|
||||
0, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 1);
|
||||
if (ret)
|
||||
|
@ -303,10 +303,10 @@ static int atao_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
if (!devpriv)
|
||||
return -ENOMEM;
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + ATAO_82C53_BASE,
|
||||
0, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + ATAO_82C53_BASE,
|
||||
0, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
|
@ -1222,24 +1222,24 @@ int labpc_common_attach(struct comedi_device *dev,
|
||||
}
|
||||
|
||||
if (dev->mmio) {
|
||||
dev->pacer = comedi_8254_mm_init(dev->mmio + COUNTER_B_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ,
|
||||
I8254_IO8, 0);
|
||||
devpriv->counter = comedi_8254_mm_init(dev->mmio +
|
||||
COUNTER_A_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ,
|
||||
I8254_IO8, 0);
|
||||
dev->pacer =
|
||||
comedi_8254_mm_alloc(dev->mmio + COUNTER_B_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO8, 0);
|
||||
devpriv->counter =
|
||||
comedi_8254_mm_alloc(dev->mmio + COUNTER_A_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO8, 0);
|
||||
} else {
|
||||
dev->pacer = comedi_8254_init(dev->iobase + COUNTER_B_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ,
|
||||
I8254_IO8, 0);
|
||||
devpriv->counter = comedi_8254_init(dev->iobase +
|
||||
COUNTER_A_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ,
|
||||
I8254_IO8, 0);
|
||||
dev->pacer =
|
||||
comedi_8254_io_alloc(dev->iobase + COUNTER_B_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO8, 0);
|
||||
devpriv->counter =
|
||||
comedi_8254_io_alloc(dev->iobase + COUNTER_A_BASE_REG,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO8, 0);
|
||||
}
|
||||
if (!dev->pacer || !devpriv->counter)
|
||||
return -ENOMEM;
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
if (IS_ERR(devpriv->counter))
|
||||
return PTR_ERR(devpriv->counter);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 5);
|
||||
if (ret)
|
||||
@ -1341,8 +1341,10 @@ void labpc_common_detach(struct comedi_device *dev)
|
||||
{
|
||||
struct labpc_private *devpriv = dev->private;
|
||||
|
||||
if (devpriv)
|
||||
kfree(devpriv->counter);
|
||||
if (devpriv) {
|
||||
if (!IS_ERR(devpriv->counter))
|
||||
kfree(devpriv->counter);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(labpc_common_detach);
|
||||
|
||||
|
@ -429,10 +429,10 @@ static int pcl711_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
dev->irq = it->options[1];
|
||||
}
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCL711_TIMER_BASE,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + PCL711_TIMER_BASE,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
|
@ -1143,11 +1143,11 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
return ret;
|
||||
|
||||
if (board->irq_bits) {
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCL812_TIMER_BASE,
|
||||
I8254_OSC_BASE_2MHZ,
|
||||
I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer =
|
||||
comedi_8254_io_alloc(dev->iobase + PCL812_TIMER_BASE,
|
||||
I8254_OSC_BASE_2MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
if ((1 << it->options[1]) & board->irq_bits) {
|
||||
ret = request_irq(it->options[1], pcl812_interrupt, 0,
|
||||
|
@ -615,10 +615,10 @@ static int pcl816_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
/* an IRQ and DMA are required to support async commands */
|
||||
pcl816_alloc_irq_and_dma(dev, it);
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCL816_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + PCL816_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
|
@ -1015,10 +1015,10 @@ static int pcl818_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
else
|
||||
osc_base = I8254_OSC_BASE_1MHZ;
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + PCL818_TIMER_BASE,
|
||||
osc_base, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
dev->pacer = comedi_8254_io_alloc(dev->iobase + PCL818_TIMER_BASE,
|
||||
osc_base, I8254_IO8, 0);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return PTR_ERR(dev->pacer);
|
||||
|
||||
/* max sampling speed */
|
||||
devpriv->ns_min = board->ns_min;
|
||||
|
@ -1289,9 +1289,9 @@ static int rtd_auto_attach(struct comedi_device *dev,
|
||||
|
||||
/* 8254 Timer/Counter subdevice */
|
||||
s = &dev->subdevices[3];
|
||||
dev->pacer = comedi_8254_mm_init(dev->mmio + LAS0_8254_TIMER_BASE,
|
||||
RTD_CLOCK_BASE, I8254_IO8, 2);
|
||||
if (!dev->pacer)
|
||||
dev->pacer = comedi_8254_mm_alloc(dev->mmio + LAS0_8254_TIMER_BASE,
|
||||
RTD_CLOCK_BASE, I8254_IO8, 2);
|
||||
if (IS_ERR(dev->pacer))
|
||||
return -ENOMEM;
|
||||
|
||||
comedi_8254_subdevice_init(s, dev->pacer);
|
||||
|
@ -136,13 +136,13 @@ void comedi_8254_set_busy(struct comedi_8254 *i8254,
|
||||
void comedi_8254_subdevice_init(struct comedi_subdevice *s,
|
||||
struct comedi_8254 *i8254);
|
||||
|
||||
struct comedi_8254 *comedi_8254_init(unsigned long iobase,
|
||||
unsigned int osc_base,
|
||||
unsigned int iosize,
|
||||
unsigned int regshift);
|
||||
struct comedi_8254 *comedi_8254_mm_init(void __iomem *mmio,
|
||||
unsigned int osc_base,
|
||||
unsigned int iosize,
|
||||
unsigned int regshift);
|
||||
struct comedi_8254 *comedi_8254_io_alloc(unsigned long iobase,
|
||||
unsigned int osc_base,
|
||||
unsigned int iosize,
|
||||
unsigned int regshift);
|
||||
struct comedi_8254 *comedi_8254_mm_alloc(void __iomem *mmio,
|
||||
unsigned int osc_base,
|
||||
unsigned int iosize,
|
||||
unsigned int regshift);
|
||||
|
||||
#endif /* _COMEDI_8254_H */
|
||||
|
Loading…
Reference in New Issue
Block a user