All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v6] USB: HID: random timeout failures tackle try.
Date: Wed, 05 Feb 2020 17:12:30 +0000	[thread overview]
Message-ID: <20200205171230.GV1778@kadam> (raw)
In-Reply-To: <20200205153944.11955-1-lja@iki.fi>

I never recieved v2-v5 so I can't really comment on those.  If you
didn't send those to linux-usb then let's just pretend we're still on
v1 otherwise it's just confusing.

This is not how we send v2 patches.  Put [PATCH v6], that's good.
Then the normal changelog and the Signed-off-by: then under the ---
cut off put a small comment.

Signed-off-by: you
---
v6: changed commit message
v5: fixed error reported by kbuild
v4: blah blah


> +/* Wrapper function to send control messages */

Don't include obvious comments like this.

> +static int usbhid_control_msg(struct usb_device *dev, unsigned int pipe,
> +				_u8 request, __u8 requesttype, __u16 value,
> +				__u16 index, void *data, __u16 size,
> +				int timeout)
> +{
> +	/* calculate timeout per call, to archieve total timeout requested */

This should be obvious if the variables and functions are named well.

It's weird that we're passing the total timeout and then dividing it
into littler chunks...  Normally we would know the timeout from the
spec and then the total would be something like "a timeout of 400ms
won't annoy users."  (This seems wrong).


> +	int call_timeout = USBHID_CONTROL_COMMAND_TIMEOUT_CALC(timeout);

CALC is a bad name because obviously it's going to calculate something.

> +	int call_count   = USBHID_CONTROL_COMMAND_RETRY_COUNT;

Just call it "int retry = USBHID_CONTROL_COMMAND_RETRY_COUNT;".  Don't
do anything fancy with the white space.

> +	int ret;
> +	int timeout_looping;
> +
> +	do {
> +		ret = usb_control_msg(dev, pipe, request, requesttype,
> +				value, index, data, size, call_timeout);

The indenting is wrong.  Use checkpatch.pl --strict

> +
> +		timeout_looping =	(call_count-- > 0) &&
> +					(ret = -ETIMEDOUT);
> +	} while (timeout_looping);

Delete the "timeout_looping" variable.

	} while (ret = -ETIMEDOUT && retry-- > 0);

Have you tested with just one retry?

regards,
dan carpenter

  reply	other threads:[~2020-02-05 17:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 15:39 [PATCH v6] USB: HID: random timeout failures tackle try Lauri Jakku
2020-02-05 17:12 ` Dan Carpenter [this message]
2020-02-06 10:37 ` Lauri Jakku
2020-02-06 14:26   ` Lauri Jakku
2020-02-06 14:26     ` Lauri Jakku
2020-02-06 10:59 ` Dan Carpenter
2020-02-06 15:03 ` Lauri Jakku

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=20200205171230.GV1778@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.