Re: [PATCH v2 2/4] mfd: ioc3: Add driver for SGI IOC3 chip

From: Esben Haabendal
Date: Tue May 14 2019 - 08:41:07 EST


On Tue, 09 Apr 2019, Thomas Bogendoerfer wrote:
>
> diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
> index 358e66b81926..21fe722ebcd8 100644
> --- a/drivers/net/ethernet/sgi/ioc3-eth.c
> +++ b/drivers/net/ethernet/sgi/ioc3-eth.c
>
> [ ... ]
>
> - err = pci_request_regions(pdev, "ioc3");

Why are you dropping the call to pci_request_regions()? Shouldn't you
do something similar in the new mfd driver?

When you are use the the BAR 0 resource as mem_base argument to
mfd_add_devices() later on, it will be split into child resources for
the child devices, but they will not be related to the IORESOURCE_MEM
root tree (iomem_resource) anymore. I don't think that is how it is
supposed to be done, as it will allow random other drivers to request
the exact same memory area.

How/where is the memory resources inserted in the root IORESOURCE_MEM
resource (iomem_resource)? Or is it allowed to use resources without
inserting it into the root tree?

> + SET_NETDEV_DEV(dev, &pdev->dev);
> + ip = netdev_priv(dev);
> + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + ip->regs = ioremap(r->start, resource_size(r));
> + r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + ip->ssram = ioremap(r->start, resource_size(r));

Maybe use devm_platform_ioremap_resource() instead, which handles both
platform_get_resource() and ioremap() in one call..

/Esben