lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200910093641.GB1975@gnbcxd0016.gnb.st.com>
Date:   Thu, 10 Sep 2020 11:36:41 +0200
From:   Alain Volmat <alain.volmat@...com>
To:     Krzysztof Kozlowski <krzk@...nel.org>
CC:     Nicolas Saenz Julienne <nsaenzjulienne@...e.de>,
        Florian Fainelli <f.fainelli@...il.com>,
        Ray Jui <rjui@...adcom.com>,
        Scott Branden <sbranden@...adcom.com>,
        <bcm-kernel-feedback-list@...adcom.com>,
        Michal Simek <michal.simek@...inx.com>,
        Sekhar Nori <nsekhar@...com>,
        Bartosz Golaszewski <bgolaszewski@...libre.com>,
        Oleksij Rempel <linux@...pel-privat.de>,
        Pengutronix Kernel Team <kernel@...gutronix.de>,
        Shawn Guo <shawnguo@...nel.org>,
        Sascha Hauer <s.hauer@...gutronix.de>,
        Fabio Estevam <festevam@...il.com>,
        NXP Linux Team <linux-imx@....com>,
        Heiko Stuebner <heiko@...ech.de>,
        Pierre-Yves MORDRET <pierre-yves.mordret@...com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...com>,
        Peter Rosin <peda@...ntia.se>, Wolfram Sang <wsa@...nel.org>,
        <linux-i2c@...r.kernel.org>,
        <linux-rpi-kernel@...ts.infradead.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>,
        <linux-rockchip@...ts.infradead.org>,
        <linux-stm32@...md-mailman.stormreply.com>
Subject: Re: [PATCH 1/9] i2c: stm32: Simplify with dev_err_probe()

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 <krzk@...nel.org>

Reviewed-by: Alain Volmat <alain.volmat@...com>

> ---
>  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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ