Skip to content

Commit 46dcd1c

Browse files
tititiou36Jiri Kosina
authored andcommitted
HID: logitech-hidpp: Use 'atomic_inc_return' instead of hand-writing it
This function logs a warning if the workqueue gets too big. In order to save a few cycles, use 'atomic_inc_return()' instead of an 'atomic_inc()/atomic_read()' sequence. This axes a line of code and saves a 'atomic_read()' call. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent df04fbe commit 46dcd1c

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/hid/hid-logitech-hidpp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,11 +2240,10 @@ static int hidpp_ff_queue_work(struct hidpp_ff_private_data *data, int effect_id
22402240
wd->size = size;
22412241
memcpy(wd->params, params, size);
22422242

2243-
atomic_inc(&data->workqueue_size);
2243+
s = atomic_inc_return(&data->workqueue_size);
22442244
queue_work(data->wq, &wd->work);
22452245

22462246
/* warn about excessive queue size */
2247-
s = atomic_read(&data->workqueue_size);
22482247
if (s >= 20 && s % 20 == 0)
22492248
hid_warn(data->hidpp->hid_dev, "Force feedback command queue contains %d commands, causing substantial delays!", s);
22502249

0 commit comments

Comments
 (0)