Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit da6070fc authored by Linus Walleij's avatar Linus Walleij
Browse files

Merge tag 'gpio-v5.3-updates-for-linus' of...

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
parents 8df9d7f7 f360dcd4
Loading
Loading
Loading
Loading
+10 −24
Original line number Diff line number Diff line
@@ -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;
}
+1 −5
Original line number Diff line number Diff line
// 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>
+16 −29
Original line number Diff line number Diff line
@@ -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;
}

+5 −16
Original line number Diff line number Diff line
@@ -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,
		debugfs_create_file(name, 0200, chip->dbg_dir, priv,
				    &gpio_mockup_debugfs_ops);
		if (IS_ERR_OR_NULL(evfile))
			goto err;
	}

	return;

err:
	dev_err(dev, "error creating debugfs files\n");
}

static int gpio_mockup_name_lines(struct device *dev,
@@ -447,7 +439,6 @@ 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);

	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) {
+1 −1
Original line number Diff line number Diff line
gpio-event-mon
gpio-hammer
lsgpio
include/linux/gpio.h