mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 19:07:52 +00:00
Input: pegasus_notetaker - handle usb control msg errors
Signed-off-by: Martin Kepplinger <martink@posteo.de> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
3746e56752
commit
168c1398e0
1 changed files with 20 additions and 9 deletions
|
@ -80,15 +80,16 @@ struct pegasus {
|
||||||
struct work_struct init;
|
struct work_struct init;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len)
|
static int pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len)
|
||||||
{
|
{
|
||||||
const int sizeof_buf = len + 2;
|
const int sizeof_buf = len + 2;
|
||||||
int result;
|
int result;
|
||||||
|
int error;
|
||||||
u8 *cmd_buf;
|
u8 *cmd_buf;
|
||||||
|
|
||||||
cmd_buf = kmalloc(sizeof_buf, GFP_KERNEL);
|
cmd_buf = kmalloc(sizeof_buf, GFP_KERNEL);
|
||||||
if (!cmd_buf)
|
if (!cmd_buf)
|
||||||
return;
|
return -ENOMEM;
|
||||||
|
|
||||||
cmd_buf[0] = NOTETAKER_REPORT_ID;
|
cmd_buf[0] = NOTETAKER_REPORT_ID;
|
||||||
cmd_buf[1] = len;
|
cmd_buf[1] = len;
|
||||||
|
@ -101,17 +102,23 @@ static void pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len)
|
||||||
0, 0, cmd_buf, sizeof_buf,
|
0, 0, cmd_buf, sizeof_buf,
|
||||||
USB_CTRL_SET_TIMEOUT);
|
USB_CTRL_SET_TIMEOUT);
|
||||||
|
|
||||||
if (result != sizeof_buf)
|
|
||||||
dev_err(&pegasus->usbdev->dev, "control msg error\n");
|
|
||||||
|
|
||||||
kfree(cmd_buf);
|
kfree(cmd_buf);
|
||||||
|
|
||||||
|
if (unlikely(result != sizeof_buf)) {
|
||||||
|
error = result < 0 ? result : -EIO;
|
||||||
|
dev_err(&pegasus->usbdev->dev, "control msg error: %d\n",
|
||||||
|
error);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pegasus_set_mode(struct pegasus *pegasus, u8 mode, u8 led)
|
static int pegasus_set_mode(struct pegasus *pegasus, u8 mode, u8 led)
|
||||||
{
|
{
|
||||||
u8 cmd[] = { NOTETAKER_SET_CMD, NOTETAKER_SET_MODE, led, mode };
|
u8 cmd[] = { NOTETAKER_SET_CMD, NOTETAKER_SET_MODE, led, mode };
|
||||||
|
|
||||||
pegasus_control_msg(pegasus, cmd, sizeof(cmd));
|
return pegasus_control_msg(pegasus, cmd, sizeof(cmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pegasus_parse_packet(struct pegasus *pegasus)
|
static void pegasus_parse_packet(struct pegasus *pegasus)
|
||||||
|
@ -191,8 +198,12 @@ static void pegasus_irq(struct urb *urb)
|
||||||
static void pegasus_init(struct work_struct *work)
|
static void pegasus_init(struct work_struct *work)
|
||||||
{
|
{
|
||||||
struct pegasus *pegasus = container_of(work, struct pegasus, init);
|
struct pegasus *pegasus = container_of(work, struct pegasus, init);
|
||||||
|
int error;
|
||||||
|
|
||||||
pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
|
error = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
|
||||||
|
if (error)
|
||||||
|
dev_err(&pegasus->usbdev->dev, "pegasus_set_mode error: %d\n",
|
||||||
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pegasus_open(struct input_dev *dev)
|
static int pegasus_open(struct input_dev *dev)
|
||||||
|
@ -208,7 +219,7 @@ static int pegasus_open(struct input_dev *dev)
|
||||||
if (usb_submit_urb(pegasus->irq, GFP_KERNEL))
|
if (usb_submit_urb(pegasus->irq, GFP_KERNEL))
|
||||||
retval = -EIO;
|
retval = -EIO;
|
||||||
|
|
||||||
pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
|
retval = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
|
||||||
|
|
||||||
usb_autopm_put_interface(pegasus->intf);
|
usb_autopm_put_interface(pegasus->intf);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue