Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753832AbbBZKFx (ORCPT ); Thu, 26 Feb 2015 05:05:53 -0500 Received: from mail-pd0-f180.google.com ([209.85.192.180]:33082 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753637AbbBZKC2 (ORCPT ); Thu, 26 Feb 2015 05:02:28 -0500 From: Peter Hung X-Google-Original-From: Peter Hung To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, tom_tsai@fintek.com.tw, peter_hong@fintek.com.tw, hpeter@gmail.com, Peter Hung Subject: [PATCH V8 03/10] USB: f81232: change lock mechanism Date: Thu, 26 Feb 2015 18:02:09 +0800 Message-Id: <1424944936-7117-4-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424944936-7117-1-git-send-email-hpeter+linux_kernel@gmail.com> References: <1424944936-7117-1-git-send-email-hpeter+linux_kernel@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2148 Lines: 70 The original driver lock with spin_lock_irqsave()/spin_unlock_irqrestore() because of it's maybe used in interrupt context f81232_process_read_urb(). We had remove it from previous patch "implement RX bulk-in EP", so we can change it from busying loop spin_lock to sleepable mutex_lock. Signed-off-by: Peter Hung --- drivers/usb/serial/f81232.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 25b1a47..cf5b902 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include @@ -46,7 +46,7 @@ MODULE_DEVICE_TABLE(usb, id_table); #define UART_CTS 0x80 struct f81232_private { - spinlock_t lock; + struct mutex lock; u8 line_control; u8 modem_status; }; @@ -227,17 +227,16 @@ static void f81232_close(struct usb_serial_port *port) static void f81232_dtr_rts(struct usb_serial_port *port, int on) { struct f81232_private *priv = usb_get_serial_port_data(port); - unsigned long flags; u8 control; - spin_lock_irqsave(&priv->lock, flags); + mutex_lock(&priv->lock); /* Change DTR and RTS */ if (on) priv->line_control |= (CONTROL_DTR | CONTROL_RTS); else priv->line_control &= ~(CONTROL_DTR | CONTROL_RTS); control = priv->line_control; - spin_unlock_irqrestore(&priv->lock, flags); + mutex_unlock(&priv->lock); set_control_lines(port->serial->dev, control); } @@ -281,7 +280,7 @@ static int f81232_port_probe(struct usb_serial_port *port) if (!priv) return -ENOMEM; - spin_lock_init(&priv->lock); + mutex_init(&priv->lock); usb_set_serial_port_data(port, priv); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/