From: Martin Kepplinger <martink@posteo.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH 1/4] input: tablet: pegasus_notetaker: Track usb control msg errors
Date: Thu, 21 Jul 2016 13:06:57 +0200 [thread overview]
Message-ID: <6e467acb-27e7-563c-7d33-e4f94cfe8dca@posteo.de> (raw)
In-Reply-To: <20160720210653.GF25655@dtor-ws>
Am 2016-07-20 um 23:06 schrieb Dmitry Torokhov:
> Hi Martin,
>
> On Mon, Jul 18, 2016 at 04:29:06PM +0200, Martin Kepplinger wrote:
>> Signed-off-by: Martin Kepplinger <martink@posteo.de>
>> ---
>> drivers/input/tablet/pegasus_notetaker.c | 26 ++++++++++++++++++--------
>> 1 file changed, 18 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/input/tablet/pegasus_notetaker.c b/drivers/input/tablet/pegasus_notetaker.c
>> index 83aa583..27cb352 100644
>> --- a/drivers/input/tablet/pegasus_notetaker.c
>> +++ b/drivers/input/tablet/pegasus_notetaker.c
>> @@ -79,7 +79,7 @@ struct pegasus {
>> 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;
>> int result;
>> @@ -87,7 +87,7 @@ static void pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len)
>>
>> cmd_buf = kmalloc(sizeof_buf, GFP_KERNEL);
>> if (!cmd_buf)
>> - return;
>> + return -ENOMEM;
>>
>> cmd_buf[0] = NOTETAKER_REPORT_ID;
>> cmd_buf[1] = len;
>> @@ -100,17 +100,23 @@ static void pegasus_control_msg(struct pegasus *pegasus, u8 *data, int len)
>> 0, 0, cmd_buf, sizeof_buf,
>> USB_CTRL_SET_TIMEOUT);
>>
>> - if (result != sizeof_buf)
>> - dev_err(&pegasus->usbdev->dev, "control msg error\n");
>> + if (result != sizeof_buf) {
>> + if (result >= 0)
>> + result = -EIO;
>> + dev_err(&pegasus->usbdev->dev, "control msg error: %d\n",
>> + result);
>> + }
>>
>> kfree(cmd_buf);
>> +
>> + return result;
>
> Your 4th patch relies on pegasus_control_msg() returning 0 on success,
> otherwise you will not restart the URB when doing reset resume. I
> rearranged the code here so we free cmd_buf right after calling
> usb_control_msg() and the explicitly returnig 0 in success branch.
>
Yes, I saw it. Thanks for your explaining and fixing!
>> }
>>
>> -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};
>>
>> - pegasus_control_msg(pegasus, cmd, sizeof(cmd));
>> + return pegasus_control_msg(pegasus, cmd, sizeof(cmd));
>> }
>>
>> static void pegasus_parse_packet(struct pegasus *pegasus)
>> @@ -184,8 +190,12 @@ static void pegasus_irq(struct urb *urb)
>> static void pegasus_init(struct work_struct *work)
>> {
>> struct pegasus *pegasus = container_of(work, struct pegasus, init);
>> + int retval;
>>
>> - pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
>> + retval = pegasus_set_mode(pegasus, PEN_MODE_XY, NOTETAKER_LED_MOUSE);
>> + if (retval < 0)
>> + dev_err(&pegasus->usbdev->dev, "pegasus_set_mode error: %d\n",
>> + retval);
>> }
>>
>> static int pegasus_open(struct input_dev *dev)
>> @@ -201,7 +211,7 @@ static int pegasus_open(struct input_dev *dev)
>> if (usb_submit_urb(pegasus->irq, GFP_KERNEL))
>> 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);
>>
>
> Thanks.
>
next prev parent reply other threads:[~2016-07-21 11:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1468852149-2614-1-git-send-email-martink@posteo.de>
2016-07-18 14:29 ` Martin Kepplinger
2016-07-20 21:06 ` Dmitry Torokhov
2016-07-21 11:06 ` Martin Kepplinger [this message]
2016-07-18 14:29 ` [PATCH 2/4] input: tablet: pegasus_notetaker: Fix usb_autopm calls to be balanced Martin Kepplinger
2016-07-20 21:29 ` Dmitry Torokhov
2016-07-21 11:00 ` Martin Kepplinger
2016-07-18 14:29 ` [PATCH 3/4] input: tablet: pegasus_notetaker: Cancel workqueue's work in suspend() Martin Kepplinger
2016-07-20 21:30 ` Dmitry Torokhov
2016-07-18 14:29 ` [PATCH 4/4] input: tablet: pegasus_notetaker: Set device mode in reset_resume() if in use Martin Kepplinger
2016-07-20 21:30 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e467acb-27e7-563c-7d33-e4f94cfe8dca@posteo.de \
--to=martink@posteo.de \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome