X86 platform drivers
 help / color / mirror / Atom feed
From: Daniel Dadap <ddadap@nvidia.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: <platform-driver-x86@vger.kernel.org>,
	<mario.limonciello@outlook.com>, <pobrn@protonmail.com>,
	<andy.shevchenko@gmail.com>, <hdegoede@redhat.com>,
	<aplattner@nvidia.com>
Subject: Re: [PATCH v5] platform/x86: Add driver for ACPI WMAA EC-based backlight control
Date: Thu, 2 Sep 2021 19:22:11 -0500	[thread overview]
Message-ID: <43912a84-511d-18d9-7a3f-61716d9889ad@nvidia.com> (raw)
In-Reply-To: <e63904b7-105b-4401-bd40-82854b7d42d1@t-8ch.de>


On 9/2/21 6:20 PM, Thomas Weißschuh wrote:
> Hi Daniel,
>
> one more actual thing and two tiny nitpicks.
>
> On 2021-09-02T16:47-0500, Daniel Dadap wrote:
>> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
>> index d12db6c316ea..0df908ef8d7c 100644
>> --- a/drivers/platform/x86/Kconfig
>> +++ b/drivers/platform/x86/Kconfig
>> @@ -113,6 +113,22 @@ config PEAQ_WMI
>>   	help
>>   	 Say Y here if you want to support WMI-based hotkeys on PEAQ 2-in-1s.
>>   
>> +config WMAA_BACKLIGHT_WMI
>> +	tristate "ACPI WMAA Backlight Driver"
>> +	depends on ACPI_WMI
>> +	depends on BACKLIGHT_CLASS_DEVICE
>> +	help
>> +	  This driver provides a sysfs backlight interface for notebook
>> +	  systems which expose the WMAA ACPI method and an associated WMI
>> +	  wrapper to drive LCD backlight levels through the system's
>> +	  Embedded Controller (EC).
> system's -> systems


"system's" is what I intended, and I believe it's correct. The meaning 
I'm going for here is "the Embedded Controller (EC) belonging to the 
system". I guess maybe there could be some confusion because earlier in 
the same sentence I refer to "systems" plural, referring to the class of 
systems that expose this backlight control scheme, and later in the 
sentence "system's" refers to something belonging to a singular member 
of this class. It would probably be more clear if I just drop the word 
"system's" here.


>
>> +
>> +	  Say Y or M here if you want to control the backlight on a notebook
>> +	  system with an EC-driven backlight using the ACPI WMAA method.
>> +
>> +	  If you choose to compile this driver as a module the module will be
>> +	  called wmaa-backlight-wmi.
>> +
>>   config XIAOMI_WMI
>>   	tristate "Xiaomi WMI key driver"
>>   	depends on ACPI_WMI
>> diff --git a/drivers/platform/x86/wmaa-backlight-wmi.c b/drivers/platform/x86/wmaa-backlight-wmi.c
>> new file mode 100644
>> index 000000000000..fa3f41302299
>> --- /dev/null
>> +++ b/drivers/platform/x86/wmaa-backlight-wmi.c
>> @@ -0,0 +1,194 @@
>> [..]
>> +static int wmaa_backlight_update_status(struct backlight_device *bd)
>> +{
>> +	struct wmi_device *wdev = bl_get_data(bd);
>> +
>> +	return wmi_call_wmaa(wdev, WMAA_METHOD_LEVEL, WMAA_MODE_SET,
>> +			     &bd->props.brightness);
>> +}
>> +
>> +static int wmaa_backlight_get_brightness(struct backlight_device *bd)
>> +{
>> +	struct wmi_device *wdev = bl_get_data(bd);
>> +	u32 level;
>> +	int ret;
>> +
>> +	ret = wmi_call_wmaa(wdev, WMAA_METHOD_LEVEL, WMAA_MODE_GET, &level);
>> +	if (ret > 0)
>> +		return -EINVAL;
>> +	else if (ret < 0)
>> +		return ret;
> Nowhere else is the return value of wmi_call_wmaa() checked explicitly for
> greater than zero and less than zero. Why here?
> At least wmaa_backlight_update_status() should have identical semantics.
> The case ret > 0 should never happen.


wmaa_backlight_update_status() has different semantics precisely because 
the .get_brightness() and .update_status() callbacks registered in the 
struct backlight_ops have different semantics. The return value of 
.get_brightness() serves dual duty, where a positive return value could 
be interpreted as a valid brightness level value, while in the case of 
.update_status() a positive return value is invalid.

I agree that wmi_call_wmaa() should never return > 0, but I wanted to 
protect against someone deciding in the future (for whatever reason) to 
add a code path that returns a positive value, without checking all of 
the callers of wmi_call_wmaa() to realize that this could cause a 
problem. There are not many callers of the function, though, and they're 
all in the same file, so perhaps this is not something worth worrying 
about. I suppose I could check for just the < 0 case, and add document 
the API of wmi_call_wmaa(), explicitly stating that the return value 
should be zero or negative errno.


>
>> +
>> +	return level;
>> +}
>> [..]
>> +
>> +
>> +#define WMAA_WMI_GUID "603E9613-EF25-4338-A3D0-C46177516DB7"
>> +
>> +static const struct wmi_device_id wmaa_backlight_wmi_id_table[] = {
>> +	{ .guid_string = WMAA_WMI_GUID },
> This could also be inlined as:
> 	{ "603E9613-EF25-4338-A3D0-C46177516DB7" },
>
> More a stylistic thing though.


I considered that when switching to MODULE_DEVICE_TABLE, since the value 
is now only used in one place, but looking at other similar drivers, it 
does seem that the most common convention is to define the GUID as a 
macro even if it's only used once. I'll leave this as-is, I think.


  reply	other threads:[~2021-09-03  0:22 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <DM6PR19MB2636AB267CD321DE40EF324AFA730@DM6PR19MB2636.namprd19.prod.outlook.com>
     [not found] ` <20200731202154.11382-1-ddadap@nvidia.com>
     [not found]   ` <20200731202154.11382-2-ddadap@nvidia.com>
2020-11-10  9:34     ` [PATCH v2 2/2] platform/x86: wmi: fail wmi_driver_register when no GUID is found Hans de Goede
2020-11-12 18:54       ` Daniel Dadap
2021-08-24 22:04       ` [PATCH v3] platform/x86: Add driver for ACPI WMAA EC-based backlight control Daniel Dadap
2021-08-24 22:47         ` Barnabás Pőcze
2021-08-25 16:36           ` Daniel Dadap
2021-08-25 22:26           ` Daniel Dadap
2021-08-27 16:47             ` Daniel Dadap
2021-08-27 17:12               ` Daniel Dadap
2021-08-25  9:05         ` Andy Shevchenko
2021-08-25 16:47           ` Daniel Dadap
2021-08-25 22:06             ` Thomas Weißschuh
2021-08-25 22:28               ` Daniel Dadap
2021-08-26 13:35             ` Andy Shevchenko
2021-08-26 15:39               ` Daniel Dadap
2021-08-31 22:49                 ` [PATCH v4] " Daniel Dadap
2021-09-01  9:25                   ` Thomas Weißschuh
2021-09-02  2:12                     ` Daniel Dadap
2021-09-02 10:19                       ` Thomas Weißschuh
2021-09-02 20:15                         ` Daniel Dadap
2021-09-02 20:31                           ` Hans de Goede
2021-09-02 21:47                             ` [PATCH v5] " Daniel Dadap
2021-09-02 23:20                               ` Thomas Weißschuh
2021-09-03  0:22                                 ` Daniel Dadap [this message]
2021-09-03  8:14                                   ` Andy Shevchenko
2021-09-03 17:55                                     ` Daniel Dadap
2021-09-03  0:38                                 ` [PATCH v6] " Daniel Dadap
2021-09-13  9:01                                   ` Hans de Goede
2021-09-20 13:29                                     ` Pali Rohár
2021-09-20 13:33                                       ` Hans de Goede
2021-09-20 13:51                                         ` Pali Rohár
2021-09-20 17:34                                           ` Daniel Dadap
2021-09-20 17:55                                             ` Pali Rohár
2021-09-20 19:38                                               ` Daniel Dadap
2021-09-20 19:52                                                 ` Pali Rohár
2021-09-21 13:53                                           ` Hans de Goede
2021-09-21 14:02                                             ` Pali Rohár
2021-09-21 14:29                                             ` Daniel Dadap
2021-09-21 14:58                                               ` Hans de Goede
2021-09-27 20:23                                                 ` [PATCH 1/2] platform/x86: Remove "WMAA" from identifier names in wmaa-backlight-wmi.c Daniel Dadap
2021-09-27 20:23                                                   ` [PATCH 2/2] platform/x86: Rename wmaa-backlight-wmi to nvidia-wmi-ec-backlight Daniel Dadap
2021-10-11 13:00                                                   ` [PATCH 1/2] platform/x86: Remove "WMAA" from identifier names in wmaa-backlight-wmi.c Hans de Goede
2021-09-27 22:52                                                 ` [PATCH v6] platform/x86: Add driver for ACPI WMAA EC-based backlight control Daniel Dadap
2021-09-02  9:28                     ` [PATCH v4] " Andy Shevchenko
2021-09-02  9:33                       ` Thomas Weißschuh
2021-09-02  9:36                         ` Andy Shevchenko
2021-09-01 15:57                   ` Andy Shevchenko
2021-09-01 23:12                     ` Aaron Plattner
2021-09-02  2:37                     ` Daniel Dadap
2021-09-02  9:35                       ` Andy Shevchenko
2021-09-02 20:15                         ` Daniel Dadap
2021-09-03  8:10                           ` Andy Shevchenko
2021-09-02 15:38                   ` Hans de Goede

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=43912a84-511d-18d9-7a3f-61716d9889ad@nvidia.com \
    --to=ddadap@nvidia.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=aplattner@nvidia.com \
    --cc=hdegoede@redhat.com \
    --cc=linux@weissschuh.net \
    --cc=mario.limonciello@outlook.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=pobrn@protonmail.com \
    /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