public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Mark Brown <broonie@linaro.org>,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Carlo Caione <carlo@caione.org>,
	Maxime Ripard <maxime.ripard@free-electrons.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-sunxi@googlegroups.com
Subject: Re: [PATCH resend v2 1/3] mfd-core: Don't register supplies from add_device, add register_supply_aliases()
Date: Tue, 1 Jul 2014 10:22:55 +0100	[thread overview]
Message-ID: <20140701092255.GF27971@lee--X1> (raw)
In-Reply-To: <1404138369-23907-2-git-send-email-hdegoede@redhat.com>

On Mon, 30 Jun 2014, Hans de Goede wrote:

> We cannot register supply alias in mfd_add_device before calling
> platform_add_device because platform-dev's name must be set before registering
> the aliases which happens from platform_add_device.
> 
> So stop registering supply aliases from mfd_add_device, and add a
> mfd_register_supply_aliases helper functions for the cell's plaform driver
> probe method to use.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Didn't I already Ack this?

> ---
>  drivers/mfd/mfd-core.c   | 37 +++++++++++++++++++++----------------
>  include/linux/mfd/core.h |  6 +++++-
>  2 files changed, 26 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index 892d343..03f6fee 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -102,13 +102,6 @@ static int mfd_add_device(struct device *parent, int id,
>  	pdev->dev.dma_mask = parent->dma_mask;
>  	pdev->dev.dma_parms = parent->dma_parms;
>  
> -	ret = regulator_bulk_register_supply_alias(
> -			&pdev->dev, cell->parent_supplies,
> -			parent, cell->parent_supplies,
> -			cell->num_parent_supplies);
> -	if (ret < 0)
> -		goto fail_res;
> -
>  	if (parent->of_node && cell->of_compatible) {
>  		for_each_child_of_node(parent->of_node, np) {
>  			if (of_device_is_compatible(np, cell->of_compatible)) {
> @@ -122,12 +115,12 @@ static int mfd_add_device(struct device *parent, int id,
>  		ret = platform_device_add_data(pdev,
>  					cell->platform_data, cell->pdata_size);
>  		if (ret)
> -			goto fail_alias;
> +			goto fail_res;
>  	}
>  
>  	ret = mfd_platform_add_cell(pdev, cell, usage_count);
>  	if (ret)
> -		goto fail_alias;
> +		goto fail_res;
>  
>  	for (r = 0; r < cell->num_resources; r++) {
>  		res[r].name = cell->resources[r].name;
> @@ -162,17 +155,17 @@ static int mfd_add_device(struct device *parent, int id,
>  		if (!cell->ignore_resource_conflicts) {
>  			ret = acpi_check_resource_conflict(&res[r]);
>  			if (ret)
> -				goto fail_alias;
> +				goto fail_res;
>  		}
>  	}
>  
>  	ret = platform_device_add_resources(pdev, res, cell->num_resources);
>  	if (ret)
> -		goto fail_alias;
> +		goto fail_res;
>  
>  	ret = platform_device_add(pdev);
>  	if (ret)
> -		goto fail_alias;
> +		goto fail_res;
>  
>  	if (cell->pm_runtime_no_callbacks)
>  		pm_runtime_no_callbacks(&pdev->dev);
> @@ -181,10 +174,6 @@ static int mfd_add_device(struct device *parent, int id,
>  
>  	return 0;
>  
> -fail_alias:
> -	regulator_bulk_unregister_supply_alias(&pdev->dev,
> -					       cell->parent_supplies,
> -					       cell->num_parent_supplies);
>  fail_res:
>  	kfree(res);
>  fail_device:
> @@ -289,5 +278,21 @@ int mfd_clone_cell(const char *cell, const char **clones, size_t n_clones)
>  }
>  EXPORT_SYMBOL(mfd_clone_cell);
>  
> +int mfd_register_supply_aliases(struct platform_device *pdev)
> +{
> +	const struct mfd_cell *cell;
> +
> +	if (pdev->dev.type != &mfd_dev_type)
> +		return -EINVAL;
> +
> +	cell = mfd_get_cell(pdev);
> +
> +	return devm_regulator_bulk_register_supply_alias(
> +			&pdev->dev, cell->parent_supplies,
> +			pdev->dev.parent, cell->parent_supplies,
> +			cell->num_parent_supplies);
> +}
> +EXPORT_SYMBOL(mfd_register_supply_aliases);
> +
>  MODULE_LICENSE("GPL");
>  MODULE_AUTHOR("Ian Molton, Dmitry Baryshkov");
> diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
> index f543de9..f05488e 100644
> --- a/include/linux/mfd/core.h
> +++ b/include/linux/mfd/core.h
> @@ -61,7 +61,9 @@ struct mfd_cell {
>  	bool			pm_runtime_no_callbacks;
>  
>  	/* A list of regulator supplies that should be mapped to the MFD
> -	 * device rather than the child device when requested
> +	 * device rather than the child device when requested.
> +	 * Drivers using this must call mfd_register_supply_aliases()
> +	 * from their probe method.
>  	 */
>  	const char * const	*parent_supplies;
>  	int			num_parent_supplies;
> @@ -110,4 +112,6 @@ extern int mfd_add_devices(struct device *parent, int id,
>  
>  extern void mfd_remove_devices(struct device *parent);
>  
> +extern int mfd_register_supply_aliases(struct platform_device *pdev);
> +
>  #endif

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2014-07-01  9:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-30 14:26 [PATCH resend v2 0/3] mfd-core: Don't register supplies from add_device, add register_supply_aliases() Hans de Goede
2014-06-30 14:26 ` [PATCH resend v2 1/3] " Hans de Goede
2014-07-01  9:22   ` Lee Jones [this message]
2014-07-01  9:38     ` Hans de Goede
2014-07-01 14:14       ` Lee Jones
2014-06-30 14:26 ` [PATCH resend v2 2/3] regulator/axp20x: Call mfd_register_supply_aliases Hans de Goede
2014-06-30 14:26 ` [PATCH resend v2 3/3] arizona-mfd-codecs: Add mfd_register_supply_aliases() calls Hans de Goede
2014-07-01  9:05 ` [PATCH resend v2 0/3] mfd-core: Don't register supplies from add_device, add register_supply_aliases() Lee Jones
2014-07-01  9:06   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140701092255.GF27971@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=broonie@linaro.org \
    --cc=carlo@caione.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=hdegoede@redhat.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=sameo@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox