Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / linux / siox.h
blob6bfbda3f634c2d7cb48fd057656e8e2c5b2d6f43
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (C) 2015 Pengutronix, Uwe Kleine-König <kernel@pengutronix.de>
4 */
6 #include <linux/device.h>
8 #define to_siox_device(_dev) container_of((_dev), struct siox_device, dev)
9 struct siox_device {
10 struct list_head node; /* node in smaster->devices */
11 struct siox_master *smaster;
12 struct device dev;
14 const char *type;
15 size_t inbytes;
16 size_t outbytes;
17 u8 statustype;
19 u8 status_read_clean;
20 u8 status_written;
21 u8 status_written_lastcycle;
22 bool connected;
24 /* statistics */
25 unsigned int watchdog_errors;
26 unsigned int status_errors;
28 struct kernfs_node *status_errors_kn;
29 struct kernfs_node *watchdog_kn;
30 struct kernfs_node *watchdog_errors_kn;
31 struct kernfs_node *connected_kn;
34 bool siox_device_synced(struct siox_device *sdevice);
35 bool siox_device_connected(struct siox_device *sdevice);
37 struct siox_driver {
38 int (*probe)(struct siox_device *sdevice);
39 void (*remove)(struct siox_device *sdevice);
40 void (*shutdown)(struct siox_device *sdevice);
43 * buf is big enough to hold sdev->inbytes - 1 bytes, the status byte
44 * is in the scope of the framework.
46 int (*set_data)(struct siox_device *sdevice, u8 status, u8 buf[]);
48 * buf is big enough to hold sdev->outbytes - 1 bytes, the status byte
49 * is in the scope of the framework
51 int (*get_data)(struct siox_device *sdevice, const u8 buf[]);
53 struct device_driver driver;
56 static inline struct siox_driver *to_siox_driver(struct device_driver *driver)
58 if (driver)
59 return container_of(driver, struct siox_driver, driver);
60 else
61 return NULL;
64 int __siox_driver_register(struct siox_driver *sdriver, struct module *owner);
66 static inline int siox_driver_register(struct siox_driver *sdriver)
68 return __siox_driver_register(sdriver, THIS_MODULE);
71 static inline void siox_driver_unregister(struct siox_driver *sdriver)
73 return driver_unregister(&sdriver->driver);
77 * module_siox_driver() - Helper macro for drivers that don't do
78 * anything special in module init/exit. This eliminates a lot of
79 * boilerplate. Each module may only use this macro once, and
80 * calling it replaces module_init() and module_exit()
82 #define module_siox_driver(__siox_driver) \
83 module_driver(__siox_driver, siox_driver_register, \
84 siox_driver_unregister)