Skip to contentSkip to conversation

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

PATCH In review Ayman Bagabas 3 participants 6 messages Oct 18, 2019 – Oct 20, 2019 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

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

Check if battery thresholds are within 0 and 100.

---
 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: fd13c8622a5ad4f7317b64de4f6aa2de1962220e

Signature · 1 line
2.21.0
#1 lore raw

PATCH 2/2 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.

---
 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

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

Quoted 3 lines · Ayman Bagabas

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

Thank you,
Ayman

Quoted 23 lines
---
 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);

#4 lore raw
Quoted 7 lines · Dan Carpenter
Quoted 2 lines · Ayman Bagabas

Check if battery thresholds are within 0 and 100.
---

Thanks!

Don't forget to add your Signed-off-by: though.

Thank you,
Ayman

Quoted 4 lines

regards,
dan carpenter

#5 lore raw
Quoted 5 lines · On Sun, Oct 20, 2019 at 3:33 AM <[email protected]> wrote:
Quoted 4 lines · Dan Carpenter
Quoted 1 line · Ayman Bagabas

Check if battery thresholds are within 0 and 100.

Don't forget to add your Signed-off-by: though.

Please, resend all three with properly tagged with Sob, Fixes, etc.

Signature · 2 lines
With Best Regards,
Andy Shevchenko