On Thu, Nov 08, 2018 at 01:17:47PM +0000, Ioana Ciornei wrote:
> The fsl_mc_object_allocate function can fail because not all allocatable
> objects are probed by the fsl_mc_allocator at the call time. Defer the
> dpaa2-eth probe when this happens.
> 
> Signed-off-by: Ioana Ciornei <ioana.cior...@nxp.com>
> ---
>  drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 30 
> +++++++++++++++++-------
>  1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c 
> b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> index 88f7acc..71f5cd4 100644
> --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
> @@ -1434,8 +1434,11 @@ static struct fsl_mc_device *setup_dpcon(struct 
> dpaa2_eth_priv *priv)
>       err = fsl_mc_object_allocate(to_fsl_mc_device(dev),
>                                    FSL_MC_POOL_DPCON, &dpcon);
>       if (err) {
> -             dev_info(dev, "Not enough DPCONs, will go on as-is\n");
> -             return NULL;
> +             if (err == -ENXIO)
> +                     err = -EPROBE_DEFER;
> +             else
> +                     dev_info(dev, "Not enough DPCONs, will go on as-is\n");
> +             return ERR_PTR(err);
>       }
>  
>       err = dpcon_open(priv->mc_io, 0, dpcon->obj_desc.id, &dpcon->mc_handle);
> @@ -1493,8 +1496,10 @@ static void free_dpcon(struct dpaa2_eth_priv *priv,
>               return NULL;
>  
>       channel->dpcon = setup_dpcon(priv);
> -     if (!channel->dpcon)
> +     if (IS_ERR_OR_NULL(channel->dpcon)) {
> +             err = PTR_ERR(channel->dpcon);
>               goto err_setup;
> +     }

Hi Ioana

You need to be careful with IS_ERR_OR_NULL(). If it is a NULL,
PTR_ERR() is going to return 0. You then jump to the error cleanup
code, but return 0, meaning everything is O.K.

      Andrew

Reply via email to