Commit e0c81040 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski
Browse files

Merge tag 'ib-gpio-remove-of-gpio-h-for-v7.1' of...

Merge tag 'ib-gpio-remove-of-gpio-h-for-v7.1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux.git into gpio/for-next

Immutable branch between GPIO and net

Convert remaining users of of_gpio.h to using GPIO descriptors and
remove the header.
parents c452588f b6420bd5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -10959,7 +10959,6 @@ F: drivers/gpio/
F:	include/dt-bindings/gpio/
F:	include/linux/gpio.h
F:	include/linux/gpio/
F:	include/linux/of_gpio.h
K:	(devm_)?gpio_(request|free|direction|get|set)
K:	GPIOD_FLAGS_BIT_NONEXCLUSIVE
K:	devm_gpiod_unhinge
+0 −28
Original line number Diff line number Diff line
@@ -58,34 +58,6 @@ Work items:

-------------------------------------------------------------------------------

Get rid of <linux/of_gpio.h>

This header and helpers appeared at one point when there was no proper
driver infrastructure for doing simpler MMIO GPIO devices and there was
no core support for parsing device tree GPIOs from the core library with
the [devm_]gpiod_get() calls we have today that will implicitly go into
the device tree back-end. It is legacy and should not be used in new code.

Work items:

- Change all consumer drivers that #include <linux/of_gpio.h> to
  #include <linux/gpio/consumer.h> and stop doing custom parsing of the
  GPIO lines from the device tree. This can be tricky and often involves
  changing board files, etc.

- Pull semantics for legacy device tree (OF) GPIO lookups into
  gpiolib-of.c: in some cases subsystems are doing custom flags and
  lookups for polarity inversion, open drain and what not. As we now
  handle this with generic OF bindings, pull all legacy handling into
  gpiolib so the library API becomes narrow and deep and handle all
  legacy bindings internally. (See e.g. commits 6953c57ab172,
  6a537d48461d etc)

- Delete <linux/of_gpio.h> when all the above is complete and everything
  uses <linux/gpio/consumer.h> or <linux/gpio/driver.h> instead.

-------------------------------------------------------------------------------

Collect drivers

Collect GPIO drivers from arch/* and other places that should be placed
+4 −27
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_gpio.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/slab.h>
#include <linux/string.h>
@@ -446,32 +445,6 @@ static struct gpio_desc *of_get_named_gpiod_flags(const struct device_node *np,
	return desc;
}

/**
 * of_get_named_gpio() - Get a GPIO number to use with GPIO API
 * @np:		device node to get GPIO from
 * @propname:	Name of property containing gpio specifier(s)
 * @index:	index of the GPIO
 *
 * **DEPRECATED** This function is deprecated and must not be used in new code.
 *
 * Returns:
 * GPIO number to use with Linux generic GPIO API, or one of the errno
 * value on the error condition.
 */
int of_get_named_gpio(const struct device_node *np, const char *propname,
		      int index)
{
	struct gpio_desc *desc;

	desc = of_get_named_gpiod_flags(np, propname, index, NULL);

	if (IS_ERR(desc))
		return PTR_ERR(desc);
	else
		return desc_to_gpio(desc);
}
EXPORT_SYMBOL_GPL(of_get_named_gpio);

/* Converts gpio_lookup_flags into bitmask of GPIO_* values */
static unsigned long of_convert_gpio_flags(enum of_gpio_flags flags)
{
@@ -542,6 +515,10 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
		{ "reset",	"reset-n-io",	"marvell,nfc-uart" },
		{ "reset",	"reset-n-io",	"mrvl,nfc-uart" },
#endif
#if IS_ENABLED(CONFIG_NFC_S3FWRN5_I2C)
		{ "en",		"s3fwrn5,en-gpios",	"samsung,s3fwrn5-i2c" },
		{ "wake",	"s3fwrn5,fw-gpios",	"samsung,s3fwrn5-i2c" },
#endif
#if IS_ENABLED(CONFIG_PCI_LANTIQ)
		/* MIPS Lantiq PCI */
		{ "reset",	"gpio-reset",	"lantiq,pci-xway" },
+16 −31
Original line number Diff line number Diff line
@@ -6,9 +6,9 @@
 */

#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/delay.h>
#include <linux/of_gpio.h>
#include <linux/of.h>
#include <linux/nfc.h>
#include <net/nfc/nci.h>
#include <net/nfc/nci_core.h>
@@ -112,13 +112,12 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,

	memcpy(&priv->config, pdata, sizeof(*pdata));

	if (gpio_is_valid(priv->config.reset_n_io)) {
		rc = gpio_request_one(priv->config.reset_n_io,
				      GPIOF_OUT_INIT_LOW,
				      "nfcmrvl_reset_n");
		if (rc < 0) {
			priv->config.reset_n_io = -EINVAL;
			nfc_err(dev, "failed to request reset_n io\n");
	if (!priv->config.reset_gpio) {
		priv->config.reset_gpio =
			devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
		if (IS_ERR(priv->config.reset_gpio)) {
			priv->config.reset_gpio = NULL;
			nfc_err(dev, "failed to get reset gpio\n");
		}
	}

@@ -144,7 +143,7 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
	if (!priv->ndev) {
		nfc_err(dev, "nci_allocate_device failed\n");
		rc = -ENOMEM;
		goto error_free_gpio;
		goto error_free;
	}

	rc = nfcmrvl_fw_dnld_init(priv);
@@ -171,9 +170,7 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
	nfcmrvl_fw_dnld_deinit(priv);
error_free_dev:
	nci_free_device(priv->ndev);
error_free_gpio:
	if (gpio_is_valid(priv->config.reset_n_io))
		gpio_free(priv->config.reset_n_io);
error_free:
	kfree(priv);
	return ERR_PTR(rc);
}
@@ -189,9 +186,6 @@ void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private *priv)

	nfcmrvl_fw_dnld_deinit(priv);

	if (gpio_is_valid(priv->config.reset_n_io))
		gpio_free(priv->config.reset_n_io);

	nci_free_device(ndev);
	kfree(priv);
}
@@ -233,34 +227,25 @@ void nfcmrvl_chip_reset(struct nfcmrvl_private *priv)
	/* Reset possible fault of previous session */
	clear_bit(NFCMRVL_PHY_ERROR, &priv->flags);

	if (gpio_is_valid(priv->config.reset_n_io)) {
	if (priv->config.reset_gpio) {
		nfc_info(priv->dev, "reset the chip\n");
		gpio_set_value(priv->config.reset_n_io, 0);
		gpiod_set_value(priv->config.reset_gpio, 1);
		usleep_range(5000, 10000);
		gpio_set_value(priv->config.reset_n_io, 1);
		gpiod_set_value(priv->config.reset_gpio, 0);
	} else
		nfc_info(priv->dev, "no reset available on this interface\n");
}

void nfcmrvl_chip_halt(struct nfcmrvl_private *priv)
{
	if (gpio_is_valid(priv->config.reset_n_io))
		gpio_set_value(priv->config.reset_n_io, 0);
	if (priv->config.reset_gpio)
		gpiod_set_value(priv->config.reset_gpio, 1);
}

int nfcmrvl_parse_dt(struct device_node *node,
		     struct nfcmrvl_platform_data *pdata)
{
	int reset_n_io;

	reset_n_io = of_get_named_gpio(node, "reset-n-io", 0);
	if (reset_n_io < 0) {
		pr_info("no reset-n-io config\n");
	} else if (!gpio_is_valid(reset_n_io)) {
		pr_err("invalid reset-n-io GPIO\n");
		return reset_n_io;
	}
	pdata->reset_n_io = reset_n_io;
	pdata->reset_gpio = NULL;
	pdata->hci_muxed = of_property_read_bool(node, "hci-muxed");

	return 0;
+3 −1
Original line number Diff line number Diff line
@@ -10,6 +10,8 @@

#include "fw_dnld.h"

struct gpio_desc;

/* Define private flags: */
#define NFCMRVL_NCI_RUNNING			1
#define NFCMRVL_PHY_ERROR			2
@@ -54,7 +56,7 @@ struct nfcmrvl_platform_data {
	 */

	/* GPIO that is wired to RESET_N signal */
	int reset_n_io;
	struct gpio_desc *reset_gpio;
	/* Tell if transport is muxed in HCI one */
	bool hci_muxed;

Loading