Skip to content

Commit 78f4c4c

Browse files
committed
drivers: video: sw_generator: make k_work_sync a local variable
The documentation of k_work_cancel_delayable_sync() states that the input k_work_sync parameter needs to be valid until the function call returns, so there is no need to preserve the state across successive calls. Now that there is a single work-related field in the struct, rename it to simply "work". Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent 14c8f41 commit 78f4c4c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/video/video_sw_generator.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ struct video_sw_generator_data {
3939
struct video_format fmt;
4040
struct k_fifo fifo_in;
4141
struct k_fifo fifo_out;
42-
struct k_work_delayable buf_work;
43-
struct k_work_sync work_sync;
42+
struct k_work_delayable work;
4443
int pattern;
4544
struct k_poll_signal *sig;
4645
uint32_t frame_rate;
@@ -98,11 +97,12 @@ static int video_sw_generator_set_stream(const struct device *dev, bool enable,
9897
enum video_buf_type type)
9998
{
10099
struct video_sw_generator_data *data = dev->data;
100+
struct k_work_sync work_sync = {0};
101101

102102
if (enable) {
103-
k_work_schedule(&data->buf_work, K_MSEC(1000 / data->frame_rate));
103+
k_work_schedule(&data->work, K_MSEC(1000 / data->frame_rate));
104104
} else {
105-
k_work_cancel_delayable_sync(&data->buf_work, &data->work_sync);
105+
k_work_cancel_delayable_sync(&data->work, &work_sync);
106106
}
107107

108108
return 0;
@@ -289,9 +289,9 @@ static void video_sw_generator_worker(struct k_work *work)
289289
struct video_sw_generator_data *data;
290290
struct video_buffer *vbuf;
291291

292-
data = CONTAINER_OF(dwork, struct video_sw_generator_data, buf_work);
292+
data = CONTAINER_OF(dwork, struct video_sw_generator_data, work);
293293

294-
k_work_reschedule(&data->buf_work, K_MSEC(1000 / data->frame_rate));
294+
k_work_reschedule(&data->work, K_MSEC(1000 / data->frame_rate));
295295

296296
vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
297297
if (vbuf == NULL) {
@@ -476,7 +476,7 @@ static int video_sw_generator_init(const struct device *dev)
476476
data->dev = dev;
477477
k_fifo_init(&data->fifo_in);
478478
k_fifo_init(&data->fifo_out);
479-
k_work_init_delayable(&data->buf_work, video_sw_generator_worker);
479+
k_work_init_delayable(&data->work, video_sw_generator_worker);
480480

481481
return video_sw_generator_init_controls(dev);
482482
}

0 commit comments

Comments
 (0)