Re: [PATCH] gpu/drm/bridge/sii9234: Use common error handling code in sii9234_writebm()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Oct 22, 2017 at 09:32:46PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> Date: Sun, 22 Oct 2017 21:21:44 +0200
> 
> * Add a jump target so that a bit of exception handling can be better
>   reused at the end of this function.
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Adjust condition checks.
> 
> Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/bridge/sii9234.c | 28 ++++++++++------------------
>  1 file changed, 10 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/sii9234.c b/drivers/gpu/drm/bridge/sii9234.c
> index c77000626c22..fbdacdaf485c 100644
> --- a/drivers/gpu/drm/bridge/sii9234.c
> +++ b/drivers/gpu/drm/bridge/sii9234.c
> @@ -231,30 +231,22 @@ static int sii9234_writebm(struct sii9234 *ctx, int id, int offset,
>  		return ctx->i2c_error;
>  
>  	ret = i2c_smbus_write_byte(client, offset);
> -	if (ret < 0) {
> -		dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n",
> -			sii9234_client_name[id], offset, value);
> -		ctx->i2c_error = ret;
> -		return ret;
> -	}
> +	if (ret)
> +		goto report_failure;
>  
>  	ret = i2c_smbus_read_byte(client);
> -	if (ret < 0) {
> -		dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n",
> -			sii9234_client_name[id], offset, value);
> -		ctx->i2c_error = ret;
> -		return ret;
> -	}
> +	if (ret)
> +		goto report_failure;
>  
>  	value = (value & mask) | (ret & ~mask);
> -
>  	ret = i2c_smbus_write_byte_data(client, offset, value);
> -	if (ret < 0) {
> -		dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n",
> -			sii9234_client_name[id], offset, value);
> -		ctx->i2c_error = ret;
> -	}
> +	if (!ret)
> +		return 0;

Ugh.  No.  Don't do success handling on the last if statement.  Also
while I personally prefer testing for non-zero, the ALSA people got
annoyed at you for changing tests for < 0 but you're doing it again.
And it introduces a bug, although I see now that you fixed it in v2.

I can't get excited about these sort of risky low value patches.

>  
> +report_failure:
> +	dev_err(ctx->dev, "writebm: %4s[0x%02x] <- 0x%02x\n",
> +		sii9234_client_name[id], offset, value);
> +	ctx->i2c_error = ret;
>  	return ret;
>  }

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux