diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-04-12 14:33:14 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-04-17 09:21:10 +0200 |
commit | c2ee90fb9ed90c3612301e2b86c05cfb3c008fde (patch) | |
tree | bf1200bdc97642a02a7ed89cca57be1daf57ef9c /include/console.h | |
parent | 84fc6119d3aaa33344d154428ce37800a96a39b9 (diff) | |
download | barebox-c2ee90fb9ed90c3612301e2b86c05cfb3c008fde.tar.gz barebox-c2ee90fb9ed90c3612301e2b86c05cfb3c008fde.tar.xz |
console: Add simplified 'serdev' framework from Linux kernel
Port 'serdev' UART-slave deivce framework found in recent Linux
kernels (post 4.13) in order to be able to port 'serdev' slave drivers
from Linux.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/console.h')
-rw-r--r-- | include/console.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/console.h b/include/console.h index da867e70a6..673921331d 100644 --- a/include/console.h +++ b/include/console.h @@ -23,6 +23,7 @@ #include <param.h> #include <linux/list.h> #include <driver.h> +#include <serdev.h> #include <clock.h> #include <kfifo.h> @@ -66,8 +67,34 @@ struct console_device { struct cdev devfs; struct cdev_operations fops; + + struct serdev_device serdev; }; +static inline struct serdev_device *to_serdev_device(struct device_d *d) +{ + struct console_device *cdev = + container_of(d, struct console_device, class_dev); + return &cdev->serdev; +} + +static inline struct console_device * +to_console_device(struct serdev_device *serdev) +{ + return container_of(serdev, struct console_device, serdev); +} + +static inline struct device_node * +console_is_serdev_node(struct console_device *cdev) +{ + struct device_d *dev = cdev->dev; + if (dev && dev->device_node && + of_get_child_count(dev->device_node)) + return dev->device_node; + + return NULL; +} + int console_register(struct console_device *cdev); int console_unregister(struct console_device *cdev); |