2022-12-19 13:37:08

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 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.

Signed-off-by: Andy Shevchenko <[email protected]>
---
include/linux/pinctrl/pinctrl.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/include/linux/pinctrl/pinctrl.h b/include/linux/pinctrl/pinctrl.h
index a0d39b303431..4d252ea00ed1 100644
--- a/include/linux/pinctrl/pinctrl.h
+++ b/include/linux/pinctrl/pinctrl.h
@@ -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
--
2.35.1


2022-12-19 13:39:27

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 7/8] pinctrl: moorefield: Convert to use new memeber in struct intel_function

Convert driver to use generic data type and hence a new member in
the struct intel_function. No functional change intended.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/intel/pinctrl-moorefield.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-moorefield.c b/drivers/pinctrl/intel/pinctrl-moorefield.c
index e3eec671e15d..3c9a8484b442 100644
--- a/drivers/pinctrl/intel/pinctrl-moorefield.c
+++ b/drivers/pinctrl/intel/pinctrl-moorefield.c
@@ -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;
}

--
2.35.1

2022-12-19 13:46:25

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 4/8] pinctrl: cherryview: Convert to use new memeber in struct intel_function

Convert driver to use generic data type and hence a new member in
the struct intel_function. No functional change intended.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/intel/pinctrl-cherryview.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/intel/pinctrl-cherryview.c b/drivers/pinctrl/intel/pinctrl-cherryview.c
index 11b81213922d..722990e27836 100644
--- a/drivers/pinctrl/intel/pinctrl-cherryview.c
+++ b/drivers/pinctrl/intel/pinctrl-cherryview.c
@@ -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;
}

--
2.35.1

2022-12-19 15:58:35

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 1/8] pinctrl: Introduce struct pinfunction and PINCTRL_PINFUNCTION() macro

On Mon, Dec 19, 2022 at 02:42:33PM +0200, Andy Shevchenko wrote:
> 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(-)

--
With Best Regards,
Andy Shevchenko


2022-12-20 06:53:20

by Mika Westerberg

[permalink] [raw]
Subject: Re: [PATCH v1 1/8] pinctrl: Introduce struct pinfunction and PINCTRL_PINFUNCTION() macro

On Mon, Dec 19, 2022 at 04:42:41PM +0200, Andy Shevchenko wrote:
> On Mon, Dec 19, 2022 at 02:42:33PM +0200, Andy Shevchenko wrote:
> > 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(-)

Thanks!

For the series,

Acked-by: Mika Westerberg <[email protected]>

2022-12-27 22:41:45

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 1/8] pinctrl: Introduce struct pinfunction and PINCTRL_PINFUNCTION() macro

On Tue, Dec 20, 2022 at 08:20:31AM +0200, Mika Westerberg wrote:
> On Mon, Dec 19, 2022 at 04:42:41PM +0200, Andy Shevchenko wrote:
> > On Mon, Dec 19, 2022 at 02:42:33PM +0200, Andy Shevchenko wrote:
> > > 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(-)
>
> Thanks!
>
> For the series,
>
> Acked-by: Mika Westerberg <[email protected]>

Pushed to my review and testing queue, thanks!

--
With Best Regards,
Andy Shevchenko


2022-12-29 21:19:25

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v1 1/8] pinctrl: Introduce struct pinfunction and PINCTRL_PINFUNCTION() macro

On Mon, Dec 19, 2022 at 1:42 PM Andy Shevchenko
<[email protected]> wrote:

> 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!
Reviewed-by: Linus Walleij <[email protected]>

Yours,
Linus Walleij