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 <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52675
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Angel Pons 2021-04-26 18:05:42 +02:00 committed by Patrick Georgi
parent bd9d6ab2d5
commit 9157ccb097
1 changed files with 2 additions and 2 deletions

View File

@ -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)) &&