Skip to contentSkip to conversation

platform/x86: huawei-wmi: Stricter battery thresholds set

PATCH New Ayman Bagabas 1 participant 3 messages Oct 20, 2019 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 platform/x86: huawei-wmi: Stricter battery thresholds set

Check if battery thresholds are within 0 and 100.

Fixes 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging thresholds")
---
 drivers/platform/x86/huawei-wmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/huawei-wmi.c +1 -1
index 5837d1b8693d..26041d44286a 100644
@@ -345,7 +345,7 @@ static int huawei_wmi_battery_set(int start, int end)
 	union hwmi_arg arg;
 	int err;
 
-	if (start < 0 || end > 100)
+	if (start < 0 || end < 0 || start > 100 || end > 100)
 		return -EINVAL;
 
 	arg.cmd = BATTERY_THRESH_SET;

base-commit: c4b9850b3676869ac0def5885d781d17f64b3a86

Signature · 1 line
2.21.0
#1 lore raw

PATCH 2/3 platform/x86: huawei-wmi: No need to check for battery name

No need to check for battery name, we already check if the WMI function is available in huawei_wmi_battery_setup.

Fixes 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging thresholds")
---
 drivers/platform/x86/huawei-wmi.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/platform/x86/huawei-wmi.c +0 -4
index 26041d44286a..7373a65a61d3 100644
@@ -471,10 +471,6 @@ static DEVICE_ATTR_RW(charge_control_thresholds);
 
 static int huawei_wmi_battery_add(struct power_supply *battery)
 {
-	/* Huawei laptops come with one battery only */
-	if (strcmp(battery->desc->name, "BAT") != 1)
-		return -ENODEV;
-
 	device_create_file(&battery->dev, &dev_attr_charge_control_start_threshold);
 	device_create_file(&battery->dev, &dev_attr_charge_control_end_threshold);
 
Signature · 1 line
2.21.0
#2 lore raw

PATCH 3/3 platform/x86: huawei-wmi: Remove unnecessary battery mutex

In reply to Ayman Bagabas

battery_lock mutex is never used and not needed.

Fixes 355a070b09ab ("platform/x86: huawei-wmi: Add battery charging thresholds")
---
 drivers/platform/x86/huawei-wmi.c | 2 --
 1 file changed, 2 deletions(-)
drivers/platform/x86/huawei-wmi.c +0 -2
index 7373a65a61d3..a2d846c4a7ee 100644
@@ -67,7 +67,6 @@ struct huawei_wmi {
 	struct led_classdev cdev;
 	struct device *dev;
 
-	struct mutex battery_lock;
 	struct mutex wmi_lock;
 };
 
@@ -807,7 +806,6 @@ static int huawei_wmi_probe(struct platform_device *pdev)
 
 	if (wmi_has_guid(HWMI_METHOD_GUID)) {
 		mutex_init(&huawei_wmi->wmi_lock);
-		mutex_init(&huawei_wmi->battery_lock);
 
 		huawei_wmi_leds_setup(&pdev->dev);
 		huawei_wmi_fn_lock_setup(&pdev->dev);
Signature · 1 line
2.21.0