Skip to content

Commit 5687dc8

Browse files
josuahkartben
authored andcommitted
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 04912d4 commit 5687dc8

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;
@@ -100,11 +99,12 @@ static int video_sw_generator_set_stream(const struct device *dev, bool enable,
10099
enum video_buf_type type)
101100
{
102101
struct video_sw_generator_data *data = dev->data;
102+
struct k_work_sync work_sync = {0};
103103

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

110110
return 0;
@@ -291,9 +291,9 @@ static void video_sw_generator_worker(struct k_work *work)
291291
struct video_sw_generator_data *data;
292292
struct video_buffer *vbuf;
293293

294-
data = CONTAINER_OF(dwork, struct video_sw_generator_data, buf_work);
294+
data = CONTAINER_OF(dwork, struct video_sw_generator_data, work);
295295

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

298298
vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
299299
if (vbuf == NULL) {
@@ -478,7 +478,7 @@ static int video_sw_generator_init(const struct device *dev)
478478
data->dev = dev;
479479
k_fifo_init(&data->fifo_in);
480480
k_fifo_init(&data->fifo_out);
481-
k_work_init_delayable(&data->buf_work, video_sw_generator_worker);
481+
k_work_init_delayable(&data->work, video_sw_generator_worker);
482482

483483
return video_sw_generator_init_controls(dev);
484484
}

0 commit comments

Comments
 (0)