From: Jonathan Woithe <jwoithe@just42.net>
To: Luiz Sampaio <sampaio.ime@gmail.com>
Cc: "Lee, Chun-Yi" <jlee@suse.com>,
"Hans de Goede" <hdegoede@redhat.com>,
"Mark Gross" <markgross@kernel.org>,
"Corentin Chary" <corentin.chary@gmail.com>,
"João Paulo Rechi Vita" <jprvita@gmail.com>,
"Matthew Garrett" <mjg59@srcf.ucam.org>,
"Pali Rohár" <pali@kernel.org>,
"Matan Ziv-Av" <matan@svgalib.org>,
"Jeremy Soller" <jeremy@system76.com>,
"System76 Product Development" <productdev@system76.com>,
"Henrique de Moraes Holschuh" <hmh@hmh.eng.br>,
"Herton Ronaldo Krzesinski" <herton@canonical.com>,
"Azael Avalos" <coproscefalo@gmail.com>,
linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org,
acpi4asus-user@lists.sourceforge.net,
ibm-acpi-devel@lists.sourceforge.net
Subject: Re: [PATCH 20/31] platform: x86: changing LED_* from enum led_brightness to actual value
Date: Sat, 22 Jan 2022 22:37:30 +1030 [thread overview]
Message-ID: <20220122120730.GA12371@marvin.atrad.com.au> (raw)
In-Reply-To: <20220121165436.30956-21-sampaio.ime@gmail.com>
On Fri, Jan 21, 2022 at 01:54:25PM -0300, Luiz Sampaio wrote:
> The enum led_brightness, which contains the declaration of LED_OFF,
> LED_ON, LED_HALF and LED_FULL is obsolete, as the led class now supports
> max_brightness.
> ---
> drivers/platform/x86/acer-wmi.c | 6 ++---
> drivers/platform/x86/asus-wireless.c | 6 ++---
> drivers/platform/x86/dell/dell-laptop.c | 2 +-
> drivers/platform/x86/dell/dell-wmi-led.c | 4 ++--
> drivers/platform/x86/fujitsu-laptop.c | 28 ++++++++++++------------
> drivers/platform/x86/lg-laptop.c | 18 +++++++--------
> drivers/platform/x86/system76_acpi.c | 4 ++--
> drivers/platform/x86/thinkpad_acpi.c | 14 ++++++------
> drivers/platform/x86/topstar-laptop.c | 4 ++--
> drivers/platform/x86/toshiba_acpi.c | 24 ++++++++++----------
> 10 files changed, 55 insertions(+), 55 deletions(-)
>
> ...
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index 80929380ec7e..6ebfda771209 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -584,10 +584,10 @@ static int logolamp_set(struct led_classdev *cdev,
> int poweron = FUNC_LED_ON, always = FUNC_LED_ON;
> int ret;
>
> - if (brightness < LED_HALF)
> + if (brightness < 127)
> poweron = FUNC_LED_OFF;
>
> - if (brightness < LED_FULL)
> + if (brightness < 255)
> always = FUNC_LED_OFF;
>
> ret = call_fext_func(device, FUNC_LEDS, 0x1, LOGOLAMP_POWERON, poweron);
> @@ -604,13 +604,13 @@ static enum led_brightness logolamp_get(struct led_classdev *cdev)
>
> ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_ALWAYS, 0x0);
> if (ret == FUNC_LED_ON)
> - return LED_FULL;
> + return 255;
>
> ret = call_fext_func(device, FUNC_LEDS, 0x2, LOGOLAMP_POWERON, 0x0);
> if (ret == FUNC_LED_ON)
> - return LED_HALF;
> + return 127;
>
> - return LED_OFF;
> + return 0;
> }
>
> static int kblamps_set(struct led_classdev *cdev,
> @@ -618,7 +618,7 @@ static int kblamps_set(struct led_classdev *cdev,
> {
> struct acpi_device *device = to_acpi_device(cdev->dev->parent);
>
> - if (brightness >= LED_FULL)
> + if (brightness >= 255)
> return call_fext_func(device, FUNC_LEDS, 0x1, KEYBOARD_LAMPS,
> FUNC_LED_ON);
> else
> @@ -629,11 +629,11 @@ static int kblamps_set(struct led_classdev *cdev,
> static enum led_brightness kblamps_get(struct led_classdev *cdev)
> {
> struct acpi_device *device = to_acpi_device(cdev->dev->parent);
> - enum led_brightness brightness = LED_OFF;
> + unsigned int brightness = 0;
>
> if (call_fext_func(device,
> FUNC_LEDS, 0x2, KEYBOARD_LAMPS, 0x0) == FUNC_LED_ON)
> - brightness = LED_FULL;
> + brightness = 255;
>
> return brightness;
> }
> @@ -643,7 +643,7 @@ static int radio_led_set(struct led_classdev *cdev,
> {
> struct acpi_device *device = to_acpi_device(cdev->dev->parent);
>
> - if (brightness >= LED_FULL)
> + if (brightness >= 255)
> return call_fext_func(device, FUNC_FLAGS, 0x5, RADIO_LED_ON,
> RADIO_LED_ON);
> else
> @@ -654,10 +654,10 @@ static int radio_led_set(struct led_classdev *cdev,
> static enum led_brightness radio_led_get(struct led_classdev *cdev)
> {
> struct acpi_device *device = to_acpi_device(cdev->dev->parent);
> - enum led_brightness brightness = LED_OFF;
> + unsigned int brightness = 0;
>
> if (call_fext_func(device, FUNC_FLAGS, 0x4, 0x0, 0x0) & RADIO_LED_ON)
> - brightness = LED_FULL;
> + brightness = 255;
>
> return brightness;
> }
> @@ -669,7 +669,7 @@ static int eco_led_set(struct led_classdev *cdev,
> int curr;
>
> curr = call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0);
> - if (brightness >= LED_FULL)
> + if (brightness >= 255)
> return call_fext_func(device, FUNC_LEDS, 0x1, ECO_LED,
> curr | ECO_LED_ON);
> else
> @@ -680,10 +680,10 @@ static int eco_led_set(struct led_classdev *cdev,
> static enum led_brightness eco_led_get(struct led_classdev *cdev)
> {
> struct acpi_device *device = to_acpi_device(cdev->dev->parent);
> - enum led_brightness brightness = LED_OFF;
> + unsigned int brightness = 0;
>
> if (call_fext_func(device, FUNC_LEDS, 0x2, ECO_LED, 0x0) & ECO_LED_ON)
> - brightness = LED_FULL;
> + brightness = 255;
>
> return brightness;
> }
In a way it's less descriptive to revert from the identifiers to what amount
to seemingly magic numbers. However, since the value attributed to maximum
LED brightness in the LED class is now variable I can see why the global
enum no longer makes sense. We could define a suitable enum within
fujitsu-laptop.c, but there's probably little to be gained in the long run.
To make the patch description a little clearer, could I suggest you add the
word "variable" before "max_brightness", or even just use the phrase
"variable maximum brightness"?
For the fujitsu-laptop.c portion of this patch:
Acked-by: Jonathan Woithe <jwoithe@just42.net>
Regards
jonathan
next prev parent reply other threads:[~2022-01-22 12:39 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-21 16:54 [PATCH 00/31] leds: start removing obsolete/useless enum Luiz Sampaio
2022-01-21 16:54 ` [PATCH 01/31] gpu: nouveau: nouveau_led: changing LED_FULL to actual value Luiz Sampaio
2022-01-22 13:33 ` Fabio Estevam
2022-01-21 16:54 ` [PATCH 02/31] hid: changing LED_* from enum led_brightness " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 03/31] hwmon: pmbus: " Luiz Sampaio
2022-01-25 2:03 ` Guenter Roeck
2022-01-21 16:54 ` [PATCH 04/31] iio: light: cm3605: " Luiz Sampaio
2022-01-22 16:38 ` Jonathan Cameron
2022-01-21 16:54 ` [PATCH 05/31] input: keyboard: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 06/31] input: misc: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 07/31] input: touchscreen: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 08/31] leds: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 09/31] macintosh: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 10/31] media: radio: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 11/31] media: rc: " Luiz Sampaio
2022-01-21 18:06 ` Sean Young
2022-01-21 16:54 ` [PATCH 12/31] media: v4l2-core: " Luiz Sampaio
2022-02-02 12:54 ` Sakari Ailus
2022-11-26 10:14 ` Hans Verkuil
2022-01-21 16:54 ` [PATCH 13/31] mmc: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 14/31] net: wireless: ath: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 15/31] net: wireless: atmel: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 16/31] net: broadcom: " Luiz Sampaio
2022-01-22 8:21 ` Arend van Spriel
2022-01-21 16:54 ` [PATCH 17/31] net: intersil: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 18/31] net: wireless: ralink: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 19/31] net: realtek: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 20/31] platform: x86: " Luiz Sampaio
2022-01-22 12:07 ` Jonathan Woithe [this message]
2022-01-24 10:14 ` Hans de Goede
2022-01-21 16:54 ` [PATCH 21/31] power: supply: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 22/31] tty: vt: " Luiz Sampaio
2022-01-22 7:32 ` Greg Kroah-Hartman
2022-01-21 16:54 ` [PATCH 23/31] usb: core: " Luiz Sampaio
2022-01-22 7:22 ` Greg Kroah-Hartman
2022-01-21 16:54 ` [PATCH 24/31] video: backlight: " Luiz Sampaio
2022-01-21 17:05 ` Daniel Thompson
2022-01-21 18:06 ` Luiz Sampaio
2022-01-21 18:09 ` Luiz Sampaio
2022-01-24 10:53 ` Lee Jones
2022-01-21 16:54 ` [PATCH 25/31] include: linux: leds: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 26/31] net: bluetooth: " Luiz Sampaio
2022-01-21 20:19 ` Marcel Holtmann
2022-01-21 16:54 ` [PATCH 27/31] net: mac80211 : " Luiz Sampaio
2022-01-21 19:28 ` Johannes Berg
2022-01-21 16:54 ` [PATCH 28/31] net: netfilter: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 29/31] net: rfkill: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 30/31] sound: core: " Luiz Sampaio
2022-01-21 16:54 ` [PATCH 31/31] sound: soc: sof: " Luiz Sampaio
2022-02-11 11:58 ` Mark Brown
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=20220122120730.GA12371@marvin.atrad.com.au \
--to=jwoithe@just42.net \
--cc=acpi4asus-user@lists.sourceforge.net \
--cc=coproscefalo@gmail.com \
--cc=corentin.chary@gmail.com \
--cc=hdegoede@redhat.com \
--cc=herton@canonical.com \
--cc=hmh@hmh.eng.br \
--cc=ibm-acpi-devel@lists.sourceforge.net \
--cc=jeremy@system76.com \
--cc=jlee@suse.com \
--cc=jprvita@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=matan@svgalib.org \
--cc=mjg59@srcf.ucam.org \
--cc=pali@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=productdev@system76.com \
--cc=sampaio.ime@gmail.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
Powered by JetHome