From patchwork Thu Jul 11 09:05:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 2826161 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E7C43C0AB2 for ; Thu, 11 Jul 2013 09:15:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A5ED520107 for ; Thu, 11 Jul 2013 09:15:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9E19200D0 for ; Thu, 11 Jul 2013 09:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932420Ab3GKJKx (ORCPT ); Thu, 11 Jul 2013 05:10:53 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:63256 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932278Ab3GKJKq (ORCPT ); Thu, 11 Jul 2013 05:10:46 -0400 Received: by mail-pd0-f179.google.com with SMTP id q10so7249732pdj.38 for ; Thu, 11 Jul 2013 02:10:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=wK2Fhs6s4XAVlnxZRKtJhK1y/cmOvgIFETguou5p6Vk=; b=Sst6XOqqvT8bJfOALjHkrLF6Ew/AJ6tQ2QnAtOTJCqfjZaUHDYJlVkYukySXQ8VW0q v5HI3etYNd1AvERPMLUTNzgz8RcyC/HySffMjWBp23wUvyZ8f+9b/XUH/q5hjN1+VG8v Vl5PD+bqON8U2ovqOKLfcdNPDaOKNNuZX9nWIivw9W87MgFStLPt2a+rYO3lzCSrFp0+ vn3D+v7OR31tttYf0vg1NzDUN/Mm4XgKPVjWlqCvF6Lir2+EAgwASHeJ5okRIZaaJosm 4bu0GjjYQQzlJDFDUvr2g0uDrJQOFe6yTW0XHpNOYFwHeGfSj99IGjlU5G+xNkRGdVwl tJ7g== X-Received: by 10.69.4.5 with SMTP id ca5mr35879522pbd.109.1373533846180; Thu, 11 Jul 2013 02:10:46 -0700 (PDT) Received: from localhost ([183.37.203.123]) by mx.google.com with ESMTPSA id zn4sm41047627pac.21.2013.07.11.02.10.40 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 11 Jul 2013 02:10:45 -0700 (PDT) From: Ming Lei To: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, Oliver Neukum , Alan Stern , linux-input@vger.kernel.org, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-media@vger.kernel.org, alsa-devel@alsa-project.org, Ming Lei , Daniel Drake , Ulrich Kunitz , "John W. Linville" Subject: [PATCH 31/50] wireless: zd1211rw: spin_lock in complete() cleanup Date: Thu, 11 Jul 2013 17:05:54 +0800 Message-Id: <1373533573-12272-32-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1373533573-12272-1-git-send-email-ming.lei@canonical.com> References: <1373533573-12272-1-git-send-email-ming.lei@canonical.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Complete() will be run with interrupt enabled, so change to spin_lock_irqsave(). Cc: Daniel Drake Cc: Ulrich Kunitz Cc: "John W. Linville" Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Ming Lei --- drivers/net/wireless/zd1211rw/zd_usb.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c index 7ef0b4a..8169ee0 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zd1211rw/zd_usb.c @@ -372,14 +372,15 @@ static inline void handle_regs_int_override(struct urb *urb) { struct zd_usb *usb = urb->context; struct zd_usb_interrupt *intr = &usb->intr; + unsigned long flags; - spin_lock(&intr->lock); + spin_lock_irqsave(&intr->lock, flags); if (atomic_read(&intr->read_regs_enabled)) { atomic_set(&intr->read_regs_enabled, 0); intr->read_regs_int_overridden = 1; complete(&intr->read_regs.completion); } - spin_unlock(&intr->lock); + spin_unlock_irqrestore(&intr->lock, flags); } static inline void handle_regs_int(struct urb *urb) @@ -388,9 +389,10 @@ static inline void handle_regs_int(struct urb *urb) struct zd_usb_interrupt *intr = &usb->intr; int len; u16 int_num; + unsigned long flags; ZD_ASSERT(in_interrupt()); - spin_lock(&intr->lock); + spin_lock_irqsave(&intr->lock, flags); int_num = le16_to_cpu(*(__le16 *)(urb->transfer_buffer+2)); if (int_num == CR_INTERRUPT) { @@ -426,7 +428,7 @@ static inline void handle_regs_int(struct urb *urb) } out: - spin_unlock(&intr->lock); + spin_unlock_irqrestore(&intr->lock, flags); /* CR_INTERRUPT might override read_reg too. */ if (int_num == CR_INTERRUPT && atomic_read(&intr->read_regs_enabled)) @@ -666,6 +668,7 @@ static void rx_urb_complete(struct urb *urb) struct zd_usb_rx *rx; const u8 *buffer; unsigned int length; + unsigned long flags; switch (urb->status) { case 0: @@ -694,14 +697,14 @@ static void rx_urb_complete(struct urb *urb) /* If there is an old first fragment, we don't care. */ dev_dbg_f(urb_dev(urb), "*** first fragment ***\n"); ZD_ASSERT(length <= ARRAY_SIZE(rx->fragment)); - spin_lock(&rx->lock); + spin_lock_irqsave(&rx->lock, flags); memcpy(rx->fragment, buffer, length); rx->fragment_length = length; - spin_unlock(&rx->lock); + spin_unlock_irqrestore(&rx->lock, flags); goto resubmit; } - spin_lock(&rx->lock); + spin_lock_irqsave(&rx->lock, flags); if (rx->fragment_length > 0) { /* We are on a second fragment, we believe */ ZD_ASSERT(length + rx->fragment_length <= @@ -711,9 +714,9 @@ static void rx_urb_complete(struct urb *urb) handle_rx_packet(usb, rx->fragment, rx->fragment_length + length); rx->fragment_length = 0; - spin_unlock(&rx->lock); + spin_unlock_irqrestore(&rx->lock, flags); } else { - spin_unlock(&rx->lock); + spin_unlock_irqrestore(&rx->lock, flags); handle_rx_packet(usb, buffer, length); }