hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/media/usb/uvc/uvc_ctrl.c
....@@ -6,6 +6,7 @@
66 * Laurent Pinchart (laurent.pinchart@ideasonboard.com)
77 */
88
9
+#include <asm/barrier.h>
910 #include <linux/kernel.h>
1011 #include <linux/list.h>
1112 #include <linux/module.h>
....@@ -1275,17 +1276,12 @@
12751276 uvc_ctrl_send_event(chain, handle, ctrl, mapping, val, changes);
12761277 }
12771278
1278
-static void uvc_ctrl_status_event_work(struct work_struct *work)
1279
+void uvc_ctrl_status_event(struct uvc_video_chain *chain,
1280
+ struct uvc_control *ctrl, const u8 *data)
12791281 {
1280
- struct uvc_device *dev = container_of(work, struct uvc_device,
1281
- async_ctrl.work);
1282
- struct uvc_ctrl_work *w = &dev->async_ctrl;
1283
- struct uvc_video_chain *chain = w->chain;
12841282 struct uvc_control_mapping *mapping;
1285
- struct uvc_control *ctrl = w->ctrl;
12861283 struct uvc_fh *handle;
12871284 unsigned int i;
1288
- int ret;
12891285
12901286 mutex_lock(&chain->ctrl_mutex);
12911287
....@@ -1293,7 +1289,7 @@
12931289 ctrl->handle = NULL;
12941290
12951291 list_for_each_entry(mapping, &ctrl->info.mappings, list) {
1296
- s32 value = __uvc_ctrl_get_value(mapping, w->data);
1292
+ s32 value = __uvc_ctrl_get_value(mapping, data);
12971293
12981294 /*
12991295 * handle may be NULL here if the device sends auto-update
....@@ -1312,6 +1308,20 @@
13121308 }
13131309
13141310 mutex_unlock(&chain->ctrl_mutex);
1311
+}
1312
+
1313
+static void uvc_ctrl_status_event_work(struct work_struct *work)
1314
+{
1315
+ struct uvc_device *dev = container_of(work, struct uvc_device,
1316
+ async_ctrl.work);
1317
+ struct uvc_ctrl_work *w = &dev->async_ctrl;
1318
+ int ret;
1319
+
1320
+ uvc_ctrl_status_event(w->chain, w->ctrl, w->data);
1321
+
1322
+ /* The barrier is needed to synchronize with uvc_status_stop(). */
1323
+ if (smp_load_acquire(&dev->flush_status))
1324
+ return;
13151325
13161326 /* Resubmit the URB. */
13171327 w->urb->interval = dev->int_ep->desc.bInterval;
....@@ -1321,8 +1331,8 @@
13211331 ret);
13221332 }
13231333
1324
-bool uvc_ctrl_status_event(struct urb *urb, struct uvc_video_chain *chain,
1325
- struct uvc_control *ctrl, const u8 *data)
1334
+bool uvc_ctrl_status_event_async(struct urb *urb, struct uvc_video_chain *chain,
1335
+ struct uvc_control *ctrl, const u8 *data)
13261336 {
13271337 struct uvc_device *dev = chain->dev;
13281338 struct uvc_ctrl_work *w = &dev->async_ctrl;