From patchwork Fri Jul 1 08:01:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9209431 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 561E960221 for ; Fri, 1 Jul 2016 08:14:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46374281C3 for ; Fri, 1 Jul 2016 08:14:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38F9828696; Fri, 1 Jul 2016 08:14:47 +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 C6015281C3 for ; Fri, 1 Jul 2016 08:14:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752624AbcGAIOU (ORCPT ); Fri, 1 Jul 2016 04:14:20 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:32973 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752526AbcGAINF (ORCPT ); Fri, 1 Jul 2016 04:13:05 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9M01PQZMAZWLB0@mailout1.samsung.com>; Fri, 01 Jul 2016 17:01:47 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 4A.63.05161.B6326775; Fri, 1 Jul 2016 17:01:47 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-8e-5776236bf1fc Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id CA.75.02101.B6326775; Fri, 1 Jul 2016 17:01:47 +0900 (KST) Received: from samsunx.samsung ([10.113.63.54]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9M00G9YMAVFJA0@mmp2.samsung.com>; Fri, 01 Jul 2016 17:01:47 +0900 (KST) From: Andi Shyti To: Mauro Carvalho Chehab Cc: Joe Perches , Sean Young , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH v2 07/15] [media] lirc_dev: simplify if statement in lirc_add_to_buf Date: Fri, 01 Jul 2016 17:01:30 +0900 Message-id: <1467360098-12539-8-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1467360098-12539-1-git-send-email-andi.shyti@samsung.com> References: <1467360098-12539-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrLLMWRmVeSWpSXmKPExsWyRsSkUDdbuSzc4Mp/SYvtR56xWiz+8ZzJ Yvb9xywWl3fNYbPo2bCV1WL1swqLhU+/sziwe1xf8onZY8kba48t/XfZPb6susbs0bdlFaPH 501yAWxRXDYpqTmZZalF+nYJXBmXLs1lL9jKXdHy4RZ7A+N7ji5GTg4JAROJXQ+msEHYYhIX 7q0Hsrk4hARWMEo0HvzBCFN0cuUyqMQsRonlhw8wQzgfGSVWb+8Dq2IT0JRouv0DqIqDQ0TA WOLcD3WQMLPAAUaJ3m4XkLCwQJjEoR/yIGEWAVWJkx8vgXXyCrhJdP9sZIHYJSdxefoDsIM4 Bdwl7r7bBVYjBFQzd9c9dpC1EgKL2CXOTDvIBjFIQOLb5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TqoHRVED4JI9Xp0v2+4JLD4TuZZ2vXH/V/WqZNMs08dTfczNMj06dt0V91onb uxff9F/fsWEft9DH/NPifVeZfBydF/6a/+4AUz2DU/DXvZzikTd/vuWeeSIq5IbGU+HNhcdd gjMW8/5Ma5U1Zp0kkqzLGzRnQYJ9eLRi5oSTdTHsj1Vbr5uU2YspsRRnJBpqMRcVJwIAKbGi 0b0CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The whole function is inside an 'if' statement ("if (ir->d.add_to_buf)"). Check the opposite of that statement at the beginning and exit, this way we can have one level less of indentation. Signed-off-by: Andi Shyti --- drivers/media/rc/lirc_dev.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index da1777c..2468849 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -97,26 +97,25 @@ static void lirc_irctl_cleanup(struct irctl *ir) */ static int lirc_add_to_buf(struct irctl *ir) { - if (ir->d.add_to_buf) { - int res = -ENODATA; - int got_data = -1; + int res; + int got_data = -1; - /* - * service the device as long as it is returning - * data and we have space - */ - do { - got_data++; - res = ir->d.add_to_buf(ir->d.data, ir->buf); - } while (!res); + if (!ir->d.add_to_buf) + return 0; - if (res == -ENODEV) - kthread_stop(ir->task); + /* + * service the device as long as it is returning + * data and we have space + */ + do { + got_data++; + res = ir->d.add_to_buf(ir->d.data, ir->buf); + } while (!res); - return got_data ? 0 : res; - } + if (res == -ENODEV) + kthread_stop(ir->task); - return 0; + return got_data ? 0 : res; } /* main function of the polling thread