Linus,
please pull from
git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git tags/for-linus-2023060501
to receive
=====
- Final, confirmed fix for regression causing some devices connected via
Logitech HID++ Unifying receiver take too long to initialize (Benjamin
Tissoires)
======
----------------------------------------------------------------
Benjamin Tissoires (1):
HID: hidpp: terminate retry loop on success
drivers/hid/hid-logitech-hidpp.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
--
Jiri Kosina
SUSE Labs
On Mon, Jun 5, 2023 at 2:39 PM Jiri Kosina <[email protected]> wrote:
>
> - Final, confirmed fix for regression causing some devices connected via
> Logitech HID++ Unifying receiver take too long to initialize (Benjamin
> Tissoires)
Thanks.
The 'don't use goto' looks good, but can we simplify things further?
In particular, this kind of loop is why "do { } while ()" exists.
But also, testing "ret" in that end condition is all kinds of strange.
It smells of Pascal loops, because Pascal didn't have any sane control
flow (little known fact: in a rare show of self-reflection, "Pascal"
was named to sound like the Finnish word "paska", meaning "shit").
The *sane* thing to do is not to test "ret" in the loop condition, but
just add the obvious control flow - so the code that wants to retry
should just do 'continue' in that loop.
Then the loop itself ends up being just
do {
...
} while (--max_retries);
and we don't need any fake initialization of 'ret'.
Anyway, just a thought.
It would also simplify things a lot if that function was split up so
that you'd have that whole loop in a helper function. That way it
could just use "return ret" or whatever, with the mutex_lock/unlock in
the caller.
Btw, it does look like the code is mixing two different kinds of
return types in 'ret': regular Linux error numbers as negative
numbers, but then possibly positive "HIDPP status" values that it gets
from the report (ie
ret = response->rap.params[1];
ends up being returned as a value, mixed with
ret = -ETIMEDOUT;
so which is it? A negative error, or a positive HID report byte value? Or both?
Linus
The pull request you sent on Mon, 5 Jun 2023 23:39:17 +0200 (CEST):
> git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git tags/for-linus-2023060501
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/fa56e0e44f658085262f536bbfdfff3374b8828d
Thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html