From patchwork Tue Oct 25 19:23:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9395275 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 042CB60233 for ; Tue, 25 Oct 2016 19:24:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4478529730 for ; Tue, 25 Oct 2016 19:24:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35CF029734; Tue, 25 Oct 2016 19:24:32 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 1C2BD2972D for ; Tue, 25 Oct 2016 19:24:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933047AbcJYTYS (ORCPT ); Tue, 25 Oct 2016 15:24:18 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36398 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753871AbcJYTYQ (ORCPT ); Tue, 25 Oct 2016 15:24:16 -0400 Received: by mail-wm0-f66.google.com with SMTP id c78so1922505wme.3 for ; Tue, 25 Oct 2016 12:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=nGqtUpyNrugy1p+SOkGuvr9w65/D2ZwEaMiyg1sL+tc=; b=JkFusdxGm8tU3bPr8nDwoEegc5FyGx5gNYtDG8GfBKfgXNsh+17Lv17P4NYuyHGSJq +wR3+RcWtX03TBRWSIwQxpN+65xWY8aTAZ0rft3GP7Q5aCJjCQlTBlMViXLO51lXL2j6 1iUpinUg9Mg2PVPrBP4dAYuK0vOv2Evp0Ybr0OkW4aIAr91vGD3El9mn/lFakfFOExai iN7/VroFiuWnXDnS76k2nLK2VIZVAw6KOCeAnl8np70ngFyyhpwwNc8/5auv1PO/5ItB 5AyGAKwzWFphqUbbZKzAfFd6uX9twKjZ5dtRuY3+0zXfetBpsWDwXOaD3H3byQBggK+u Sb5w== 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:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=nGqtUpyNrugy1p+SOkGuvr9w65/D2ZwEaMiyg1sL+tc=; b=TrIBTEZFyfEBXX4vv11nLb84zSTMSkxpY0NCyzlK913rr8TjA8gXRwb8Z1HW6Rqido DOZVNyAnfvoVPRThap0zHZtJkV00LUScK+H1RnUaYhjbigEXYL0QVSr7+A6iiMwpD44G VjYDVnFroNwUVws2FEF8ceklPvsMj5glczrWfLp5P45ofLr1tGwCrpUqLtBCkRezZ6YY jScXSihe5N6/UWH4j8xQ8s6cVGCwkgEzuZdysyAzkuudcaeJlFLrFhKj6DWi84ILeYCl Iavi9mVjUXCCzxw9VMEML2LhbmnH0GWdpjD107gyDa8LpRgsmT9v3C7OilZi+ygS6xgq AqEQ== X-Gm-Message-State: ABUngvc8+3yH9WP3vF6KARmXh+0FkiOZvgPcBM7KR3JpcSliR5xZTN141M4nuq56PvL+Rg== X-Received: by 10.28.1.83 with SMTP id 80mr4610481wmb.31.1477423454859; Tue, 25 Oct 2016 12:24:14 -0700 (PDT) Received: from ?IPv6:2003:62:5f6e:ba00:954e:ed47:430f:d580? (p200300625F6EBA00954EED47430FD580.dip0.t-ipconnect.de. [2003:62:5f6e:ba00:954e:ed47:430f:d580]) by smtp.googlemail.com with ESMTPSA id a7sm26637525wjj.22.2016.10.25.12.24.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Oct 2016 12:24:14 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH 3/5] media: rc: nuvoton: eliminate nvt->tx.lock To: Mauro Carvalho Chehab References: Cc: linux-media@vger.kernel.org Message-ID: <3ebbfb6b-8417-f1a9-ad7e-b1432e582ccd@gmail.com> Date: Tue, 25 Oct 2016 21:23:45 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: 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 Using a separate spinlock to protect access to substruct tx of struct nvt_dev doesn't provide any actual benefit. We can use spinlock nvt_lock to protect all access to struct nvt_dev and get rid of nvt->tx.lock. Signed-off-by: Heiner Kallweit --- drivers/media/rc/nuvoton-cir.c | 35 +++++++++-------------------------- drivers/media/rc/nuvoton-cir.h | 1 - 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/drivers/media/rc/nuvoton-cir.c b/drivers/media/rc/nuvoton-cir.c index a583066..c677628 100644 --- a/drivers/media/rc/nuvoton-cir.c +++ b/drivers/media/rc/nuvoton-cir.c @@ -688,7 +688,7 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n) u8 iren; int ret; - spin_lock_irqsave(&nvt->tx.lock, flags); + spin_lock_irqsave(&nvt->nvt_lock, flags); ret = min((unsigned)(TX_BUF_LEN / sizeof(unsigned)), n); nvt->tx.buf_count = (ret * sizeof(unsigned)); @@ -712,13 +712,13 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n) for (i = 0; i < 9; i++) nvt_cir_reg_write(nvt, 0x01, CIR_STXFIFO); - spin_unlock_irqrestore(&nvt->tx.lock, flags); + spin_unlock_irqrestore(&nvt->nvt_lock, flags); wait_event(nvt->tx.queue, nvt->tx.tx_state == ST_TX_REQUEST); - spin_lock_irqsave(&nvt->tx.lock, flags); + spin_lock_irqsave(&nvt->nvt_lock, flags); nvt->tx.tx_state = ST_TX_NONE; - spin_unlock_irqrestore(&nvt->tx.lock, flags); + spin_unlock_irqrestore(&nvt->nvt_lock, flags); /* restore enabled interrupts to prior state */ nvt_cir_reg_write(nvt, iren, CIR_IREN); @@ -832,14 +832,7 @@ static void nvt_cir_log_irqs(u8 status, u8 iren) static bool nvt_cir_tx_inactive(struct nvt_dev *nvt) { - unsigned long flags; - u8 tx_state; - - spin_lock_irqsave(&nvt->tx.lock, flags); - tx_state = nvt->tx.tx_state; - spin_unlock_irqrestore(&nvt->tx.lock, flags); - - return tx_state == ST_TX_NONE; + return nvt->tx.tx_state == ST_TX_NONE; } /* interrupt service routine for incoming and outgoing CIR data */ @@ -902,8 +895,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) nvt_get_rx_ir_data(nvt); } - spin_unlock_irqrestore(&nvt->nvt_lock, flags); - if (status & CIR_IRSTS_TE) nvt_clear_tx_fifo(nvt); @@ -911,8 +902,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) unsigned int pos, count; u8 tmp; - spin_lock_irqsave(&nvt->tx.lock, flags); - pos = nvt->tx.cur_buf_num; count = nvt->tx.buf_count; @@ -925,20 +914,17 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) tmp = nvt_cir_reg_read(nvt, CIR_IREN); nvt_cir_reg_write(nvt, tmp & ~CIR_IREN_TTR, CIR_IREN); } - - spin_unlock_irqrestore(&nvt->tx.lock, flags); - } if (status & CIR_IRSTS_TFU) { - spin_lock_irqsave(&nvt->tx.lock, flags); if (nvt->tx.tx_state == ST_TX_REPLY) { nvt->tx.tx_state = ST_TX_REQUEST; wake_up(&nvt->tx.queue); } - spin_unlock_irqrestore(&nvt->tx.lock, flags); } + spin_unlock_irqrestore(&nvt->nvt_lock, flags); + nvt_dbg_verbose("%s done", __func__); return IRQ_HANDLED; } @@ -1019,7 +1005,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) nvt->cr_efdr = CR_EFDR; spin_lock_init(&nvt->nvt_lock); - spin_lock_init(&nvt->tx.lock); pnp_set_drvdata(pdev, nvt); @@ -1117,12 +1102,10 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state) nvt_dbg("%s called", __func__); - spin_lock_irqsave(&nvt->tx.lock, flags); - nvt->tx.tx_state = ST_TX_NONE; - spin_unlock_irqrestore(&nvt->tx.lock, flags); - spin_lock_irqsave(&nvt->nvt_lock, flags); + nvt->tx.tx_state = ST_TX_NONE; + /* disable all CIR interrupts */ nvt_cir_reg_write(nvt, 0, CIR_IREN); diff --git a/drivers/media/rc/nuvoton-cir.h b/drivers/media/rc/nuvoton-cir.h index 77102a9..a8569b6 100644 --- a/drivers/media/rc/nuvoton-cir.h +++ b/drivers/media/rc/nuvoton-cir.h @@ -87,7 +87,6 @@ struct nvt_dev { unsigned int pkts; struct { - spinlock_t lock; u8 buf[TX_BUF_LEN]; unsigned int buf_count; unsigned int cur_buf_num;