pinctrl: Introduce struct pinfunction and PINCTRL_PINFUNCTION() macro
PATCH 1/8 pinctrl: Introduce struct pinfunction and PINCTRL_PINFUNCTION() macro
There are many pin control drivers define their own data type for pin function representation which is the same or embed the same data as newly introduced one. Provide the data type and convenient macro for all pin control drivers.
--- include/linux/pinctrl/pinctrl.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/linux/pinctrl/pinctrl.h +20 -0
@@ -206,6 +206,26 @@ extern int pinctrl_get_group_pins(struct pinctrl_dev *pctldev, const char *pin_group, const unsigned **pins, unsigned *num_pins); +/** +* struct pinfunction - Description about a function +* @name: Name of the function +* @groups: An array of groups for this function +* @ngroups: Number of groups in @groups +*/ +struct pinfunction { +const char *name; +const char *const *groups; +size_t ngroups; +}; + +/* Convenience macro to define a single named pinfunction */ +#define PINCTRL_PINFUNCTION (_name, _groups, _ngroups) \ +(struct pinfunction) { \ + .name = (_name), \ + .groups = (_groups), \ + .ngroups = (_ngroups), \ + } +#if IS_ENABLED (CONFIG_OF ) &&IS_ENABLED (CONFIG_PINCTRL )extern struct pinctrl_dev *of_pinctrl_get (struct device_node *np);#else
Signature · 1 line
2.35.1
PATCH 2/8 pinctrl: intel: Make use of struct pinfunction and PINCTRL_PINFUNCTION()
Since pin control provides a generic data type and a macro for the pin function definition, use them in the Intel driver.
---
I went with the embedding a generic structure into intel_function instead of replacing the latter in order to keep symmetry with intel_pingroup. In the case we will need the additional memeber in the future there will be less churn, otherwise from the code generation perspective it's the same.
drivers/pinctrl/intel/pinctrl-intel.c | 6 +++--- drivers/pinctrl/intel/pinctrl-intel.h | 13 ++++++++----- 2 files changed, 11 insertions(+), 8 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.c +3 -3
@@ -372,7 +372,7 @@ static const char *intel_get_function_name(struct pinctrl_dev *pctldev, {struct intel_pinctrl *pctrl =pinctrl_dev_get_drvdata (pctldev); -return pctrl->soc->functions[function].name; +return pctrl->soc->functions[function].func.name; } static int intel_get_function_groups(struct pinctrl_dev *pctldev,
@@ -382,8 +382,8 @@ static int intel_get_function_groups(struct pinctrl_dev *pctldev, {struct intel_pinctrl *pctrl =pinctrl_dev_get_drvdata (pctldev); - *groups = pctrl->soc->functions[function].groups; - *ngroups = pctrl->soc->functions[function].ngroups; + *groups = pctrl->soc->functions[function].func.groups; + *ngroups = pctrl->soc->functions[function].func.ngroups;return 0 ; }
drivers/pinctrl/intel/pinctrl-intel.h +8 -5
@@ -36,11 +36,13 @@ struct intel_pingroup {/** * struct intel_function - Description about a function +* @func: Generic data of the pin function (name and groups of pins) * @name: Name of the function * @groups: An array of groups for this function * @ngroups: Number of groups in @groups */ struct intel_function { +struct pinfunction func;const char *name;const char *const *groups;size_t ngroups;
@@ -183,11 +185,12 @@ struct intel_community { .modes = __builtin_choose_expr(__builtin_constant_p((m)), NULL, (m)), \ } -#define FUNCTION (n, g) \ - { \ - .name = (n), \ - .groups = (g), \ - .ngroups = ARRAY_SIZE((g)), \ +#define FUNCTION (n, g) \ + { \ + .func = PINCTRL_PINFUNCTION((n), (g), ARRAY_SIZE(g)), \ + .name = (n), \ + .groups = (g), \ + .ngroups = ARRAY_SIZE((g)), \ }/**
Signature · 1 line
2.35.1
PATCH 3/8 pinctrl: baytrail: Convert to use new memeber in struct intel_function
In reply to Andy ShevchenkoConvert driver to use generic data type and hence a new member in the struct intel_function. No functional change intended.
--- drivers/pinctrl/intel/pinctrl-baytrail.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/pinctrl/intel/pinctrl-baytrail.c +5 -5
@@ -637,18 +637,18 @@ static const char *byt_get_function_name(struct pinctrl_dev *pctldev, {struct intel_pinctrl *vg =pinctrl_dev_get_drvdata (pctldev); -return vg->soc->functions[selector].name; +return vg->soc->functions[selector].func.name; }static int byt_get_function_groups (struct pinctrl_dev *pctldev,unsigned int selector,const char *const **groups, -unsigned int *num_groups) +unsigned int *ngroups) {struct intel_pinctrl *vg =pinctrl_dev_get_drvdata (pctldev); - *groups = vg->soc->functions[selector].groups; - *num_groups = vg->soc->functions[selector].ngroups; + *groups = vg->soc->functions[selector].func.groups; + *ngroups = vg->soc->functions[selector].func.ngroups;return 0 ; }
@@ -722,7 +722,7 @@ static int byt_set_mux(struct pinctrl_dev *pctldev, unsigned int func_selector,if (group.modes)byt_set_group_mixed_mux (vg, group, group.modes); -else if (!strcmp (func.name,"gpio" )) +else if (!strcmp (func.func.name,"gpio" ))byt_set_group_simple_mux (vg, group,BYT_DEFAULT_GPIO_MUX );else byt_set_group_simple_mux (vg, group, group.mode);
Signature · 1 line
2.35.1
PATCH 4/8 pinctrl: cherryview: Convert to use new memeber in struct intel_function
In reply to Andy ShevchenkoConvert driver to use generic data type and hence a new member in the struct intel_function. No functional change intended.
--- drivers/pinctrl/intel/pinctrl-cherryview.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-cherryview.c +3 -3
@@ -694,7 +694,7 @@ static const char *chv_get_function_name(struct pinctrl_dev *pctldev, {struct intel_pinctrl *pctrl =pinctrl_dev_get_drvdata (pctldev); -return pctrl->soc->functions[function].name; +return pctrl->soc->functions[function].func.name; } static int chv_get_function_groups(struct pinctrl_dev *pctldev,
@@ -704,8 +704,8 @@ static int chv_get_function_groups(struct pinctrl_dev *pctldev, {struct intel_pinctrl *pctrl =pinctrl_dev_get_drvdata (pctldev); - *groups = pctrl->soc->functions[function].groups; - *ngroups = pctrl->soc->functions[function].ngroups; + *groups = pctrl->soc->functions[function].func.groups; + *ngroups = pctrl->soc->functions[function].func.ngroups;return 0 ; }
Signature · 1 line
2.35.1
PATCH 5/8 pinctrl: lynxpoint: Convert to use new memeber in struct intel_function
In reply to Andy ShevchenkoConvert driver to use generic data type and hence a new member in the struct intel_function. No functional change intended.
--- drivers/pinctrl/intel/pinctrl-lynxpoint.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/intel/pinctrl-lynxpoint.c +4 -4
@@ -341,18 +341,18 @@ static const char *lp_get_function_name(struct pinctrl_dev *pctldev, {struct intel_pinctrl *lg =pinctrl_dev_get_drvdata (pctldev); -return lg->soc->functions[selector].name; +return lg->soc->functions[selector].func.name; }static int lp_get_function_groups (struct pinctrl_dev *pctldev,unsigned int selector,const char *const **groups, -unsigned int *num_groups) +unsigned int *ngroups) {struct intel_pinctrl *lg =pinctrl_dev_get_drvdata (pctldev); - *groups = lg->soc->functions[selector].groups; - *num_groups = lg->soc->functions[selector].ngroups; + *groups = lg->soc->functions[selector].func.groups; + *ngroups = lg->soc->functions[selector].func.ngroups;return 0 ; }
Signature · 1 line
2.35.1
PATCH 6/8 pinctrl: merrifield: Convert to use new memeber in struct intel_function
In reply to Andy ShevchenkoConvert driver to use generic data type and hence a new member in the struct intel_function. No functional change intended.
--- drivers/pinctrl/intel/pinctrl-merrifield.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-merrifield.c +3 -3
@@ -576,7 +576,7 @@ static const char *mrfld_get_function_name(struct pinctrl_dev *pctldev, {struct mrfld_pinctrl *mp =pinctrl_dev_get_drvdata (pctldev); -return mp->functions[function].name; +return mp->functions[function].func.name; } static int mrfld_get_function_groups(struct pinctrl_dev *pctldev,
@@ -586,8 +586,8 @@ static int mrfld_get_function_groups(struct pinctrl_dev *pctldev, {struct mrfld_pinctrl *mp =pinctrl_dev_get_drvdata (pctldev); - *groups = mp->functions[function].groups; - *ngroups = mp->functions[function].ngroups; + *groups = mp->functions[function].func.groups; + *ngroups = mp->functions[function].func.ngroups;return 0 ; }
Signature · 1 line
2.35.1
PATCH 7/8 pinctrl: moorefield: Convert to use new memeber in struct intel_function
In reply to Andy ShevchenkoConvert driver to use generic data type and hence a new member in the struct intel_function. No functional change intended.
--- drivers/pinctrl/intel/pinctrl-moorefield.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/intel/pinctrl-moorefield.c +3 -3
@@ -530,7 +530,7 @@ static const char *mofld_get_function_name(struct pinctrl_dev *pctldev, unsigned {struct mofld_pinctrl *mp =pinctrl_dev_get_drvdata (pctldev); -return mp->functions[function].name; +return mp->functions[function].func.name; } static int mofld_get_function_groups(struct pinctrl_dev *pctldev, unsigned int function,
@@ -538,8 +538,8 @@ static int mofld_get_function_groups(struct pinctrl_dev *pctldev, unsigned int f {struct mofld_pinctrl *mp =pinctrl_dev_get_drvdata (pctldev); - *groups = mp->functions[function].groups; - *ngroups = mp->functions[function].ngroups; + *groups = mp->functions[function].func.groups; + *ngroups = mp->functions[function].func.ngroups;return 0 ; }
Signature · 1 line
2.35.1
PATCH 8/8 pinctrl: intel: Get rid of unused members in struct intel_function
In reply to Andy ShevchenkoThe driver has been converted to a generic data type and macro for the pin function definition, hence get rid of not used members in the struct intel_function.
--- drivers/pinctrl/intel/pinctrl-intel.h | 9 --------- 1 file changed, 9 deletions(-)
drivers/pinctrl/intel/pinctrl-intel.h +0 -9
@@ -37,15 +37,9 @@ struct intel_pingroup {/** * struct intel_function - Description about a function * @func: Generic data of the pin function (name and groups of pins) -* @name: Name of the function -* @groups: An array of groups for this function -* @ngroups: Number of groups in @groups */ struct intel_function {struct pinfunction func; -const char *name; -const char *const *groups; -size_t ngroups; };#define INTEL_PINCTRL_MAX_GPP_SIZE 32
@@ -188,9 +182,6 @@ struct intel_community {#define FUNCTION (n, g) \ { \ .func = PINCTRL_PINFUNCTION((n), (g), ARRAY_SIZE(g)), \ - .name = (n), \ - .groups = (g), \ - .ngroups = ARRAY_SIZE((g)), \ }/**
Signature · 1 line
2.35.1
Quoted 4 lines · Andy Shevchenko
There are many pin control drivers define their own data type for pin function representation which is the same or embed the same data as newly introduced one. Provide the data type and convenient macro for all pin control drivers.
The stats for the entire series:
drivers/pinctrl/intel/pinctrl-baytrail.c | 10 +++++----- drivers/pinctrl/intel/pinctrl-cherryview.c | 6 +++--- drivers/pinctrl/intel/pinctrl-intel.c | 6 +++--- drivers/pinctrl/intel/pinctrl-intel.h | 16 +++++----------- drivers/pinctrl/intel/pinctrl-lynxpoint.c | 8 ++++---- drivers/pinctrl/intel/pinctrl-merrifield.c | 6 +++--- drivers/pinctrl/intel/pinctrl-moorefield.c | 6 +++--- include/linux/pinctrl/pinctrl.h | 20 ++++++++++++++++++++ 8 files changed, 46 insertions(+), 32 deletions(-)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
There are many pin control drivers define their own data type for pin function representation which is the same or embed the same data as newly introduced one. Provide the data type and convenient macro for all pin control drivers.
The stats for the entire series:
Quoted 9 lines
drivers/pinctrl/intel/pinctrl-baytrail.c | 10 +++++----- drivers/pinctrl/intel/pinctrl-cherryview.c | 6 +++--- drivers/pinctrl/intel/pinctrl-intel.c | 6 +++--- drivers/pinctrl/intel/pinctrl-intel.h | 16 +++++----------- drivers/pinctrl/intel/pinctrl-lynxpoint.c | 8 ++++---- drivers/pinctrl/intel/pinctrl-merrifield.c | 6 +++--- drivers/pinctrl/intel/pinctrl-moorefield.c | 6 +++--- include/linux/pinctrl/pinctrl.h | 20 ++++++++++++++++++++ 8 files changed, 46 insertions(+), 32 deletions(-)
Thanks!
For the series,
Quoted 19 lines · Mika Westerberg
Quoted 8 lines · Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
There are many pin control drivers define their own data type for pin function representation which is the same or embed the same data as newly introduced one. Provide the data type and convenient macro for all pin control drivers.
The stats for the entire series:
Quoted 9 lines
drivers/pinctrl/intel/pinctrl-baytrail.c | 10 +++++----- drivers/pinctrl/intel/pinctrl-cherryview.c | 6 +++--- drivers/pinctrl/intel/pinctrl-intel.c | 6 +++--- drivers/pinctrl/intel/pinctrl-intel.h | 16 +++++----------- drivers/pinctrl/intel/pinctrl-lynxpoint.c | 8 ++++---- drivers/pinctrl/intel/pinctrl-merrifield.c | 6 +++--- drivers/pinctrl/intel/pinctrl-moorefield.c | 6 +++--- include/linux/pinctrl/pinctrl.h | 20 ++++++++++++++++++++ 8 files changed, 46 insertions(+), 32 deletions(-)
Quoted 5 lines
Thanks!
For the series,
Acked-by Mika Westerberg <[email protected]>
Pushed to my review and testing queue, thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 6 lines · Andy Shevchenko
There are many pin control drivers define their own data type for pin function representation which is the same or embed the same data as newly introduced one. Provide the data type and convenient macro for all pin control drivers.
Signed-off-by Andy Shevchenko <[email protected]>
Very nice and helpful!
Yours,
Linus Walleij