gpio: updates for v5.3

- add include/linux/gpio.h to .gitignore in /tools
 - improve and simplify code in the em driver
 - simplify code in max732x by using devm helpers (including the new
   devm_i2c_new_dummy_device())
 - fix SPDX header for madera
 - remove checking of return values of debugfs routines in gpio-mockup
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAl0U1WkACgkQEacuoBRx
 13K77Q//XrOD5oHh7yoNttxghRs9DSQrKWmwGoICCd01M870bx60MsfqyGgLowSa
 NHgeOr9+BjYHfVhfx8dGobo1EDq6YDiMJUPT++GFFwAgu6RlYpdKvCSm0/KqN8bG
 8qkR3BTLQHTUZgMa9Xkj/qFwGMpETqHLsKx3PUjsNESesv6dSI01kJa9meansjtS
 H8rrDymQPdewzfeHcYWaCA2AiUMCxmCPygQAbpIyhnASW5GGfsemtsXCIHANp5nC
 /TqTdTMUrUBAh7uD43pw7lNBLoSjBGEQRqAOuri2BmUKDUlTJvrC7+9CQz94+bz1
 CL23RbChtb94xI+iEPvXo/b6reDg6ulAYuv9UiuGHA+MEPvo/CTobKTK1pSlLjSX
 zZ05/vrpVzla/AH3smtbmvwsNeQIF+2FGuqSrvxP9dZ6Ql0XEh2TxkBHgMyrxc7m
 W37Mnx+mPbUINkkXr9BXCi8k+zKIwCUZy5B23CUAsS4vx/ONlOzr8VEbQiqa4dn3
 TRHG8gUctdHc/Ei/ybeY5HCE5dFCQ+yYQy79RDyJUObht2Ican6axm+h6Ik1nU2M
 dP1x/bGzCeVTQvQ7lo+fku7N36CpNR0Je9F+JlUdfdqg7gspbPvMsq2G9n33/a7O
 bvJJPBkFdFkzFe2Zxvew/V/mcjJfmjWCvEKZRGT44uz2H7e2Avo=
 =55gk
 -----END PGP SIGNATURE-----

Merge tag 'gpio-v5.3-updates-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into devel

gpio: updates for v5.3

- add include/linux/gpio.h to .gitignore in /tools
- improve and simplify code in the em driver
- simplify code in max732x by using devm helpers (including the new
  devm_i2c_new_dummy_device())
- fix SPDX header for madera
- remove checking of return values of debugfs routines in gpio-mockup
This commit is contained in:
Linus Walleij 2019-06-27 15:59:16 +01:00
commit da6070fc55
5 changed files with 33 additions and 75 deletions

View File

@ -282,10 +282,8 @@ static int em_gio_probe(struct platform_device *pdev)
int ret; int ret;
p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL); p = devm_kzalloc(&pdev->dev, sizeof(*p), GFP_KERNEL);
if (!p) { if (!p)
ret = -ENOMEM; return -ENOMEM;
goto err0;
}
p->pdev = pdev; p->pdev = pdev;
platform_set_drvdata(pdev, p); 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]) { if (!io[0] || !io[1] || !irq[0] || !irq[1]) {
dev_err(&pdev->dev, "missing IRQ or IOMEM\n"); dev_err(&pdev->dev, "missing IRQ or IOMEM\n");
ret = -EINVAL; return -EINVAL;
goto err0;
} }
p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start, p->base0 = devm_ioremap_nocache(&pdev->dev, io[0]->start,
resource_size(io[0])); resource_size(io[0]));
if (!p->base0) { if (!p->base0)
dev_err(&pdev->dev, "failed to remap low I/O memory\n"); return -ENOMEM;
ret = -ENXIO;
goto err0;
}
p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start, p->base1 = devm_ioremap_nocache(&pdev->dev, io[1]->start,
resource_size(io[1])); resource_size(io[1]));
if (!p->base1) { if (!p->base1)
dev_err(&pdev->dev, "failed to remap high I/O memory\n"); return -ENOMEM;
ret = -ENXIO;
goto err0;
}
if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) { if (of_property_read_u32(pdev->dev.of_node, "ngpios", &ngpios)) {
dev_err(&pdev->dev, "Missing ngpios OF property\n"); dev_err(&pdev->dev, "Missing ngpios OF property\n");
ret = -EINVAL; return -EINVAL;
goto err0;
} }
gpio_chip = &p->gpio_chip; 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, p->irq_domain = irq_domain_add_simple(pdev->dev.of_node, ngpios, 0,
&em_gio_irq_domain_ops, p); &em_gio_irq_domain_ops, p);
if (!p->irq_domain) { if (!p->irq_domain) {
ret = -ENXIO;
dev_err(&pdev->dev, "cannot initialize irq domain\n"); dev_err(&pdev->dev, "cannot initialize irq domain\n");
goto err0; return -ENXIO;
} }
if (devm_request_irq(&pdev->dev, irq[0]->start, if (devm_request_irq(&pdev->dev, irq[0]->start,
@ -370,7 +359,7 @@ static int em_gio_probe(struct platform_device *pdev)
goto err1; goto err1;
} }
ret = gpiochip_add_data(gpio_chip, p); ret = devm_gpiochip_add_data(&pdev->dev, gpio_chip, p);
if (ret) { if (ret) {
dev_err(&pdev->dev, "failed to add GPIO controller\n"); dev_err(&pdev->dev, "failed to add GPIO controller\n");
goto err1; goto err1;
@ -380,7 +369,6 @@ static int em_gio_probe(struct platform_device *pdev)
err1: err1:
irq_domain_remove(p->irq_domain); irq_domain_remove(p->irq_domain);
err0:
return ret; return ret;
} }
@ -388,8 +376,6 @@ static int em_gio_remove(struct platform_device *pdev)
{ {
struct em_gio_priv *p = platform_get_drvdata(pdev); struct em_gio_priv *p = platform_get_drvdata(pdev);
gpiochip_remove(&p->gpio_chip);
irq_domain_remove(p->irq_domain); irq_domain_remove(p->irq_domain);
return 0; return 0;
} }

View File

@ -1,12 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0-only
/* /*
* GPIO support for Cirrus Logic Madera codecs * GPIO support for Cirrus Logic Madera codecs
* *
* Copyright (C) 2015-2018 Cirrus Logic * 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> #include <linux/gpio/driver.h>

View File

@ -652,12 +652,12 @@ static int max732x_probe(struct i2c_client *client,
case 0x60: case 0x60:
chip->client_group_a = client; chip->client_group_a = client;
if (nr_port > 8) { if (nr_port > 8) {
c = i2c_new_dummy(client->adapter, addr_b); c = devm_i2c_new_dummy_device(&client->dev,
if (!c) { client->adapter, addr_b);
if (IS_ERR(c)) {
dev_err(&client->dev, dev_err(&client->dev,
"Failed to allocate I2C device\n"); "Failed to allocate I2C device\n");
ret = -ENODEV; return PTR_ERR(c);
goto out_failed;
} }
chip->client_group_b = chip->client_dummy = c; chip->client_group_b = chip->client_dummy = c;
} }
@ -665,12 +665,12 @@ static int max732x_probe(struct i2c_client *client,
case 0x50: case 0x50:
chip->client_group_b = client; chip->client_group_b = client;
if (nr_port > 8) { if (nr_port > 8) {
c = i2c_new_dummy(client->adapter, addr_a); c = devm_i2c_new_dummy_device(&client->dev,
if (!c) { client->adapter, addr_a);
if (IS_ERR(c)) {
dev_err(&client->dev, dev_err(&client->dev,
"Failed to allocate I2C device\n"); "Failed to allocate I2C device\n");
ret = -ENODEV; return PTR_ERR(c);
goto out_failed;
} }
chip->client_group_a = chip->client_dummy = c; chip->client_group_a = chip->client_dummy = c;
} }
@ -678,37 +678,33 @@ static int max732x_probe(struct i2c_client *client,
default: default:
dev_err(&client->dev, "invalid I2C address specified %02x\n", dev_err(&client->dev, "invalid I2C address specified %02x\n",
client->addr); client->addr);
ret = -EINVAL; return -EINVAL;
goto out_failed;
} }
if (nr_port > 8 && !chip->client_dummy) { if (nr_port > 8 && !chip->client_dummy) {
dev_err(&client->dev, dev_err(&client->dev,
"Failed to allocate second group I2C device\n"); "Failed to allocate second group I2C device\n");
ret = -ENODEV; return -ENODEV;
goto out_failed;
} }
mutex_init(&chip->lock); mutex_init(&chip->lock);
ret = max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]); ret = max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]);
if (ret) if (ret)
goto out_failed; return ret;
if (nr_port > 8) { if (nr_port > 8) {
ret = max732x_readb(chip, is_group_a(chip, 8), &chip->reg_out[1]); ret = max732x_readb(chip, is_group_a(chip, 8), &chip->reg_out[1]);
if (ret) 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) if (ret)
goto out_failed; return ret;
ret = max732x_irq_setup(chip, id); ret = max732x_irq_setup(chip, id);
if (ret) { if (ret)
gpiochip_remove(&chip->gpio_chip); return ret;
goto out_failed;
}
if (pdata && pdata->setup) { if (pdata && pdata->setup) {
ret = pdata->setup(client, chip->gpio_chip.base, 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); i2c_set_clientdata(client, chip);
return 0; return 0;
out_failed:
i2c_unregister_device(chip->client_dummy);
return ret;
} }
static int max732x_remove(struct i2c_client *client) 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; return 0;
} }

View File

@ -315,7 +315,6 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
struct gpio_mockup_chip *chip) struct gpio_mockup_chip *chip)
{ {
struct gpio_mockup_dbgfs_private *priv; struct gpio_mockup_dbgfs_private *priv;
struct dentry *evfile;
struct gpio_chip *gc; struct gpio_chip *gc;
const char *devname; const char *devname;
char *name; char *name;
@ -325,32 +324,25 @@ static void gpio_mockup_debugfs_setup(struct device *dev,
devname = dev_name(&gc->gpiodev->dev); devname = dev_name(&gc->gpiodev->dev);
chip->dbg_dir = debugfs_create_dir(devname, gpio_mockup_dbg_dir); 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++) { for (i = 0; i < gc->ngpio; i++) {
name = devm_kasprintf(dev, GFP_KERNEL, "%d", i); name = devm_kasprintf(dev, GFP_KERNEL, "%d", i);
if (!name) if (!name)
goto err; return;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv) if (!priv)
goto err; return;
priv->chip = chip; priv->chip = chip;
priv->offset = i; priv->offset = i;
priv->desc = &gc->gpiodev->descs[i]; priv->desc = &gc->gpiodev->descs[i];
evfile = debugfs_create_file(name, 0200, chip->dbg_dir, priv, debugfs_create_file(name, 0200, chip->dbg_dir, priv,
&gpio_mockup_debugfs_ops); &gpio_mockup_debugfs_ops);
if (IS_ERR_OR_NULL(evfile))
goto err;
} }
return; return;
err:
dev_err(dev, "error creating debugfs files\n");
} }
static int gpio_mockup_name_lines(struct device *dev, static int gpio_mockup_name_lines(struct device *dev,
@ -447,8 +439,7 @@ static int gpio_mockup_probe(struct platform_device *pdev)
if (rv) if (rv)
return 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; return 0;
} }
@ -501,8 +492,6 @@ static int __init gpio_mockup_init(void)
} }
gpio_mockup_dbg_dir = debugfs_create_dir("gpio-mockup", NULL); 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); err = platform_driver_register(&gpio_mockup_driver);
if (err) { if (err) {

View File

@ -1,4 +1,4 @@
gpio-event-mon gpio-event-mon
gpio-hammer gpio-hammer
lsgpio lsgpio
include/linux/gpio.h