platform/x86: uniwill-laptop: Implement USB-C power priority setting
Hello Werner Sembach,
Commit 03ae0a0d0973 ("platform/x86: uniwill-laptop: Implement USB-C power priority setting") from Mar 24, 2026 (linux-next), leads to the following Smatch static checker warning:
drivers/platform/x86/uniwill/uniwill-acpi.c:919 usb_c_power_priority_store()
warn: error code type promoted to positive: 'option'
drivers/platform/x86/uniwill/uniwill-acpi.c
909 static ssize_t usb_c_power_priority_store(struct device *dev,
910 struct device_attribute *attr,
911 const char *buf, size_t count)
912 {
913 struct uniwill_data *data = dev_get_drvdata(dev);
914 enum usb_c_power_priority_options option;
915 unsigned int value;
916 int ret;
917
918 option = sysfs_match_string(usb_c_power_priority_text, buf);--> 919 if (option < 0)
enums are unsigned in this context so option can't be negative.
920 return option;
921
922 value = usb_c_power_priority_value[option];
923
924 guard(mutex)(&data->usb_c_power_priority_lock);
925
926 ret = regmap_update_bits(data->regmap, EC_ADDR_USB_C_POWER_PRIORITY,
927 USB_C_POWER_PRIORITY, value);
928 if (ret < 0)
929 return ret;
930
931 data->last_usb_c_power_priority_option = option;
932
933 return count;
934 }This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
Am 10.04.26 um 20:04 schrieb Dan Carpenter:
Quoted 40 lines
Hello Werner Sembach,
Commit
03ae0a0d0973("platform/x86: uniwill-laptop: Implement USB-C power priority setting") from Mar 24, 2026 (linux-next), leads to the following Smatch static checker warning:
drivers/platform/x86/uniwill/uniwill-acpi.c:919usb_c_power_priority_store()
warn: error code type promoted to positive: 'option'
drivers/platform/x86/uniwill/uniwill-acpi.c909 static ssize_t usb_c_power_priority_store(struct device *dev, 910 struct device_attribute *attr, 911 const char *buf, size_t count) 912 { 913 struct uniwill_data *data = dev_get_drvdata(dev); 914 enum usb_c_power_priority_options option; 915 unsigned int value; 916 int ret; 917 918 option = sysfs_match_string(usb_c_power_priority_text, buf);--> 919 if (option < 0)
enums are unsigned in this context so option can't be negative.
920 return option; 921 922 value = usb_c_power_priority_value[option]; 923 924 guard(mutex)(&data->usb_c_power_priority_lock); 925 926 ret = regmap_update_bits(data->regmap, EC_ADDR_USB_C_POWER_PRIORITY, 927 USB_C_POWER_PRIORITY, value); 928 if (ret < 0) 929 return ret; 930 931 data->last_usb_c_power_priority_option = option; 932 933 return count; 934 }
Quoted 4 lines
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter
Thanks, Ethan already submitted a patch to fix this:
https://lore.kernel.org/platform-driver-x86/[email protected]/T/#t
Thanks,
Armin Wolf