lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <SY4P282MB3063D447DA09D35F5FBD4721C5312@SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM>
Date: Fri, 22 Mar 2024 20:27:59 +1000
From: Stephen Horvath <s.horvath@...look.com.au>
To: Lee Jones <lee@...nel.org>,
	Benson Leung <bleung@...omium.org>,
	Guenter Roeck <groeck@...omium.org>,
	Tzung-Bi Shih <tzungbi@...nel.org>,
	chrome-platform@...ts.linux.dev,
	linux-kernel@...r.kernel.org
Cc: Stephen Horvath <s.horvath@...look.com.au>
Subject: [PATCH 2/2] platform/chrome: cros_kbd_led_backlight: Remove obsolete commands (EC_CMD_PWM_*_KEYBOARD_BACKLIGHT)

EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT and EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT
are marked as obsolete in `cros_ec_commands.h`, this patch removes the
usage of these commands from the driver.

The max brightness value is now set to `EC_PWM_MAX_DUTY` (65535) when
running on the EC, as this is the maximum value that the EC can accept.

Signed-off-by: Stephen Horvath <s.horvath@...look.com.au>
---
 .../platform/chrome/cros_kbd_led_backlight.c  | 37 +++++++++++++------
 1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index 06e9a57536af..bc021437e8b1 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -47,10 +47,10 @@ struct keyboard_led_drvdata {
 	enum led_brightness max_brightness;
 };
 
-#define KEYBOARD_BACKLIGHT_MAX 100
-
 #ifdef CONFIG_ACPI
 
+#define ACPI_KEYBOARD_BACKLIGHT_MAX 100
+
 /* Keyboard LED ACPI Device must be defined in firmware */
 #define ACPI_KEYBOARD_BACKLIGHT_DEVICE	"\\_SB.KBLT"
 #define ACPI_KEYBOARD_BACKLIGHT_READ	ACPI_KEYBOARD_BACKLIGHT_DEVICE ".KBQC"
@@ -114,7 +114,7 @@ static const struct keyboard_led_drvdata keyboard_led_drvdata_acpi = {
 	.init = keyboard_led_init_acpi,
 	.brightness_set = keyboard_led_set_brightness_acpi,
 	.brightness_get = keyboard_led_get_brightness_acpi,
-	.max_brightness = KEYBOARD_BACKLIGHT_MAX,
+	.max_brightness = ACPI_KEYBOARD_BACKLIGHT_MAX,
 };
 
 #endif /* CONFIG_ACPI */
@@ -127,18 +127,22 @@ keyboard_led_set_brightness_ec_pwm(struct led_classdev *cdev,
 {
 	struct {
 		struct cros_ec_command msg;
-		struct ec_params_pwm_set_keyboard_backlight params;
+		struct ec_params_pwm_set_duty params;
 	} __packed buf;
-	struct ec_params_pwm_set_keyboard_backlight *params = &buf.params;
+	struct ec_params_pwm_set_duty *params = &buf.params;
 	struct cros_ec_command *msg = &buf.msg;
 	struct keyboard_led *keyboard_led = container_of(cdev, struct keyboard_led, cdev);
 
 	memset(&buf, 0, sizeof(buf));
 
-	msg->command = EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT;
+	msg->version = 0;
+	msg->command = EC_CMD_PWM_SET_DUTY;
+	msg->insize = 0;
 	msg->outsize = sizeof(*params);
 
-	params->percent = brightness;
+	params->duty = brightness;
+	params->pwm_type = EC_PWM_TYPE_KB_LIGHT;
+	params->index = 0;
 
 	return cros_ec_cmd_xfer_status(keyboard_led->ec, msg);
 }
@@ -148,23 +152,32 @@ keyboard_led_get_brightness_ec_pwm(struct led_classdev *cdev)
 {
 	struct {
 		struct cros_ec_command msg;
-		struct ec_response_pwm_get_keyboard_backlight resp;
+		union {
+			struct ec_params_pwm_get_duty params;
+			struct ec_response_pwm_get_duty resp;
+		};
 	} __packed buf;
-	struct ec_response_pwm_get_keyboard_backlight *resp = &buf.resp;
+	struct ec_params_pwm_get_duty *params = &buf.params;
+	struct ec_response_pwm_get_duty *resp = &buf.resp;
 	struct cros_ec_command *msg = &buf.msg;
 	struct keyboard_led *keyboard_led = container_of(cdev, struct keyboard_led, cdev);
 	int ret;
 
 	memset(&buf, 0, sizeof(buf));
 
-	msg->command = EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT;
+	msg->version = 0;
+	msg->command = EC_CMD_PWM_GET_DUTY;
 	msg->insize = sizeof(*resp);
+	msg->outsize = sizeof(*params);
+
+	params->pwm_type = EC_PWM_TYPE_KB_LIGHT;
+	params->index = 0;
 
 	ret = cros_ec_cmd_xfer_status(keyboard_led->ec, msg);
 	if (ret < 0)
 		return ret;
 
-	return resp->percent;
+	return resp->duty;
 }
 
 static int keyboard_led_init_ec_pwm(struct platform_device *pdev)
@@ -186,7 +199,7 @@ static const __maybe_unused struct keyboard_led_drvdata keyboard_led_drvdata_ec_
 	.init = keyboard_led_init_ec_pwm,
 	.brightness_set_blocking = keyboard_led_set_brightness_ec_pwm,
 	.brightness_get = keyboard_led_get_brightness_ec_pwm,
-	.max_brightness = KEYBOARD_BACKLIGHT_MAX,
+	.max_brightness = EC_PWM_MAX_DUTY,
 };
 
 #else /* IS_ENABLED(CONFIG_CROS_EC) */
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ