[v1,5/5] mfd: intel_quark_i2c_gpio: Reuse BAR definitions for MFD cell indexing
diff mbox series

Message ID 20210302135620.89958-5-andriy.shevchenko@linux.intel.com
State New, archived
Headers show
Series
  • [v1,1/5] mfd: intel_quark_i2c_gpio: revert "Constify static struct resources"
Related show

Commit Message

Andy Shevchenko March 2, 2021, 1:56 p.m. UTC
It's convenient and less error prone to use definitions to address
different cells in an array. For this purpose we may reuse existing
BAR definitions.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/mfd/intel_quark_i2c_gpio.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Comments

Lee Jones March 23, 2021, 9:20 a.m. UTC | #1
On Tue, 02 Mar 2021, Andy Shevchenko wrote:

> It's convenient and less error prone to use definitions to address
> different cells in an array. For this purpose we may reuse existing
> BAR definitions.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/mfd/intel_quark_i2c_gpio.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mfd/intel_quark_i2c_gpio.c b/drivers/mfd/intel_quark_i2c_gpio.c
> index 7af22d1399e1..40871ce34e82 100644
> --- a/drivers/mfd/intel_quark_i2c_gpio.c
> +++ b/drivers/mfd/intel_quark_i2c_gpio.c
> @@ -98,14 +98,6 @@ static struct mfd_cell_acpi_match intel_quark_acpi_match_gpio = {
>  };
>  
>  static struct mfd_cell intel_quark_mfd_cells[] = {
> -	{
> -		.id = MFD_GPIO_BAR,
> -		.name = "gpio-dwapb",
> -		.acpi_match = &intel_quark_acpi_match_gpio,
> -		.num_resources = ARRAY_SIZE(intel_quark_gpio_res),
> -		.resources = intel_quark_gpio_res,
> -		.ignore_resource_conflicts = true,
> -	},
>  	{
>  		.id = MFD_I2C_BAR,
>  		.name = "i2c_designware",
> @@ -114,6 +106,14 @@ static struct mfd_cell intel_quark_mfd_cells[] = {
>  		.resources = intel_quark_i2c_res,
>  		.ignore_resource_conflicts = true,
>  	},
> +	{
> +		.id = MFD_GPIO_BAR,
> +		.name = "gpio-dwapb",
> +		.acpi_match = &intel_quark_acpi_match_gpio,
> +		.num_resources = ARRAY_SIZE(intel_quark_gpio_res),
> +		.resources = intel_quark_gpio_res,
> +		.ignore_resource_conflicts = true,
> +	},
>  };

I would make this more explicit.

[MFD_I2C_BAR] = { }

If someone comes along and re-reorders these, it will break.

>  static const struct pci_device_id intel_quark_mfd_ids[] = {
> @@ -245,11 +245,11 @@ static int intel_quark_mfd_probe(struct pci_dev *pdev,
>  	if (ret)
>  		return ret;
>  
> -	ret = intel_quark_i2c_setup(pdev, &intel_quark_mfd_cells[1]);
> +	ret = intel_quark_i2c_setup(pdev, &intel_quark_mfd_cells[MFD_I2C_BAR]);
>  	if (ret)
>  		goto err_unregister_i2c_clk;
>  
> -	ret = intel_quark_gpio_setup(pdev, &intel_quark_mfd_cells[0]);
> +	ret = intel_quark_gpio_setup(pdev, &intel_quark_mfd_cells[MFD_GPIO_BAR]);
>  	if (ret)
>  		goto err_unregister_i2c_clk;
>
Andy Shevchenko March 23, 2021, 10:31 a.m. UTC | #2
On Tue, Mar 23, 2021 at 09:20:57AM +0000, Lee Jones wrote:
> On Tue, 02 Mar 2021, Andy Shevchenko wrote:
> 
> > It's convenient and less error prone to use definitions to address
> > different cells in an array. For this purpose we may reuse existing
> > BAR definitions.

...

> > +	{
> > +		.id = MFD_GPIO_BAR,
> > +		.name = "gpio-dwapb",
> > +		.acpi_match = &intel_quark_acpi_match_gpio,
> > +		.num_resources = ARRAY_SIZE(intel_quark_gpio_res),
> > +		.resources = intel_quark_gpio_res,
> > +		.ignore_resource_conflicts = true,
> > +	},
> >  };
> 
> I would make this more explicit.
> 
> [MFD_I2C_BAR] = { }
> 
> If someone comes along and re-reorders these, it will break.

Agree.
Will do for v2.

Patch
diff mbox series

diff --git a/drivers/mfd/intel_quark_i2c_gpio.c b/drivers/mfd/intel_quark_i2c_gpio.c
index 7af22d1399e1..40871ce34e82 100644
--- a/drivers/mfd/intel_quark_i2c_gpio.c
+++ b/drivers/mfd/intel_quark_i2c_gpio.c
@@ -98,14 +98,6 @@  static struct mfd_cell_acpi_match intel_quark_acpi_match_gpio = {
 };
 
 static struct mfd_cell intel_quark_mfd_cells[] = {
-	{
-		.id = MFD_GPIO_BAR,
-		.name = "gpio-dwapb",
-		.acpi_match = &intel_quark_acpi_match_gpio,
-		.num_resources = ARRAY_SIZE(intel_quark_gpio_res),
-		.resources = intel_quark_gpio_res,
-		.ignore_resource_conflicts = true,
-	},
 	{
 		.id = MFD_I2C_BAR,
 		.name = "i2c_designware",
@@ -114,6 +106,14 @@  static struct mfd_cell intel_quark_mfd_cells[] = {
 		.resources = intel_quark_i2c_res,
 		.ignore_resource_conflicts = true,
 	},
+	{
+		.id = MFD_GPIO_BAR,
+		.name = "gpio-dwapb",
+		.acpi_match = &intel_quark_acpi_match_gpio,
+		.num_resources = ARRAY_SIZE(intel_quark_gpio_res),
+		.resources = intel_quark_gpio_res,
+		.ignore_resource_conflicts = true,
+	},
 };
 
 static const struct pci_device_id intel_quark_mfd_ids[] = {
@@ -245,11 +245,11 @@  static int intel_quark_mfd_probe(struct pci_dev *pdev,
 	if (ret)
 		return ret;
 
-	ret = intel_quark_i2c_setup(pdev, &intel_quark_mfd_cells[1]);
+	ret = intel_quark_i2c_setup(pdev, &intel_quark_mfd_cells[MFD_I2C_BAR]);
 	if (ret)
 		goto err_unregister_i2c_clk;
 
-	ret = intel_quark_gpio_setup(pdev, &intel_quark_mfd_cells[0]);
+	ret = intel_quark_gpio_setup(pdev, &intel_quark_mfd_cells[MFD_GPIO_BAR]);
 	if (ret)
 		goto err_unregister_i2c_clk;