Skip to content

Commit 01a0909

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 678a10b commit 01a0909

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;
@@ -105,11 +104,12 @@ static int video_sw_generator_set_stream(const struct device *dev, bool enable,
105104
enum video_buf_type type)
106105
{
107106
struct video_sw_generator_data *data = dev->data;
107+
struct k_work_sync work_sync = {0};
108108

109109
if (enable) {
110-
k_work_schedule(&data->buf_work, K_MSEC(1000 / data->frame_rate));
110+
k_work_schedule(&data->work, K_MSEC(1000 / data->frame_rate));
111111
} else {
112-
k_work_cancel_delayable_sync(&data->buf_work, &data->work_sync);
112+
k_work_cancel_delayable_sync(&data->work, &work_sync);
113113
}
114114

115115
return 0;
@@ -281,9 +281,9 @@ static void video_sw_generator_worker(struct k_work *work)
281281
struct video_sw_generator_data *data;
282282
struct video_buffer *vbuf;
283283

284-
data = CONTAINER_OF(dwork, struct video_sw_generator_data, buf_work);
284+
data = CONTAINER_OF(dwork, struct video_sw_generator_data, work);
285285

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

288288
vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
289289
if (vbuf == NULL) {
@@ -472,7 +472,7 @@ static int video_sw_generator_init(const struct device *dev)
472472
data->dev = dev;
473473
k_fifo_init(&data->fifo_in);
474474
k_fifo_init(&data->fifo_out);
475-
k_work_init_delayable(&data->buf_work, video_sw_generator_worker);
475+
k_work_init_delayable(&data->work, video_sw_generator_worker);
476476

477477
return video_sw_generator_init_controls(dev);
478478
}

0 commit comments

Comments
 (0)