From patchwork Fri Jul 1 08:01:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9209477 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 A7A6360221 for ; Fri, 1 Jul 2016 08:21:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98FAD2837F for ; Fri, 1 Jul 2016 08:21:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D94C28695; Fri, 1 Jul 2016 08:21:58 +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 B4B1F2837F for ; Fri, 1 Jul 2016 08:21:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752780AbcGAIUF (ORCPT ); Fri, 1 Jul 2016 04:20:05 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:55383 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751523AbcGAIE1 (ORCPT ); Fri, 1 Jul 2016 04:04:27 -0400 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O9M0046VMAZ8SA0@mailout2.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 CA.63.05161.B6326775; Fri, 1 Jul 2016 17:01:47 +0900 (KST) X-AuditID: cbfee68f-f79476d000001429-90-5776236b6aa1 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id DA.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 08/15] [media] lirc_dev: remove double if ... else statement Date: Fri, 01 Jul 2016 17:01:31 +0900 Message-id: <1467360098-12539-9-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+NgFrrLLMWRmVeSWpSXmKPExsWyRsSkUDdbuSzcoH2josX2I89YLRb/eM5k Mfv+YxaLy7vmsFn0bNjKarH6WYXFwqffWRzYPa4v+cTsseSNtceW/rvsHl9WXWP26NuyitHj 8ya5ALYoLpuU1JzMstQifbsErowVN2wLJnFXnD/zj7GB8SlHFyMnh4SAicTRHZMZIWwxiQv3 1rN1MXJxCAmsYJRYdPoAK0zR94+9UIlZQIlV51ghnI+MEqu394G1swloSjTd/gFUxcEhImAs ce6HOkiYWeAAo0RvtwuILSzgL/HrWCsLiM0ioCrxe8NGNhCbV8BNYvKTBUwQy+QkLk9/ABbn FHCXuPtuF9h4IaCaubvusYPslRBYxC7ROvEbO8QgAYlvkw+xgOyVEJCV2HSAGWKOpM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E359Cnt74uaM7Tqzj3Mv1Gi8FT7fymBrW+2upRf8 tWxqgr8c6c6q3SdUGyy/i3OtcvGFGyxap3yf6f5Qe/NosUh+YNOdSW+m/fr189uteeaJknsi mqdOkdivJXaKqabxZED087gcvi0v3kiu+9m36bsb86H0x4XahmG1SizFGYmGWsxFxYkAltCp 3L0CAAA= 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 There are two if ... else which check the same thing in different part of the code, they can be merged in a single check. Signed-off-by: Andi Shyti --- drivers/media/rc/lirc_dev.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index 2468849..2643336 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -310,13 +310,6 @@ static int lirc_allocate_driver(struct lirc_driver *d) irctls[minor] = ir; d->minor = minor; - if (d->sample_rate) { - ir->jiffies_to_wait = HZ / d->sample_rate; - } else { - /* it means - wait for external event in task queue */ - ir->jiffies_to_wait = 0; - } - /* some safety check 8-) */ d->name[sizeof(d->name)-1] = '\0'; @@ -330,6 +323,8 @@ static int lirc_allocate_driver(struct lirc_driver *d) "lirc%u", ir->d.minor); if (d->sample_rate) { + ir->jiffies_to_wait = HZ / d->sample_rate; + /* try to fire up polling thread */ ir->task = kthread_run(lirc_thread, (void *)ir, "lirc_dev"); if (IS_ERR(ir->task)) { @@ -338,6 +333,9 @@ static int lirc_allocate_driver(struct lirc_driver *d) err = -ECHILD; goto out_sysfs; } + } else { + /* it means - wait for external event in task queue */ + ir->jiffies_to_wait = 0; } err = lirc_cdev_add(ir);