All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Francesco Dolcini <francesco.dolcini@toradex.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: Re: [PATCH v1 1/4] mfd: stmpe: Probe sub-function by compatible
Date: Tue, 12 Jul 2022 14:33:13 +0100	[thread overview]
Message-ID: <Ys14GboRr4+GVMX1@google.com> (raw)
In-Reply-To: <20220712110232.329164-2-francesco.dolcini@toradex.com>

On Tue, 12 Jul 2022, Francesco Dolcini wrote:

> Use sub-function of_compatible during probe, instead of using the node
> name. The code should not rely on the node names during probe, in
> addition to that the previously hard-coded node names are not compliant
> to the latest naming convention (they are not generic and they use
> underscores), and it was broken by mistake already once [1].
> 
> While doing this change `rotator` entry was removed, it is not
> used in any device tree file, there is no cell defined, it's just dead
> non-working code with no of_compatible for it.
> 
> [1] commit 56086b5e804f ("ARM: dts: imx6qdl-apalis: Avoid underscore in node name")
> 
> Suggested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
> ---
>  drivers/mfd/stmpe.c | 31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> index aeb9ea55f97d..90a07a94455f 100644
> --- a/drivers/mfd/stmpe.c
> +++ b/drivers/mfd/stmpe.c
> @@ -23,6 +23,12 @@
>  #include <linux/regulator/consumer.h>
>  #include "stmpe.h"
>  
> +#define STMPE_GPIO_COMPATIBLE   "st,stmpe-gpio"
> +#define STMPE_KEYPAD_COMPATIBLE "st,stmpe-keypad"
> +#define STMPE_PWM_COMPATIBLE    "st,stmpe-pwm"
> +#define STMPE_TS_COMPATIBLE     "st,stmpe-ts"
> +#define STMPE_ADC_COMPATIBLE    "st,stmpe-adc"

This is horrible.

Please refrain from defining device/compatible strings.

>  /**
>   * struct stmpe_platform_data - STMPE platform data
>   * @id: device id to distinguish between multiple STMPEs on the same board
> @@ -321,14 +327,14 @@ static struct resource stmpe_gpio_resources[] = {
>  
>  static const struct mfd_cell stmpe_gpio_cell = {
>  	.name		= "stmpe-gpio",
> -	.of_compatible	= "st,stmpe-gpio",
> +	.of_compatible	= STMPE_GPIO_COMPATIBLE,
>  	.resources	= stmpe_gpio_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_gpio_resources),
>  };
>  
>  static const struct mfd_cell stmpe_gpio_cell_noirq = {
>  	.name		= "stmpe-gpio",
> -	.of_compatible	= "st,stmpe-gpio",
> +	.of_compatible	= STMPE_GPIO_COMPATIBLE,
>  	/* gpio cell resources consist of an irq only so no resources here */
>  };
>  
> @@ -350,7 +356,7 @@ static struct resource stmpe_keypad_resources[] = {
>  
>  static const struct mfd_cell stmpe_keypad_cell = {
>  	.name		= "stmpe-keypad",
> -	.of_compatible  = "st,stmpe-keypad",
> +	.of_compatible  = STMPE_KEYPAD_COMPATIBLE,
>  	.resources	= stmpe_keypad_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_keypad_resources),
>  };
> @@ -376,7 +382,7 @@ static struct resource stmpe_pwm_resources[] = {
>  
>  static const struct mfd_cell stmpe_pwm_cell = {
>  	.name		= "stmpe-pwm",
> -	.of_compatible  = "st,stmpe-pwm",
> +	.of_compatible  = STMPE_PWM_COMPATIBLE,
>  	.resources	= stmpe_pwm_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_pwm_resources),
>  };
> @@ -461,7 +467,7 @@ static struct resource stmpe_ts_resources[] = {
>  
>  static const struct mfd_cell stmpe_ts_cell = {
>  	.name		= "stmpe-ts",
> -	.of_compatible	= "st,stmpe-ts",
> +	.of_compatible	= STMPE_TS_COMPATIBLE,
>  	.resources	= stmpe_ts_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_ts_resources),
>  };
> @@ -484,7 +490,7 @@ static struct resource stmpe_adc_resources[] = {
>  
>  static const struct mfd_cell stmpe_adc_cell = {
>  	.name		= "stmpe-adc",
> -	.of_compatible	= "st,stmpe-adc",
> +	.of_compatible	= STMPE_ADC_COMPATIBLE,
>  	.resources	= stmpe_adc_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_adc_resources),
>  };
> @@ -1362,19 +1368,16 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
>  	pdata->autosleep = (pdata->autosleep_timeout) ? true : false;
>  
>  	for_each_available_child_of_node(np, child) {
> -		if (of_node_name_eq(child, "stmpe_gpio")) {
> +		if (of_device_is_compatible(child, STMPE_GPIO_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_GPIO;
> -		} else if (of_node_name_eq(child, "stmpe_keypad")) {
> +		else if (of_device_is_compatible(child, STMPE_KEYPAD_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_KEYPAD;
> -		} else if (of_node_name_eq(child, "stmpe_touchscreen")) {
> +		else if (of_device_is_compatible(child, STMPE_TS_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_TOUCHSCREEN;
> -		} else if (of_node_name_eq(child, "stmpe_adc")) {
> +		else if (of_device_is_compatible(child, STMPE_ADC_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_ADC;
> -		} else if (of_node_name_eq(child, "stmpe_pwm")) {
> +		else if (of_device_is_compatible(child, STMPE_PWM_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_PWM;
> -		} else if (of_node_name_eq(child, "stmpe_rotator")) {
> -			pdata->blocks |= STMPE_BLOCK_ROTATOR;
> -		}

This should be a separate patch.

>  	}
>  }
>  

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones@linaro.org>
To: Francesco Dolcini <francesco.dolcini@toradex.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: Re: [PATCH v1 1/4] mfd: stmpe: Probe sub-function by compatible
Date: Tue, 12 Jul 2022 14:33:13 +0100	[thread overview]
Message-ID: <Ys14GboRr4+GVMX1@google.com> (raw)
In-Reply-To: <20220712110232.329164-2-francesco.dolcini@toradex.com>

On Tue, 12 Jul 2022, Francesco Dolcini wrote:

> Use sub-function of_compatible during probe, instead of using the node
> name. The code should not rely on the node names during probe, in
> addition to that the previously hard-coded node names are not compliant
> to the latest naming convention (they are not generic and they use
> underscores), and it was broken by mistake already once [1].
> 
> While doing this change `rotator` entry was removed, it is not
> used in any device tree file, there is no cell defined, it's just dead
> non-working code with no of_compatible for it.
> 
> [1] commit 56086b5e804f ("ARM: dts: imx6qdl-apalis: Avoid underscore in node name")
> 
> Suggested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
> ---
>  drivers/mfd/stmpe.c | 31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> index aeb9ea55f97d..90a07a94455f 100644
> --- a/drivers/mfd/stmpe.c
> +++ b/drivers/mfd/stmpe.c
> @@ -23,6 +23,12 @@
>  #include <linux/regulator/consumer.h>
>  #include "stmpe.h"
>  
> +#define STMPE_GPIO_COMPATIBLE   "st,stmpe-gpio"
> +#define STMPE_KEYPAD_COMPATIBLE "st,stmpe-keypad"
> +#define STMPE_PWM_COMPATIBLE    "st,stmpe-pwm"
> +#define STMPE_TS_COMPATIBLE     "st,stmpe-ts"
> +#define STMPE_ADC_COMPATIBLE    "st,stmpe-adc"

This is horrible.

Please refrain from defining device/compatible strings.

>  /**
>   * struct stmpe_platform_data - STMPE platform data
>   * @id: device id to distinguish between multiple STMPEs on the same board
> @@ -321,14 +327,14 @@ static struct resource stmpe_gpio_resources[] = {
>  
>  static const struct mfd_cell stmpe_gpio_cell = {
>  	.name		= "stmpe-gpio",
> -	.of_compatible	= "st,stmpe-gpio",
> +	.of_compatible	= STMPE_GPIO_COMPATIBLE,
>  	.resources	= stmpe_gpio_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_gpio_resources),
>  };
>  
>  static const struct mfd_cell stmpe_gpio_cell_noirq = {
>  	.name		= "stmpe-gpio",
> -	.of_compatible	= "st,stmpe-gpio",
> +	.of_compatible	= STMPE_GPIO_COMPATIBLE,
>  	/* gpio cell resources consist of an irq only so no resources here */
>  };
>  
> @@ -350,7 +356,7 @@ static struct resource stmpe_keypad_resources[] = {
>  
>  static const struct mfd_cell stmpe_keypad_cell = {
>  	.name		= "stmpe-keypad",
> -	.of_compatible  = "st,stmpe-keypad",
> +	.of_compatible  = STMPE_KEYPAD_COMPATIBLE,
>  	.resources	= stmpe_keypad_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_keypad_resources),
>  };
> @@ -376,7 +382,7 @@ static struct resource stmpe_pwm_resources[] = {
>  
>  static const struct mfd_cell stmpe_pwm_cell = {
>  	.name		= "stmpe-pwm",
> -	.of_compatible  = "st,stmpe-pwm",
> +	.of_compatible  = STMPE_PWM_COMPATIBLE,
>  	.resources	= stmpe_pwm_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_pwm_resources),
>  };
> @@ -461,7 +467,7 @@ static struct resource stmpe_ts_resources[] = {
>  
>  static const struct mfd_cell stmpe_ts_cell = {
>  	.name		= "stmpe-ts",
> -	.of_compatible	= "st,stmpe-ts",
> +	.of_compatible	= STMPE_TS_COMPATIBLE,
>  	.resources	= stmpe_ts_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_ts_resources),
>  };
> @@ -484,7 +490,7 @@ static struct resource stmpe_adc_resources[] = {
>  
>  static const struct mfd_cell stmpe_adc_cell = {
>  	.name		= "stmpe-adc",
> -	.of_compatible	= "st,stmpe-adc",
> +	.of_compatible	= STMPE_ADC_COMPATIBLE,
>  	.resources	= stmpe_adc_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_adc_resources),
>  };
> @@ -1362,19 +1368,16 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
>  	pdata->autosleep = (pdata->autosleep_timeout) ? true : false;
>  
>  	for_each_available_child_of_node(np, child) {
> -		if (of_node_name_eq(child, "stmpe_gpio")) {
> +		if (of_device_is_compatible(child, STMPE_GPIO_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_GPIO;
> -		} else if (of_node_name_eq(child, "stmpe_keypad")) {
> +		else if (of_device_is_compatible(child, STMPE_KEYPAD_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_KEYPAD;
> -		} else if (of_node_name_eq(child, "stmpe_touchscreen")) {
> +		else if (of_device_is_compatible(child, STMPE_TS_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_TOUCHSCREEN;
> -		} else if (of_node_name_eq(child, "stmpe_adc")) {
> +		else if (of_device_is_compatible(child, STMPE_ADC_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_ADC;
> -		} else if (of_node_name_eq(child, "stmpe_pwm")) {
> +		else if (of_device_is_compatible(child, STMPE_PWM_COMPATIBLE))
>  			pdata->blocks |= STMPE_BLOCK_PWM;
> -		} else if (of_node_name_eq(child, "stmpe_rotator")) {
> -			pdata->blocks |= STMPE_BLOCK_ROTATOR;
> -		}

This should be a separate patch.

>  	}
>  }
>  

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2022-07-12 13:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-12 11:02 [PATCH v1 0/4] mfd: stmpe: Probe sub-function by compatible Francesco Dolcini
2022-07-12 11:02 ` Francesco Dolcini
2022-07-12 11:02 ` [PATCH v1 1/4] " Francesco Dolcini
2022-07-12 11:02   ` Francesco Dolcini
2022-07-12 13:33   ` Lee Jones [this message]
2022-07-12 13:33     ` Lee Jones
2022-07-12 11:02 ` [PATCH v1 2/4] dt-bindings: gpio: stmpe: Remove node name requirement Francesco Dolcini
2022-07-12 11:02   ` Francesco Dolcini
2022-07-13  7:43   ` Bartosz Golaszewski
2022-07-13  7:43     ` Bartosz Golaszewski
2022-07-18  9:44   ` Linus Walleij
2022-07-18  9:44     ` Linus Walleij
2022-07-12 11:02 ` [PATCH v1 3/4] dt-bindings: iio: adc: " Francesco Dolcini
2022-07-12 11:02   ` Francesco Dolcini
2022-07-12 11:02 ` [PATCH v1 4/4] dt-bindings: input: touchscreen: " Francesco Dolcini
2022-07-12 11:02   ` Francesco Dolcini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ys14GboRr4+GVMX1@google.com \
    --to=lee.jones@linaro.org \
    --cc=a.fatoum@pengutronix.de \
    --cc=alexandre.torgue@foss.st.com \
    --cc=devicetree@vger.kernel.org \
    --cc=francesco.dolcini@toradex.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.