Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] lirc: use kfifo_initialized() on lirc_buffer's fifo

We can use kfifo_initialized() to check if the fifo in lirc_buffer is
initialized or not. There's no need to have a dedicated fifo status
variable in lirc_buffer.

[m.chehab@samsung.com: add the same change to lirc_zilog, to avoid
breaking compilation of staging drivers]
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

authored by

Martin Kaiser and committed by
Mauro Carvalho Chehab
77d381af 37314528

+3 -7
+1 -1
drivers/staging/media/lirc/lirc_zilog.c
··· 199 199 lirc_unregister_driver(ir->l.minor); 200 200 ir->l.minor = MAX_IRCTL_DEVICES; 201 201 } 202 - if (ir->rbuf.fifo_initialized) 202 + if (kfifo_initialized(&ir->rbuf.fifo)) 203 203 lirc_buffer_free(&ir->rbuf); 204 204 list_del(&ir->list); 205 205 kfree(ir);
+2 -6
include/media/lirc_dev.h
··· 29 29 /* Using chunks instead of bytes pretends to simplify boundary checking 30 30 * And should allow for some performance fine tunning later */ 31 31 struct kfifo fifo; 32 - u8 fifo_initialized; 33 32 }; 34 33 35 34 static inline void lirc_buffer_clear(struct lirc_buffer *buf) 36 35 { 37 36 unsigned long flags; 38 37 39 - if (buf->fifo_initialized) { 38 + if (kfifo_initialized(&buf->fifo)) { 40 39 spin_lock_irqsave(&buf->fifo_lock, flags); 41 40 kfifo_reset(&buf->fifo); 42 41 spin_unlock_irqrestore(&buf->fifo_lock, flags); ··· 55 56 buf->chunk_size = chunk_size; 56 57 buf->size = size; 57 58 ret = kfifo_alloc(&buf->fifo, size * chunk_size, GFP_KERNEL); 58 - if (ret == 0) 59 - buf->fifo_initialized = 1; 60 59 61 60 return ret; 62 61 } 63 62 64 63 static inline void lirc_buffer_free(struct lirc_buffer *buf) 65 64 { 66 - if (buf->fifo_initialized) { 65 + if (kfifo_initialized(&buf->fifo)) { 67 66 kfifo_free(&buf->fifo); 68 - buf->fifo_initialized = 0; 69 67 } else 70 68 WARN(1, "calling %s on an uninitialized lirc_buffer\n", 71 69 __func__);