From patchwork Tue Dec 12 16:35:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 121564 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4345723qgn; Tue, 12 Dec 2017 08:35:26 -0800 (PST) X-Google-Smtp-Source: ACJfBosm2AImXcCzU98ml5IJYm0KUhbmYw6A90DZZPtqpfw8knbGvDNAu+lTFdekOcic+pgA70Ut X-Received: by 10.99.183.15 with SMTP id t15mr2626362pgf.128.1513096526703; Tue, 12 Dec 2017 08:35:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513096526; cv=none; d=google.com; s=arc-20160816; b=zppjgQJgaUoOw2y92H5rVuV13QlaufkZ5pAoQKRSgHPDtPQ+lOuGMozofzuBlpFYtO KzexqgKOvvSxv9exh22wu0TbyEJjdjOFqmqwjdnYAyf2Jr7J+QfXrVolXmjE5i1OxYO1 wK8Ksp1yr774TSBZ/L+LJU3WF7kP/r+LOuFAZ0uZE6OPVPWL1AUBcSKEmA9pp+ufd0Lp pa+nhvZ0Ridbl4A8fuaCFwajukuyyTJ8p/tQBAmdRgH6facnKw4YtIiSt/lhLgI0ygas uKzxQih7gA7247RAra/mnrMYXmnQICVVihECxLMwLQiC4PlDPK0N9gh5zAHuBY8aco0q xZgw== 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=wRUqVCV4+E3ucwIdI3+fPdqo42vjbQLZEooSKQ571g4=; b=fc9IXm8mNg9bzXn3LO7c4QaVkax+RJ3lQFIcDwygEybr6N7xYRHyvWh0cxRGvXMk3w FlxLXDqubHfIITtVJUdn2I9TtdCCwowgo2Eq0wT8ygArbnRaIwgqu7Tn2m0ymTgnk4yw AT2TyZYqW38xwnquPuTV5qtP9qjw2/h1fP7Gj3gl3CoD1Z3kMTcD+q5b9vOc7+9g1CmV 76KLKJT9bngn3HZR7VmMBh+orHAiArCbvINKsX6JZ3op3rHB9hoAl08aWBkKnGI3sKTe TXKjFgBBG4GA9GGUcbzDu7yEPN4tRIYG1dML3jIQ+ahpNuXUyfIWMX/Q3bVrRNQYMSNK IrtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=GRvsyaAY; 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 y11si11693897pgr.791.2017.12.12.08.35.26; Tue, 12 Dec 2017 08:35:26 -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=GRvsyaAY; 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 S1751799AbdLLQfY (ORCPT + 4 others); Tue, 12 Dec 2017 11:35:24 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36586 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751499AbdLLQfX (ORCPT ); Tue, 12 Dec 2017 11:35:23 -0500 Received: by mail-lf0-f68.google.com with SMTP id f20so23913176lfe.3 for ; Tue, 12 Dec 2017 08:35:22 -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=XQTY3luUsu6+w0yunoQeQDK3Fj7Rq+3g3uUqyAeeeUg=; b=GRvsyaAYHptpZtFugDy2XwZISGs4kDufiYpXuf70+a+22Bqmt6G7FQ51T10OfILJ47 erZY60MZ53DPhqxjIBweg+LPmVoBLTAUWtwdpxm3bbBugrAV/R9nO6bpKC4Ia30CDy9v yKBIbf6I/o/eJ3EoFVw8I0BJAKxWbpZkyluJA= 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=XQTY3luUsu6+w0yunoQeQDK3Fj7Rq+3g3uUqyAeeeUg=; b=dWWWwkuEurfIm/ktc+KmGqjJ9+TzE8lSMW/5g7FypwvaAYaeFVCAlJwC+wtCGx1etl hPqE+BQj3CN92TJaWqbM5NDkSHlzQAF5rR+qXVGT/QUOygwfRqzriWtRX0pHCQ6euRz7 8XQu4kQ24BJ634k4QNXqJm/3mGK607NiPd7285PMgtEA3r2on15WLAGHZgrpAiVznmVh 4hOQYYpQdt2kXZFNI7zg2ActNfF5D8KgPHU/ND+r7MTuJzLdAjc6GkfRX37H5NWQVGxv P6/dPbghWtohyko9IuLcLNwgi5GY6a6z/4h0pUOeXQoVOvX+mL4luCVz+D5+tWkEspPA o7YQ== X-Gm-Message-State: AKGB3mKhMPuDDTereSHjGQtixoEVx6UBJAD9GsgLG1ejOaAiuS6z/x6S ZUw5AYk0ynm4PmDLCpIi9TcO/Q== X-Received: by 10.46.18.216 with SMTP id 85mr2241028ljs.100.1513096521880; Tue, 12 Dec 2017 08:35:21 -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 w62sm3369129lje.59.2017.12.12.08.35.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Dec 2017 08:35:20 -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 v2 net-next] net: ethernet: ti: cpdma: correct error handling for chan create Date: Tue, 12 Dec 2017 18:35:17 +0200 Message-Id: <1513096517-3905-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 duplicated 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 | 9 +++++++-- 3 files changed, 17 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..3d4af64 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1870,10 +1870,15 @@ 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 (WARN_ON(IS_ERR(priv->txchan))) { + 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 (WARN_ON(IS_ERR(priv->rxchan))) { + rc = PTR_ERR(priv->rxchan); goto no_cpdma_chan; }