netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Colin Foster <colin.foster@in-advantage.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Steen Hegelund <Steen.Hegelund@microchip.com>,
	Lars Povlsen <lars.povlsen@microchip.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Russell King <linux@armlinux.org.uk>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	UNGLinuxDriver@microchip.com,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Manoil <claudiu.manoil@nxp.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	katie.morris@in-advantage.com
Subject: Re: [RFC v6 net-next 5/9] mfd: add interface to check whether a device is mfd
Date: Mon, 31 Jan 2022 08:47:33 +0000	[thread overview]
Message-ID: <YfeiJVmAbLa497Ht@google.com> (raw)
In-Reply-To: <20220129220221.2823127-6-colin.foster@in-advantage.com>

On Sat, 29 Jan 2022, Colin Foster wrote:

> Some drivers will need to create regmaps differently based on whether they
> are a child of an MFD or a standalone device. An example of this would be
> if a regmap were directly memory-mapped or an external bus. In the
> memory-mapped case a call to devm_regmap_init_mmio would return the correct
> regmap. In the case of an MFD, the regmap would need to be requested from
> the parent device.
> 
> This addition allows the driver to correctly reason about these scenarios.
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---
>  drivers/mfd/mfd-core.c   |  6 ++++++
>  include/linux/mfd/core.h | 10 ++++++++++
>  2 files changed, 16 insertions(+)
> 
> diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
> index 684a011a6396..2ba6a692499b 100644
> --- a/drivers/mfd/mfd-core.c
> +++ b/drivers/mfd/mfd-core.c
> @@ -33,6 +33,12 @@ static struct device_type mfd_dev_type = {
>  	.name	= "mfd_device",
>  };
>  
> +int device_is_mfd(struct platform_device *pdev)
> +{
> +	return (!strcmp(pdev->dev.type->name, mfd_dev_type.name));
> +}
> +EXPORT_SYMBOL(device_is_mfd);

As I said before, I really don't want MFDness leaking out into other
parts of the kernel.  Please find another way to differentiate between
devices registered via the MFD API and by other means.

I'm happy to help here.

How else could these devices be enumerated? 

>  int mfd_cell_enable(struct platform_device *pdev)
>  {
>  	const struct mfd_cell *cell = mfd_get_cell(pdev);
> diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
> index 0bc7cba798a3..c0719436b652 100644
> --- a/include/linux/mfd/core.h
> +++ b/include/linux/mfd/core.h
> @@ -10,6 +10,7 @@
>  #ifndef MFD_CORE_H
>  #define MFD_CORE_H
>  
> +#include <generated/autoconf.h>
>  #include <linux/platform_device.h>
>  
>  #define MFD_RES_SIZE(arr) (sizeof(arr) / sizeof(struct resource))
> @@ -123,6 +124,15 @@ struct mfd_cell {
>  	int			num_parent_supplies;
>  };
>  
> +#ifdef CONFIG_MFD_CORE
> +int device_is_mfd(struct platform_device *pdev);
> +#else
> +static inline int device_is_mfd(struct platform_device *pdev)
> +{
> +	return 0;
> +}
> +#endif
> +
>  /*
>   * Convenience functions for clients using shared cells.  Refcounting
>   * happens automatically, with the cell's enable/disable callbacks

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

  reply	other threads:[~2022-01-31  8:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-29 22:02 [RFC v6 net-next 0/9] add support for VSC7512 control over SPI Colin Foster
2022-01-29 22:02 ` [RFC v6 net-next 1/9] pinctrl: ocelot: allow pinctrl-ocelot to be loaded as a module Colin Foster
2022-01-30  0:30   ` Linus Walleij
2022-01-30 21:30     ` Colin Foster
2022-01-31 23:11   ` Florian Fainelli
2022-01-29 22:02 ` [RFC v6 net-next 2/9] pinctrl: microchip-sgpio: allow sgpio driver to be used " Colin Foster
2022-01-30  0:31   ` Linus Walleij
2022-01-31 23:11   ` Florian Fainelli
2022-01-31 23:14     ` Colin Foster
2022-01-29 22:02 ` [RFC v6 net-next 3/9] net: mdio: mscc-miim: add local dev variable to cleanup probe function Colin Foster
2022-01-31 17:07   ` Vladimir Oltean
2022-01-31 23:12   ` Florian Fainelli
2022-01-29 22:02 ` [RFC v6 net-next 4/9] net: mdio: mscc-miim: add ability to externally register phy reset control Colin Foster
2022-01-31 17:13   ` Vladimir Oltean
2022-01-31 17:32     ` Colin Foster
2022-01-29 22:02 ` [RFC v6 net-next 5/9] mfd: add interface to check whether a device is mfd Colin Foster
2022-01-31  8:47   ` Lee Jones [this message]
2022-01-29 22:02 ` [RFC v6 net-next 6/9] mfd: ocelot: add support for external mfd control over SPI for the VSC7512 Colin Foster
2022-01-31  9:29   ` Lee Jones
2022-01-31 17:29     ` Colin Foster
2022-02-01  7:36       ` Lee Jones
2022-02-01 17:27         ` Colin Foster
2022-01-29 22:02 ` [RFC v6 net-next 7/9] net: mscc: ocelot: expose ocelot wm functions Colin Foster
2022-01-29 22:02 ` [RFC v6 net-next 8/9] net: dsa: felix: add configurable device quirks Colin Foster
2022-01-31 18:15   ` Vladimir Oltean
2022-01-29 22:02 ` [RFC v6 net-next 9/9] net: dsa: ocelot: add external ocelot switch control Colin Foster
2022-01-31 18:50   ` Vladimir Oltean
2022-03-06  0:28     ` Colin Foster
2022-03-07 21:51       ` Vladimir Oltean
2022-03-08  1:31         ` Colin Foster

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=YfeiJVmAbLa497Ht@google.com \
    --to=lee.jones@linaro.org \
    --cc=Steen.Hegelund@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=colin.foster@in-advantage.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=katie.morris@in-advantage.com \
    --cc=kuba@kernel.org \
    --cc=lars.povlsen@microchip.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).