From: "Bjørn Mork" <bjorn-yOkvZcmFvRU@public.gmane.org>
To: Eric Wong <e@80x24.org>
Cc: Henrique de Moraes Holschuh
<ibm-acpi-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
platform-driver-x86-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Shuduo Sang <shuduo.sang-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
Darren Hart <dvhart-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
Andy Shevchenko <andy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
Subject: Re: [PATCH] platform/x86: thinkpad_acpi: add adaptive_kbd_modes parameter
Date: Sun, 25 Nov 2018 16:41:15 +0100 [thread overview]
Message-ID: <87zhtx17xg.fsf@miraculix.mork.no> (raw)
In-Reply-To: <20181125144441.xpwuov2i7lab3agh@dcvr> (Eric Wong's message of "Sun, 25 Nov 2018 14:44:41 +0000")
Eric Wong <e@80x24.org> writes:
> Bjørn Mork <bjorn@mork.no> wrote:
>
>> And then I believe you have a busy loop here:
>>
>> > @@ -3815,20 +3838,20 @@ static int adaptive_keyboard_set_mode(int new_mode)
>> >
>> > static int adaptive_keyboard_get_next_mode(int mode)
>> > {
>> > - size_t i;
>> > - size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1;
>> > -
>> > - for (i = 0; i <= max_mode; i++) {
>> > - if (adaptive_keyboard_modes[i] == mode)
>> > - break;
>> > - }
>> > + int max_mode = fls(adaptive_kbd_modes);
>> > + int new_mode = mode >= max_mode ? HOME_MODE : mode + 1;
>> >
>> > - if (i >= max_mode)
>> > - i = 0;
>> > - else
>> > - i++;
>> > + /* make sure the new mode is allowed by the user */
>> > + while (!(adaptive_kbd_modes & (1 << new_mode))) {
>> > + new_mode++;
>> > + if (new_mode > max_mode)
>> > + new_mode = HOME_MODE;
>> >
>> > - return adaptive_keyboard_modes[i];
>> > + /* maybe the user disabled all other modes: */
>> > + if (new_mode == mode)
>> > + return mode;
>> > + }
>> > + return new_mode;
>> > }
>
> Not a busy loop, since new_mode will reset at HOME_MODE (0)
> and then it'll hit "new_mode == mode" and remain locked in
> to the current mode.
Right. I see it now. Thanks for explaining.
I guess I was expecting a complete loop bypass ala
if (!max_mode)
return mode:
but your solution will of course work just as fine.
Bjørn
_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel
prev parent reply other threads:[~2018-11-25 15:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 7:34 [PATCH] platform/x86: thinkpad_acpi: add adaptive_kbd_modes parameter Eric Wong
2018-11-24 23:23 ` Eric Wong
2018-11-25 10:21 ` Bjørn Mork
2018-11-25 14:44 ` Eric Wong
2018-11-25 15:41 ` Bjørn Mork [this message]
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=87zhtx17xg.fsf@miraculix.mork.no \
--to=bjorn-yokvzcmfvru@public.gmane.org \
--cc=andy-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=dvhart-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=e@80x24.org \
--cc=ibm-acpi-N3TV7GIv+o9fyO9Q7EP/yw@public.gmane.org \
--cc=ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=platform-driver-x86-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=shuduo.sang-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.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