From 9157ccb097d853645e8b1f4a6d82a93d677f6b1b Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Mon, 26 Apr 2021 18:05:42 +0200 Subject: [PATCH] ec/lenovo/h8/h8.c: Skip setting volume if out of range This change is needed to update the option API to use unsigned integers. The CMOS option system does not support negative numbers. The volume field is only 8 bits long. Do not set the volume if it is out of range. Also, use an out-of-range value as fallback to skip setting the volume when it cannot be read using the option API, to preserve the current behavior. Change-Id: I7af68bb5c1ecd4489ab4b826b9a5e7999c77b1ff Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/52675 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Rudolph Reviewed-by: Nico Huber --- src/ec/lenovo/h8/h8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ec/lenovo/h8/h8.c b/src/ec/lenovo/h8/h8.c index be2eee6f74..e17f0fb2d4 100644 --- a/src/ec/lenovo/h8/h8.c +++ b/src/ec/lenovo/h8/h8.c @@ -299,8 +299,8 @@ static void h8_enable(struct device *dev) h8_trackpoint_enable(1); h8_usb_power_enable(1); - int volume = get_int_option("volume", -1); - if (volume >= 0 && !acpi_is_wakeup_s3()) + unsigned int volume = get_int_option("volume", ~0); + if (volume <= 0xff && !acpi_is_wakeup_s3()) ec_write(H8_VOLUME_CONTROL, volume); val = (CONFIG(H8_SUPPORT_BT_ON_WIFI) || h8_has_bdc(dev)) &&