From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E345C43461 for ; Thu, 10 Sep 2020 09:37:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A487320882 for ; Thu, 10 Sep 2020 09:37:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="yCROhYCW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730573AbgIJJho (ORCPT ); Thu, 10 Sep 2020 05:37:44 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:60321 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730719AbgIJJhH (ORCPT ); Thu, 10 Sep 2020 05:37:07 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9WvjY018630; Thu, 10 Sep 2020 11:36:48 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=STMicroelectronics; bh=htF5W68VT3+jaLIm4WZe10OWVU7UYb45MQ9aXHRF1so=; b=yCROhYCWdgIz8wOPw4PtsKSJqhWpURbMqwcJYEVPFC3bss6G9pG9VzfAlEDYIi/jXrbB 7L0IYZXQwBa24D/ARYktaV8Nct0Eoh/MSoLOJ88aziEngyxK++PzWQatix4CW7z4+nzM fo5a1IYLE8ZIn98Xy5qnz4DFLtHYsYwceiVf58rzGfKpeepeYMO+HSpqYBj7wYrXDLEa A6KS+qwz4XyU2MvgDaRsIZ6XOBzxxkmDb7SpXXV0QMkkla+uIGTx/2uXb/0aVoL9wQuf 5pjc98J7PVRa3uKVXEZ3EUG9UXgXK9soEZXg9x+tg7t4BJESpcAwo1A8xFghAlWeUmBh Xg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 33c051ja88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 11:36:48 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C6C0210002A; Thu, 10 Sep 2020 11:36:43 +0200 (CEST) Received: from Webmail-eu.st.com (gpxdag3node5.st.com [10.75.127.72]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 874D5220AE5; Thu, 10 Sep 2020 11:36:43 +0200 (CEST) Received: from gnbcxd0016.gnb.st.com (10.75.127.48) by GPXDAG3NODE5.st.com (10.75.127.72) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 10 Sep 2020 11:36:42 +0200 Date: Thu, 10 Sep 2020 11:36:41 +0200 From: Alain Volmat To: Krzysztof Kozlowski CC: Nicolas Saenz Julienne , Florian Fainelli , Ray Jui , Scott Branden , , 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 , , , , , , Subject: Re: [PATCH 1/9] i2c: stm32: Simplify with dev_err_probe() Message-ID: <20200910093641.GB1975@gnbcxd0016.gnb.st.com> Mail-Followup-To: Krzysztof Kozlowski , 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 References: <20200902150643.14839-1-krzk@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200902150643.14839-1-krzk@kernel.org> X-Disclaimer: ce message est personnel / this message is private X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG7NODE2.st.com (10.75.127.20) To GPXDAG3NODE5.st.com (10.75.127.72) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-10_01:2020-09-10,2020-09-10 signatures=0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Hi, On Wed, Sep 02, 2020 at 05:06:35PM +0200, Krzysztof Kozlowski wrote: > 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 Reviewed-by: Alain Volmat > --- > 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 >