From patchwork Wed Jun 29 13:20:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9205101 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 858FF607D8 for ; Wed, 29 Jun 2016 13:23:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77856285BA for ; Wed, 29 Jun 2016 13:23:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C58528655; Wed, 29 Jun 2016 13:23:38 +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 EAB74285BA for ; Wed, 29 Jun 2016 13:23:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752706AbcF2NXW (ORCPT ); Wed, 29 Jun 2016 09:23:22 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:57719 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752543AbcF2NVE (ORCPT ); Wed, 29 Jun 2016 09:21:04 -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 <0O9J02CH2BQWFN40@mailout1.samsung.com>; Wed, 29 Jun 2016 22:20:56 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id EF.5E.05161.83BC3775; Wed, 29 Jun 2016 22:20:56 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-1e-5773cb38e856 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id C2.6D.04429.83BC3775; Wed, 29 Jun 2016 06:20:56 -0700 (MST) Received: from samsunx.samsung ([10.113.63.54]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O9J0087XBQTVM50@mmp1.samsung.com>; Wed, 29 Jun 2016 22:20:56 +0900 (KST) From: Andi Shyti To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH 07/15] lirc_dev: simplify if statement in lirc_add_to_buf Date: Wed, 29 Jun 2016 22:20:36 +0900 Message-id: <1467206444-9935-8-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1467206444-9935-1-git-send-email-andi.shyti@samsung.com> References: <1467206444-9935-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRmVeSWpSXmKPExsWyRsSkUNfidHG4wdZuC4vtR56xWiz+8ZzJ 4vKuOWwWPRu2slqsflbhwOpxfcknZo8t/XfZPfq2rGL0+LxJLoAlissmJTUnsyy1SN8ugSuj falJwRXuigPrPzI2MDZydjFyckgImEgcPf+dFcIWk7hwbz1bFyMXh5DACkaJ1kd/2WCKeuZP YodILGWU2Dx3HTOE85FRYtKp72BVbAKaEk23fwDZHBwiAsYS536og4SZBZoZJXZfNwIJCwt4 Suw5YwISZhFQlfjy9ywLiM0r4CoxYdE3JohdchKXpz8Am8gp4Cax/PxNdhBbCKim9el/RpC1 EgLN7BIdO2YyQwwSkPg2+RALyHwJAVmJTQeYIeZIShxccYNlAqPwAkaGVYyiqQXJBcVJ6UXG esWJuc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pSY5b dtj7JMTwxm16fPnoFe34F/vdegOn1soWbsljPca+5KFMlY/AH21Zy4n5/PdnmNo0Ogb1q2+W rStVW3XnxP3c1mmP3FtfFRr6KrEUZyQaajEXFScCAMq176KpAgAA 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 | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index cc00b9a..d63ff85 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -95,27 +95,26 @@ 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 = 0; + int res; + int got_data = 0; - /* - * service the device as long as it is returning - * data and we have space - */ - do { - res = ir->d.add_to_buf(ir->d.data, ir->buf); - if (!res) - got_data++; - } 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 { + res = ir->d.add_to_buf(ir->d.data, ir->buf); + if (!res) + got_data++; + } 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