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;
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,
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)
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:
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))