static inline int errno_to_device_error(int err)
{
- if (err == -EACCES)
+ switch (err) {
+ case 0:
+ return DEVICE_ERROR_NONE;
+ case -EACCES:
+ case -EPERM:
return DEVICE_ERROR_PERMISSION_DENIED;
- else if (err == -EBUSY)
+ case -EBUSY:
return DEVICE_ERROR_RESOURCE_BUSY;
- else if (err == -ENOTSUP || err == -ENODEV || err == -ENOENT)
+ case -ENOTSUP:
+ case -ENODEV:
+ case -ENOENT:
return DEVICE_ERROR_NOT_SUPPORTED;
- else if (err < 0)
+ default:
return DEVICE_ERROR_OPERATION_FAILED;
-
- return DEVICE_ERROR_NONE;
+ }
}
#endif /* __COMMON_H__ */
if (!max_brightness)
return DEVICE_ERROR_INVALID_PARAMETER;
- if (display_cnt < 0)
- device_display_get_numbers(&display_cnt);
+ if (display_cnt < 0) {
+ ret = device_display_get_numbers(&display_cnt);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+ }
if (display_index < 0 || display_index >= display_cnt)
return DEVICE_ERROR_INVALID_PARAMETER;
if (!brightness)
return DEVICE_ERROR_INVALID_PARAMETER;
- if (display_cnt < 0)
- device_display_get_numbers(&display_cnt);
+ if (display_cnt < 0) {
+ ret = device_display_get_numbers(&display_cnt);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+ }
if (display_index < 0 || display_index >= display_cnt)
return DEVICE_ERROR_INVALID_PARAMETER;
char str_val[32];
int ret, max;
- if (display_cnt < 0)
- device_display_get_numbers(&display_cnt);
+ if (display_cnt < 0) {
+ ret = device_display_get_numbers(&display_cnt);
+ if (ret != DEVICE_ERROR_NONE)
+ return ret;
+ }
if (display_index < 0 || display_index >= display_cnt)
return DEVICE_ERROR_INVALID_PARAMETER;