diff mbox series

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

Message ID 20191018125608.5362-4-lee.jones@linaro.org
State New
Headers show
Series Remove mfd_clone_cell() from the MFD API | expand

Commit Message

Lee Jones Oct. 18, 2019, 12:56 p.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 | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

-- 
2.17.1

Comments

Daniel Thompson Oct. 18, 2019, 4:06 p.m. UTC | #1
On Fri, Oct 18, 2019 at 01:56:07PM +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.


Like the other thread... this looks like it takes a shared (cloned)
reference counter and creates two independant ones instead.


Daniel.

> 

> Signed-off-by: Lee Jones <lee.jones@linaro.org>

> ---

>  drivers/mfd/cs5535-mfd.c | 34 +++++++++++++++++++++++++++++-----

>  1 file changed, 29 insertions(+), 5 deletions(-)

> 

> diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c

> index b01e5bb4ed03..2711e6e42742 100644

> --- a/drivers/mfd/cs5535-mfd.c

> +++ b/drivers/mfd/cs5535-mfd.c

> @@ -95,9 +95,23 @@ 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],

> +

> +		.enable = cs5535_mfd_res_enable,

> +		.disable = cs5535_mfd_res_disable,

> +	},

> +	{

> +		.name = "olpc-xo1-sci-acpi",

> +		.num_resources = 1,

> +		.resources = &cs5535_mfd_resources[ACPI_BAR],

> +

> +		.enable = cs5535_mfd_res_enable,

> +		.disable = cs5535_mfd_res_disable,

> +	},

>  };

>  

>  static int cs5535_mfd_probe(struct pci_dev *pdev,

> @@ -130,8 +144,18 @@ static int cs5535_mfd_probe(struct pci_dev *pdev,

>  		goto err_disable;

>  	}

>  

> -	if (machine_is_olpc())

> -		mfd_clone_cell("cs5535-acpi", olpc_acpi_clones, ARRAY_SIZE(olpc_acpi_clones));

> +	if (machine_is_olpc()) {

> +		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 add CS5532 OLPC sub-devices: %d\n",

> +				err);

> +			goto err_disable;

> +		}

> +	}

>  

>  	dev_info(&pdev->dev, "%zu devices registered.\n",

>  			ARRAY_SIZE(cs5535_mfd_cells));

> -- 

> 2.17.1

>
diff mbox series

Patch

diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c
index b01e5bb4ed03..2711e6e42742 100644
--- a/drivers/mfd/cs5535-mfd.c
+++ b/drivers/mfd/cs5535-mfd.c
@@ -95,9 +95,23 @@  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],
+
+		.enable = cs5535_mfd_res_enable,
+		.disable = cs5535_mfd_res_disable,
+	},
+	{
+		.name = "olpc-xo1-sci-acpi",
+		.num_resources = 1,
+		.resources = &cs5535_mfd_resources[ACPI_BAR],
+
+		.enable = cs5535_mfd_res_enable,
+		.disable = cs5535_mfd_res_disable,
+	},
 };
 
 static int cs5535_mfd_probe(struct pci_dev *pdev,
@@ -130,8 +144,18 @@  static int cs5535_mfd_probe(struct pci_dev *pdev,
 		goto err_disable;
 	}
 
-	if (machine_is_olpc())
-		mfd_clone_cell("cs5535-acpi", olpc_acpi_clones, ARRAY_SIZE(olpc_acpi_clones));
+	if (machine_is_olpc()) {
+		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 add CS5532 OLPC sub-devices: %d\n",
+				err);
+			goto err_disable;
+		}
+	}
 
 	dev_info(&pdev->dev, "%zu devices registered.\n",
 			ARRAY_SIZE(cs5535_mfd_cells));