1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (C) 2015 Pengutronix, Uwe Kleine-König <kernel@pengutronix.de>
6 #include <linux/device.h>
8 #define to_siox_device(_dev) container_of((_dev), struct siox_device, dev)
10 struct list_head node; /* node in smaster->devices */
11 struct siox_master *smaster;
21 u8 status_written_lastcycle;
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);
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)
59 return container_of(driver, struct siox_driver, driver);
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)