diff mbox series

[v2,4/9] mfd: cs5535-mfd: Register clients using their own dedicated MFD cell entries

Message ID 20191021105822.20271-5-lee.jones@linaro.org (mailing list archive)
State New, archived
Headers show
Series Simplify MFD Core | expand

Commit Message

Lee Jones Oct. 21, 2019, 10:58 a.m. UTC
CS5535 is the only user of mfd_clone_cell().  It makes more sense to
register child devices in the traditional way and remove the quite
bespoke mfd_clone_cell() call from the MFD API.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/cs5535-mfd.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

Comments

Daniel Thompson Oct. 21, 2019, 12:29 p.m. UTC | #1
On Mon, Oct 21, 2019 at 11:58:17AM +0100, Lee Jones wrote:
> CS5535 is the only user of mfd_clone_cell().  It makes more sense to
> register child devices in the traditional way and remove the quite
> bespoke mfd_clone_cell() call from the MFD API.
> 
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/mfd/cs5535-mfd.c | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c
> index 053e33447808..96a99ac13384 100644
> --- a/drivers/mfd/cs5535-mfd.c
> +++ b/drivers/mfd/cs5535-mfd.c
> @@ -57,9 +57,17 @@ static struct mfd_cell cs5535_mfd_cells[] = {
>  	},
>  };
>  
> -static const char *olpc_acpi_clones[] = {
> -	"olpc-xo1-pm-acpi",
> -	"olpc-xo1-sci-acpi"
> +static struct mfd_cell cs5535_olpc_mfd_cells[] = {
> +	{
> +		.name = "olpc-xo1-pm-acpi",
> +		.num_resources = 1,
> +		.resources = &cs5535_mfd_resources[ACPI_BAR],
> +	},
> +	{
> +		.name = "olpc-xo1-sci-acpi",
> +		.num_resources = 1,
> +		.resources = &cs5535_mfd_resources[ACPI_BAR],
> +	},

Is the cs5535-acpi cell actually used by anything? I think it was only
ever used as a template and can be removed; I didn't spot any driver that
uses it.

PS If the cell were removed then my review comment on the previous patch
   becomes moot ;-)


>  };
>  
>  static int cs5535_mfd_probe(struct pci_dev *pdev,
> @@ -105,10 +113,14 @@ static int cs5535_mfd_probe(struct pci_dev *pdev,
>  			goto err_remove_devices;
>  		}
>  
> -		err = mfd_clone_cell("cs5535-acpi", olpc_acpi_clones,
> -				     ARRAY_SIZE(olpc_acpi_clones));
> +		err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
> +				      cs5535_olpc_mfd_cells,
> +				      ARRAY_SIZE(cs5535_olpc_mfd_cells),
> +				      NULL, 0, NULL);
>  		if (err) {
> -			dev_err(&pdev->dev, "Failed to clone MFD cell\n");
> +			dev_err(&pdev->dev,
> +				"Failed to add CS5532 OLPC sub-devices: %d\n",
> +				err);
>  			goto err_release_acpi;
>  		}
>  	}
> -- 
> 2.17.1
>
Lee Jones Oct. 21, 2019, 1:21 p.m. UTC | #2
On Mon, 21 Oct 2019, Daniel Thompson wrote:

> On Mon, Oct 21, 2019 at 11:58:17AM +0100, Lee Jones wrote:
> > CS5535 is the only user of mfd_clone_cell().  It makes more sense to
> > register child devices in the traditional way and remove the quite
> > bespoke mfd_clone_cell() call from the MFD API.
> > 
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  drivers/mfd/cs5535-mfd.c | 24 ++++++++++++++++++------
> >  1 file changed, 18 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c
> > index 053e33447808..96a99ac13384 100644
> > --- a/drivers/mfd/cs5535-mfd.c
> > +++ b/drivers/mfd/cs5535-mfd.c
> > @@ -57,9 +57,17 @@ static struct mfd_cell cs5535_mfd_cells[] = {
> >  	},
> >  };
> >  
> > -static const char *olpc_acpi_clones[] = {
> > -	"olpc-xo1-pm-acpi",
> > -	"olpc-xo1-sci-acpi"
> > +static struct mfd_cell cs5535_olpc_mfd_cells[] = {
> > +	{
> > +		.name = "olpc-xo1-pm-acpi",
> > +		.num_resources = 1,
> > +		.resources = &cs5535_mfd_resources[ACPI_BAR],
> > +	},
> > +	{
> > +		.name = "olpc-xo1-sci-acpi",
> > +		.num_resources = 1,
> > +		.resources = &cs5535_mfd_resources[ACPI_BAR],
> > +	},
> 
> Is the cs5535-acpi cell actually used by anything? I think it was only
> ever used as a template and can be removed; I didn't spot any driver that
> uses it.

I did think about this, but I assumed removing it at this stage would
make the resource matching below more convoluted.

I'll take another look at see what I can do.

> PS If the cell were removed then my review comment on the previous patch
>    becomes moot ;-)
> 
> 
> >  };
> >  
> >  static int cs5535_mfd_probe(struct pci_dev *pdev,
> > @@ -105,10 +113,14 @@ static int cs5535_mfd_probe(struct pci_dev *pdev,
> >  			goto err_remove_devices;
> >  		}
> >  
> > -		err = mfd_clone_cell("cs5535-acpi", olpc_acpi_clones,
> > -				     ARRAY_SIZE(olpc_acpi_clones));
> > +		err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
> > +				      cs5535_olpc_mfd_cells,
> > +				      ARRAY_SIZE(cs5535_olpc_mfd_cells),
> > +				      NULL, 0, NULL);
> >  		if (err) {
> > -			dev_err(&pdev->dev, "Failed to clone MFD cell\n");
> > +			dev_err(&pdev->dev,
> > +				"Failed to add CS5532 OLPC sub-devices: %d\n",
> > +				err);
> >  			goto err_release_acpi;
> >  		}
> >  	}
diff mbox series

Patch

diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c
index 053e33447808..96a99ac13384 100644
--- a/drivers/mfd/cs5535-mfd.c
+++ b/drivers/mfd/cs5535-mfd.c
@@ -57,9 +57,17 @@  static struct mfd_cell cs5535_mfd_cells[] = {
 	},
 };
 
-static const char *olpc_acpi_clones[] = {
-	"olpc-xo1-pm-acpi",
-	"olpc-xo1-sci-acpi"
+static struct mfd_cell cs5535_olpc_mfd_cells[] = {
+	{
+		.name = "olpc-xo1-pm-acpi",
+		.num_resources = 1,
+		.resources = &cs5535_mfd_resources[ACPI_BAR],
+	},
+	{
+		.name = "olpc-xo1-sci-acpi",
+		.num_resources = 1,
+		.resources = &cs5535_mfd_resources[ACPI_BAR],
+	},
 };
 
 static int cs5535_mfd_probe(struct pci_dev *pdev,
@@ -105,10 +113,14 @@  static int cs5535_mfd_probe(struct pci_dev *pdev,
 			goto err_remove_devices;
 		}
 
-		err = mfd_clone_cell("cs5535-acpi", olpc_acpi_clones,
-				     ARRAY_SIZE(olpc_acpi_clones));
+		err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE,
+				      cs5535_olpc_mfd_cells,
+				      ARRAY_SIZE(cs5535_olpc_mfd_cells),
+				      NULL, 0, NULL);
 		if (err) {
-			dev_err(&pdev->dev, "Failed to clone MFD cell\n");
+			dev_err(&pdev->dev,
+				"Failed to add CS5532 OLPC sub-devices: %d\n",
+				err);
 			goto err_release_acpi;
 		}
 	}