Re: [PATCHv4 net-next] net: modernize ioremap in probe

From: Rosen Penev
Date: Wed Dec 04 2024 - 20:06:32 EST


On Tue, Dec 3, 2024 at 2:51 PM Russell King (Oracle)
<linux@xxxxxxxxxxxxxxx> wrote:
>
> On Tue, Dec 03, 2024 at 02:27:50PM -0800, Rosen Penev wrote:
> > resource aquisition and ioremap can be performed in one step.
> ...
> > diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > index 571631a30320..af9291574931 100644
> > --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
> > @@ -7425,21 +7425,16 @@ static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv)
> > static int mvpp2_get_sram(struct platform_device *pdev,
> > struct mvpp2 *priv)
> > {
> > - struct resource *res;
> > void __iomem *base;
> >
> > - res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
> > - if (!res) {
> > + base = devm_platform_ioremap_resource(pdev, 2);
> > + if (IS_ERR(base)) {
> > if (has_acpi_companion(&pdev->dev))
> > dev_warn(&pdev->dev, "ACPI is too old, Flow control not supported\n");
> > else
> > dev_warn(&pdev->dev, "DT is too old, Flow control not supported\n");
> > - return 0;
> > - }
> > -
> > - base = devm_ioremap_resource(&pdev->dev, res);
> > - if (IS_ERR(base))
> > return PTR_ERR(base);
> > + }
>
> This is not equivalent. This means if ioremap() fails inside
> devm_platform_ioremap_resource(), we end up printing a message that
> blames the firmware, which is wrong.
>
> It also changes a "resource missing, proceed anyway" situation into
> a failure situation.
>
> Please drop this change, "cleaning" this up is introducing bugs.
Will do in v5.
>
> Thanks.
>
> --
> RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
> FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!