Skip to content

Commit 80be4fd

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. Signed-off-by: Josuah Demangeon <me@josuah.net>
1 parent c47e14c commit 80be4fd

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
@@ -31,8 +31,7 @@ struct video_sw_generator_data {
3131
struct video_format fmt;
3232
struct k_fifo fifo_in;
3333
struct k_fifo fifo_out;
34-
struct k_work_delayable buf_work;
35-
struct k_work_sync work_sync;
34+
struct k_work_delayable work;
3635
int pattern;
3736
bool ctrl_hflip;
3837
bool ctrl_vflip;
@@ -113,11 +112,12 @@ static int video_sw_generator_get_fmt(const struct device *dev, enum video_endpo
113112
static int video_sw_generator_set_stream(const struct device *dev, bool enable)
114113
{
115114
struct video_sw_generator_data *data = dev->data;
115+
struct k_work_sync work_sync = {0};
116116

117117
if (enable) {
118-
k_work_schedule(&data->buf_work, K_MSEC(1000 / data->frame_rate));
118+
k_work_schedule(&data->work, K_MSEC(1000 / data->frame_rate));
119119
} else {
120-
k_work_cancel_delayable_sync(&data->buf_work, &data->work_sync);
120+
k_work_cancel_delayable_sync(&data->work, &work_sync);
121121
}
122122

123123
return 0;
@@ -265,9 +265,9 @@ static void video_sw_generator_worker(struct k_work *work)
265265
struct video_sw_generator_data *data;
266266
struct video_buffer *vbuf;
267267

268-
data = CONTAINER_OF(dwork, struct video_sw_generator_data, buf_work);
268+
data = CONTAINER_OF(dwork, struct video_sw_generator_data, work);
269269

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

272272
vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
273273
if (vbuf == NULL) {
@@ -482,7 +482,7 @@ static int video_sw_generator_init(const struct device *dev)
482482
data->dev = dev;
483483
k_fifo_init(&data->fifo_in);
484484
k_fifo_init(&data->fifo_out);
485-
k_work_init_delayable(&data->buf_work, video_sw_generator_worker);
485+
k_work_init_delayable(&data->work, video_sw_generator_worker);
486486

487487
return 0;
488488
}

0 commit comments

Comments
 (0)