From patchwork Thu Oct 26 14:23:45 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: 10028419 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 7A9AA6022E for ; Thu, 26 Oct 2017 14:24:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A25326B41 for ; Thu, 26 Oct 2017 14:24:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EA6C274D1; Thu, 26 Oct 2017 14:24:19 +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 148E826B41 for ; Thu, 26 Oct 2017 14:24:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932376AbdJZOYF (ORCPT ); Thu, 26 Oct 2017 10:24:05 -0400 Received: from mout.web.de ([212.227.17.12]:49543 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932234AbdJZOYE (ORCPT ); Thu, 26 Oct 2017 10:24:04 -0400 Received: from [192.168.1.2] ([78.48.35.118]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0LylnX-1d4sCJ1GFT-0165py; Thu, 26 Oct 2017 16:23:48 +0200 To: linux-iio@vger.kernel.org, Hartmut Knaack , Jonathan Cameron , Lars-Peter Clausen , Peter Meerwald-Stadler , Peter Rosin Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] iio/pressure/mpl3115: Improve unlocking of a mutex in mpl3115_trigger_handler() Message-ID: Date: Thu, 26 Oct 2017 16:23:45 +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:sSe2P/d8KrLuj11Nb/3denxSXusCC/3pzc94R4FIuZOYBN6WrTv ZzfTwys56fnIkyheiriBeaiMF6FKXwMv/dT9p1UAk7pflZtJ1R94sqLkv940AEe2S4PGhdH 28wQSwWyxi8Y6Lrqrc+NVdejn5cp1Qw4RsovHqQbk/XDB+8WZp6QU9f6VlqGDJqAygUD+aR Bnj3w/7MJi/LU7Fy49VEA== X-UI-Out-Filterresults: notjunk:1; V01:K0:j/OYZDFlC0w=:dJxZkX0EEnX9q0B72q/NyG XH2dur0gIHe8SkyQZqj7TaQrCspiXjaSqmjXkJYjeYnkXif7IthK/cYtTeJ2kDFzb8Twkthhe 4zqPctsBaEOUBnXCN6OOSD/7B9SMIkJbZQOVqxMQCRncZC06okRYXxkVLdNeTNJ+kwv3QdtTW DWsvb7PLZeLu3U46A0QCImmVydzlhPHIjRBFsvjgYq4FcEl4jTDFDweDcB2XPK23R9AZpiC0d q+wW3oAOF6QFt2dqpy1fAToiSMqLcOedWp+TUGz1c3+WdD0/l+5CSvPOJYm9f/rV7QijhDKaR wKxKOZJJZvkz/APSp2Xm3csq+SGgAE7BLILSU7NNBuhUVyHFYMEzwNrQLtwkJ7RPrDPJk2tZB CcW4MHOBravedgvz9zAtewgyaeXje09PsVfOfLbinFGRTK2K5jbM9nbbQLsvA+KmdNhwc+jXo 8VPVQWVsGyX85akMM6pLflKbFfZSuzDmseIrd/uW7fCwxqy71F+/rADcaQdpnmEhS6n8/OnV0 0awisgfOTI37fAId1oRRcWh728tOaTgj6jVVrVkynZmz8qKVUlhcDtD76ibt4h41vQmO8Mqra w2x/Zu6VQwfjoRJMaP8T5mcilfeJg9zD7Lm7qlAfyMoIri9dbIAxwVdkiz2ATNtaoA26hcKzM gJCrEPa6ehy7zVwnmR8SBUfMPVZpSMa0IGsNpMH1ZixMhvQ43Xb+p19nZS7Je9ES/CoUwouUX tH3kWpBiFslEPkbWuKvCUWX9LWrnX59aQbbmdQHVNclQMPHB9OnshjjcIihOPxJU3UNpt/KJj 4Y+XXZlb8CL7i6qDmPgV4yu3kQ3sO2ZZZ4KgzcYzHYWSWDFqP4= 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 16:10:46 +0200 Adjust jump targets so that a call of the function "mutex_unlock" is stored at the end of this function implementation. Replace three calls by goto statements. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/iio/pressure/mpl3115.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index 7537547fb7ee..f39e6f42a9c0 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -152,38 +152,36 @@ static irqreturn_t mpl3115_trigger_handler(int irq, void *p) mutex_lock(&data->lock); ret = mpl3115_request(data); - if (ret < 0) { - mutex_unlock(&data->lock); - goto done; - } + if (ret < 0) + goto unlock; memset(buffer, 0, sizeof(buffer)); if (test_bit(0, indio_dev->active_scan_mask)) { ret = i2c_smbus_read_i2c_block_data(data->client, MPL3115_OUT_PRESS, 3, &buffer[pos]); - if (ret < 0) { - mutex_unlock(&data->lock); - goto done; - } + if (ret < 0) + goto unlock; + pos += 4; } if (test_bit(1, indio_dev->active_scan_mask)) { ret = i2c_smbus_read_i2c_block_data(data->client, MPL3115_OUT_TEMP, 2, &buffer[pos]); - if (ret < 0) { - mutex_unlock(&data->lock); - goto done; - } + if (ret < 0) + goto unlock; } mutex_unlock(&data->lock); iio_push_to_buffers_with_timestamp(indio_dev, buffer, iio_get_time_ns(indio_dev)); - -done: +notify_trigger: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; + +unlock: + mutex_unlock(&data->lock); + goto notify_trigger; } static const struct iio_chan_spec mpl3115_channels[] = {