Netdev List
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
	<linux-omap@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 net-next] net: ethernet: ti: cpdma: correct error handling for chan create
Date: Tue, 12 Dec 2017 15:41:22 -0600	[thread overview]
Message-ID: <9d420427-3633-2d3c-fa4a-cc4388f3ef1f@ti.com> (raw)
In-Reply-To: <1513112795-20045-1-git-send-email-ivan.khoronzhuk@linaro.org>



On 12/12/2017 03:06 PM, Ivan Khoronzhuk wrote:
> It's not correct to return NULL when that is actually an error and
> function returns errors in any other wrong case. In the same time,
> the cpsw driver and davinci emac doesn't check error case while
> creating channel and it can miss actual error. Also remove WARNs
> replacing them on dev_err msgs.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com>

> ---
>   drivers/net/ethernet/ti/cpsw.c          | 12 +++++++++---
>   drivers/net/ethernet/ti/davinci_cpdma.c |  2 +-
>   drivers/net/ethernet/ti/davinci_emac.c  | 11 +++++++++--
>   3 files changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index a60a378..3c85a08 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -3065,10 +3065,16 @@ static int cpsw_probe(struct platform_device *pdev)
>   	}
>   
>   	cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0);
> +	if (IS_ERR(cpsw->txv[0].ch)) {
> +		dev_err(priv->dev, "error initializing tx dma channel\n");
> +		ret = PTR_ERR(cpsw->txv[0].ch);
> +		goto clean_dma_ret;
> +	}
> +
>   	cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1);
> -	if (WARN_ON(!cpsw->rxv[0].ch || !cpsw->txv[0].ch)) {
> -		dev_err(priv->dev, "error initializing dma channels\n");
> -		ret = -ENOMEM;
> +	if (IS_ERR(cpsw->rxv[0].ch)) {
> +		dev_err(priv->dev, "error initializing rx dma channel\n");
> +		ret = PTR_ERR(cpsw->rxv[0].ch);
>   		goto clean_dma_ret;
>   	}
>   
> diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
> index e4d6edf..6f9173f 100644
> --- a/drivers/net/ethernet/ti/davinci_cpdma.c
> +++ b/drivers/net/ethernet/ti/davinci_cpdma.c
> @@ -893,7 +893,7 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
>   	chan_num = rx_type ? rx_chan_num(chan_num) : tx_chan_num(chan_num);
>   
>   	if (__chan_linear(chan_num) >= ctlr->num_chan)
> -		return NULL;
> +		return ERR_PTR(-EINVAL);
>   
>   	chan = devm_kzalloc(ctlr->dev, sizeof(*chan), GFP_KERNEL);
>   	if (!chan)
> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
> index f58c0c6..abceea8 100644
> --- a/drivers/net/ethernet/ti/davinci_emac.c
> +++ b/drivers/net/ethernet/ti/davinci_emac.c
> @@ -1870,10 +1870,17 @@ static int davinci_emac_probe(struct platform_device *pdev)
>   
>   	priv->txchan = cpdma_chan_create(priv->dma, EMAC_DEF_TX_CH,
>   					 emac_tx_handler, 0);
> +	if (IS_ERR(priv->txchan)) {
> +		dev_err(&pdev->dev, "error initializing tx dma channel\n");
> +		rc = PTR_ERR(priv->txchan);
> +		goto no_cpdma_chan;
> +	}
> +
>   	priv->rxchan = cpdma_chan_create(priv->dma, EMAC_DEF_RX_CH,
>   					 emac_rx_handler, 1);
> -	if (WARN_ON(!priv->txchan || !priv->rxchan)) {
> -		rc = -ENOMEM;
> +	if (IS_ERR(priv->rxchan)) {
> +		dev_err(&pdev->dev, "error initializing rx dma channel\n");
> +		rc = PTR_ERR(priv->rxchan);
>   		goto no_cpdma_chan;
>   	}
>   
> 

-- 
regards,
-grygorii

  reply	other threads:[~2017-12-12 21:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12 21:06 [PATCH v3 net-next] net: ethernet: ti: cpdma: correct error handling for chan create Ivan Khoronzhuk
2017-12-12 21:41 ` Grygorii Strashko [this message]
2017-12-13 20:51 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9d420427-3633-2d3c-fa4a-cc4388f3ef1f@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=davem@davemloft.net \
    --cc=ivan.khoronzhuk@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox