1/* SPDX-License-Identifier: GPL-2.0 */ 2/* Copyright(c) 2015-17 Intel Corporation. */ 3 4#ifndef __SOUNDWIRE_TYPES_H 5#define __SOUNDWIRE_TYPES_H 6 7extern struct bus_type sdw_bus_type; 8extern struct device_type sdw_slave_type; 9extern struct device_type sdw_master_type; 10 11static inline int is_sdw_slave(const struct device *dev) 12{ 13 return dev->type == &sdw_slave_type; 14} 15 16#define drv_to_sdw_driver(_drv) container_of(_drv, struct sdw_driver, driver) 17 18#define sdw_register_driver(drv) \ 19 __sdw_register_driver(drv, THIS_MODULE) 20 21int __sdw_register_driver(struct sdw_driver *drv, struct module *owner); 22void sdw_unregister_driver(struct sdw_driver *drv); 23 24int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env); 25 26/** 27 * module_sdw_driver() - Helper macro for registering a Soundwire driver 28 * @__sdw_driver: soundwire slave driver struct 29 * 30 * Helper macro for Soundwire drivers which do not do anything special in 31 * module init/exit. This eliminates a lot of boilerplate. Each module may only 32 * use this macro once, and calling it replaces module_init() and module_exit() 33 */ 34#define module_sdw_driver(__sdw_driver) \ 35 module_driver(__sdw_driver, sdw_register_driver, \ 36 sdw_unregister_driver) 37#endif /* __SOUNDWIRE_TYPES_H */ 38