Commit 0c16ae76 authored by Ben Chan's avatar Ben Chan Committed by Greg Kroah-Hartman

staging: gdm72xx: Simplify spinlock fix for gdm_usb_send_complete

This patch simplifies the previous patch (commit
dd13c86b) for fixing the spinlock
recursion issue on several call sites of gdm_usb_send_complete.
Signed-off-by: default avatarBen Chan <benchan@chromium.org>
Cc: Sage Ahn <syahn@gctsemi.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 592314e9
...@@ -270,21 +270,17 @@ static void release_usb(struct usbwm_dev *udev) ...@@ -270,21 +270,17 @@ static void release_usb(struct usbwm_dev *udev)
} }
} }
static void gdm_usb_send_complete_impl(struct urb *urb, bool need_lock) static void __gdm_usb_send_complete(struct urb *urb)
{ {
struct usb_tx *t = urb->context; struct usb_tx *t = urb->context;
struct tx_cxt *tx = t->tx_cxt; struct tx_cxt *tx = t->tx_cxt;
u8 *pkt = t->buf; u8 *pkt = t->buf;
u16 cmd_evt; u16 cmd_evt;
unsigned long flags;
/* Completion by usb_unlink_urb */ /* Completion by usb_unlink_urb */
if (urb->status == -ECONNRESET) if (urb->status == -ECONNRESET)
return; return;
if (need_lock)
spin_lock_irqsave(&tx->lock, flags);
if (t->callback) if (t->callback)
t->callback(t->cb_data); t->callback(t->cb_data);
...@@ -296,19 +292,17 @@ static void gdm_usb_send_complete_impl(struct urb *urb, bool need_lock) ...@@ -296,19 +292,17 @@ static void gdm_usb_send_complete_impl(struct urb *urb, bool need_lock)
put_tx_struct(tx, t); put_tx_struct(tx, t);
else else
free_tx_struct(t); free_tx_struct(t);
if (need_lock)
spin_unlock_irqrestore(&tx->lock, flags);
} }
static void gdm_usb_send_complete(struct urb *urb) static void gdm_usb_send_complete(struct urb *urb)
{ {
gdm_usb_send_complete_impl(urb, true); struct usb_tx *t = urb->context;
} struct tx_cxt *tx = t->tx_cxt;
unsigned long flags;
static void gdm_usb_send_complete_no_lock(struct urb *urb) spin_lock_irqsave(&tx->lock, flags);
{ __gdm_usb_send_complete(urb);
gdm_usb_send_complete_impl(urb, false); spin_unlock_irqrestore(&tx->lock, flags);
} }
static int gdm_usb_send(void *priv_dev, void *data, int len, static int gdm_usb_send(void *priv_dev, void *data, int len,
...@@ -423,7 +417,7 @@ static int gdm_usb_send(void *priv_dev, void *data, int len, ...@@ -423,7 +417,7 @@ static int gdm_usb_send(void *priv_dev, void *data, int len,
send_fail: send_fail:
t->callback = NULL; t->callback = NULL;
gdm_usb_send_complete_no_lock(t->urb); __gdm_usb_send_complete(t->urb);
spin_unlock_irqrestore(&tx->lock, flags); spin_unlock_irqrestore(&tx->lock, flags);
return ret; return ret;
} }
...@@ -552,7 +546,7 @@ static void do_pm_control(struct work_struct *work) ...@@ -552,7 +546,7 @@ static void do_pm_control(struct work_struct *work)
if (ret) { if (ret) {
t->callback = NULL; t->callback = NULL;
gdm_usb_send_complete_no_lock(t->urb); __gdm_usb_send_complete(t->urb);
} }
} }
} }
...@@ -754,7 +748,7 @@ static int k_mode_thread(void *arg) ...@@ -754,7 +748,7 @@ static int k_mode_thread(void *arg)
if (ret) { if (ret) {
t->callback = NULL; t->callback = NULL;
gdm_usb_send_complete_no_lock(t->urb); __gdm_usb_send_complete(t->urb);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment