From patchwork Thu Oct 26 13:45:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10028277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 490876022E for ; Thu, 26 Oct 2017 13:46:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B11E28E1B for ; Thu, 26 Oct 2017 13:46:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 29EE728E22; Thu, 26 Oct 2017 13:46:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF10628E1F for ; Thu, 26 Oct 2017 13:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932231AbdJZNqO (ORCPT ); Thu, 26 Oct 2017 09:46:14 -0400 Received: from mout.web.de ([212.227.17.12]:65044 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932454AbdJZNqF (ORCPT ); Thu, 26 Oct 2017 09:46:05 -0400 Received: from [192.168.1.2] ([78.48.35.118]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MLxs8-1e6dcN0RuW-007mgX; Thu, 26 Oct 2017 15:45:47 +0200 To: linux-iio@vger.kernel.org, Crestez Dan Leonard , Hartmut Knaack , Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] iio/pressure/hp206c: Use common error handling code in hp206c_conv_and_read() Message-ID: Date: Thu, 26 Oct 2017 15:45:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:RFygU9kje4ixCnLwp0l9VtltVh5YvgE6c8rSvLF7I2De6LGFwgJ d1OjuHTAULw9vYUyv7+vZqcF7SRTlOphLxXXbn8rJcrOmM4vc5PE2HAfyoTdfKENA6uCbWs oXsqrYp4ETEQQFKjXP8ZhKC7+Mww6VSk6flh95KE0RqoYL/p5OGSBtFJpphBa2yRGnP8WEX 17POQSpTSteUvSYnHpYfA== X-UI-Out-Filterresults: notjunk:1; V01:K0:md/sze0MQW0=:EaTEpIjHoIyYX59tHQXR8f cxLV2Vthwcfa7mIcrVQ8BKSgtvvkd5QnmTvOIrYpZtf7drCjrraEUPMRFfJTu6NLyEB4pvehD Ndvwbvgfn8mvtp74iikjqfKE02JzKGTOt/ccryYK2Q9wusST/5bLO5iPw4cKjcXVYGNiSpwL2 SrxSV3liv1zmKa92GUT6OPMAAsMg1ZcpxNa0b/FFtSp1cY51WqhZZwlAedWUJ4IWWJ8LVi3xT 4Q1KZ4kVxPYjr3IgcT5tymM5UQe6vrhDIr9UU19jb2fm3mxtC5B1VwoliaNkCT1SHf8JtJvEw dlsP7RocEVgu+2WoxyV6W5Xidju79/7WBVwF1IMmm/FGm1ZhbhGyM0dWKa5rjZfnHLT7zru1F x+HKpHmqNTcWKCC/L276ets0HMfQYg409OiB7X6VcXK5kwuVwUdZdC+dosmvXsIecRhSR9FQ5 8g7HIG+fMxAQLl6M2jqhavWUQY06GMPlOXu4eIFWwCG7ocp5h/vIr/Of+lgvn4XwJoha++xRN orE3su/jnYqK4puCSvBxMQlkwEV/wlOBwWNHxDs7/1eYEd3m90WZjkneR1aRQ5uC7xTCQmyDS n2T6GZ3ruQHY9VrTf8PTSc2JPeEgQEF/GXteePQZ05yV0btYFxsZQITDapDRW3Q5Ma1ASUPh8 zTfgvfAV+0q9F1gWdK+ZIn1cM5TLbd+VvlIZQES0C6jauc8+whLF96EfMxbsBVqYCEtO3czS7 7JojXwqYDWKJ7G/4rbhvgwhNi7PJA8Vtw0pISR9MD8Oh0nj6RGqn2g6R4QllX6AkDeUvxC8xo DaWcXG8titY6ngnKC6mhm7Iukmm/jiLQs6owpj2KkCm/Zs5l9o= Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 26 Oct 2017 15:34:46 +0200 Add a jump target so that a specific error message is stored only once at the end of this function implementation. Replace two calls of the function "dev_err" by goto statements. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/iio/pressure/hp206c.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/pressure/hp206c.c b/drivers/iio/pressure/hp206c.c index c38c19678cf6..978338f2a6e5 100644 --- a/drivers/iio/pressure/hp206c.c +++ b/drivers/iio/pressure/hp206c.c @@ -176,10 +176,8 @@ static int hp206c_conv_and_read(struct iio_dev *indio_dev, struct i2c_client *client = data->client; ret = hp206c_wait_dev_rdy(indio_dev); - if (ret < 0) { - dev_err(&indio_dev->dev, "Device not ready: %d\n", ret); - return ret; - } + if (ret < 0) + goto report_failure; ret = i2c_smbus_write_byte(client, conv_cmd); if (ret < 0) { @@ -190,16 +188,18 @@ static int hp206c_conv_and_read(struct iio_dev *indio_dev, usleep_range(sleep_us, sleep_us * 3 / 2); ret = hp206c_wait_dev_rdy(indio_dev); - if (ret < 0) { - dev_err(&indio_dev->dev, "Device not ready: %d\n", ret); - return ret; - } + if (ret < 0) + goto report_failure; ret = hp206c_read_20bit(client, read_cmd); if (ret < 0) dev_err(&indio_dev->dev, "Failed read: %d\n", ret); return ret; + +report_failure: + dev_err(&indio_dev->dev, "Device not ready: %d\n", ret); + return ret; } static int hp206c_read_raw(struct iio_dev *indio_dev,