gpio: Add GPIO support for the ACCES 104-IDIO-16
Subsystems (2)
PATCH v9 1/1 gpio: Add GPIO support for the ACCES 104-IDIO-16
The ACCES 104-IDIO-16 family of PC/104 utility boards feature 16 optically isolated inputs and 16 optically isolated FET solid state outputs. This driver provides GPIO support for these 32 channels of digital I/O. Change-of-State detection interrupts are not supported.
GPIO 0-15 correspond to digital outputs 0-15, while GPIO 16-31 correspond to digital inputs 0-15. The base port address for the device may be set via the a_104_idio_16_base module parameter.
---
Changes in v9:
- Initialize GPIO device private data structure to 0 to prevent garbage data pollution
drivers/gpio/Kconfig | 10 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-104-idio-16.c | 219 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100644 drivers/gpio/gpio-104-idio-16.c
drivers/gpio/Kconfig +10 -0
@@ -684,6 +684,16 @@ config GPIO_SX150X endmenu +menu "ISA GPIO drivers" + +config GPIO_104_IDIO_16 + tristate "ACCES 104-IDIO-16 GPIO support" + depends on X86 + help + Enables GPIO support for the ACCES 104-IDIO-16 family. + +endmenu + menu "MFD GPIO expanders" config GPIO_ADP5520
drivers/gpio/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_GPIO_ACPI) += gpiolib-acpi.o # Device drivers. Generally keep list sorted alphabetically obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o +obj-$(CONFIG_GPIO_104_IDIO_16) += gpio-104-idio-16.o obj-$(CONFIG_GPIO_74X164) += gpio-74x164.o obj-$(CONFIG_GPIO_74XX_MMIO) += gpio-74xx-mmio.o obj-$(CONFIG_GPIO_ADNP) += gpio-adnp.o
drivers/gpio/gpio-104-idio-16.c new file +219 -0
219 lines not on this page · raw message
Signature · 1 line
2.4.9
Quoted 9 lines · William Breathitt Gray
The ACCES 104-IDIO-16 family of PC/104 utility boards feature 16 optically isolated inputs and 16 optically isolated FET solid state outputs. This driver provides GPIO support for these 32 channels of digital I/O. Change-of-State detection interrupts are not supported.
GPIO 0-15 correspond to digital outputs 0-15, while GPIO 16-31 correspond to digital inputs 0-15. The base port address for the device may be set via the
a_104_idio_16_basemodule parameter.
Quoted 5 lines
Signed-off-by William Breathitt Gray <[email protected]>---
Changes in v9:
- Initialize GPIO device private data structure to 0 to prevent garbage data pollution
Getting there...
drivers/gpio/gpio-104-idio-16.c line 28
Quoted 3 lines
drivers/gpio/gpio-104-idio-16.c new file +3
-0+static unsigned a_104_idio_16_base; +module_param (a_104_idio_16_base, uint,0 ); +MODULE_PARM_DESC (a_104_idio_16_base,"ACCES 104-IDIO-16 base address" );
This is nice!
drivers/gpio/gpio-104-idio-16.c line 114
Quoted 3 lines
drivers/gpio/gpio-104-idio-16.c new file +3
-0+static int __init a_104_idio_16_probe (struct platform_device *pdev) +{ +struct a_104_idio_16_gpio *const a104idio16gp = pdev->dev.platform_data;
No.
Why not just allocate zeroed it here in probe() like this:
struct a_104_idio_16_gpio *gp;
gp = devm_kzalloc(&pdev->dev, sizeof(*gp), GFP_KERNEL); if (!gp)
return -ENOMEM;
You may want to rename "a_104_idio_16_gpio" to something more everyday. This is hard to type.
drivers/gpio/gpio-104-idio-16.c line 191
Quoted 4 lines
drivers/gpio/gpio-104-idio-16.c new file +4
-0+static int __init a_104_idio_16_init (void ) +{ +int err; +const struct a_104_idio_16_gpio GP = {0 };
This just works by chance. The keyword you're looking for is not "const" but "static" if you want this to stay around. But do it as described above instead.
drivers/gpio/gpio-104-idio-16.c line 198
Quoted 6 lines
drivers/gpio/gpio-104-idio-16.c new file +6
-0+ a_104_idio_16_device =platform_device_register_data (NULL , + a_104_idio_16_driver.driver.name,-1 , &GP ,sizeof (GP )); +if (IS_ERR (a_104_idio_16_device)) { + err =PTR_ERR (a_104_idio_16_device); + goto out_platform_device; + }
Skip all this. Use devm_kzalloc() in probe as described.
Quoted 4 lines
drivers/gpio/gpio-104-idio-16.c new file +4
-0+ +dev_info (&a_104_idio_16_device->dev,"Initializing module\n" ); + + err =platform_driver_probe (&a_104_idio_16_driver, a_104_idio_16_probe);
drivers/gpio/gpio-104-idio-16.c line 212
Quoted 10 lines
drivers/gpio/gpio-104-idio-16.c new file +10
-0+if (err) + goto out_platform_driver; + +return 0 ; + +out_platform_driver: +platform_device_unregister (a_104_idio_16_device); +out_platform_device: +return err; +}
Then this can be just return platform_driver_probe(...);
Yours,
Linus Walleij