Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp542670pxk; Wed, 2 Sep 2020 08:21:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytZ8zz/VOl0NJkCyjyPplE6qwaPP0fWJmQwtaubVpigixPhPeipFg4k7SqD+Mzx2+SSjb1 X-Received: by 2002:a17:906:8401:: with SMTP id n1mr485160ejx.215.1599060089169; Wed, 02 Sep 2020 08:21:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599060089; cv=none; d=google.com; s=arc-20160816; b=kvthRli5r5alcv8rclURZNlWEuv3fYtipxrDZIjk9Ks/sbbOhAinm8wjvC8Bxpm/9s ER+OQc3WCq6fdFpYARBcuH4SCqItN/6Ttml/1BBPhnzXIuM6WhXEQ5H+GO403LwrcEHU fFtabF2gzjfCsMEvkJi9rr/Mww4+N4ogRpKSgFXuanp1RgOLxFo+B9WUVXH/jTBoP9Di pr26ZcPZDM1lSUOYdjywrxdlRociDxg1Adbewtsu0AMMYGEigOyR4XAnxLiPyVSZE1au RNXpxqOH5AvDDF5bet2cAKyBpiNUvjnn3efDUxJ1E3k56s+ktesG6H8nFJGxrk6Vdnju ysdw== 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; bh=V+1GWCR1TvQJ2umNPVX5igS+5WySmTOYN2RnS+oK5PI=; b=R92C44kOMOkqDdnTAOOEk7eU3VaJL+vovWlC5MIUgK0v4W3X3S0CeCkOTAmF3h+xhF dBMg4nvjp5t1IQ0HQXje+1sz5doqODbXKaVC/WxfBeF+H8D9riQH4nyfNEc2DG7Cub0U coTKax2zhttUipsskj6frHcgmtl+BHXcGoJz3HbzPWKgWn7KqDs451U5q89DXPY6KOUn GXUXL5nA3Dejkuj3RKlw64LYcEz/ivkSW8EtMsRaiLeTZE/dMrSkOoaWKiQM+v4/m1Ap O7DAjedtq36cC1DrWXW2pXdWV3BTxdqjZTspCQmEZYSrnLSzj6xxJhn1pDLAuIhDcDqN pqCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z3DPtyJp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm12si2824071ejb.186.2020.09.02.08.21.06; Wed, 02 Sep 2020 08:21:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z3DPtyJp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727823AbgIBPRS (ORCPT + 99 others); Wed, 2 Sep 2020 11:17:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:43806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727842AbgIBPGz (ORCPT ); Wed, 2 Sep 2020 11:06:55 -0400 Received: from kozik-lap.mshome.net (unknown [194.230.155.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8D58920773; Wed, 2 Sep 2020 15:06:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599059214; bh=5IrQM4zaWaI46iMLqvoLFQL1xUrFrBFsc04JUwsbfdc=; h=From:To:Cc:Subject:Date:From; b=z3DPtyJpm5wBhKasevREMy5GD7UXAoh+kvi2/+R3Qwd1ZBJwh0NWDq1IE7SZdzxep aZJ3ZX3DySSwZ5ws8RPm5NzbxX3NYTbNBB2ugRhEPM5BdaCC66EGXXR7NGiflRpfl7 /lh8zD3aes02nzAVbZNXUlIGB3nybWAhdvuT0IfA= From: Krzysztof Kozlowski To: Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Michal Simek , Sekhar Nori , Bartosz Golaszewski , Oleksij Rempel , Pengutronix Kernel Team , Shawn Guo , Sascha Hauer , Fabio Estevam , NXP Linux Team , Heiko Stuebner , Pierre-Yves MORDRET , Maxime Coquelin , Alexandre Torgue , Peter Rosin , Wolfram Sang , linux-i2c@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com Cc: Krzysztof Kozlowski Subject: [PATCH 1/9] i2c: stm32: Simplify with dev_err_probe() Date: Wed, 2 Sep 2020 17:06:35 +0200 Message-Id: <20200902150643.14839-1-krzk@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and the error value gets printed. Signed-off-by: Krzysztof Kozlowski --- drivers/i2c/busses/i2c-stm32.c | 11 ++++------- drivers/i2c/busses/i2c-stm32f4.c | 6 ++---- drivers/i2c/busses/i2c-stm32f7.c | 24 +++++++++--------------- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/i2c/busses/i2c-stm32.c b/drivers/i2c/busses/i2c-stm32.c index 3f69a3bb6119..198f848b7be9 100644 --- a/drivers/i2c/busses/i2c-stm32.c +++ b/drivers/i2c/busses/i2c-stm32.c @@ -25,9 +25,8 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, /* Request and configure I2C TX dma channel */ dma->chan_tx = dma_request_chan(dev, "tx"); if (IS_ERR(dma->chan_tx)) { - ret = PTR_ERR(dma->chan_tx); - if (ret != -EPROBE_DEFER) - dev_err(dev, "can't request DMA tx channel\n"); + ret = dev_err_probe(dev, PTR_ERR(dma->chan_tx), + "can't request DMA tx channel\n"); goto fail_al; } @@ -45,10 +44,8 @@ struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev, /* Request and configure I2C RX dma channel */ dma->chan_rx = dma_request_chan(dev, "rx"); if (IS_ERR(dma->chan_rx)) { - ret = PTR_ERR(dma->chan_rx); - if (ret != -EPROBE_DEFER) - dev_err(dev, "can't request DMA rx channel\n"); - + ret = dev_err_probe(dev, PTR_ERR(dma->chan_rx), + "can't request DMA rx channel\n"); goto fail_tx; } diff --git a/drivers/i2c/busses/i2c-stm32f4.c b/drivers/i2c/busses/i2c-stm32f4.c index 48e269284369..937c2c8fd349 100644 --- a/drivers/i2c/busses/i2c-stm32f4.c +++ b/drivers/i2c/busses/i2c-stm32f4.c @@ -797,10 +797,8 @@ static int stm32f4_i2c_probe(struct platform_device *pdev) rst = devm_reset_control_get_exclusive(&pdev->dev, NULL); if (IS_ERR(rst)) { - ret = PTR_ERR(rst); - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "Error: Missing reset ctrl\n"); - + ret = dev_err_probe(&pdev->dev, PTR_ERR(rst), + "Error: Missing reset ctrl\n"); goto clk_free; } reset_control_assert(rst); diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c index bff3479fe122..a8f1758e4c5b 100644 --- a/drivers/i2c/busses/i2c-stm32f7.c +++ b/drivers/i2c/busses/i2c-stm32f7.c @@ -1968,11 +1968,9 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) "wakeup-source"); i2c_dev->clk = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(i2c_dev->clk)) { - if (PTR_ERR(i2c_dev->clk) != -EPROBE_DEFER) - dev_err(&pdev->dev, "Failed to get controller clock\n"); - return PTR_ERR(i2c_dev->clk); - } + if (IS_ERR(i2c_dev->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->clk), + "Failed to get controller clock\n"); ret = clk_prepare_enable(i2c_dev->clk); if (ret) { @@ -1982,10 +1980,8 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) rst = devm_reset_control_get(&pdev->dev, NULL); if (IS_ERR(rst)) { - ret = PTR_ERR(rst); - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, "Error: Missing reset ctrl\n"); - + ret = dev_err_probe(&pdev->dev, PTR_ERR(rst), + "Error: Missing reset ctrl\n"); goto clk_free; } reset_control_assert(rst); @@ -2052,13 +2048,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev) i2c_dev->dma = stm32_i2c_dma_request(i2c_dev->dev, phy_addr, STM32F7_I2C_TXDR, STM32F7_I2C_RXDR); - if (PTR_ERR(i2c_dev->dma) == -ENODEV) + if (PTR_ERR(i2c_dev->dma) == -ENODEV) { i2c_dev->dma = NULL; - else if (IS_ERR(i2c_dev->dma)) { - ret = PTR_ERR(i2c_dev->dma); - if (ret != -EPROBE_DEFER) - dev_err(&pdev->dev, - "Failed to request dma error %i\n", ret); + } else if (IS_ERR(i2c_dev->dma)) { + ret = dev_err_probe(&pdev->dev, PTR_ERR(i2c_dev->dma), + "Failed to request dma error\n"); goto fmp_clear; } -- 2.17.1