lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220920103108.23074-21-jay.xu@rock-chips.com>
Date:   Tue, 20 Sep 2022 18:31:08 +0800
From:   Jianqun Xu <jay.xu@...k-chips.com>
To:     linus.walleij@...aro.org, heiko@...ech.de, brgl@...ev.pl,
        andriy.shevchenko@...ux.intel.com
Cc:     robert.moore@...el.com, robh@...nel.org,
        linux-rockchip@...ts.infradead.org, linux-kernel@...r.kernel.org,
        lenb@...nel.org, rafael@...nel.org,
        Jianqun Xu <jay.xu@...k-chips.com>
Subject: [PATCH 20/20] pinctrl/rockchip: find existed gpiochip by gpio label

Currently the pinctrl device acts as parent for the GPIO devices for
Rockchip platform, the pinctrl driver creates the gpiochips and pass to
the GPIO driver.

This patch makes the member of pinctrl structure from gpiochip to
*gpiochip, switch to find existed gpiochips instead of creating them,
that requires the GPIO driver to create them and earlier than the
pinctrl driver.

Signed-off-by: Jianqun Xu <jay.xu@...k-chips.com>
---
 drivers/pinctrl/pinctrl-rockchip.c | 24 +++++++++++++++++++++---
 drivers/pinctrl/pinctrl-rockchip.h |  2 +-
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
index 97af52bb5481..05e688cd8536 100644
--- a/drivers/pinctrl/pinctrl-rockchip.c
+++ b/drivers/pinctrl/pinctrl-rockchip.c
@@ -2725,7 +2725,7 @@ static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
 {
 	struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
 	struct rockchip_pin_bank *bank = pin_to_bank(info, pin);
-	struct gpio_chip *gpio = &bank->gpio_chip;
+	struct gpio_chip *gpio = bank->gpio_chip;
 	enum pin_config_param param;
 	u32 arg;
 	int i;
@@ -2828,7 +2828,7 @@ static int rockchip_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
 {
 	struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
 	struct rockchip_pin_bank *bank = pin_to_bank(info, pin);
-	struct gpio_chip *gpio = &bank->gpio_chip;
+	struct gpio_chip *gpio = bank->gpio_chip;
 	enum pin_config_param param = pinconf_to_config_param(*config);
 	u16 arg;
 	int rc;
@@ -3293,7 +3293,7 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
 	struct rockchip_pin_ctrl *ctrl;
 	struct resource *res;
 	void __iomem *base;
-	int ret;
+	int ret, i;
 
 	if (is_of_node(fwnode)) {
 		ret = of_platform_populate(np, NULL, NULL, dev);
@@ -3357,6 +3357,24 @@ static int rockchip_pinctrl_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
+	for (i = 0; i < ctrl->nr_banks; i++) {
+		struct gpio_chip *gc;
+		struct rockchip_pin_bank *bank = &ctrl->pin_banks[i];
+
+		gc = gpiochip_find_by_name((void *)ctrl->pin_banks[i].name);
+		if (!gc) {
+			dev_err(dev, "fail to find gpiochip\n");
+			return ret;
+		}
+
+		ret = gpiochip_add_pin_range(gc, dev_name(dev), 0, gc->base, gc->ngpio);
+		if (ret) {
+			dev_err(dev, "fail to add pin range\n");
+			return ret;
+		}
+		bank->gpio_chip = gc;
+	}
+
 	platform_set_drvdata(pdev, info);
 	dev_info(dev, "probed %pfw\n", fwnode);
 
diff --git a/drivers/pinctrl/pinctrl-rockchip.h b/drivers/pinctrl/pinctrl-rockchip.h
index 3531633c0397..8b44e02bce97 100644
--- a/drivers/pinctrl/pinctrl-rockchip.h
+++ b/drivers/pinctrl/pinctrl-rockchip.h
@@ -330,7 +330,7 @@ struct rockchip_pin_bank {
 	struct device_node		*of_node;
 	struct rockchip_pinctrl		*drvdata;
 	struct irq_domain		*domain;
-	struct gpio_chip		gpio_chip;
+	struct gpio_chip		*gpio_chip;
 	struct pinctrl_gpio_range	grange;
 	raw_spinlock_t			slock;
 	const struct rockchip_gpio_regs	*gpio_regs;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ