From patchwork Wed Jul 6 09:01:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9215891 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 CD2DE608A6 for ; Wed, 6 Jul 2016 09:44:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE51F287D6 for ; Wed, 6 Jul 2016 09:44:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3291287DD; Wed, 6 Jul 2016 09:44:10 +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 013E6287D7 for ; Wed, 6 Jul 2016 09:44:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753215AbcGFJoF (ORCPT ); Wed, 6 Jul 2016 05:44:05 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:55244 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752701AbcGFJoA (ORCPT ); Wed, 6 Jul 2016 05:44:00 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9W019QX0D60Y40@mailout3.samsung.com>; Wed, 06 Jul 2016 18:43:54 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id DB.69.05161.9D2DC775; Wed, 6 Jul 2016 18:43:54 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-37-577cd2d937d1 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 46.12.02101.9D2DC775; Wed, 6 Jul 2016 18:43:53 +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 <0O9W003BE0D2J600@mmp2.samsung.com>; Wed, 06 Jul 2016 18:43:53 +0900 (KST) From: Andi Shyti To: Mauro Carvalho Chehab Cc: Joe Perches , Sean Young , Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Andi Shyti , Andi Shyti Subject: [PATCH v3 07/15] [media] lirc_dev: simplify if statement in lirc_add_to_buf Date: Wed, 06 Jul 2016 18:01:19 +0900 Message-id: <1467795687-10737-8-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1467795687-10737-1-git-send-email-andi.shyti@samsung.com> References: <1467795687-10737-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRmVeSWpSXmKPExsWyRsSkUPfWpZpwgxnHGC22H3nGarH4x3Mm i1OTnzFZzL7/mMXi8q45bBY9G7ayWqx+VmGx8Ol3FgcOj+tLPjF7LHlj7bGl/y67x5dV15g9 +rasYvT4vEnO49TXz+wB7FFcNimpOZllqUX6dglcGYcWPGEu2Mpdcfz9KbYGxvccXYycHBIC JhKv2t+zQ9hiEhfurWfrYuTiEBJYwSjx4Nd7FpiiZ5e2sUMkZjFKXHs9D8r5yCjxa9lNJpAq NgFNiabbP4DaOThEBIwlzv1QB6lhFnjKKLFv6lywGmGBMImle1YxgtgsAqoSW1feB7N5Bdwk bv+E2SYncXn6A7A5nALuEleXK4GEhYBK9m+7CbZXQm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cS 5338f12YkEB6YklqdmpqQWoRTB8TB6dUA6NH/kl2BZ2flbMdPl0vjnMVPSfM37kgW+dAoujh iYFBX92UTp+6Hyl7dV/xbOlDGbxBx1nuFbRHz/fSufs5g/1/bWhJqNkqpknc+37NuXlo4qeE xn2/Aq9dXFkR83Kxr25Il7NwYv9P9jOi3R92T5Wb+Cowo8zUYF78+/K5D1Wi/P9I/f8+L0mJ pTgj0VCLuag4EQC6ODiLyAIAAA== 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 cfa6031..c2826a7 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