diff mbox series

[v3,10/10] mfd: mfd-core: Move pdev->mfd_cell creation back into mfd_add_device()

Message ID 20191024163832.31326-11-lee.jones@linaro.org
State Superseded
Headers show
Series Simplify MFD Core | expand

Commit Message

Lee Jones Oct. 24, 2019, 4:38 p.m. UTC
Most of the complexity of mfd_platform_add_cell() has been removed. The
only functionality left duplicates cell memory into the child's platform
device. Since it's only a few lines, moving it to the main thread and
removing the superfluous function makes sense.

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

---
 drivers/mfd/mfd-core.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

-- 
2.17.1

Comments

Daniel Thompson Oct. 25, 2019, 8:56 a.m. UTC | #1
On Thu, Oct 24, 2019 at 05:38:32PM +0100, Lee Jones wrote:
> Most of the complexity of mfd_platform_add_cell() has been removed. The

> only functionality left duplicates cell memory into the child's platform

> device. Since it's only a few lines, moving it to the main thread and

> removing the superfluous function makes sense.

> 

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


Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>



> ---

>  drivers/mfd/mfd-core.c | 21 ++++-----------------

>  1 file changed, 4 insertions(+), 17 deletions(-)

> 

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

> index 2535dd3605c0..cb3e0a14bbdd 100644

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

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

> @@ -49,19 +49,6 @@ int mfd_cell_disable(struct platform_device *pdev)

>  }

>  EXPORT_SYMBOL(mfd_cell_disable);

>  

> -static int mfd_platform_add_cell(struct platform_device *pdev,

> -				 const struct mfd_cell *cell)

> -{

> -	if (!cell)

> -		return 0;

> -

> -	pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL);

> -	if (!pdev->mfd_cell)

> -		return -ENOMEM;

> -

> -	return 0;

> -}

> -

>  #if IS_ENABLED(CONFIG_ACPI)

>  static void mfd_acpi_add_device(const struct mfd_cell *cell,

>  				struct platform_device *pdev)

> @@ -141,6 +128,10 @@ static int mfd_add_device(struct device *parent, int id,

>  	if (!pdev)

>  		goto fail_alloc;

>  

> +	pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL);

> +	if (!pdev->mfd_cell)

> +		goto fail_device;

> +

>  	res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL);

>  	if (!res)

>  		goto fail_device;

> @@ -183,10 +174,6 @@ static int mfd_add_device(struct device *parent, int id,

>  			goto fail_alias;

>  	}

>  

> -	ret = mfd_platform_add_cell(pdev, cell);

> -	if (ret)

> -		goto fail_alias;

> -

>  	for (r = 0; r < cell->num_resources; r++) {

>  		res[r].name = cell->resources[r].name;

>  		res[r].flags = cell->resources[r].flags;

> -- 

> 2.17.1

>
Mark Brown Oct. 25, 2019, 2:56 p.m. UTC | #2
On Thu, Oct 24, 2019 at 05:38:32PM +0100, Lee Jones wrote:
> Most of the complexity of mfd_platform_add_cell() has been removed. The

> only functionality left duplicates cell memory into the child's platform

> device. Since it's only a few lines, moving it to the main thread and

> removing the superfluous function makes sense.


Reviewed-by: Mark Brown <broonie@kernel.org>
diff mbox series

Patch

diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 2535dd3605c0..cb3e0a14bbdd 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -49,19 +49,6 @@  int mfd_cell_disable(struct platform_device *pdev)
 }
 EXPORT_SYMBOL(mfd_cell_disable);
 
-static int mfd_platform_add_cell(struct platform_device *pdev,
-				 const struct mfd_cell *cell)
-{
-	if (!cell)
-		return 0;
-
-	pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL);
-	if (!pdev->mfd_cell)
-		return -ENOMEM;
-
-	return 0;
-}
-
 #if IS_ENABLED(CONFIG_ACPI)
 static void mfd_acpi_add_device(const struct mfd_cell *cell,
 				struct platform_device *pdev)
@@ -141,6 +128,10 @@  static int mfd_add_device(struct device *parent, int id,
 	if (!pdev)
 		goto fail_alloc;
 
+	pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL);
+	if (!pdev->mfd_cell)
+		goto fail_device;
+
 	res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL);
 	if (!res)
 		goto fail_device;
@@ -183,10 +174,6 @@  static int mfd_add_device(struct device *parent, int id,
 			goto fail_alias;
 	}
 
-	ret = mfd_platform_add_cell(pdev, cell);
-	if (ret)
-		goto fail_alias;
-
 	for (r = 0; r < cell->num_resources; r++) {
 		res[r].name = cell->resources[r].name;
 		res[r].flags = cell->resources[r].flags;