From patchwork Tue Aug 2 05:44:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9255213 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 3F9B56048B for ; Tue, 2 Aug 2016 06:39:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F38F2850B for ; Tue, 2 Aug 2016 06:39:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 241BA284E5; Tue, 2 Aug 2016 06:39:01 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 ACD20284E5 for ; Tue, 2 Aug 2016 06:39:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756220AbcHBGi4 (ORCPT ); Tue, 2 Aug 2016 02:38:56 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36521 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751475AbcHBGiy (ORCPT ); Tue, 2 Aug 2016 02:38:54 -0400 Received: by mail-wm0-f68.google.com with SMTP id x83so29091620wma.3 for ; Mon, 01 Aug 2016 23:37:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=BWHkLuJc1SE1coe+WGYQfv90JWgzWiSj2qknDq+AhHQ=; b=fqyJfGHisPqGxGhJTqYoZt0IevbnWcXqjWb0fJtlA78B8P5NI0YlGFlyKBLtfHNsAA ZGyfW3207RFtS9vPmx4wWxfoyKZiiesJG3fK6xiDwcLx7IAmkG2FDOdIs0aj/Uscz8WC ftC/iu8E8ywYLRHl8O/dRgowckttaSzaFM4l1n7YR+XxgoJ8op5N+p7wYuWjvgc1yKZP F9ZZaGFJvgYwV6KR1qF86EExl2xyundtrwfeoUy/baGOCIN0TFxpCSj4DNaPPnLLL1Lv bGORgUkup8/A6roywQIhuJuJFgLqa/KfGiBxDOezVgxuNdwwYjEdxTxD7k2YGwnDwIz1 fsAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=BWHkLuJc1SE1coe+WGYQfv90JWgzWiSj2qknDq+AhHQ=; b=Of2UBao786F691iHc9JXcmiMoKaHqyBkKzoXkXM1Xx9HlF7V/BRaZogTul8zwlPVHa 7WugUT7j8Y5lQ4N8L5Bfil6Mk1ba+n9mLEd25z2mqFMw2WVsOvH/36mu9+aiekCH8/1N 9cMH7Z67v3h1Wk/yzc2hjf3MVRhcK/g2XeHuCC5qP1Q9PEs2jOzvAk9w4+Id7Cp7Hej8 VelnsFryLxECfSOeNseBsHNUGhQPgh9KNjQD26aylakDRmLM70JJuy77uPQs3d6TX+0E t+kDrGM5xubTVFupuR/25Hz/nfFpfbD3tTINmTdnHw+4ld8kkjJ1zDO1jcD/kxLoU+V7 ycJg== X-Gm-Message-State: AEkoousX7mMT1x7V2rQFnFK2VZydibmZNZMO3V5AR1ZD6Ott1WJ+caJXPowNJAthncy3hA== X-Received: by 10.194.47.100 with SMTP id c4mr52746698wjn.34.1470116761466; Mon, 01 Aug 2016 22:46:01 -0700 (PDT) Received: from ?IPv6:2003:62:5f01:4400:28d9:4ab3:6068:8ae5? (p200300625F01440028D94AB360688AE5.dip0.t-ipconnect.de. [2003:62:5f01:4400:28d9:4ab3:6068:8ae5]) by smtp.googlemail.com with ESMTPSA id g67sm1174857wme.5.2016.08.01.22.46.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Aug 2016 22:46:00 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH 1/3] media: rc: nuvoton: remove usage of b_idx in nvt_get_rx_ir_data To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Message-ID: Date: Tue, 2 Aug 2016 07:44:44 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 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 call to nvt_get_rx_ir_data and nvt_process_rx_ir_data from the ISR is protected with spinlock nvt->lock. Therefore it's guaranteed that nvt->pkts is 0 when entering nvt_get_rx_ir_data (as nvt->pkts is set to 0 at the end of nvt_process_rx_ir_data). Having said that we can remove b_idx. Signed-off-by: Heiner Kallweit --- drivers/media/rc/nuvoton-cir.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index 0c69536..e4158a9 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -802,7 +802,6 @@ static void nvt_handle_rx_fifo_overrun(struct nvt_dev *nvt) static void nvt_get_rx_ir_data(struct nvt_dev *nvt) { u8 fifocount, val; - unsigned int b_idx; int i; /* Get count of how many bytes to read from RX FIFO */ @@ -810,21 +809,13 @@ static void nvt_get_rx_ir_data(struct nvt_dev *nvt) nvt_dbg("attempting to fetch %u bytes from hw rx fifo", fifocount); - b_idx = nvt->pkts; - - /* This should never happen, but lets check anyway... */ - if (b_idx + fifocount > RX_BUF_LEN) { - nvt_process_rx_ir_data(nvt); - b_idx = 0; - } - /* Read fifocount bytes from CIR Sample RX FIFO register */ for (i = 0; i < fifocount; i++) { val = nvt_cir_reg_read(nvt, CIR_SRXFIFO); - nvt->buf[b_idx + i] = val; + nvt->buf[i] = val; } - nvt->pkts += fifocount; + nvt->pkts = fifocount; nvt_dbg("%s: pkts now %d", __func__, nvt->pkts); nvt_process_rx_ir_data(nvt);