Skip to content

Commit 3cfe8af

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 09097b0 commit 3cfe8af

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;
@@ -257,9 +257,9 @@ static void video_sw_generator_worker(struct k_work *work)
257257
struct video_sw_generator_data *data;
258258
struct video_buffer *vbuf;
259259

260-
data = CONTAINER_OF(dwork, struct video_sw_generator_data, buf_work);
260+
data = CONTAINER_OF(dwork, struct video_sw_generator_data, work);
261261

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

264264
vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
265265
if (vbuf == NULL) {
@@ -474,7 +474,7 @@ static int video_sw_generator_init(const struct device *dev)
474474
data->dev = dev;
475475
k_fifo_init(&data->fifo_in);
476476
k_fifo_init(&data->fifo_out);
477-
k_work_init_delayable(&data->buf_work, video_sw_generator_worker);
477+
k_work_init_delayable(&data->work, video_sw_generator_worker);
478478

479479
return 0;
480480
}

0 commit comments

Comments
 (0)