linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luke Jones <luke@ljones.dev>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mark Gross <markgross@kernel.org>,
	Platform Driver <platform-driver-x86@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/5] asus-wmi: Add support for TUF laptop keyboard RGB mode control
Date: Sat, 06 Aug 2022 22:33:45 +1200	[thread overview]
Message-ID: <90W6GR.9Z5CYBT7NOHJ1@ljones.dev> (raw)
In-Reply-To: <CAHp75VcYba6wYwkMo_Q_QEZsr4wyfDB5czu13w-y6hfQ13CkvQ@mail.gmail.com>

Hi Andy,

On Sat, Aug 6 2022 at 11:56:58 +0200, Andy Shevchenko 
<andy.shevchenko@gmail.com> wrote:
> On Fri, Aug 5, 2022 at 10:20 AM Luke D. Jones <luke@ljones.dev> wrote:
>> 
>>  Adds support for TUF laptop RGB mode control.
>> 
>>  Two paths are added:
>>  - /sys/devices/platform/asus-nb-wmi/kernel_rgb_mode
>>  - /sys/devices/platform/asus-nb-wmi/kernel_rgb_mode_index
> 
> ...
> 
>>  +static int keyboard_rgb_mode_check_present(struct asus_wmi *asus)
>>  +{
>>  +       u32 result;
>>  +       int err;
>>  +
>>  +       asus->keyboard_rgb_mode_available = false;
>>  +
>>  +       err = asus_wmi_get_devstate(asus, 
>> ASUS_WMI_DEVID_TUF_RGB_MODE, &result);
>>  +       if (err) {
>>  +               if (err == -ENODEV)
>>  +                       return 0;
>>  +               return err;
>>  +       }
> 
>>  +       if (result & ASUS_WMI_DSTS_PRESENCE_BIT) {
>>  +               asus->keyboard_rgb_mode_available = true;
>>  +       }
> 
> {} are not needed (except if they will be utilized in the next patches
> in the series).

I've usually been pretty good at catching these. I must not have run 
the patch check script on this one.

Fixed.

> 
>>  +       return 0;
>>  +}
> 
> ...
> 
>>  +       if (sscanf(buf, "%hhd %hhd %hhd", &save, &mode, &speed) != 
>> 3)
>>  +               return -EINVAL;
> 
> Usually we have three separate nodes for that, but they are kinda
> hidden in one driver, so I don't care much.

I don't really understand what you mean sorry.

> 
> ...
> 
>>  +       asus->keyboard_rgb_mode.save = save > 0 ? 1 : 0;
> 
> So, it's actually boolean.
> 
> You may write it as
> 
>     ...save = !!save;

Err okay. Done.

> 
>>  +       /* These are the known usable modes across all TUF/ROG */
>>  +       asus->keyboard_rgb_mode.mode = mode < 12 && mode != 9 ? 
>> mode : 0x0a;
>>  +
>>  +       if (speed == 0)
>>  +               asus->keyboard_rgb_mode.speed = 0xe1;
>>  +       else if (speed == 1)
>>  +               asus->keyboard_rgb_mode.speed = 0xeb;
>>  +       else if (speed == 2)
>>  +               asus->keyboard_rgb_mode.speed = 0xf5;
> 
>>  +       else
>>  +               asus->keyboard_rgb_mode.speed = 0xeb;
> 
> So the 1 is default then, why not use switch-case to show this 
> explicitly?
> 
> switch (speed) {
>   case 0:
>     ...
>   break;
>   case 1:
>   default:
>     ...
>   break;
>   case 2:
>     ...
>   break;
> }
> 
> Yes, it's longer, but I think it's cleaner.

Agreed. Done.

> 
>>  +       err = tuf_rgb_brightness_set(cdev, cdev->brightness);
>>  +       if (err)
>>  +               return err;
>>  +       return 0;
> 
> return tuf_rgb_brightness_set(...);

This causes a hang (waiting for return somewhere?) if I don't return 
count. Especially true if the return is 0.

> 
>>  +}
> 
> --
> With Best Regards,
> Andy Shevchenko



  reply	other threads:[~2022-08-06 10:34 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-05  8:19 [PATCH 0/5] asus-wmi: Add support for RGB keyboards Luke D. Jones
2022-08-05  8:19 ` [PATCH 1/5] asus-wmi: Add basic support for TUF laptop keyboard RGB Luke D. Jones
2022-08-06  9:44   ` Andy Shevchenko
2022-08-06 10:16     ` Luke Jones
2022-08-06 10:27       ` Andy Shevchenko
2022-08-06 10:27         ` Andy Shevchenko
2022-08-06 17:30   ` Barnabás Pőcze
2022-08-07  1:54     ` Luke Jones
2022-08-05  8:19 ` [PATCH 2/5] asus-wmi: Add support for TUF laptop keyboard RGB mode control Luke D. Jones
2022-08-06  9:56   ` Andy Shevchenko
2022-08-06 10:33     ` Luke Jones [this message]
2022-08-06 11:12       ` Andy Shevchenko
2022-08-05  8:19 ` [PATCH 3/5] asus-wmi: Add support for TUF laptop keyboard states Luke D. Jones
2022-08-05 12:08   ` Pavel Machek
2022-08-05 21:29     ` Luke Jones
2022-08-07  7:44     ` Luke Jones
2022-08-07 12:41       ` Pavel Machek
2022-08-09 23:03         ` Luke Jones
2022-08-05  8:19 ` [PATCH 4/5] asus-wmi: Document many of the undocumented API Luke D. Jones
2022-08-05 21:43   ` kernel test robot
2022-08-06 10:00   ` Andy Shevchenko
2022-08-05  8:19 ` [PATCH 5/5] asus-wmi: Convert all attr _show to use sysfs_emit Luke D. Jones
2022-08-06 10:05   ` Andy Shevchenko
2022-08-05 12:05 ` [PATCH 0/5] asus-wmi: Add support for RGB keyboards Pavel Machek
2022-08-05 21:30   ` Luke Jones
2022-08-06  9:10 ` Andy Shevchenko
2022-08-06  9:32   ` Luke Jones
2022-08-06  9:48     ` Andy Shevchenko
2022-08-06 10:02     ` Andy Shevchenko
2022-08-06 10:48       ` Luke Jones
2022-08-06 11:16         ` Andy Shevchenko

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=90W6GR.9Z5CYBT7NOHJ1@ljones.dev \
    --to=luke@ljones.dev \
    --cc=andy.shevchenko@gmail.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=platform-driver-x86@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;
as well as URLs for NNTP newsgroup(s).