From patchwork Thu Jul 11 09:05:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 2826078 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6D8659F7D6 for ; Thu, 11 Jul 2013 09:08:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5AE92011B for ; Thu, 11 Jul 2013 09:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 387B4200B9 for ; Thu, 11 Jul 2013 09:08:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932141Ab3GKJIC (ORCPT ); Thu, 11 Jul 2013 05:08:02 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:39578 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932090Ab3GKJH6 (ORCPT ); Thu, 11 Jul 2013 05:07:58 -0400 Received: by mail-pa0-f46.google.com with SMTP id fa11so7701645pad.33 for ; Thu, 11 Jul 2013 02:07:58 -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=lUvRL+m5JQflQPrSvBDKdSRI9Q+ockJuxHlFW4s7eCs=; b=MHBFF4yTLhpns3IPNK9i+604SNdJnn0hORv81Ht2WkmPhKTlP1oOKqBFrajhTShCZD R3SPWw9dpBimQ/Q0gbIHXFqJXJ9we3FIltzH0tvADxUQncRdfox7HVBu7zwsK/nVPKNm tWE7x4+Asnf4LHSof4gTZLREe/GxgWljfU6vqNZSnu6Tjh7HKQfUUVqNowvtqSrnZREp SvYKRH/oeFexj2yk9qxmOwh646EnrRtLjElQvzeFmjFrZIUxTjMcLhihiD//J38ziXnG QyodAcAKBF6wNFhk5psJ4cj9RfTw8UJinuB66p7mfHJpTx7ad/F1+PM474sjS/3jD/CB b52g== X-Received: by 10.66.146.66 with SMTP id ta2mr37578392pab.11.1373533678135; Thu, 11 Jul 2013 02:07:58 -0700 (PDT) Received: from localhost ([183.37.203.123]) by mx.google.com with ESMTPSA id br1sm38659969pbb.4.2013.07.11.02.07.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 11 Jul 2013 02:07:57 -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 , Matthias Bruestle and Harald Welte Subject: [PATCH 10/50] USB: serial: cyberjack: spin_lock in complete() cleanup Date: Thu, 11 Jul 2013 17:05:33 +0800 Message-Id: <1373533573-12272-11-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=ham 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: Matthias Bruestle and Harald Welte Signed-off-by: Ming Lei --- drivers/usb/serial/cyberjack.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c index 7814262..0ab0957 100644 --- a/drivers/usb/serial/cyberjack.c +++ b/drivers/usb/serial/cyberjack.c @@ -271,11 +271,12 @@ static void cyberjack_read_int_callback(struct urb *urb) /* React only to interrupts signaling a bulk_in transfer */ if (urb->actual_length == 4 && data[0] == 0x01) { short old_rdtodo; + unsigned long flags; /* This is a announcement of coming bulk_ins. */ unsigned short size = ((unsigned short)data[3]<<8)+data[2]+3; - spin_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, flags); old_rdtodo = priv->rdtodo; @@ -290,7 +291,7 @@ static void cyberjack_read_int_callback(struct urb *urb) dev_dbg(dev, "%s - rdtodo: %d\n", __func__, priv->rdtodo); - spin_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); if (!old_rdtodo) { result = usb_submit_urb(port->read_urb, GFP_ATOMIC); @@ -317,6 +318,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) short todo; int result; int status = urb->status; + unsigned long flags; usb_serial_debug_data(dev, __func__, urb->actual_length, data); if (status) { @@ -330,7 +332,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) tty_flip_buffer_push(&port->port); } - spin_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, flags); /* Reduce urbs to do by one. */ priv->rdtodo -= urb->actual_length; @@ -339,7 +341,7 @@ static void cyberjack_read_bulk_callback(struct urb *urb) priv->rdtodo = 0; todo = priv->rdtodo; - spin_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); dev_dbg(dev, "%s - rdtodo: %d\n", __func__, todo); @@ -359,6 +361,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) struct cyberjack_private *priv = usb_get_serial_port_data(port); struct device *dev = &port->dev; int status = urb->status; + unsigned long flags; set_bit(0, &port->write_urbs_free); if (status) { @@ -367,7 +370,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) return; } - spin_lock(&priv->lock); + spin_lock_irqsave(&priv->lock, flags); /* only do something if we have more data to send */ if (priv->wrfilled) { @@ -411,7 +414,7 @@ static void cyberjack_write_bulk_callback(struct urb *urb) } exit: - spin_unlock(&priv->lock); + spin_unlock_irqrestore(&priv->lock, flags); usb_serial_port_softint(port); }