]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
media: v4l: Don't turn on privacy LED if streamon fails
authorSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 10 Apr 2024 09:58:44 +0000 (12:58 +0300)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 22 Apr 2024 09:41:04 +0000 (11:41 +0200)
Turn on the privacy LED only if streamon succeeds. This can be done after
enabling streaming on the sensor.

Fixes: b6e10ff6c23d ("media: v4l2-core: Make the v4l2-core code enable/disable the privacy LED if present")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/v4l2-core/v4l2-subdev.c

index 0f590c9dc6caa0bb396c5b28e3dd120a6db471cc..2d67ec54569aadf97ff916d7e9bfa377f1d5dcc7 100644 (file)
@@ -442,15 +442,6 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable)
        if (WARN_ON(!!sd->enabled_streams == !!enable))
                return 0;
 
-#if IS_REACHABLE(CONFIG_LEDS_CLASS)
-       if (!IS_ERR_OR_NULL(sd->privacy_led)) {
-               if (enable)
-                       led_set_brightness(sd->privacy_led,
-                                          sd->privacy_led->max_brightness);
-               else
-                       led_set_brightness(sd->privacy_led, 0);
-       }
-#endif
        ret = sd->ops->video->s_stream(sd, enable);
 
        if (!enable && ret < 0) {
@@ -458,9 +449,20 @@ static int call_s_stream(struct v4l2_subdev *sd, int enable)
                ret = 0;
        }
 
-       if (!ret)
+       if (!ret) {
                sd->enabled_streams = enable ? BIT(0) : 0;
 
+#if IS_REACHABLE(CONFIG_LEDS_CLASS)
+               if (!IS_ERR_OR_NULL(sd->privacy_led)) {
+                       if (enable)
+                               led_set_brightness(sd->privacy_led,
+                                                  sd->privacy_led->max_brightness);
+                       else
+                               led_set_brightness(sd->privacy_led, 0);
+               }
+#endif
+       }
+
        return ret;
 }