platform/x86: asus-wmi: Refactor charge_threshold_store()
There are few issues with the current code: - the error code from kstrtouint() is shadowed - the error code from asus_wmi_set_devstate() is ignored - the extra check against 0 for count (this is guaranteed by sysfs) Fix these issues by doing a slight refactoring of charge_threshold_store(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
This commit is contained in:
		
							parent
							
								
									d507a54f58
								
							
						
					
					
						commit
						84d8e80b0a
					
				| @ -2086,13 +2086,15 @@ static ssize_t charge_threshold_store(struct device *dev, | |||||||
| 	int value, ret, rv; | 	int value, ret, rv; | ||||||
| 
 | 
 | ||||||
| 	ret = kstrtouint(buf, 10, &value); | 	ret = kstrtouint(buf, 10, &value); | ||||||
|  | 	if (ret) | ||||||
|  | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	if (!count || ret != 0) |  | ||||||
| 		return -EINVAL; |  | ||||||
| 	if (value < 0 || value > 100) | 	if (value < 0 || value > 100) | ||||||
| 		return -EINVAL; | 		return -EINVAL; | ||||||
| 
 | 
 | ||||||
| 	asus_wmi_set_devstate(ASUS_WMI_CHARGE_THRESHOLD, value, &rv); | 	ret = asus_wmi_set_devstate(ASUS_WMI_CHARGE_THRESHOLD, value, &rv); | ||||||
|  | 	if (!ret) | ||||||
|  | 		return ret; | ||||||
| 
 | 
 | ||||||
| 	if (rv != 1) | 	if (rv != 1) | ||||||
| 		return -EIO; | 		return -EIO; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user