From patchwork Tue Dec 12 21:06:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 121653 Delivered-To: patch@linaro.org Received: by 10.80.152.193 with SMTP id j59csp4560220edb; Tue, 12 Dec 2017 13:06:44 -0800 (PST) X-Google-Smtp-Source: ACJfBovl7O1065jlweOKSf2FpLt6dAtfEhKX82OhcKxx3hXrGmwL5233K+DX3OtLHChFRsqLjmsx X-Received: by 10.98.104.194 with SMTP id d185mr3542284pfc.155.1513112804793; Tue, 12 Dec 2017 13:06:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513112804; cv=none; d=google.com; s=arc-20160816; b=lX6slC12+eQQlwRuL4dfbBbZX5xOfzDSwy6EMR2w1icoPwHnVMkwrfeFBwxIvRYI3U aO4oigBtk7Dh43QxFYzmIc8IvJt4crAC+HdNeZtvy0dS8uku0RbMCf6M7m6gi8sppvJN BUPGZ7n5y4Htfm3VMYlywZ5oSJppLrmuznos1BsOcK3XKuSvjvmvzHzUIVoT3d3li1cz L2AJKuKQC19sYQ9k6em9ky/8aiPv4peNVvCJcGFKhz3sO4FoMuvYBfbThzWPYJvogCyY FRLjJPX/N/hv2QU/JEeJrG7/a8uvNPUsLEYs8sAeb8CuwBI6SXI1uJWooZvPF4Ov5PrF H4ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=4eFfR4EQveYHXw6gxCdweqX/fCugyLtLe91rtgUf6oI=; b=fkAXH2zKXeqSnpLxhJ3hBcftzF5kKKV7ND18tqNBSWf38UVv7PqPQBAXcD0dDKmeHu hHNmJrodtcCw82DbJHThqYtvS0eZ8GKEMEn54sosXr51za/B/tdqK4WA/wZqlc44ObNd u8ODZEZyMTAKSTvMVn9hPalLFEoQLGpXKaYyAt5VOnxbOuAPBJzZYgfbqQcJWC4ohpHJ auF1W9eTZU9FNt0aK+3Y9B74UgDY47PBu1oRhav7pjHpRbUG8AGU0YgzwqxOkBF9TgZl Q4vv0lnp/CBmQ3bZ1vEOaVAeUS8z6ndbVGKI9E3N9MESwzFCIpoyc7I5rBdUc7YIalPL ce6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fo6YJs44; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si53482ple.296.2017.12.12.13.06.44; Tue, 12 Dec 2017 13:06:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fo6YJs44; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752452AbdLLVGm (ORCPT + 4 others); Tue, 12 Dec 2017 16:06:42 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:45158 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752425AbdLLVGl (ORCPT ); Tue, 12 Dec 2017 16:06:41 -0500 Received: by mail-lf0-f68.google.com with SMTP id f13so230662lff.12 for ; Tue, 12 Dec 2017 13:06:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=mgrNmuyIvINhrrTLfBcnNuH0Yl2bgwqvmCfFhOfP+M4=; b=fo6YJs44naBo6/vws5PJgcT/kkYRXbjyS8hBZOkHYnJ04efC3AItg0Un1IqkV1tS/c oysxqMQnCZBUbbp3LbzZohIthYSnRdfcRn8gnLYL5fVsqqBjnwgc35KN3IHn2BW+inAr 95MxdDepXg/3ZkqPzf6s7AWAupoyuvCjhblFc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=mgrNmuyIvINhrrTLfBcnNuH0Yl2bgwqvmCfFhOfP+M4=; b=jJaKODUv0cinrTSUciHDybqjfBAaWq91RW0VEmSRPRXaWaQUeUH24lMHmwFqou/hit PPNdT9DMnQvMOPCzDovFWWQ7pj1LVvtpf56DSGHK/T+yL86WxhYKs+yif5wQ39YXVdOH xFeTIgKWil9NBVZHiGL9VfVw7xnmBSYsB/8n4/C50iPyqnUSkn9K8oqO7pW8VwZcXDvy rLD8QFtm8W7+1Ds+GW+74D7RknfkXpMTjk0u5zPhFcvSHqMmrG63t6N5Bh9Aiuy5TbdD K3toAX2v9Xk6mz1qvs0O/Y5TaW9L2Q6T4MNs62GQBYatcXuL8ve2qmFDg8IJu33XvCkJ 7vvQ== X-Gm-Message-State: AKGB3mKwdEZFQ+Kq2Bg60fCREkZtdH9CmgZStjRsAb82UP9tEvnSgl3h 34kvlzB6R1gJPcWEyWCXKMQtJg== X-Received: by 10.25.18.36 with SMTP id h36mr104197lfi.75.1513112800211; Tue, 12 Dec 2017 13:06:40 -0800 (PST) Received: from khorivan.synapse.com (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id r66sm12887lfe.48.2017.12.12.13.06.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Dec 2017 13:06:39 -0800 (PST) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com Cc: netdev@vger.kernel.org, davem@davemloft.net, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Ivan Khoronzhuk Subject: [PATCH v3 net-next] net: ethernet: ti: cpdma: correct error handling for chan create Date: Tue, 12 Dec 2017 23:06:35 +0200 Message-Id: <1513112795-20045-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org 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 --- 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(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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; }