summaryrefslogtreecommitdiffstats
path: root/include/media
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2017-06-25 09:32:36 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2017-10-04 14:53:07 -0300
commitb15e39379fe8700fe0ec849a5c5ee2b44cd16381 (patch)
treeef7d8a0a058a048db765dd87af0bad28727dd39a /include/media
parent13f96555d6faa6dc57fb5faedf728447a3188230 (diff)
downloadtalos-obmc-linux-b15e39379fe8700fe0ec849a5c5ee2b44cd16381.tar.gz
talos-obmc-linux-b15e39379fe8700fe0ec849a5c5ee2b44cd16381.zip
[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>
Diffstat (limited to 'include/media')
-rw-r--r--include/media/lirc_dev.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/include/media/lirc_dev.h b/include/media/lirc_dev.h
index 4b0dc640e142..981dcabd5fd5 100644
--- a/include/media/lirc_dev.h
+++ b/include/media/lirc_dev.h
@@ -17,6 +17,8 @@
#include <linux/poll.h>
#include <linux/kfifo.h>
#include <media/lirc.h>
+#include <linux/device.h>
+#include <linux/cdev.h>
struct lirc_buffer {
wait_queue_head_t wait_poll;
@@ -127,14 +129,19 @@ static inline unsigned int lirc_buffer_write(struct lirc_buffer *buf,
* LIRC_CAN_SET_REC_TIMEOUT is defined.
* @max_timeout: Maximum timeout for record. Valid only if
* LIRC_CAN_SET_REC_TIMEOUT is defined.
- * @rbuf: if not NULL, it will be used as a read buffer, you will
+ * @buf: if %NULL, lirc_dev will allocate and manage the buffer,
+ * otherwise allocated by the caller which will
* have to write to the buffer by other means, like irq's
* (see also lirc_serial.c).
+ * @buf_internal: whether lirc_dev has allocated the read buffer or not
* @rdev: &struct rc_dev associated with the device
* @fops: &struct file_operations for the device
- * @dev: &struct device assigned to the device
* @owner: the module owning this struct
- * @irctl: &struct irctl assigned to the device
+ * @attached: if the device is still live
+ * @open: open count for the device's chardev
+ * @mutex: serialises file_operations calls
+ * @dev: &struct device assigned to the device
+ * @cdev: &struct cdev assigned to the device
*/
struct lirc_dev {
char name[40];
@@ -144,16 +151,23 @@ struct lirc_dev {
unsigned int buffer_size; /* in chunks holding one code each */
unsigned int chunk_size;
+ struct lirc_buffer *buf;
+ bool buf_internal;
void *data;
int min_timeout;
int max_timeout;
- struct lirc_buffer *rbuf;
struct rc_dev *rdev;
const struct file_operations *fops;
- struct device *dev;
struct module *owner;
- struct irctl *irctl;
+
+ bool attached;
+ int open;
+
+ struct mutex mutex; /* protect from simultaneous accesses */
+
+ struct device dev;
+ struct cdev cdev;
};
struct lirc_dev *lirc_allocate_device(void);
OpenPOWER on IntegriCloud