[net-next PATCH v10 5/9] mfd: an8855: Add support for Airoha AN8855 Switch MFD

Christophe JAILLET christophe.jaillet at wanadoo.fr
Sun Dec 8 07:38:02 PST 2024


Le 08/12/2024 à 16:12, Christian Marangi a écrit :
> On Sun, Dec 08, 2024 at 04:09:25PM +0100, Christophe JAILLET wrote:
>> Le 08/12/2024 à 01:20, Christian Marangi a écrit :
>>> Add support for Airoha AN8855 Switch MFD that provide support for a DSA
>>> switch and a NVMEM provider. Also provide support for a virtual MDIO
>>> passthrough as the PHYs address for the switch are shared with the switch
>>> address
>>>
>>> Signed-off-by: Christian Marangi <ansuelsmth-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org>
>>> ---
>>>    MAINTAINERS                           |   1 +
>>>    drivers/mfd/Kconfig                   |   9 +
>>>    drivers/mfd/Makefile                  |   1 +
>>>    drivers/mfd/airoha-an8855.c           | 279 ++++++++++++++++++++++++++
>>>    include/linux/mfd/airoha-an8855-mfd.h |  41 ++++
>>>    5 files changed, 331 insertions(+)
>>>    create mode 100644 drivers/mfd/airoha-an8855.c
>>>    create mode 100644 include/linux/mfd/airoha-an8855-mfd.h
>>>
>>> diff --git a/MAINTAINERS b/MAINTAINERS
>>> index f3e3f6938824..7f4d7c48b6e1 100644
>>> --- a/MAINTAINERS
>>> +++ b/MAINTAINERS
>>> @@ -721,6 +721,7 @@ F:	Documentation/devicetree/bindings/mfd/airoha,an8855-mfd.yaml
>>>    F:	Documentation/devicetree/bindings/net/airoha,an8855-mdio.yaml
>>>    F:	Documentation/devicetree/bindings/net/dsa/airoha,an8855-switch.yaml
>>>    F:	Documentation/devicetree/bindings/nvmem/airoha,an8855-efuse.yaml
>>> +F:	drivers/mfd/airoha-an8855.c
>>>    AIROHA ETHERNET DRIVER
>>>    M:	Lorenzo Bianconi <lorenzo-DgEjT+Ai2ygdnm+yROfE0A at public.gmane.org>
>>> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
>>> index ae23b317a64e..a83db24336d9 100644
>>> --- a/drivers/mfd/Kconfig
>>> +++ b/drivers/mfd/Kconfig
>>> @@ -53,6 +53,15 @@ config MFD_ALTERA_SYSMGR
>>>    	  using regmap_mmio accesses for ARM32 parts and SMC calls to
>>>    	  EL3 for ARM64 parts.
>>> +config MFD_AIROHA_AN8855
>>> +	bool "Airoha AN8855 Switch MFD"
>>> +	depends on MDIO && OF
>>> +	select MFD_CORE
>>> +	help
>>> +	  Support for the Airoha AN8855 Switch MFD. This is a SoC Switch
>>> +	  that provide various peripherals. Currently it provides a
>>
>> provides?
>>
>>> +	  DSA switch and a NVMEM provider.
>>> +
>>>    config MFD_ACT8945A
>>>    	tristate "Active-semi ACT8945A"
>>>    	select MFD_CORE
>>
>> ...
>>
>>> +static int an8855_mfd_probe(struct mdio_device *mdiodev)
>>> +{
>>> +	struct an8855_mfd_priv *priv;
>>> +	struct regmap *regmap;
>>> +
>>> +	priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL);
>>> +	if (!priv)
>>> +		return -ENOMEM;
>>> +
>>> +	priv->bus = mdiodev->bus;
>>> +	priv->dev = &mdiodev->dev;
>>> +	priv->switch_addr = mdiodev->addr;
>>> +	/* no DMA for mdiobus, mute warning for DMA mask not set */
>>> +	priv->dev->dma_mask = &priv->dev->coherent_dma_mask;
>>> +
>>> +	regmap = devm_regmap_init(priv->dev, NULL, priv,
>>> +				  &an8855_regmap_config);
>>> +	if (IS_ERR(regmap)) {
>>> +		dev_err(priv->dev, "regmap initialization failed");
>>
>> Nitpick: Missing ending \n.
>> Also, return dev_err_probe() could be used.
>>
> 
> Can regmap PROBE_DEFER? Or it's just common practice?

It is a common practice to easily log the error code in a human readable 
format, even when PROBE_DEFER can't happen.

It sometimes also saves 1 or 2 LoC because it may save the { } and the 
line with return.

Leaving it as-is is obviously also just fine ;-).

CJ

> 
>>> +		return PTR_ERR(priv->dev);
>>> +	}
>>> +
>>> +	dev_set_drvdata(&mdiodev->dev, priv);
>>
>> Is it needed?
>> There is no dev_get_drvdata() in this patch
>>
> 
> Yes it is, MFD child makes use of dev_get_drv_data(dev->parent) to
> access the bug and current_page.
> 
>>> +
>>> +	return devm_mfd_add_devices(priv->dev, PLATFORM_DEVID_AUTO, an8855_mfd_devs,
>>> +				    ARRAY_SIZE(an8855_mfd_devs), NULL, 0,
>>> +				    NULL);
>>> +}
>>
>> ...
>>
>> CJ
> 




More information about the linux-arm-kernel mailing list