diff options
-rw-r--r-- | drivers/gpio/gpio-em.c | 34 | ||||
-rw-r--r-- | drivers/gpio/gpio-madera.c | 6 | ||||
-rw-r--r-- | drivers/gpio/gpio-max732x.c | 45 | ||||
-rw-r--r-- | drivers/gpio/gpio-mockup.c | 21 | ||||
-rw-r--r-- | tools/gpio/.gitignore | 2 |
5 files changed, 33 insertions, 75 deletions
diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c index 982e699a5b81..299101d25fa8 100644 --- a/drivers/gpio/gpio-em.c +++ b/drivers/gpio/gpio-em.c @@ -282,10 +282,8 @@ static int em_gio_probe(struct platform_device *pdev) int ret; p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); - if (!p) { - ret = -ENOMEM; - goto err0; - } + if (!p) + return -ENOMEM; p->pdev = pdev; platform_set_drvdata(pdev, p); @@ -298,30 +296,22 @@ static int em_gio_probe(struct platform_device *pdev) if (!io[0] || !io[1] || !irq[0] || !irq[1]) { dev_err(&pdev->dev, "missing IRQ or IOMEM\n"); - ret = -EINVAL; - goto err0; + return -EINVAL; } p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start, resource_size(io[0])); - if (!p->base0) { - dev_err(&pdev->dev, "failed to remap low I/O memory\n"); - ret = -ENXIO; - goto err0; - } + if (!p->base0) + return -ENOMEM; p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start, resource_size(io[1])); - if (!p->base1) { - dev_err(&pdev->dev, "failed to remap high I/O memory\n"); - ret = -ENXIO; - goto err0; - } + if (!p->base1) + return -ENOMEM; if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) { dev_err(&pdev->dev, "Missing ngpios OF property\n"); - ret = -EINVAL; - goto err0; + return -EINVAL; } gpio_chip = &p->gpio_chip; @@ -351,9 +341,8 @@ static int em_gio_probe(struct platform_device *pdev) p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, ngpios, 0, &em_gio_irq_domain_ops, p); if (!p->irq_domain) { - ret = -ENXIO; dev_err(&pdev->dev, "cannot initialize irq domain\n"); - goto err0; + return -ENXIO; } if (devm_request_irq(&pdev->dev, irq[0]->start, @@ -370,7 +359,7 @@ static int em_gio_probe(struct platform_device *pdev) goto err1; } - ret = gpiochip_add_data(gpio_chip, p); + ret = devm_gpiochip_add_data(&pdev->dev, gpio_chip, p); if (ret) { dev_err(&pdev->dev, "failed to add GPIO controller\n"); goto err1; @@ -380,7 +369,6 @@ static int em_gio_probe(struct platform_device *pdev) err1: irq_domain_remove(p->irq_domain); -err0: return ret; } @@ -388,8 +376,6 @@ static int em_gio_remove(struct platform_device *pdev) { struct em_gio_priv *p = platform_get_drvdata(pdev); - gpiochip_remove(&p->gpio_chip); - irq_domain_remove(p->irq_domain); return 0; } diff --git a/drivers/gpio/gpio-madera.c b/drivers/gpio/gpio-madera.c index c9dad0543672..4dbc837d1215 100644 --- a/drivers/gpio/gpio-madera.c +++ b/drivers/gpio/gpio-madera.c @@ -1,12 +1,8 @@ -// SPDX-License-Identifier: GPL-2.0 +// SPDX-License-Identifier: GPL-2.0-only /* * GPIO support for Cirrus Logic Madera codecs * * Copyright (C) 2015-2018 Cirrus Logic - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by the - * Free Software Foundation; version 2. */ #include <linux/gpio/driver.h> diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index f03cb0ba7726..42c9b6ce4227 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c @@ -652,12 +652,12 @@ static int max732x_probe(struct i2c_client *client, case 0x60: chip->client_group_a = client; if (nr_port > 8) { - c = i2c_new_dummy(client->adapter, addr_b); - if (!c) { + c = devm_i2c_new_dummy_device(&client->dev, + client->adapter, addr_b); + if (IS_ERR(c)) { dev_err(&client->dev, "Failed to allocate I2C device\n"); - ret = -ENODEV; - goto out_failed; + return PTR_ERR(c); } chip->client_group_b = chip->client_dummy = c; } @@ -665,12 +665,12 @@ static int max732x_probe(struct i2c_client *client, case 0x50: chip->client_group_b = client; if (nr_port > 8) { - c = i2c_new_dummy(client->adapter, addr_a); - if (!c) { + c = devm_i2c_new_dummy_device(&client->dev, + client->adapter, addr_a); + if (IS_ERR(c)) { dev_err(&client->dev, "Failed to allocate I2C device\n"); - ret = -ENODEV; - goto out_failed; + return PTR_ERR(c); } chip->client_group_a = chip->client_dummy = c; } @@ -678,37 +678,33 @@ static int max732x_probe(struct i2c_client *client, default: dev_err(&client->dev, "invalid I2C address specified %02x\n", client->addr); - ret = -EINVAL; - goto out_failed; + return -EINVAL; } if (nr_port > 8 && !chip->client_dummy) { dev_err(&client->dev, "Failed to allocate second group I2C device\n"); - ret = -ENODEV; - goto out_failed; + return -ENODEV; } mutex_init(&chip->lock); ret = max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]); if (ret) - goto out_failed; + return ret; if (nr_port > 8) { ret = max732x_readb(chip, is_group_a(chip, 8), &chip->reg_out[1]); if (ret) - goto out_failed; + return ret; } - ret = gpiochip_add_data(&chip->gpio_chip, chip); + ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip); if (ret) - goto out_failed; + return ret; ret = max732x_irq_setup(chip, id); - if (ret) { - gpiochip_remove(&chip->gpio_chip); - goto out_failed; - } + if (ret) + return ret; if (pdata && pdata->setup) { ret = pdata->setup(client, chip->gpio_chip.base, @@ -719,10 +715,6 @@ static int max732x_probe(struct i2c_client *client, i2c_set_clientdata(client, chip); return 0; - -out_failed: - i2c_unregister_device(chip->client_dummy); - return ret; } static int max732x_remove(struct i2c_client *client) @@ -742,11 +734,6 @@ static int max732x_remove(struct i2c_client *client) } } - gpiochip_remove(&chip->gpio_chip); - - /* unregister any dummy i2c_client */ - i2c_unregister_device(chip->client_dummy); - return 0; } diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index b6a4efce7c92..f1a9c0544e3f 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -315,7 +315,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev, struct gpio_mockup_chip *chip) { struct gpio_mockup_dbgfs_private *priv; - struct dentry *evfile; struct gpio_chip *gc; const char *devname; char *name; @@ -325,32 +324,25 @@ static void gpio_mockup_debugfs_setup(struct device *dev, devname = dev_name(&gc->gpiodev->dev); chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir); - if (IS_ERR_OR_NULL(chip->dbg_dir)) - goto err; for (i = 0; i < gc->ngpio; i++) { name = devm_kasprintf(dev, GFP_KERNEL, "%d", i); if (!name) - goto err; + return; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) - goto err; + return; priv->chip = chip; priv->offset = i; priv->desc = &gc->gpiodev->descs[i]; - evfile = debugfs_create_file(name, 0200, chip->dbg_dir, priv, - &gpio_mockup_debugfs_ops); - if (IS_ERR_OR_NULL(evfile)) - goto err; + debugfs_create_file(name, 0200, chip->dbg_dir, priv, + &gpio_mockup_debugfs_ops); } return; - -err: - dev_err(dev, "error creating debugfs files\n"); } static int gpio_mockup_name_lines(struct device *dev, @@ -447,8 +439,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) if (rv) return rv; - if (!IS_ERR_OR_NULL(gpio_mockup_dbg_dir)) - gpio_mockup_debugfs_setup(dev, chip); + gpio_mockup_debugfs_setup(dev, chip); return 0; } @@ -501,8 +492,6 @@ static int __init gpio_mockup_init(void) } gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup", NULL); - if (IS_ERR_OR_NULL(gpio_mockup_dbg_dir)) - gpio_mockup_err("error creating debugfs directory\n"); err = platform_driver_register(&gpio_mockup_driver); if (err) { diff --git a/tools/gpio/.gitignore b/tools/gpio/.gitignore index 9e9dd4b681b2..a94c0e83b209 100644 --- a/tools/gpio/.gitignore +++ b/tools/gpio/.gitignore @@ -1,4 +1,4 @@ gpio-event-mon gpio-hammer lsgpio - +include/linux/gpio.h |