summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Shiyan <shc_work@mail.ru>2016-06-07 18:59:23 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-25 13:55:35 -0700
commit0e8cc7c2ea025b96b4ed57b52c61f2d982a95ddb (patch)
treefceefa73687a56ee44d59b4b5b774a20c6c86856
parent5bdb48b501e8366d5fd361cd402816aa3e525895 (diff)
downloadlinux-0e8cc7c2ea025b96b4ed57b52c61f2d982a95ddb.tar.gz
linux-0e8cc7c2ea025b96b4ed57b52c61f2d982a95ddb.tar.bz2
linux-0e8cc7c2ea025b96b4ed57b52c61f2d982a95ddb.zip
serial: max310x: Using resource-managed function for GPIO
Use resource managed functions devm_gpiochip_add_data() to make error & exit path a bit simpler. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/max310x.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index bf6e3e08ec67..6e2edbb942d6 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1193,9 +1193,11 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
s->gpio.base = -1;
s->gpio.ngpio = devtype->nr * 4;
s->gpio.can_sleep = 1;
- ret = gpiochip_add_data(&s->gpio, s);
- if (ret)
- goto out_uart;
+ ret = devm_gpiochip_add_data(dev, &s->gpio, s);
+ if (ret) {
+ uart_unregister_driver(&s->uart);
+ goto out_clk;
+ }
#endif
mutex_init(&s->mutex);
@@ -1244,11 +1246,6 @@ static int max310x_probe(struct device *dev, struct max310x_devtype *devtype,
mutex_destroy(&s->mutex);
-#ifdef CONFIG_GPIOLIB
- gpiochip_remove(&s->gpio);
-
-out_uart:
-#endif
uart_unregister_driver(&s->uart);
out_clk:
@@ -1262,10 +1259,6 @@ static int max310x_remove(struct device *dev)
struct max310x_port *s = dev_get_drvdata(dev);
int i;
-#ifdef CONFIG_GPIOLIB
- gpiochip_remove(&s->gpio);
-#endif
-
for (i = 0; i < s->uart.nr; i++) {
cancel_work_sync(&s->p[i].tx_work);
cancel_work_sync(&s->p[i].md_work);