From patchwork Sun Jun 24 22:08:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 10484889 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 854006019D for ; Sun, 24 Jun 2018 22:09:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E15B2884E for ; Sun, 24 Jun 2018 22:09:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72EC328858; Sun, 24 Jun 2018 22:09:09 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 1CFD72884E for ; Sun, 24 Jun 2018 22:09:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752141AbeFXWJG (ORCPT ); Sun, 24 Jun 2018 18:09:06 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:45336 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752091AbeFXWJF (ORCPT ); Sun, 24 Jun 2018 18:09:05 -0400 Received: from localhost ([127.0.0.1] helo=bazinga.breakpoint.cc) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1fXDBt-0000Vg-0v; Mon, 25 Jun 2018 00:09:01 +0200 From: Sebastian Andrzej Siewior To: linux-usb@vger.kernel.org Cc: tglx@linutronix.de, Greg Kroah-Hartman , Sebastian Andrzej Siewior Subject: [PATCH 10/12] usb: iowarrior: remove intr_idx_lock Date: Mon, 25 Jun 2018 00:08:43 +0200 Message-Id: <20180624220845.6726-11-bigeasy@linutronix.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180624220845.6726-1-bigeasy@linutronix.de> References: <20180624220845.6726-1-bigeasy@linutronix.de> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The intr_idx_lock lock is acquired only in the completion callback of the ->int_in_urb (iowarrior_callback()). There is only one URB that is scheduled / completed so there can't be more than one user of the lock. The comment says that it protects ->intr_idx and the callback is the only place in driver that writes to it. Remove the intr_idx_lock lock because it is superfluous. Cc: Greg Kroah-Hartman Signed-off-by: Sebastian Andrzej Siewior --- drivers/usb/misc/iowarrior.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 8d33187ce2af..c2991b8a65ce 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -81,7 +81,6 @@ struct iowarrior { atomic_t write_busy; /* number of write-urbs submitted */ atomic_t read_idx; atomic_t intr_idx; - spinlock_t intr_idx_lock; /* protects intr_idx */ atomic_t overflow_flag; /* signals an index 'rollover' */ int present; /* this is 1 as long as the device is connected */ int opened; /* this is 1 if the device is currently open */ @@ -166,7 +165,6 @@ static void iowarrior_callback(struct urb *urb) goto exit; } - spin_lock(&dev->intr_idx_lock); intr_idx = atomic_read(&dev->intr_idx); /* aux_idx become previous intr_idx */ aux_idx = (intr_idx == 0) ? (MAX_INTERRUPT_BUFFER - 1) : (intr_idx - 1); @@ -181,7 +179,6 @@ static void iowarrior_callback(struct urb *urb) (dev->read_queue + offset, urb->transfer_buffer, dev->report_size)) { /* equal values on interface 0 will be ignored */ - spin_unlock(&dev->intr_idx_lock); goto exit; } } @@ -202,7 +199,6 @@ static void iowarrior_callback(struct urb *urb) *(dev->read_queue + offset + (dev->report_size)) = dev->serial_number++; atomic_set(&dev->intr_idx, aux_idx); - spin_unlock(&dev->intr_idx_lock); /* tell the blocking read about the new data */ wake_up_interruptible(&dev->read_wait); @@ -762,7 +758,6 @@ static int iowarrior_probe(struct usb_interface *interface, atomic_set(&dev->intr_idx, 0); atomic_set(&dev->read_idx, 0); - spin_lock_init(&dev->intr_idx_lock); atomic_set(&dev->overflow_flag, 0); init_waitqueue_head(&dev->read_wait); atomic_set(&dev->write_busy, 0);