History

[media] media: lirc_dev: merge struct irctl into struct lirc_dev

The use of two separate structs (lirc_dev aka lirc_driver and irctl) makes it much harder to follow the proper lifetime of the various structs and necessitates hacks such as keeping a copy of struct lirc_dev inside struct irctl. Merging the two structs means that lirc_dev can properly manage the lifetime of the resulting struct and simplifies the code at the same time. [mchehab@s-opensource.com: fix merge conflict] Signed-off-by: David Härdeman <david@hardeman.nu> Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>

David Härdeman committed 9 years ago

Commit b15e3931 parent 13f96554 files · +175 −200Browse files

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

Unified · Split

include/media/lirc_dev.h+20−6
@@ -17,6 +17,8 @@ · 16 unmodified lines
1717 #include <linux/poll.h>
1818 #include <linux/kfifo.h>
1919 #include <media/lirc.h>
20+#include <linux/device.h>
21+#include <linux/cdev.h>
2022
2123 struct lirc_buffer {
2224 wait_queue_head_t wait_poll;
@@ -127,14 +129,19 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, · 104 unmodified lines
127129 * LIRC_CAN_SET_REC_TIMEOUT is defined.
128130 * @max_timeout: Maximum timeout for record. Valid only if
129131 * LIRC_CAN_SET_REC_TIMEOUT is defined.
130− * @rbuf: if not NULL, it will be used as a read buffer, you will
132+ * @buf: if %NULL, lirc_dev will allocate and manage the buffer,
133+ * otherwise allocated by the caller which will
131134 * have to write to the buffer by other means, like irq's
132135 * (see also lirc_serial.c).
136+ * @buf_internal: whether lirc_dev has allocated the read buffer or not
133137 * @rdev: &struct rc_dev associated with the device
134138 * @fops: &struct file_operations for the device
135− * @dev: &struct device assigned to the device
136139 * @owner: the module owning this struct
137− * @irctl: &struct irctl assigned to the device
140+ * @attached: if the device is still live
141+ * @open: open count for the device's chardev
142+ * @mutex: serialises file_operations calls
143+ * @dev: &struct device assigned to the device
144+ * @cdev: &struct cdev assigned to the device
138145 */
139146 struct lirc_dev {
140147 char name[40];
@@ -144,16 +151,23 @@ struct lirc_dev { · 3 unmodified lines
144151
145152 unsigned int buffer_size; /* in chunks holding one code each */
146153 unsigned int chunk_size;
154+ struct lirc_buffer *buf;
155+ bool buf_internal;
147156
148157 void *data;
149158 int min_timeout;
150159 int max_timeout;
151− struct lirc_buffer *rbuf;
152160 struct rc_dev *rdev;
153161 const struct file_operations *fops;
154− struct device *dev;
155162 struct module *owner;
156− struct irctl *irctl;
163+
164+ bool attached;
165+ int open;
166+
167+ struct mutex mutex; /* protect from simultaneous accesses */
168+
169+ struct device dev;
170+ struct cdev cdev;
157171 };
158172
159173 struct lirc_dev *lirc_allocate_device(void);