public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] gpio: Simplify with of_device_get_match_data()
@ 2025-12-19 10:11 Krzysztof Kozlowski
  2025-12-19 10:11 ` [PATCH v2 1/3] gpio: aspeed: " Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-19 10:11 UTC (permalink / raw)
  To: Linus Walleij, Joel Stanley, Andrew Jeffery, Eugeniy Paltsev,
	Shubhrajyoti Datta, Srinivas Neeli, Michal Simek, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, linux-arm-kernel, linux-aspeed,
	Krzysztof Kozlowski

Changes in v2:
- Drop applied patch
- Use device_get_match_data() as suggested by Bartosz
- Link to v1: https://patch.msgid.link/20251106-gpio-of-match-v1-0-50c7115a045e@linaro.org

Few simple cleanups, not tested on the hardware.

Care has to be taken when converting of_match_data() into
of_device_get_match_data(), because first can check arbitrary
device_node and the latter checks device's node.  Cases here should be
safe because of_match_data() uses 'pdev->dev.of_node'.

Best regards,
Krzysztof

---
Krzysztof Kozlowski (3):
      gpio: aspeed: Simplify with of_device_get_match_data()
      gpio: creg-snps: Simplify with of_device_get_match_data()
      gpio: zynq: Simplify with of_device_get_match_data()

 drivers/gpio/gpio-aspeed.c    | 7 ++-----
 drivers/gpio/gpio-creg-snps.c | 4 +---
 drivers/gpio/gpio-zynq.c      | 8 +++-----
 3 files changed, 6 insertions(+), 13 deletions(-)
---
base-commit: 26ac2c4153a2c543a4ef3dee421b46bedb0f8f0f
change-id: 20251106-gpio-of-match-23b24cddf063

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>



^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/3] gpio: aspeed: Simplify with of_device_get_match_data()
  2025-12-19 10:11 [PATCH v2 0/3] gpio: Simplify with of_device_get_match_data() Krzysztof Kozlowski
@ 2025-12-19 10:11 ` Krzysztof Kozlowski
  2026-01-01 22:35   ` Linus Walleij
  2025-12-19 10:11 ` [PATCH v2 2/3] gpio: creg-snps: " Krzysztof Kozlowski
  2025-12-19 10:11 ` [PATCH v2 3/3] gpio: zynq: " Krzysztof Kozlowski
  2 siblings, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-19 10:11 UTC (permalink / raw)
  To: Linus Walleij, Joel Stanley, Andrew Jeffery, Eugeniy Paltsev,
	Shubhrajyoti Datta, Srinivas Neeli, Michal Simek, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, linux-arm-kernel, linux-aspeed,
	Krzysztof Kozlowski

Driver's probe function matches against driver's of_device_id table,
where each entry has non-NULL match data, so of_match_node() can be
simplified with of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/gpio/gpio-aspeed.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
index cbdf781994dc..9115e56a1626 100644
--- a/drivers/gpio/gpio-aspeed.c
+++ b/drivers/gpio/gpio-aspeed.c
@@ -1302,7 +1302,6 @@ MODULE_DEVICE_TABLE(of, aspeed_gpio_of_table);
 
 static int aspeed_gpio_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *gpio_id;
 	struct gpio_irq_chip *girq;
 	struct aspeed_gpio *gpio;
 	int rc, irq, i, banks, err;
@@ -1320,8 +1319,8 @@ static int aspeed_gpio_probe(struct platform_device *pdev)
 
 	raw_spin_lock_init(&gpio->lock);
 
-	gpio_id = of_match_node(aspeed_gpio_of_table, pdev->dev.of_node);
-	if (!gpio_id)
+	gpio->config = device_get_match_data(&pdev->dev);
+	if (!gpio->config)
 		return -EINVAL;
 
 	gpio->clk = devm_clk_get_enabled(&pdev->dev, NULL);
@@ -1331,8 +1330,6 @@ static int aspeed_gpio_probe(struct platform_device *pdev)
 		gpio->clk = NULL;
 	}
 
-	gpio->config = gpio_id->data;
-
 	if (!gpio->config->llops->reg_bit_set || !gpio->config->llops->reg_bit_get ||
 	    !gpio->config->llops->reg_bank_get)
 		return -EINVAL;

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 2/3] gpio: creg-snps: Simplify with of_device_get_match_data()
  2025-12-19 10:11 [PATCH v2 0/3] gpio: Simplify with of_device_get_match_data() Krzysztof Kozlowski
  2025-12-19 10:11 ` [PATCH v2 1/3] gpio: aspeed: " Krzysztof Kozlowski
@ 2025-12-19 10:11 ` Krzysztof Kozlowski
  2026-01-01 22:35   ` Linus Walleij
  2025-12-19 10:11 ` [PATCH v2 3/3] gpio: zynq: " Krzysztof Kozlowski
  2 siblings, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-19 10:11 UTC (permalink / raw)
  To: Linus Walleij, Joel Stanley, Andrew Jeffery, Eugeniy Paltsev,
	Shubhrajyoti Datta, Srinivas Neeli, Michal Simek, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, linux-arm-kernel, linux-aspeed,
	Krzysztof Kozlowski

Driver's probe function matches against driver's of_device_id table,
where each entry has non-NULL match data, so of_match_node() can be
simplified with of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/gpio/gpio-creg-snps.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-creg-snps.c b/drivers/gpio/gpio-creg-snps.c
index f8ea961fa1de..157ab90f5ba8 100644
--- a/drivers/gpio/gpio-creg-snps.c
+++ b/drivers/gpio/gpio-creg-snps.c
@@ -134,7 +134,6 @@ static const struct of_device_id creg_gpio_ids[] = {
 
 static int creg_gpio_probe(struct platform_device *pdev)
 {
-	const struct of_device_id *match;
 	struct device *dev = &pdev->dev;
 	struct creg_gpio *hcg;
 	u32 ngpios;
@@ -148,8 +147,7 @@ static int creg_gpio_probe(struct platform_device *pdev)
 	if (IS_ERR(hcg->regs))
 		return PTR_ERR(hcg->regs);
 
-	match = of_match_node(creg_gpio_ids, pdev->dev.of_node);
-	hcg->layout = match->data;
+	hcg->layout = device_get_match_data(dev);
 	if (!hcg->layout)
 		return -EINVAL;
 

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v2 3/3] gpio: zynq: Simplify with of_device_get_match_data()
  2025-12-19 10:11 [PATCH v2 0/3] gpio: Simplify with of_device_get_match_data() Krzysztof Kozlowski
  2025-12-19 10:11 ` [PATCH v2 1/3] gpio: aspeed: " Krzysztof Kozlowski
  2025-12-19 10:11 ` [PATCH v2 2/3] gpio: creg-snps: " Krzysztof Kozlowski
@ 2025-12-19 10:11 ` Krzysztof Kozlowski
  2025-12-19 10:14   ` Michal Simek
  2025-12-19 10:15   ` Bartosz Golaszewski
  2 siblings, 2 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-19 10:11 UTC (permalink / raw)
  To: Linus Walleij, Joel Stanley, Andrew Jeffery, Eugeniy Paltsev,
	Shubhrajyoti Datta, Srinivas Neeli, Michal Simek, Linus Walleij,
	Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, linux-arm-kernel, linux-aspeed,
	Krzysztof Kozlowski

Driver's probe function matches against driver's of_device_id table,
where each entry has non-NULL match data, so of_match_node() can be
simplified with of_device_get_match_data().

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
---
 drivers/gpio/gpio-zynq.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
index 97780c57ab56..d69773318888 100644
--- a/drivers/gpio/gpio-zynq.c
+++ b/drivers/gpio/gpio-zynq.c
@@ -903,18 +903,16 @@ static int zynq_gpio_probe(struct platform_device *pdev)
 	struct zynq_gpio *gpio;
 	struct gpio_chip *chip;
 	struct gpio_irq_chip *girq;
-	const struct of_device_id *match;
 
 	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
 	if (!gpio)
 		return -ENOMEM;
 
-	match = of_match_node(zynq_gpio_of_match, pdev->dev.of_node);
-	if (!match) {
-		dev_err(&pdev->dev, "of_match_node() failed\n");
+	gpio->p_data = device_get_match_data(&pdev->dev);
+	if (!gpio->p_data) {
+		dev_err(&pdev->dev, "of_device_get_match_data() failed\n");
 		return -EINVAL;
 	}
-	gpio->p_data = match->data;
 	platform_set_drvdata(pdev, gpio);
 
 	gpio->base_addr = devm_platform_ioremap_resource(pdev, 0);

-- 
2.51.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] gpio: zynq: Simplify with of_device_get_match_data()
  2025-12-19 10:11 ` [PATCH v2 3/3] gpio: zynq: " Krzysztof Kozlowski
@ 2025-12-19 10:14   ` Michal Simek
  2025-12-19 10:15   ` Bartosz Golaszewski
  1 sibling, 0 replies; 9+ messages in thread
From: Michal Simek @ 2025-12-19 10:14 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Linus Walleij, Joel Stanley, Andrew Jeffery,
	Eugeniy Paltsev, Shubhrajyoti Datta, Srinivas Neeli,
	Linus Walleij, Bartosz Golaszewski
  Cc: linux-gpio, linux-kernel, linux-arm-kernel, linux-aspeed



On 12/19/25 11:11, Krzysztof Kozlowski wrote:
> Driver's probe function matches against driver's of_device_id table,
> where each entry has non-NULL match data, so of_match_node() can be
> simplified with of_device_get_match_data().

device_get_match_data() right?

> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> ---
>   drivers/gpio/gpio-zynq.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-zynq.c b/drivers/gpio/gpio-zynq.c
> index 97780c57ab56..d69773318888 100644
> --- a/drivers/gpio/gpio-zynq.c
> +++ b/drivers/gpio/gpio-zynq.c
> @@ -903,18 +903,16 @@ static int zynq_gpio_probe(struct platform_device *pdev)
>   	struct zynq_gpio *gpio;
>   	struct gpio_chip *chip;
>   	struct gpio_irq_chip *girq;
> -	const struct of_device_id *match;
>   
>   	gpio = devm_kzalloc(&pdev->dev, sizeof(*gpio), GFP_KERNEL);
>   	if (!gpio)
>   		return -ENOMEM;
>   
> -	match = of_match_node(zynq_gpio_of_match, pdev->dev.of_node);
> -	if (!match) {
> -		dev_err(&pdev->dev, "of_match_node() failed\n");
> +	gpio->p_data = device_get_match_data(&pdev->dev);
> +	if (!gpio->p_data) {
> +		dev_err(&pdev->dev, "of_device_get_match_data() failed\n");

device_get_match_data() ?




>   		return -EINVAL;
>   	}
> -	gpio->p_data = match->data;
>   	platform_set_drvdata(pdev, gpio);
>   
>   	gpio->base_addr = devm_platform_ioremap_resource(pdev, 0);
> 

M


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] gpio: zynq: Simplify with of_device_get_match_data()
  2025-12-19 10:11 ` [PATCH v2 3/3] gpio: zynq: " Krzysztof Kozlowski
  2025-12-19 10:14   ` Michal Simek
@ 2025-12-19 10:15   ` Bartosz Golaszewski
  2025-12-19 12:10     ` Krzysztof Kozlowski
  1 sibling, 1 reply; 9+ messages in thread
From: Bartosz Golaszewski @ 2025-12-19 10:15 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Joel Stanley, Andrew Jeffery, Eugeniy Paltsev,
	Shubhrajyoti Datta, Srinivas Neeli, Michal Simek, Linus Walleij,
	linux-gpio, linux-kernel, linux-arm-kernel, linux-aspeed

On Fri, Dec 19, 2025 at 11:12 AM Krzysztof Kozlowski
<krzysztof.kozlowski@oss.qualcomm.com> wrote:
>
> Driver's probe function matches against driver's of_device_id table,
> where each entry has non-NULL match data, so of_match_node() can be
> simplified with of_device_get_match_data().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
> ---

I think there are some copy-paste leftovers in your commit messages.
You're saying you're using of_ functions but you're really going for
the device_ ones. Also update error messages. And possibly use
dev_err_probe() too while at it?

Same elsewhere.

Bart


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 3/3] gpio: zynq: Simplify with of_device_get_match_data()
  2025-12-19 10:15   ` Bartosz Golaszewski
@ 2025-12-19 12:10     ` Krzysztof Kozlowski
  0 siblings, 0 replies; 9+ messages in thread
From: Krzysztof Kozlowski @ 2025-12-19 12:10 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Linus Walleij, Joel Stanley, Andrew Jeffery, Eugeniy Paltsev,
	Shubhrajyoti Datta, Srinivas Neeli, Michal Simek, Linus Walleij,
	linux-gpio, linux-kernel, linux-arm-kernel, linux-aspeed

On 19/12/2025 11:15, Bartosz Golaszewski wrote:
> On Fri, Dec 19, 2025 at 11:12 AM Krzysztof Kozlowski
> <krzysztof.kozlowski@oss.qualcomm.com> wrote:
>>
>> Driver's probe function matches against driver's of_device_id table,
>> where each entry has non-NULL match data, so of_match_node() can be
>> simplified with of_device_get_match_data().
>>
>> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
>> ---
> 
> I think there are some copy-paste leftovers in your commit messages.

I just did not update the commit msg.

> You're saying you're using of_ functions but you're really going for
> the device_ ones. Also update error messages. And possibly use
> dev_err_probe() too while at it?

Sure

> 
> Same elsewhere.
> 
> Bart


Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 1/3] gpio: aspeed: Simplify with of_device_get_match_data()
  2025-12-19 10:11 ` [PATCH v2 1/3] gpio: aspeed: " Krzysztof Kozlowski
@ 2026-01-01 22:35   ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2026-01-01 22:35 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Joel Stanley, Andrew Jeffery, Eugeniy Paltsev,
	Shubhrajyoti Datta, Srinivas Neeli, Michal Simek,
	Bartosz Golaszewski, linux-gpio, linux-kernel, linux-arm-kernel,
	linux-aspeed

On Fri, Dec 19, 2025 at 11:12 AM Krzysztof Kozlowski
<krzysztof.kozlowski@oss.qualcomm.com> wrote:

> Driver's probe function matches against driver's of_device_id table,
> where each entry has non-NULL match data, so of_match_node() can be
> simplified with of_device_get_match_data().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 2/3] gpio: creg-snps: Simplify with of_device_get_match_data()
  2025-12-19 10:11 ` [PATCH v2 2/3] gpio: creg-snps: " Krzysztof Kozlowski
@ 2026-01-01 22:35   ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2026-01-01 22:35 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Linus Walleij, Joel Stanley, Andrew Jeffery, Eugeniy Paltsev,
	Shubhrajyoti Datta, Srinivas Neeli, Michal Simek,
	Bartosz Golaszewski, linux-gpio, linux-kernel, linux-arm-kernel,
	linux-aspeed

On Fri, Dec 19, 2025 at 11:12 AM Krzysztof Kozlowski
<krzysztof.kozlowski@oss.qualcomm.com> wrote:

> Driver's probe function matches against driver's of_device_id table,
> where each entry has non-NULL match data, so of_match_node() can be
> simplified with of_device_get_match_data().
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>

Reviewed-by: Linus Walleij <linusw@kernel.org>

Yours,
Linus Walleij


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-01-01 22:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-19 10:11 [PATCH v2 0/3] gpio: Simplify with of_device_get_match_data() Krzysztof Kozlowski
2025-12-19 10:11 ` [PATCH v2 1/3] gpio: aspeed: " Krzysztof Kozlowski
2026-01-01 22:35   ` Linus Walleij
2025-12-19 10:11 ` [PATCH v2 2/3] gpio: creg-snps: " Krzysztof Kozlowski
2026-01-01 22:35   ` Linus Walleij
2025-12-19 10:11 ` [PATCH v2 3/3] gpio: zynq: " Krzysztof Kozlowski
2025-12-19 10:14   ` Michal Simek
2025-12-19 10:15   ` Bartosz Golaszewski
2025-12-19 12:10     ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox