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
17#include <linux/poll.h>17#include <linux/poll.h>
18#include <linux/kfifo.h>18#include <linux/kfifo.h>
19#include <media/lirc.h>19#include <media/lirc.h>
20#include <linux/device.h>
21#include <linux/cdev.h>
20 22
21struct lirc_buffer {23struct lirc_buffer {
22 wait_queue_head_t wait_poll;24 wait_queue_head_t wait_poll;
@@ -127,14 +129,19 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf, · 104 unmodified lines
127 * LIRC_CAN_SET_REC_TIMEOUT is defined.129 * LIRC_CAN_SET_REC_TIMEOUT is defined.
128 * @max_timeout: Maximum timeout for record. Valid only if130 * @max_timeout: Maximum timeout for record. Valid only if
129 * LIRC_CAN_SET_REC_TIMEOUT is defined.131 * LIRC_CAN_SET_REC_TIMEOUT is defined.
130 * @rbuf: if not NULL, it will be used as a read buffer, you will132 * @buf: if %NULL, lirc_dev will allocate and manage the buffer,
133 * otherwise allocated by the caller which will
131 * have to write to the buffer by other means, like irq's134 * have to write to the buffer by other means, like irq's
132 * (see also lirc_serial.c).135 * (see also lirc_serial.c).
136 * @buf_internal: whether lirc_dev has allocated the read buffer or not
133 * @rdev: &struct rc_dev associated with the device137 * @rdev: &struct rc_dev associated with the device
134 * @fops: &struct file_operations for the device138 * @fops: &struct file_operations for the device
135 * @dev: &struct device assigned to the device
136 * @owner: the module owning this struct139 * @owner: the module owning this struct
137 * @irctl: &struct irctl assigned to the device140 * @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
138 */145 */
139struct lirc_dev {146struct lirc_dev {
140 char name[40];147 char name[40];
@@ -144,16 +151,23 @@ struct lirc_dev { · 3 unmodified lines
144 151
145 unsigned int buffer_size; /* in chunks holding one code each */152 unsigned int buffer_size; /* in chunks holding one code each */
146 unsigned int chunk_size;153 unsigned int chunk_size;
154 struct lirc_buffer *buf;
155 bool buf_internal;
147 156
148 void *data;157 void *data;
149 int min_timeout;158 int min_timeout;
150 int max_timeout;159 int max_timeout;
151 struct lirc_buffer *rbuf;
152 struct rc_dev *rdev;160 struct rc_dev *rdev;
153 const struct file_operations *fops;161 const struct file_operations *fops;
154 struct device *dev;
155 struct module *owner;162 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;
157};171};
158 172
159struct lirc_dev *lirc_allocate_device(void);173struct lirc_dev *lirc_allocate_device(void);