On Mon, 21 Oct 2019 02:08:19 +0200, Linus Walleij wrote:
> @@ -1376,7 +1365,7 @@ static const struct net_device_ops ixp4xx_netdev_ops = {
>       .ndo_validate_addr = eth_validate_addr,
>  };
>  
> -static int eth_init_one(struct platform_device *pdev)
> +static int ixp4xx_eth_probe(struct platform_device *pdev)
>  {
>       struct port *port;
>       struct net_device *dev;
> @@ -1396,14 +1385,46 @@ static int eth_init_one(struct platform_device *pdev)
>  
>       switch (port->id) {
>       case IXP4XX_ETH_NPEA:
> +             /* If the MDIO bus is not up yet, defer probe */
> +             if (!mdio_bus)
> +                     return -EPROBE_DEFER;

There's an allocation at the top of this function. All the rest of the
code does goto err_xyz. I don't think you can just return directly here,
or anywhere below.

>               port->regs = (struct eth_regs __iomem *)IXP4XX_EthA_BASE_VIRT;
>               regs_phys  = IXP4XX_EthA_BASE_PHYS;
>               break;
>       case IXP4XX_ETH_NPEB:
> +             /*
> +              * On all except IXP43x, NPE-B is used for the MDIO bus.
> +              * If there is no NPE-B in the feature set, bail out, else
> +              * register the MDIO bus.
> +              */
> +             if (!cpu_is_ixp43x()) {
> +                     if (!(ixp4xx_read_feature_bits() &
> +                           IXP4XX_FEATURE_NPEB_ETH0))
> +                             return -ENODEV;
> +                     /* Else register the MDIO bus on NPE-B */
> +                     if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
> +                             return err;
> +             }
> +             if (!mdio_bus)
> +                     return -EPROBE_DEFER;
>               port->regs = (struct eth_regs __iomem *)IXP4XX_EthB_BASE_VIRT;
>               regs_phys  = IXP4XX_EthB_BASE_PHYS;
>               break;
>       case IXP4XX_ETH_NPEC:
> +             /*
> +              * IXP43x lacks NPE-B and uses NPE-C for the MDIO bus access,
> +              * of there is no NPE-C, no bus, nothing works, so bail out.
> +              */
> +             if (cpu_is_ixp43x()) {
> +                     if (!(ixp4xx_read_feature_bits() &
> +                           IXP4XX_FEATURE_NPEC_ETH))
> +                             return -ENODEV;
> +                     /* Else register the MDIO bus on NPE-C */
> +                     if ((err = ixp4xx_mdio_register(IXP4XX_EthC_BASE_VIRT)))
> +                             return err;
> +             }
> +             if (!mdio_bus)
> +                     return -EPROBE_DEFER;
>               port->regs = (struct eth_regs __iomem *)IXP4XX_EthC_BASE_VIRT;
>               regs_phys  = IXP4XX_EthC_BASE_PHYS;
>               break;

Reply via email to