Skip to content

Commit 8caaa0d

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 ff7d7f6 commit 8caaa0d

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;
@@ -108,11 +107,12 @@ static int video_sw_generator_get_fmt(const struct device *dev, enum video_endpo
108107
static int video_sw_generator_set_stream(const struct device *dev, bool enable)
109108
{
110109
struct video_sw_generator_data *data = dev->data;
110+
struct k_work_sync work_sync = {0};;
111111

112112
if (enable) {
113-
k_work_schedule(&data->buf_work, K_MSEC(1000 / data->frame_rate));
113+
k_work_schedule(&data->work, K_MSEC(1000 / data->frame_rate));
114114
} else {
115-
k_work_cancel_delayable_sync(&data->buf_work, &data->work_sync);
115+
k_work_cancel_delayable_sync(&data->work, &work_sync);
116116
}
117117

118118
return 0;
@@ -259,9 +259,9 @@ static void video_sw_generator_worker(struct k_work *work)
259259
struct video_sw_generator_data *data;
260260
struct video_buffer *vbuf;
261261

262-
data = CONTAINER_OF(dwork, struct video_sw_generator_data, buf_work);
262+
data = CONTAINER_OF(dwork, struct video_sw_generator_data, work);
263263

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

266266
vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
267267
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 0;
482482
}

0 commit comments

Comments
 (0)