public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Robert Hancock <hancock@sedsystems.ca>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] mfd: core: Support multiple OF child devices of the same type
Date: Wed, 5 Jun 2019 07:31:08 +0100	[thread overview]
Message-ID: <20190605063108.GF4797@dell> (raw)
In-Reply-To: <1559687743-31879-2-git-send-email-hancock@sedsystems.ca>

On Tue, 04 Jun 2019, Robert Hancock wrote:

> Previously the MFD core supported assigning OF nodes to created MFD
> devices, but relied solely on matching the of_compatible string. This
> would result in devices being potentially assigned the wrong node if
> there are multiple devices with the same compatible string within a
> multifunction device.
> 
> Add support for matching the full name of the node in the MFD cell
> definition, so that we can match against a specific instance of a
> device. If this is not specified, we match just based on the
> compatible string, as before.
> 
> Signed-off-by: Robert Hancock <hancock@sedsystems.ca>
> ---
>  drivers/mfd/mfd-core.c   | 5 ++++-
>  include/linux/mfd/core.h | 3 +++
>  2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index 1ade4c8..74bc895 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -177,7 +177,10 @@ static int mfd_add_device(struct device *parent, int id,
>  
>  	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)) {
> +			if (of_device_is_compatible(np, cell->of_compatible) &&
> +			    (!cell->of_full_name ||
> +			     !strcmp(cell->of_full_name,
> +				     of_node_full_name(np)))) {
>  				pdev->dev.of_node = np;
>  				break;

That is some ugly, squashed up code.

If we end up accepting this, I suggest flattening this out a bit.

... but we'll cross that bridge when we come to it.

> diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
> index 99c0395..470f6cb 100644
> --- a/include/linux/mfd/core.h
> +++ b/include/linux/mfd/core.h
> @@ -55,6 +55,9 @@ struct mfd_cell {
>  	 */
>  	const char		*of_compatible;
>  
> +	/* Optionally match against a specific device of a given type */
> +	const char		*of_full_name;
> +

Can you give me an example for when this might be useful?

>  	/* Matches ACPI */
>  	const struct mfd_cell_acpi_match	*acpi_match;
>  

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2019-06-05  6:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-04 22:35 [PATCH 0/2] MFD core updates for device tree binding support Robert Hancock
2019-06-04 22:35 ` [PATCH 1/2] mfd: core: Support multiple OF child devices of the same type Robert Hancock
2019-06-05  6:31   ` Lee Jones [this message]
2019-06-05 16:23     ` Robert Hancock
2019-06-05 18:45       ` Lee Jones
2019-06-05 19:26         ` Robert Hancock
2019-06-06  5:27           ` Lee Jones
2019-06-06 15:33             ` Robert Hancock
2019-06-10  8:08               ` Lee Jones
2019-06-04 22:35 ` [PATCH 2/2] mfd: core: Set fwnode for created devices Robert Hancock
2019-06-05  6:31   ` Lee Jones

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=20190605063108.GF4797@dell \
    --to=lee.jones@linaro.org \
    --cc=hancock@sedsystems.ca \
    --cc=linux-kernel@vger.kernel.org \
    /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