Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 104219
b: refs/heads/master
c: b4ecda3
h: refs/heads/master
i:
  104217: b5d44cc
  104215: b92ff3e
v: v3
  • Loading branch information
Oliver Neukum authored and Dmitry Torokhov committed Jul 7, 2008
1 parent c5a6ae7 commit 12d3e54
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4ad88901dd675acb9c8d1eca1f083c3d22cbbd4d
refs/heads/master: b4ecda3e965a87881a94017cb0cd484d65799261
44 changes: 29 additions & 15 deletions trunk/drivers/input/misc/yealink.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ struct yealink_dev {
u8 lcdMap[ARRAY_SIZE(lcdMap)]; /* state of LCD, LED ... */
int key_code; /* last reported key */

unsigned int shutdown:1;

int stat_ix;
union {
struct yld_status s;
Expand Down Expand Up @@ -424,10 +426,10 @@ static int yealink_do_idle_tasks(struct yealink_dev *yld)
static void urb_irq_callback(struct urb *urb)
{
struct yealink_dev *yld = urb->context;
int ret;
int ret, status = urb->status;

if (urb->status)
err("%s - urb status %d", __func__, urb->status);
if (status)
err("%s - urb status %d", __func__, status);

switch (yld->irq_data->cmd) {
case CMD_KEYPRESS:
Expand All @@ -447,32 +449,37 @@ static void urb_irq_callback(struct urb *urb)

yealink_do_idle_tasks(yld);

ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC);
if (ret)
err("%s - usb_submit_urb failed %d", __func__, ret);
if (!yld->shutdown) {
ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC);
if (ret && ret != -EPERM)
err("%s - usb_submit_urb failed %d", __func__, ret);
}
}

static void urb_ctl_callback(struct urb *urb)
{
struct yealink_dev *yld = urb->context;
int ret;
int ret = 0, status = urb->status;

if (urb->status)
err("%s - urb status %d", __func__, urb->status);
if (status)
err("%s - urb status %d", __func__, status);

switch (yld->ctl_data->cmd) {
case CMD_KEYPRESS:
case CMD_SCANCODE:
/* ask for a response */
ret = usb_submit_urb(yld->urb_irq, GFP_ATOMIC);
if (!yld->shutdown)
ret = usb_submit_urb(yld->urb_irq, GFP_ATOMIC);
break;
default:
/* send new command */
yealink_do_idle_tasks(yld);
ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC);
if (!yld->shutdown)
ret = usb_submit_urb(yld->urb_ctl, GFP_ATOMIC);
break;
}

if (ret)
if (ret && ret != -EPERM)
err("%s - usb_submit_urb failed %d", __func__, ret);
}

Expand Down Expand Up @@ -531,8 +538,18 @@ static void input_close(struct input_dev *dev)
{
struct yealink_dev *yld = input_get_drvdata(dev);

yld->shutdown = 1;
/*
* Make sure the flag is seen by other CPUs before we start
* killing URBs so new URBs won't be submitted
*/
smp_wmb();

usb_kill_urb(yld->urb_ctl);
usb_kill_urb(yld->urb_irq);

yld->shutdown = 0;
smp_wmb();
}

/*******************************************************************************
Expand Down Expand Up @@ -809,9 +826,6 @@ static int usb_cleanup(struct yealink_dev *yld, int err)
if (yld == NULL)
return err;

usb_kill_urb(yld->urb_irq); /* parameter validation in core/urb */
usb_kill_urb(yld->urb_ctl); /* parameter validation in core/urb */

if (yld->idev) {
if (err)
input_free_device(yld->idev);
Expand Down

0 comments on commit 12d3e54

Please sign in to comment.