9
0
Fork 0

gpio: clps711x: Update driver

This patch updates the CLPS711X GPIO driver.
The update adds support for use with devicetree and
optimizes "probe" a bit.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Alexander Shiyan 2014-01-23 21:22:06 +04:00 committed by Sascha Hauer
parent 624454160b
commit 6c3e620e57
1 changed files with 25 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 Alexander Shiyan <shc_work@mail.ru>
* Copyright (C) 2013-2014 Alexander Shiyan <shc_work@mail.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@ -15,15 +15,18 @@
static int clps711x_gpio_probe(struct device_d *dev)
{
int err;
int err, id = dev->id;
void __iomem *dat, *dir = NULL, *dir_inv = NULL;
struct bgpio_chip *bgc;
if ((dev->id < 0) || (dev->id > 4))
if (dev->device_node)
id = of_alias_get_id(dev->device_node, "gpio");
if (id < 0 || id > 4)
return -ENODEV;
dat = dev_request_mem_region(dev, 0);
switch (dev->id) {
switch (id) {
case 3:
dir_inv = dev_request_mem_region(dev, 1);
break;
@ -40,27 +43,35 @@ static int clps711x_gpio_probe(struct device_d *dev)
return -ENOMEM;
err = bgpio_init(bgc, dev, 1, dat, NULL, NULL, dir, dir_inv, 0);
if (err) {
free(bgc);
return err;
}
if (err)
goto out_err;
bgc->gc.base = dev->id * 8;
switch (dev->id) {
bgc->gc.base = id * 8;
switch (id) {
case 4:
bgc->gc.ngpio = 3;
break;
default:
bgc->gc.ngpio = 8;
break;
}
return gpiochip_add(&bgc->gc);
err = gpiochip_add(&bgc->gc);
out_err:
if (err)
free(bgc);
return err;
}
static struct of_device_id __maybe_unused clps711x_gpio_dt_ids[] = {
{ .compatible = "cirrus,clps711x-gpio", },
};
static struct driver_d clps711x_gpio_driver = {
.name = "clps711x-gpio",
.probe = clps711x_gpio_probe,
.name = "clps711x-gpio",
.probe = clps711x_gpio_probe,
.of_compatible = DRV_OF_COMPAT(clps711x_gpio_dt_ids),
};
static __init int clps711x_gpio_register(void)