diff options
author | Martin Kaiser <martin@kaiser.cx> | 2014-10-28 17:51:01 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-11-03 09:53:05 -0500 |
commit | 77d381af73e905c48b992d5d8426376469bc9576 (patch) | |
tree | f957c84c6f10aed179e201ea1234e64825fd8e05 | |
parent | 373145282ea61c2a01980914ee5bbff7cf62afd6 (diff) |
[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>
-rw-r--r-- | drivers/staging/media/lirc/lirc_zilog.c | 2 | ||||
-rw-r--r-- | include/media/lirc_dev.h | 8 |
2 files changed, 3 insertions, 7 deletions
diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c index 567feba0011c..1ccf6262ab36 100644 --- a/drivers/staging/media/lirc/lirc_zilog.c +++ b/drivers/staging/media/lirc/lirc_zilog.c | |||
@@ -199,7 +199,7 @@ static void release_ir_device(struct kref *ref) | |||
199 | lirc_unregister_driver(ir->l.minor); | 199 | lirc_unregister_driver(ir->l.minor); |
200 | ir->l.minor = MAX_IRCTL_DEVICES; | 200 | ir->l.minor = MAX_IRCTL_DEVICES; |
201 | } | 201 | } |
202 | if (ir->rbuf.fifo_initialized) | 202 | if (kfifo_initialized(&ir->rbuf.fifo)) |
203 | lirc_buffer_free(&ir->rbuf); | 203 | lirc_buffer_free(&ir->rbuf); |
204 | list_del(&ir->list); | 204 | list_del(&ir->list); |
205 | kfree(ir); | 205 | kfree(ir); |
diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h index 78f0637ca68d..05e7ad5d2c8b 100644 --- a/include/media/lirc_dev.h +++ b/include/media/lirc_dev.h | |||
@@ -29,14 +29,13 @@ struct lirc_buffer { | |||
29 | /* Using chunks instead of bytes pretends to simplify boundary checking | 29 | /* Using chunks instead of bytes pretends to simplify boundary checking |
30 | * And should allow for some performance fine tunning later */ | 30 | * And should allow for some performance fine tunning later */ |
31 | struct kfifo fifo; | 31 | struct kfifo fifo; |
32 | u8 fifo_initialized; | ||
33 | }; | 32 | }; |
34 | 33 | ||
35 | static inline void lirc_buffer_clear(struct lirc_buffer *buf) | 34 | static inline void lirc_buffer_clear(struct lirc_buffer *buf) |
36 | { | 35 | { |
37 | unsigned long flags; | 36 | unsigned long flags; |
38 | 37 | ||
39 | if (buf->fifo_initialized) { | 38 | if (kfifo_initialized(&buf->fifo)) { |
40 | spin_lock_irqsave(&buf->fifo_lock, flags); | 39 | spin_lock_irqsave(&buf->fifo_lock, flags); |
41 | kfifo_reset(&buf->fifo); | 40 | kfifo_reset(&buf->fifo); |
42 | spin_unlock_irqrestore(&buf->fifo_lock, flags); | 41 | spin_unlock_irqrestore(&buf->fifo_lock, flags); |
@@ -56,17 +55,14 @@ static inline int lirc_buffer_init(struct lirc_buffer *buf, | |||
56 | buf->chunk_size = chunk_size; | 55 | buf->chunk_size = chunk_size; |
57 | buf->size = size; | 56 | buf->size = size; |
58 | ret = kfifo_alloc(&buf->fifo, size * chunk_size, GFP_KERNEL); | 57 | ret = kfifo_alloc(&buf->fifo, size * chunk_size, GFP_KERNEL); |
59 | if (ret == 0) | ||
60 | buf->fifo_initialized = 1; | ||
61 | 58 | ||
62 | return ret; | 59 | return ret; |
63 | } | 60 | } |
64 | 61 | ||
65 | static inline void lirc_buffer_free(struct lirc_buffer *buf) | 62 | static inline void lirc_buffer_free(struct lirc_buffer *buf) |
66 | { | 63 | { |
67 | if (buf->fifo_initialized) { | 64 | if (kfifo_initialized(&buf->fifo)) { |
68 | kfifo_free(&buf->fifo); | 65 | kfifo_free(&buf->fifo); |
69 | buf->fifo_initialized = 0; | ||
70 | } else | 66 | } else |
71 | WARN(1, "calling %s on an uninitialized lirc_buffer\n", | 67 | WARN(1, "calling %s on an uninitialized lirc_buffer\n", |
72 | __func__); | 68 | __func__); |