media: v4l2-flash: Check whether setting LED brightness succeeded
Setting LED brightness may return an error but the return value was never checked by the V4L2 flash LED class. Do it now. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
a40eba9b26
commit
4d7adf0236
|
@ -76,8 +76,8 @@ static s32 __led_brightness_to_intensity(struct v4l2_ctrl *ctrl,
|
|||
return (brightness * ctrl->step) + ctrl->minimum;
|
||||
}
|
||||
|
||||
static void v4l2_flash_set_led_brightness(struct v4l2_flash *v4l2_flash,
|
||||
struct v4l2_ctrl *ctrl)
|
||||
static int v4l2_flash_set_led_brightness(struct v4l2_flash *v4l2_flash,
|
||||
struct v4l2_ctrl *ctrl)
|
||||
{
|
||||
struct v4l2_ctrl **ctrls = v4l2_flash->ctrls;
|
||||
struct led_classdev *led_cdev;
|
||||
|
@ -103,20 +103,20 @@ static void v4l2_flash_set_led_brightness(struct v4l2_flash *v4l2_flash,
|
|||
|
||||
if (ctrl == ctrls[TORCH_INTENSITY]) {
|
||||
if (ctrls[LED_MODE]->val != V4L2_FLASH_LED_MODE_TORCH)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
if (WARN_ON_ONCE(!v4l2_flash->fled_cdev))
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
led_cdev = &v4l2_flash->fled_cdev->led_cdev;
|
||||
} else {
|
||||
if (WARN_ON_ONCE(!v4l2_flash->iled_cdev))
|
||||
return;
|
||||
return -EINVAL;
|
||||
|
||||
led_cdev = v4l2_flash->iled_cdev;
|
||||
}
|
||||
|
||||
led_set_brightness_sync(led_cdev, brightness);
|
||||
return led_set_brightness_sync(led_cdev, brightness);
|
||||
}
|
||||
|
||||
static int v4l2_flash_update_led_brightness(struct v4l2_flash *v4l2_flash,
|
||||
|
@ -222,8 +222,7 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c)
|
|||
switch (c->id) {
|
||||
case V4L2_CID_FLASH_TORCH_INTENSITY:
|
||||
case V4L2_CID_FLASH_INDICATOR_INTENSITY:
|
||||
v4l2_flash_set_led_brightness(v4l2_flash, c);
|
||||
return 0;
|
||||
return v4l2_flash_set_led_brightness(v4l2_flash, c);
|
||||
}
|
||||
|
||||
if (!fled_cdev)
|
||||
|
@ -262,9 +261,8 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c)
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
v4l2_flash_set_led_brightness(v4l2_flash,
|
||||
ctrls[TORCH_INTENSITY]);
|
||||
return 0;
|
||||
return v4l2_flash_set_led_brightness(v4l2_flash,
|
||||
ctrls[TORCH_INTENSITY]);
|
||||
}
|
||||
break;
|
||||
case V4L2_CID_FLASH_STROBE_SOURCE:
|
||||
|
@ -511,13 +509,19 @@ static int __sync_device_with_v4l2_controls(struct v4l2_flash *v4l2_flash)
|
|||
struct v4l2_ctrl **ctrls = v4l2_flash->ctrls;
|
||||
int ret = 0;
|
||||
|
||||
if (ctrls[TORCH_INTENSITY])
|
||||
v4l2_flash_set_led_brightness(v4l2_flash,
|
||||
ctrls[TORCH_INTENSITY]);
|
||||
if (ctrls[TORCH_INTENSITY]) {
|
||||
ret = v4l2_flash_set_led_brightness(v4l2_flash,
|
||||
ctrls[TORCH_INTENSITY]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ctrls[INDICATOR_INTENSITY])
|
||||
v4l2_flash_set_led_brightness(v4l2_flash,
|
||||
ctrls[INDICATOR_INTENSITY]);
|
||||
if (ctrls[INDICATOR_INTENSITY]) {
|
||||
ret = v4l2_flash_set_led_brightness(v4l2_flash,
|
||||
ctrls[INDICATOR_INTENSITY]);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ctrls[FLASH_TIMEOUT]) {
|
||||
if (WARN_ON_ONCE(!fled_cdev))
|
||||
|
|
Loading…
Reference in New Issue