1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2023 Ideas On Board Oy 4 */ 5 6 #ifndef _VCHIQ_DEVICE_H 7 #define _VCHIQ_DEVICE_H 8 9 #include <linux/device.h> 10 #include <linux/mod_devicetable.h> 11 12 struct vchiq_drv_mgmt; 13 14 struct vchiq_device { 15 struct device dev; 16 struct vchiq_drv_mgmt *drv_mgmt; 17 }; 18 19 struct vchiq_driver { 20 int (*probe)(struct vchiq_device *device); 21 void (*remove)(struct vchiq_device *device); 22 int (*resume)(struct vchiq_device *device); 23 int (*suspend)(struct vchiq_device *device, 24 pm_message_t state); 25 26 const struct vchiq_device_id *id_table; 27 struct device_driver driver; 28 }; 29 to_vchiq_device(struct device * d)30static inline struct vchiq_device *to_vchiq_device(struct device *d) 31 { 32 return container_of(d, struct vchiq_device, dev); 33 } 34 to_vchiq_driver(struct device_driver * d)35static inline struct vchiq_driver *to_vchiq_driver(struct device_driver *d) 36 { 37 return container_of(d, struct vchiq_driver, driver); 38 } 39 40 extern const struct bus_type vchiq_bus_type; 41 42 struct vchiq_device * 43 vchiq_device_register(struct device *parent, const char *name); 44 void vchiq_device_unregister(struct vchiq_device *dev); 45 46 int vchiq_driver_register(struct vchiq_driver *vchiq_drv); 47 void vchiq_driver_unregister(struct vchiq_driver *vchiq_drv); 48 49 /** 50 * module_vchiq_driver() - Helper macro for registering a vchiq driver 51 * @__vchiq_driver: vchiq driver struct 52 * 53 * Helper macro for vchiq drivers which do not do anything special in 54 * module init/exit. This eliminates a lot of boilerplate. Each module may only 55 * use this macro once, and calling it replaces module_init() and module_exit() 56 */ 57 #define module_vchiq_driver(__vchiq_driver) \ 58 module_driver(__vchiq_driver, vchiq_driver_register, vchiq_driver_unregister) 59 60 #endif /* _VCHIQ_DEVICE_H */ 61