XenevaOS
Loading...
Searching...
No Matches
serdev.h
Go to the documentation of this file.
1#ifndef __LINUX_SERDEV_H__
2#define __LINUX_SERDEV_H__
3
4/*
5 * DCL <linux/serdev.h> -- two functions, and mainline's own answer to both.
6 *
7 * serdev is the bus for serial devices that are *not* ttys: a modem, a
8 * Bluetooth controller, a touch panel hanging off UART2, each claimed by a
9 * client driver instead of appearing as a /dev/tty node. It is configured
10 * with CONFIG_SERIAL_DEV_CTRL_TTYPORT, and this kernel does not have that --
11 * there is no device tree to say which port carries one (see <linux/of.h>),
12 * no client drivers, and Xeneva's UARTs are wired to consoles.
13 *
14 * So this header is mainline's *#else* branch. That is worth stating
15 * precisely: the ERR_PTR(-ENODEV) below is not a DCL stand-in invented for a
16 * function nobody ported, it is the answer upstream gives for exactly this
17 * configuration -- the branch that runs when the option is off. The value is
18 * also the one both callers branch on, and both go the way this needs:
19 *
20 * tty_port.c:206 `dev = serdev_tty_port_register(...);
21 * if (PTR_ERR(dev) != -ENODEV) return dev;`
22 * -ENODEV fails the test, so the port falls through to
23 * tty_register_device_attr() and gets a /dev/tty node -- the correct
24 * outcome for a port with no serdev client. Returning NULL would have
25 * taken the early return instead and created no device at all, with
26 * nothing to say why.
27 *
28 * tty_port.c:233 `ret = serdev_tty_port_unregister(port);
29 * if (ret == 0) return;`
30 * -ENODEV is not 0, so tty_unregister_device() still runs and the node
31 * goes away. Returning 0 would have skipped it and left the device
32 * registered after the port was gone.
33 *
34 * The (void) casts on each parameter are the one departure from the upstream
35 * text: DCL builds with -Wextra, which flags an unused parameter that a
36 * kernel build does not, and a header that is quiet everywhere else should
37 * not be the source of six warnings.
38 *
39 * upstream include/linux/serdev.h (mainline v7.2), #else branch
40 */
41
42#include <linux/err.h> /* ERR_PTR */
43#include <linux/errno.h> /* ENODEV */
44
45struct tty_port;
46struct device;
47struct tty_driver;
48
49static inline struct device* serdev_tty_port_register(struct tty_port* port,
50 struct device* host,
51 struct device* parent,
52 struct tty_driver* drv,
53 int idx)
54{
55 (void)port;
56 (void)host;
57 (void)parent;
58 (void)drv;
59 (void)idx;
60 return ERR_PTR(-ENODEV);
61}
62
63static inline int serdev_tty_port_unregister(struct tty_port* port)
64{
65 (void)port;
66 return -ENODEV;
67}
68
69#endif /* __LINUX_SERDEV_H__ */
#define ENODEV
Definition acclib.h:197
#define ERR_PTR(err)
Definition err.h:51
struct kobject * parent
Definition kobject.h:91
Definition fs.h:255
Definition tty_driver.h:122
Definition tty_port.h:79