Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soundwire: bus: add enumerated Slave device to device list

Currently Slave devices are only added on startup, either from Device
Tree or ACPI entries. However Slave devices that are physically
present on the bus, but not described in platform firmware, will never
be added to the device list. The user/integrator can only know the
list of devices by looking a dynamic debug logs.

This patch suggests adding a Slave device even if there is no matching
DT or ACPI entry, so that we can see this in sysfs entry.

Initial code from Srinivas. Comments, fixes for ACPI probe and edits
of commit message by Pierre.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Co-developed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200924194430.121058-2-pierre-louis.bossart@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Srinivas Kandagatla and committed by
Vinod Koul
fcb9d730 5ec3215e

+22 -2
+9
drivers/soundwire/bus.c
··· 747 747 748 748 if (!found) { 749 749 /* TODO: Park this device in Group 13 */ 750 + 751 + /* 752 + * add Slave device even if there is no platform 753 + * firmware description. There will be no driver probe 754 + * but the user/integration will be able to see the 755 + * device, enumeration status and device number in sysfs 756 + */ 757 + sdw_slave_add(bus, &id, NULL); 758 + 750 759 dev_err(bus->dev, "Slave Entry not found\n"); 751 760 } 752 761
+2
drivers/soundwire/bus.h
··· 19 19 int sdw_of_find_slaves(struct sdw_bus *bus); 20 20 void sdw_extract_slave_id(struct sdw_bus *bus, 21 21 u64 addr, struct sdw_slave_id *id); 22 + int sdw_slave_add(struct sdw_bus *bus, struct sdw_slave_id *id, 23 + struct fwnode_handle *fwnode); 22 24 int sdw_master_device_add(struct sdw_bus *bus, struct device *parent, 23 25 struct fwnode_handle *fwnode); 24 26 int sdw_master_device_del(struct sdw_bus *bus);
+9
drivers/soundwire/bus_type.c
··· 84 84 const struct sdw_device_id *id; 85 85 int ret; 86 86 87 + /* 88 + * fw description is mandatory to bind 89 + */ 90 + if (!dev->fwnode) 91 + return -ENODEV; 92 + 93 + if (!IS_ENABLED(CONFIG_ACPI) && !dev->of_node) 94 + return -ENODEV; 95 + 87 96 id = sdw_get_device_id(slave, drv); 88 97 if (!id) 89 98 return -ENODEV;
+2 -2
drivers/soundwire/slave.c
··· 20 20 .uevent = sdw_slave_uevent, 21 21 }; 22 22 23 - static int sdw_slave_add(struct sdw_bus *bus, 24 - struct sdw_slave_id *id, struct fwnode_handle *fwnode) 23 + int sdw_slave_add(struct sdw_bus *bus, 24 + struct sdw_slave_id *id, struct fwnode_handle *fwnode) 25 25 { 26 26 struct sdw_slave *slave; 27 27 int ret;