diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-20 21:26:15 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-20 21:26:15 -0700 |
commit | 3aa2fc1667acdd9cca816a2bc9529f494bd61b05 (patch) | |
tree | 2379f33e47edacbc7a4bdf19607642d9c53caa11 /drivers/gpio/gpio-104-idi-48.c | |
parent | 5af2344013454640e0133bb62e8cf2e30190a472 (diff) | |
parent | c6e360a0d9d282e9c8688dcdabdc3669912b66ef (diff) |
Merge tag 'driver-core-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core updates from Greg KH:
"Here's the "big" driver core update for 4.7-rc1.
Mostly just debugfs changes, the long-known and messy races with
removing debugfs files should be fixed thanks to the great work of
Nicolai Stange. We also have some isa updates in here (the x86
maintainers told me to take it through this tree), a new warning when
we run out of dynamic char major numbers, and a few other assorted
changes, details in the shortlog.
All have been in linux-next for some time with no reported issues"
* tag 'driver-core-4.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (32 commits)
Revert "base: dd: don't remove driver_data in -EPROBE_DEFER case"
gpio: ws16c48: Utilize the ISA bus driver
gpio: 104-idio-16: Utilize the ISA bus driver
gpio: 104-idi-48: Utilize the ISA bus driver
gpio: 104-dio-48e: Utilize the ISA bus driver
watchdog: ebc-c384_wdt: Utilize the ISA bus driver
iio: stx104: Utilize the module_isa_driver and max_num_isa_dev macros
iio: stx104: Add X86 dependency to STX104 Kconfig option
Documentation: Add ISA bus driver documentation
isa: Implement the max_num_isa_dev macro
isa: Implement the module_isa_driver macro
pnp: pnpbios: Add explicit X86_32 dependency to PNPBIOS
isa: Decouple X86_32 dependency from the ISA Kconfig option
driver-core: use 'dev' argument in dev_dbg_ratelimited stub
base: dd: don't remove driver_data in -EPROBE_DEFER case
kernfs: Move faulting copy_user operations outside of the mutex
devcoredump: add scatterlist support
debugfs: unproxify files created through debugfs_create_u32_array()
debugfs: unproxify files created through debugfs_create_blob()
debugfs: unproxify files created through debugfs_create_bool()
...
Diffstat (limited to 'drivers/gpio/gpio-104-idi-48.c')
-rw-r--r-- | drivers/gpio/gpio-104-idi-48.c | 86 |
1 files changed, 28 insertions, 58 deletions
diff --git a/drivers/gpio/gpio-104-idi-48.c b/drivers/gpio/gpio-104-idi-48.c index e37cd4cdda35..6c75c83baf5a 100644 --- a/drivers/gpio/gpio-104-idi-48.c +++ b/drivers/gpio/gpio-104-idi-48.c @@ -10,6 +10,9 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. + * + * This driver supports the following ACCES devices: 104-IDI-48A, + * 104-IDI-48AC, 104-IDI-48B, and 104-IDI-48BC. */ #include <linux/bitops.h> #include <linux/device.h> @@ -19,18 +22,23 @@ #include <linux/ioport.h> #include <linux/interrupt.h> #include <linux/irqdesc.h> +#include <linux/isa.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> -#include <linux/platform_device.h> #include <linux/spinlock.h> -static unsigned idi_48_base; -module_param(idi_48_base, uint, 0); -MODULE_PARM_DESC(idi_48_base, "ACCES 104-IDI-48 base address"); -static unsigned idi_48_irq; -module_param(idi_48_irq, uint, 0); -MODULE_PARM_DESC(idi_48_irq, "ACCES 104-IDI-48 interrupt line number"); +#define IDI_48_EXTENT 8 +#define MAX_NUM_IDI_48 max_num_isa_dev(IDI_48_EXTENT) + +static unsigned int base[MAX_NUM_IDI_48]; +static unsigned int num_idi_48; +module_param_array(base, uint, &num_idi_48, 0); +MODULE_PARM_DESC(base, "ACCES 104-IDI-48 base addresses"); + +static unsigned int irq[MAX_NUM_IDI_48]; +module_param_array(irq, uint, NULL, 0); +MODULE_PARM_DESC(irq, "ACCES 104-IDI-48 interrupt line numbers"); /** * struct idi_48_gpio - GPIO device private data structure @@ -211,23 +219,19 @@ static irqreturn_t idi_48_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static int __init idi_48_probe(struct platform_device *pdev) +static int idi_48_probe(struct device *dev, unsigned int id) { - struct device *dev = &pdev->dev; struct idi_48_gpio *idi48gpio; - const unsigned base = idi_48_base; - const unsigned extent = 8; const char *const name = dev_name(dev); int err; - const unsigned irq = idi_48_irq; idi48gpio = devm_kzalloc(dev, sizeof(*idi48gpio), GFP_KERNEL); if (!idi48gpio) return -ENOMEM; - if (!devm_request_region(dev, base, extent, name)) { + if (!devm_request_region(dev, base[id], IDI_48_EXTENT, name)) { dev_err(dev, "Unable to lock port addresses (0x%X-0x%X)\n", - base, base + extent); + base[id], base[id] + IDI_48_EXTENT); return -EBUSY; } @@ -239,8 +243,8 @@ static int __init idi_48_probe(struct platform_device *pdev) idi48gpio->chip.get_direction = idi_48_gpio_get_direction; idi48gpio->chip.direction_input = idi_48_gpio_direction_input; idi48gpio->chip.get = idi_48_gpio_get; - idi48gpio->base = base; - idi48gpio->irq = irq; + idi48gpio->base = base[id]; + idi48gpio->irq = irq[id]; spin_lock_init(&idi48gpio->lock); @@ -253,8 +257,8 @@ static int __init idi_48_probe(struct platform_device *pdev) } /* Disable IRQ by default */ - outb(0, base + 7); - inb(base + 7); + outb(0, base[id] + 7); + inb(base[id] + 7); err = gpiochip_irqchip_add(&idi48gpio->chip, &idi_48_irqchip, 0, handle_edge_irq, IRQ_TYPE_NONE); @@ -263,7 +267,7 @@ static int __init idi_48_probe(struct platform_device *pdev) goto err_gpiochip_remove; } - err = request_irq(irq, idi_48_irq_handler, IRQF_SHARED, name, + err = request_irq(irq[id], idi_48_irq_handler, IRQF_SHARED, name, idi48gpio); if (err) { dev_err(dev, "IRQ handler registering failed (%d)\n", err); @@ -277,9 +281,9 @@ err_gpiochip_remove: return err; } -static int idi_48_remove(struct platform_device *pdev) +static int idi_48_remove(struct device *dev, unsigned int id) { - struct idi_48_gpio *const idi48gpio = platform_get_drvdata(pdev); + struct idi_48_gpio *const idi48gpio = dev_get_drvdata(dev); free_irq(idi48gpio->irq, idi48gpio); gpiochip_remove(&idi48gpio->chip); @@ -287,48 +291,14 @@ static int idi_48_remove(struct platform_device *pdev) return 0; } -static struct platform_device *idi_48_device; - -static struct platform_driver idi_48_driver = { +static struct isa_driver idi_48_driver = { + .probe = idi_48_probe, .driver = { .name = "104-idi-48" }, .remove = idi_48_remove }; - -static void __exit idi_48_exit(void) -{ - platform_device_unregister(idi_48_device); - platform_driver_unregister(&idi_48_driver); -} - -static int __init idi_48_init(void) -{ - int err; - - idi_48_device = platform_device_alloc(idi_48_driver.driver.name, -1); - if (!idi_48_device) - return -ENOMEM; - - err = platform_device_add(idi_48_device); - if (err) - goto err_platform_device; - - err = platform_driver_probe(&idi_48_driver, idi_48_probe); - if (err) - goto err_platform_driver; - - return 0; - -err_platform_driver: - platform_device_del(idi_48_device); -err_platform_device: - platform_device_put(idi_48_device); - return err; -} - -module_init(idi_48_init); -module_exit(idi_48_exit); +module_isa_driver(idi_48_driver, num_idi_48); MODULE_AUTHOR("William Breathitt Gray <vilhelm.gray@gmail.com>"); MODULE_DESCRIPTION("ACCES 104-IDI-48 GPIO driver"); |