mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-12 00:00:00 +00:00
soundwire: bus_type: introduce sdw_slave_type and sdw_master_type
this is a preparatory patch before the introduction of the sdw_master_type. The SoundWire slave support is slightly modified with the use of a sdw_slave_type, and the uevent handling move to slave.c (since it's not necessary for the master). No functionality change other than moving code around. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Acked-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20200518174322.31561-3-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
5cab3ff248
commit
90acca1d54
@ -33,13 +33,21 @@ sdw_get_device_id(struct sdw_slave *slave, struct sdw_driver *drv)
|
||||
|
||||
static int sdw_bus_match(struct device *dev, struct device_driver *ddrv)
|
||||
{
|
||||
struct sdw_slave *slave = dev_to_sdw_dev(dev);
|
||||
struct sdw_driver *drv = drv_to_sdw_driver(ddrv);
|
||||
struct sdw_slave *slave;
|
||||
struct sdw_driver *drv;
|
||||
int ret = 0;
|
||||
|
||||
return !!sdw_get_device_id(slave, drv);
|
||||
if (is_sdw_slave(dev)) {
|
||||
slave = dev_to_sdw_dev(dev);
|
||||
drv = drv_to_sdw_driver(ddrv);
|
||||
|
||||
ret = !!sdw_get_device_id(slave, drv);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size)
|
||||
static int sdw_slave_modalias(const struct sdw_slave *slave, char *buf,
|
||||
size_t size)
|
||||
{
|
||||
/* modalias is sdw:m<mfg_id>p<part_id> */
|
||||
|
||||
@ -47,7 +55,7 @@ int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size)
|
||||
slave->id.mfg_id, slave->id.part_id);
|
||||
}
|
||||
|
||||
static int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)
|
||||
int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env)
|
||||
{
|
||||
struct sdw_slave *slave = dev_to_sdw_dev(dev);
|
||||
char modalias[32];
|
||||
@ -63,7 +71,6 @@ static int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)
|
||||
struct bus_type sdw_bus_type = {
|
||||
.name = "soundwire",
|
||||
.match = sdw_bus_match,
|
||||
.uevent = sdw_uevent,
|
||||
};
|
||||
EXPORT_SYMBOL_GPL(sdw_bus_type);
|
||||
|
||||
|
@ -14,6 +14,12 @@ static void sdw_slave_release(struct device *dev)
|
||||
kfree(slave);
|
||||
}
|
||||
|
||||
struct device_type sdw_slave_type = {
|
||||
.name = "sdw_slave",
|
||||
.release = sdw_slave_release,
|
||||
.uevent = sdw_slave_uevent,
|
||||
};
|
||||
|
||||
static int sdw_slave_add(struct sdw_bus *bus,
|
||||
struct sdw_slave_id *id, struct fwnode_handle *fwnode)
|
||||
{
|
||||
@ -41,9 +47,9 @@ static int sdw_slave_add(struct sdw_bus *bus,
|
||||
id->class_id, id->unique_id);
|
||||
}
|
||||
|
||||
slave->dev.release = sdw_slave_release;
|
||||
slave->dev.bus = &sdw_bus_type;
|
||||
slave->dev.of_node = of_node_get(to_of_node(fwnode));
|
||||
slave->dev.type = &sdw_slave_type;
|
||||
slave->bus = bus;
|
||||
slave->status = SDW_SLAVE_UNATTACHED;
|
||||
init_completion(&slave->enumeration_complete);
|
||||
|
@ -5,6 +5,13 @@
|
||||
#define __SOUNDWIRE_TYPES_H
|
||||
|
||||
extern struct bus_type sdw_bus_type;
|
||||
extern struct device_type sdw_slave_type;
|
||||
extern struct device_type sdw_master_type;
|
||||
|
||||
static inline int is_sdw_slave(const struct device *dev)
|
||||
{
|
||||
return dev->type == &sdw_slave_type;
|
||||
}
|
||||
|
||||
#define drv_to_sdw_driver(_drv) container_of(_drv, struct sdw_driver, driver)
|
||||
|
||||
@ -14,7 +21,7 @@ extern struct bus_type sdw_bus_type;
|
||||
int __sdw_register_driver(struct sdw_driver *drv, struct module *owner);
|
||||
void sdw_unregister_driver(struct sdw_driver *drv);
|
||||
|
||||
int sdw_slave_modalias(const struct sdw_slave *slave, char *buf, size_t size);
|
||||
int sdw_slave_uevent(struct device *dev, struct kobj_uevent_env *env);
|
||||
|
||||
/**
|
||||
* module_sdw_driver() - Helper macro for registering a Soundwire driver
|
||||
|
Loading…
x
Reference in New Issue
Block a user