[PATCH v4 03/15] pinctrl: airoha: replace struct function_desc with struct pinfunction

Bartosz Golaszewski posted 15 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH v4 03/15] pinctrl: airoha: replace struct function_desc with struct pinfunction
Posted by Bartosz Golaszewski 1 month, 3 weeks ago
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

struct function_desc is a wrapper around struct pinfunction with an
additional void *data pointer. This driver doesn't use the data pointer.
We're also working towards reducing the usage of struct function_desc in
pinctrl drivers - they should only be created by pinmux core and
accessed by drivers using pinmux_generic_get_function(). Replace the
struct function_desc objects in this driver with smaller struct
pinfunction instances.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
 drivers/pinctrl/mediatek/pinctrl-airoha.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/pinctrl/mediatek/pinctrl-airoha.c b/drivers/pinctrl/mediatek/pinctrl-airoha.c
index 5f1ec9e0de213d587b68f41d3458cf504ee1b21f..51cd0cdc2f5170d024fe984ce8882ed9b3ce6563 100644
--- a/drivers/pinctrl/mediatek/pinctrl-airoha.c
+++ b/drivers/pinctrl/mediatek/pinctrl-airoha.c
@@ -36,11 +36,9 @@
 #define PINCTRL_FUNC_DESC(id)						\
 	{								\
 		.desc = {						\
-			.func = {					\
-				.name = #id,				\
-				.groups = id##_groups,			\
-				.ngroups = ARRAY_SIZE(id##_groups),	\
-			}						\
+			.name = #id,					\
+			.groups = id##_groups,				\
+			.ngroups = ARRAY_SIZE(id##_groups),		\
 		},							\
 		.groups = id##_func_group,				\
 		.group_size = ARRAY_SIZE(id##_func_group),		\
@@ -334,7 +332,7 @@ struct airoha_pinctrl_func_group {
 };
 
 struct airoha_pinctrl_func {
-	const struct function_desc desc;
+	const struct pinfunction desc;
 	const struct airoha_pinctrl_func_group *groups;
 	u8 group_size;
 };
@@ -2908,11 +2906,11 @@ static int airoha_pinctrl_probe(struct platform_device *pdev)
 
 		func = &airoha_pinctrl_funcs[i];
 		err = pinmux_generic_add_pinfunction(pinctrl->ctrl,
-						     &func->desc.func,
+						     &func->desc,
 						     (void *)func);
 		if (err < 0) {
 			dev_err(dev, "Failed to register function %s\n",
-				func->desc.func.name);
+				func->desc.name);
 			return err;
 		}
 	}

-- 
2.48.1
Re: [PATCH v4 03/15] pinctrl: airoha: replace struct function_desc with struct pinfunction
Posted by Andy Shevchenko 1 month, 3 weeks ago
On Tue, Aug 12, 2025 at 10:27 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> struct function_desc is a wrapper around struct pinfunction with an
> additional void *data pointer. This driver doesn't use the data pointer.
> We're also working towards reducing the usage of struct function_desc in
> pinctrl drivers - they should only be created by pinmux core and
> accessed by drivers using pinmux_generic_get_function(). Replace the
> struct function_desc objects in this driver with smaller struct
> pinfunction instances.

...

>  #define PINCTRL_FUNC_DESC(id)                                          \
>         {                                                               \
>                 .desc = {                                               \
> -                       .func = {                                       \
> -                               .name = #id,                            \
> -                               .groups = id##_groups,                  \
> -                               .ngroups = ARRAY_SIZE(id##_groups),     \
> -                       }                                               \
> +                       .name = #id,                                    \
> +                       .groups = id##_groups,                          \
> +                       .ngroups = ARRAY_SIZE(id##_groups),             \

Can this use PINCTRL_PINFUNCITON() ?

>                 },                                                      \
>                 .groups = id##_func_group,                              \
>                 .group_size = ARRAY_SIZE(id##_func_group),              \

>  };

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v4 03/15] pinctrl: airoha: replace struct function_desc with struct pinfunction
Posted by Bartosz Golaszewski 1 month, 3 weeks ago
On Wed, 13 Aug 2025 18:57:00 +0200, Andy Shevchenko
<andy.shevchenko@gmail.com> said:
> On Tue, Aug 12, 2025 at 10:27 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>>
>> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>>
>> struct function_desc is a wrapper around struct pinfunction with an
>> additional void *data pointer. This driver doesn't use the data pointer.
>> We're also working towards reducing the usage of struct function_desc in
>> pinctrl drivers - they should only be created by pinmux core and
>> accessed by drivers using pinmux_generic_get_function(). Replace the
>> struct function_desc objects in this driver with smaller struct
>> pinfunction instances.
>
> ...
>
>>  #define PINCTRL_FUNC_DESC(id)                                          \
>>         {                                                               \
>>                 .desc = {                                               \
>> -                       .func = {                                       \
>> -                               .name = #id,                            \
>> -                               .groups = id##_groups,                  \
>> -                               .ngroups = ARRAY_SIZE(id##_groups),     \
>> -                       }                                               \
>> +                       .name = #id,                                    \
>> +                       .groups = id##_groups,                          \
>> +                       .ngroups = ARRAY_SIZE(id##_groups),             \
>
> Can this use PINCTRL_PINFUNCITON() ?
>

Yes, it can. I'll update v5.

Bart

>>                 },                                                      \
>>                 .groups = id##_func_group,                              \
>>                 .group_size = ARRAY_SIZE(id##_func_group),              \
>
>>  };
>
> --
> With Best Regards,
> Andy Shevchenko
>