Commit f2bf6cd8 authored by Sakari Ailus's avatar Sakari Ailus Committed by Hans Verkuil

media: v4l: Don't turn on privacy LED if streamon fails

Turn on the privacy LED only if streamon succeeds. This can be done after
enabling streaming on the sensor.

Fixes: b6e10ff6 ("media: v4l2-core: Make the v4l2-core code enable/disable the privacy LED if present")
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: default avatarUmang Jain <umang.jain@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent ad79c9ec
...@@ -442,6 +442,16 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -442,6 +442,16 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable)
if (WARN_ON(!!sd->enabled_streams == !!enable)) if (WARN_ON(!!sd->enabled_streams == !!enable))
return 0; return 0;
ret = sd->ops->video->s_stream(sd, enable);
if (!enable && ret < 0) {
dev_warn(sd->dev, "disabling streaming failed (%d)\n", ret);
ret = 0;
}
if (!ret) {
sd->enabled_streams = enable ? BIT(0) : 0;
#if IS_REACHABLE(CONFIG_LEDS_CLASS) #if IS_REACHABLE(CONFIG_LEDS_CLASS)
if (!IS_ERR_OR_NULL(sd->privacy_led)) { if (!IS_ERR_OR_NULL(sd->privacy_led)) {
if (enable) if (enable)
...@@ -451,16 +461,8 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -451,16 +461,8 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable)
led_set_brightness(sd->privacy_led, 0); led_set_brightness(sd->privacy_led, 0);
} }
#endif #endif
ret = sd->ops->video->s_stream(sd, enable);
if (!enable && ret < 0) {
dev_warn(sd->dev, "disabling streaming failed (%d)\n", ret);
ret = 0;
} }
if (!ret)
sd->enabled_streams = enable ? BIT(0) : 0;
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment