diff mbox series

[V2,3/4] gpio: sprd: Modify the calculation method of eic number

Message ID 20230921090027.11136-4-Wenhua.Lin@unisoc.com
State Superseded
Headers show
Series None | expand

Commit Message

Wenhua Lin Sept. 21, 2023, 9 a.m. UTC
When the soc changes, the corresponding gpio-eic-sprd.c
code needs to be modified, and the corresponding
Document must also be modified, which is quite troublesome.
To avoid modifying the driver file, the number of EICs
is automatically calculated by matching dts nodes.

Fixes: 2788938b7946 ("gpio: eic-sprd: Make the irqchip immutable")

Signed-off-by: Wenhua Lin <Wenhua.Lin@unisoc.com>
---
 drivers/gpio/gpio-eic-sprd.c | 43 ++++++++++++++++++------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

Comments

Andy Shevchenko Sept. 21, 2023, 11:27 a.m. UTC | #1
On Thu, Sep 21, 2023 at 05:00:26PM +0800, Wenhua Lin wrote:
> When the soc changes, the corresponding gpio-eic-sprd.c
> code needs to be modified, and the corresponding
> Document must also be modified, which is quite troublesome.
> To avoid modifying the driver file, the number of EICs
> is automatically calculated by matching dts nodes.

> Fixes: 2788938b7946 ("gpio: eic-sprd: Make the irqchip immutable")
> 
> Signed-off-by: Wenhua Lin <Wenhua.Lin@unisoc.com>

Same comment as per patch 1. Also, fixes needs to be grouped at the beginning
of the series. (I don't remember seeing Fixes tag in the patch 2.)

...

> +#define SPRD_EIC_VAR_DATA(soc_name)				\

Misindented \

> +static const struct sprd_eic_variant_data soc_name##_eic_dbnc_data = {	\
> +	.type = SPRD_EIC_DEBOUNCE,					\
> +};									\

...

>  	struct sprd_eic *sprd_eic;
>  	struct resource *res;

>  	int ret, i;
> +	u16 num_banks = 0;

Preserve reversed xmas tree order.
Baolin Wang Sept. 27, 2023, 9:24 a.m. UTC | #2
On 9/21/2023 5:00 PM, Wenhua Lin wrote:
> When the soc changes, the corresponding gpio-eic-sprd.c
> code needs to be modified, and the corresponding
> Document must also be modified, which is quite troublesome.
> To avoid modifying the driver file, the number of EICs
> is automatically calculated by matching dts nodes.
> 
> Fixes: 2788938b7946 ("gpio: eic-sprd: Make the irqchip immutable")

This is not a bugfix and you still use an incorrect Fixes tag.

> 
> Signed-off-by: Wenhua Lin <Wenhua.Lin@unisoc.com>
> ---
>   drivers/gpio/gpio-eic-sprd.c | 43 ++++++++++++++++++------------------
>   1 file changed, 22 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
> index 96f1c7fd3988..e85addbdf8aa 100644
> --- a/drivers/gpio/gpio-eic-sprd.c
> +++ b/drivers/gpio/gpio-eic-sprd.c
> @@ -100,33 +100,32 @@ struct sprd_eic {
>   
>   struct sprd_eic_variant_data {
>   	enum sprd_eic_type type;
> -	u32 num_eics;
>   };
>   
> +#define SPRD_EIC_VAR_DATA(soc_name)				\
> +static const struct sprd_eic_variant_data soc_name##_eic_dbnc_data = {	\
> +	.type = SPRD_EIC_DEBOUNCE,					\
> +};									\
> +									\
> +static const struct sprd_eic_variant_data soc_name##_eic_latch_data = {	\
> +	.type = SPRD_EIC_LATCH,						\
> +};									\
> +									\
> +static const struct sprd_eic_variant_data soc_name##_eic_async_data = {	\
> +	.type = SPRD_EIC_ASYNC,						\
> +};									\
> +									\
> +static const struct sprd_eic_variant_data soc_name##_eic_sync_data = {	\
> +	.type = SPRD_EIC_SYNC,						\
> +}
> +
> +SPRD_EIC_VAR_DATA(sc9860);
> +
>   static const char *sprd_eic_label_name[SPRD_EIC_MAX] = {
>   	"eic-debounce", "eic-latch", "eic-async",
>   	"eic-sync",
>   };
>   
> -static const struct sprd_eic_variant_data sc9860_eic_dbnc_data = {
> -	.type = SPRD_EIC_DEBOUNCE,
> -	.num_eics = 8,
> -};
> -
> -static const struct sprd_eic_variant_data sc9860_eic_latch_data = {
> -	.type = SPRD_EIC_LATCH,
> -	.num_eics = 8,
> -};
> -
> -static const struct sprd_eic_variant_data sc9860_eic_async_data = {
> -	.type = SPRD_EIC_ASYNC,
> -	.num_eics = 8,
> -};
> -
> -static const struct sprd_eic_variant_data sc9860_eic_sync_data = {
> -	.type = SPRD_EIC_SYNC,
> -	.num_eics = 8,
> -};
>   
>   static inline void __iomem *sprd_eic_offset_base(struct sprd_eic *sprd_eic,
>   						 unsigned int bank)
> @@ -595,6 +594,7 @@ static int sprd_eic_probe(struct platform_device *pdev)
>   	struct sprd_eic *sprd_eic;
>   	struct resource *res;
>   	int ret, i;
> +	u16 num_banks = 0;
>   
>   	pdata = of_device_get_match_data(&pdev->dev);
>   	if (!pdata) {
> @@ -625,12 +625,13 @@ static int sprd_eic_probe(struct platform_device *pdev)
>   			break;
>   
>   		sprd_eic->base[i] = devm_ioremap_resource(&pdev->dev, res);
> +		num_banks++;

Please move this after the validation of the sprd_eic->base.

>   		if (IS_ERR(sprd_eic->base[i]))
>   			return PTR_ERR(sprd_eic->base[i]);
>   	}
>   
>   	sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type];
> -	sprd_eic->chip.ngpio = pdata->num_eics;
> +	sprd_eic->chip.ngpio = num_banks * SPRD_EIC_PER_BANK_NR;
>   	sprd_eic->chip.base = -1;
>   	sprd_eic->chip.parent = &pdev->dev;
>   	sprd_eic->chip.direction_input = sprd_eic_direction_input;
wenhua lin Jan. 3, 2024, 12:04 p.m. UTC | #3
On Wed, Sep 27, 2023 at 5:24 PM Baolin Wang
<baolin.wang@linux.alibaba.com> wrote:
>
>
>
> On 9/21/2023 5:00 PM, Wenhua Lin wrote:
> > When the soc changes, the corresponding gpio-eic-sprd.c
> > code needs to be modified, and the corresponding
> > Document must also be modified, which is quite troublesome.
> > To avoid modifying the driver file, the number of EICs
> > is automatically calculated by matching dts nodes.
> >
> > Fixes: 2788938b7946 ("gpio: eic-sprd: Make the irqchip immutable")
>
> This is not a bugfix and you still use an incorrect Fixes tag.
>
> >
> > Signed-off-by: Wenhua Lin <Wenhua.Lin@unisoc.com>
> > ---
> >   drivers/gpio/gpio-eic-sprd.c | 43 ++++++++++++++++++------------------
> >   1 file changed, 22 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
> > index 96f1c7fd3988..e85addbdf8aa 100644
> > --- a/drivers/gpio/gpio-eic-sprd.c
> > +++ b/drivers/gpio/gpio-eic-sprd.c
> > @@ -100,33 +100,32 @@ struct sprd_eic {
> >
> >   struct sprd_eic_variant_data {
> >       enum sprd_eic_type type;
> > -     u32 num_eics;
> >   };
> >
> > +#define SPRD_EIC_VAR_DATA(soc_name)                          \
> > +static const struct sprd_eic_variant_data soc_name##_eic_dbnc_data = {       \
> > +     .type = SPRD_EIC_DEBOUNCE,                                      \
> > +};                                                                   \
> > +                                                                     \
> > +static const struct sprd_eic_variant_data soc_name##_eic_latch_data = {      \
> > +     .type = SPRD_EIC_LATCH,                                         \
> > +};                                                                   \
> > +                                                                     \
> > +static const struct sprd_eic_variant_data soc_name##_eic_async_data = {      \
> > +     .type = SPRD_EIC_ASYNC,                                         \
> > +};                                                                   \
> > +                                                                     \
> > +static const struct sprd_eic_variant_data soc_name##_eic_sync_data = {       \
> > +     .type = SPRD_EIC_SYNC,                                          \
> > +}
> > +
> > +SPRD_EIC_VAR_DATA(sc9860);
> > +
> >   static const char *sprd_eic_label_name[SPRD_EIC_MAX] = {
> >       "eic-debounce", "eic-latch", "eic-async",
> >       "eic-sync",
> >   };
> >
> > -static const struct sprd_eic_variant_data sc9860_eic_dbnc_data = {
> > -     .type = SPRD_EIC_DEBOUNCE,
> > -     .num_eics = 8,
> > -};
> > -
> > -static const struct sprd_eic_variant_data sc9860_eic_latch_data = {
> > -     .type = SPRD_EIC_LATCH,
> > -     .num_eics = 8,
> > -};
> > -
> > -static const struct sprd_eic_variant_data sc9860_eic_async_data = {
> > -     .type = SPRD_EIC_ASYNC,
> > -     .num_eics = 8,
> > -};
> > -
> > -static const struct sprd_eic_variant_data sc9860_eic_sync_data = {
> > -     .type = SPRD_EIC_SYNC,
> > -     .num_eics = 8,
> > -};
> >
> >   static inline void __iomem *sprd_eic_offset_base(struct sprd_eic *sprd_eic,
> >                                                unsigned int bank)
> > @@ -595,6 +594,7 @@ static int sprd_eic_probe(struct platform_device *pdev)
> >       struct sprd_eic *sprd_eic;
> >       struct resource *res;
> >       int ret, i;
> > +     u16 num_banks = 0;
> >
> >       pdata = of_device_get_match_data(&pdev->dev);
> >       if (!pdata) {
> > @@ -625,12 +625,13 @@ static int sprd_eic_probe(struct platform_device *pdev)
> >                       break;
> >
> >               sprd_eic->base[i] = devm_ioremap_resource(&pdev->dev, res);
> > +             num_banks++;
>
> Please move this after the validation of the sprd_eic->base.

Thank you very much for your review.
I will fix this issue in patch v3.

>
> >               if (IS_ERR(sprd_eic->base[i]))
> >                       return PTR_ERR(sprd_eic->base[i]);
> >       }
> >
> >       sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type];
> > -     sprd_eic->chip.ngpio = pdata->num_eics;
> > +     sprd_eic->chip.ngpio = num_banks * SPRD_EIC_PER_BANK_NR;
> >       sprd_eic->chip.base = -1;
> >       sprd_eic->chip.parent = &pdev->dev;
> >       sprd_eic->chip.direction_input = sprd_eic_direction_input;
wenhua lin Jan. 4, 2024, 2:31 a.m. UTC | #4
On Thu, Sep 21, 2023 at 7:27 PM Andy Shevchenko <andy@kernel.org> wrote:
>
> On Thu, Sep 21, 2023 at 05:00:26PM +0800, Wenhua Lin wrote:
> > When the soc changes, the corresponding gpio-eic-sprd.c
> > code needs to be modified, and the corresponding
> > Document must also be modified, which is quite troublesome.
> > To avoid modifying the driver file, the number of EICs
> > is automatically calculated by matching dts nodes.
>
> > Fixes: 2788938b7946 ("gpio: eic-sprd: Make the irqchip immutable")
> >
> > Signed-off-by: Wenhua Lin <Wenhua.Lin@unisoc.com>
>
> Same comment as per patch 1. Also, fixes needs to be grouped at the beginning
> of the series. (I don't remember seeing Fixes tag in the patch 2.)
>
> ...
>
> > +#define SPRD_EIC_VAR_DATA(soc_name)                          \
>
> Misindented \

Thank you very much for your review.
I will fix this issue in patch v3.

>
> > +static const struct sprd_eic_variant_data soc_name##_eic_dbnc_data = {       \
> > +     .type = SPRD_EIC_DEBOUNCE,                                      \
> > +};                                                                   \
>
> ...
>
> >       struct sprd_eic *sprd_eic;
> >       struct resource *res;
>
> >       int ret, i;
> > +     u16 num_banks = 0;
>
> Preserve reversed xmas tree order.

Thank you very much for your review.
I will fix this issue in patch v3.

>
> --
> With Best Regards,
> Andy Shevchenko
>
>
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-eic-sprd.c b/drivers/gpio/gpio-eic-sprd.c
index 96f1c7fd3988..e85addbdf8aa 100644
--- a/drivers/gpio/gpio-eic-sprd.c
+++ b/drivers/gpio/gpio-eic-sprd.c
@@ -100,33 +100,32 @@  struct sprd_eic {
 
 struct sprd_eic_variant_data {
 	enum sprd_eic_type type;
-	u32 num_eics;
 };
 
+#define SPRD_EIC_VAR_DATA(soc_name)				\
+static const struct sprd_eic_variant_data soc_name##_eic_dbnc_data = {	\
+	.type = SPRD_EIC_DEBOUNCE,					\
+};									\
+									\
+static const struct sprd_eic_variant_data soc_name##_eic_latch_data = {	\
+	.type = SPRD_EIC_LATCH,						\
+};									\
+									\
+static const struct sprd_eic_variant_data soc_name##_eic_async_data = {	\
+	.type = SPRD_EIC_ASYNC,						\
+};									\
+									\
+static const struct sprd_eic_variant_data soc_name##_eic_sync_data = {	\
+	.type = SPRD_EIC_SYNC,						\
+}
+
+SPRD_EIC_VAR_DATA(sc9860);
+
 static const char *sprd_eic_label_name[SPRD_EIC_MAX] = {
 	"eic-debounce", "eic-latch", "eic-async",
 	"eic-sync",
 };
 
-static const struct sprd_eic_variant_data sc9860_eic_dbnc_data = {
-	.type = SPRD_EIC_DEBOUNCE,
-	.num_eics = 8,
-};
-
-static const struct sprd_eic_variant_data sc9860_eic_latch_data = {
-	.type = SPRD_EIC_LATCH,
-	.num_eics = 8,
-};
-
-static const struct sprd_eic_variant_data sc9860_eic_async_data = {
-	.type = SPRD_EIC_ASYNC,
-	.num_eics = 8,
-};
-
-static const struct sprd_eic_variant_data sc9860_eic_sync_data = {
-	.type = SPRD_EIC_SYNC,
-	.num_eics = 8,
-};
 
 static inline void __iomem *sprd_eic_offset_base(struct sprd_eic *sprd_eic,
 						 unsigned int bank)
@@ -595,6 +594,7 @@  static int sprd_eic_probe(struct platform_device *pdev)
 	struct sprd_eic *sprd_eic;
 	struct resource *res;
 	int ret, i;
+	u16 num_banks = 0;
 
 	pdata = of_device_get_match_data(&pdev->dev);
 	if (!pdata) {
@@ -625,12 +625,13 @@  static int sprd_eic_probe(struct platform_device *pdev)
 			break;
 
 		sprd_eic->base[i] = devm_ioremap_resource(&pdev->dev, res);
+		num_banks++;
 		if (IS_ERR(sprd_eic->base[i]))
 			return PTR_ERR(sprd_eic->base[i]);
 	}
 
 	sprd_eic->chip.label = sprd_eic_label_name[sprd_eic->type];
-	sprd_eic->chip.ngpio = pdata->num_eics;
+	sprd_eic->chip.ngpio = num_banks * SPRD_EIC_PER_BANK_NR;
 	sprd_eic->chip.base = -1;
 	sprd_eic->chip.parent = &pdev->dev;
 	sprd_eic->chip.direction_input = sprd_eic_direction_input;