History

[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>

Martin Kaiser committed 12 years ago

Commit 77d381a1 parent 37314522 files · +3 −7Browse files

Showing the changes to include/media/lirc_dev.h (1 of 2 files). Show all

Unified · Split

include/media/lirc_dev.h+2−6
@@ -29,14 +29,13 @@ struct lirc_buffer { · 28 unmodified lines
2929 /* Using chunks instead of bytes pretends to simplify boundary checking
3030 * And should allow for some performance fine tunning later */
3131 struct kfifo fifo;
32− u8 fifo_initialized;
3332 };
3433
3534 static inline void lirc_buffer_clear(struct lirc_buffer *buf)
3635 {
3736 unsigned long flags;
3837
39− if (buf->fifo_initialized) {
38+ if (kfifo_initialized(&buf->fifo)) {
4039 spin_lock_irqsave(&buf->fifo_lock, flags);
4140 kfifo_reset(&buf->fifo);
4241 spin_unlock_irqrestore(&buf->fifo_lock, flags);
@@ -56,17 +55,14 @@ static inline int lirc_buffer_init(struct lirc_buffer *buf, · 13 unmodified lines
5655 buf->chunk_size = chunk_size;
5756 buf->size = size;
5857 ret = kfifo_alloc(&buf->fifo, size * chunk_size, GFP_KERNEL);
59− if (ret == 0)
60− buf->fifo_initialized = 1;
6158
6259 return ret;
6360 }
6461
6562 static inline void lirc_buffer_free(struct lirc_buffer *buf)
6663 {
67− if (buf->fifo_initialized) {
64+ if (kfifo_initialized(&buf->fifo)) {
6865 kfifo_free(&buf->fifo);
69− buf->fifo_initialized = 0;
7066 } else
7167 WARN(1, "calling %s on an uninitialized lirc_buffer\n",
7268 __func__);