Add support of sub-functions disabling. It allows one to define
an stmpe sub-function device in devicetree, but keep it disabled.
Signed-off-by: Oleksandr Suvorov <[email protected]>
---
drivers/mfd/stmpe.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 90f3292230c9..2182607b75f6 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -1358,6 +1358,9 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
pdata->autosleep = (pdata->autosleep_timeout) ? true : false;
for_each_child_of_node(np, child) {
+ /* skip disabled sub-function */
+ if (!of_device_is_available(child))
+ continue;
if (of_node_name_eq(child, "stmpe_gpio")) {
pdata->blocks |= STMPE_BLOCK_GPIO;
} else if (of_node_name_eq(child, "stmpe_keypad")) {
--
2.29.2
Hello Oleksander,
On 26.12.20 10:47, Oleksandr Suvorov wrote:
> Add support of sub-functions disabling. It allows one to define
> an stmpe sub-function device in devicetree, but keep it disabled.
>
> Signed-off-by: Oleksandr Suvorov <[email protected]>
> ---
>
> drivers/mfd/stmpe.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> index 90f3292230c9..2182607b75f6 100644
> --- a/drivers/mfd/stmpe.c
> +++ b/drivers/mfd/stmpe.c
> @@ -1358,6 +1358,9 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
> pdata->autosleep = (pdata->autosleep_timeout) ? true : false;
>
> (np, child) {
> + /* skip disabled sub-function */
> + if (!of_device_is_available(child))
> + continue;
Better use for_each_available_child_of_node().
> if (of_node_name_eq(child, "stmpe_gpio")) {
> pdata->blocks |= STMPE_BLOCK_GPIO;
> } else if (of_node_name_eq(child, "stmpe_keypad")) {
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Add support of sub-functions disabling. It allows one to define
an stmpe sub-function device in devicetree, but keep it disabled.
Signed-off-by: Oleksandr Suvorov <[email protected]>
---
Changes in v2:
Use for_each_available_child_of_node() instead of checking
of_device_is_available() for each node.
Thanks for Ahmad Fatoum [email protected] for and idea
drivers/mfd/stmpe.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 90f3292230c9..3e4f32673db3 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -1357,7 +1357,7 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
pdata->autosleep = (pdata->autosleep_timeout) ? true : false;
- for_each_child_of_node(np, child) {
+ for_each_available_child_of_node(np, child) {
if (of_node_name_eq(child, "stmpe_gpio")) {
pdata->blocks |= STMPE_BLOCK_GPIO;
} else if (of_node_name_eq(child, "stmpe_keypad")) {
--
2.29.2
Hi Francesco
On Wed, 2021-10-27 at 10:21 +0200, Francesco Dolcini wrote:
> From: Oleksandr Suvorov <[email protected]>
>
> Add support of sub-functions disabling. It allows one to define
> an stmpe sub-function device in devicetree, but keep it disabled.
>
> Signed-off-by: Oleksandr Suvorov <[email protected]>
> Cc: Oleksandr Suvorov <[email protected]>
> Signed-off-by: Francesco Dolcini <[email protected]>
Reviewed-by: Marcel Ziswiler <[email protected]>
> ---
> Hello,
> the main reason for this patch is to allow enabling/disabling sub-fuctions
:s/sub-fuctions/sub-functions/
> using DTS overlay to enable more flexibility on SoM/Carrier boards
:s/boards/board/
> combinations.
> ---
> drivers/mfd/stmpe.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> index e928df95e316..aeb9ea55f97d 100644
> --- a/drivers/mfd/stmpe.c
> +++ b/drivers/mfd/stmpe.c
> @@ -1361,7 +1361,7 @@ static void stmpe_of_probe(struct stmpe_platform_data *pdata,
>
> pdata->autosleep = (pdata->autosleep_timeout) ? true : false;
>
> - for_each_child_of_node(np, child) {
> + for_each_available_child_of_node(np, child) {
> if (of_node_name_eq(child, "stmpe_gpio")) {
> pdata->blocks |= STMPE_BLOCK_GPIO;
> } else if (of_node_name_eq(child, "stmpe_keypad")) {
Cheers
Marcel