[PATCH v2 1/2] soundwire: bus: add enumerated Slave device to device list

Vinod Koul vkoul at kernel.org
Fri Sep 18 14:05:02 CEST 2020


On 17-09-20, 11:00, Pierre-Louis Bossart wrote:
> From: Srinivas Kandagatla <srinivas.kandagatla at linaro.org>
> 
> 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 eveb 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.

You should add yours as Co-developed. That is the standard tag for these
things

> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla at linaro.org>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
> ---
>  drivers/soundwire/bus.c      | 9 +++++++++
>  drivers/soundwire/bus.h      | 2 ++
>  drivers/soundwire/bus_type.c | 9 +++++++++
>  drivers/soundwire/slave.c    | 4 ++--
>  4 files changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c
> index 02574b4bb179..81807b332a12 100644
> --- a/drivers/soundwire/bus.c
> +++ b/drivers/soundwire/bus.c
> @@ -741,6 +741,15 @@ static int sdw_program_device_num(struct sdw_bus *bus)
>  
>  		if (!found) {
>  			/* TODO: Park this device in Group 13 */
> +
> +			/*
> +			 * add Slave device even if there is no platform
> +			 * firmware description. There will be no driver probe
> +			 * but the user/integration will be able to see the
> +			 * device, enumeration status and device number in sysfs
> +			 */
> +			sdw_slave_add(bus, &id, NULL);
> +
>  			dev_err(bus->dev, "Slave Entry not found\n");
>  		}
>  
> diff --git a/drivers/soundwire/bus.h b/drivers/soundwire/bus.h
> index c53345fbc4c7..fd251c1eb925 100644
> --- a/drivers/soundwire/bus.h
> +++ b/drivers/soundwire/bus.h
> @@ -19,6 +19,8 @@ static inline int sdw_acpi_find_slaves(struct sdw_bus *bus)
>  int sdw_of_find_slaves(struct sdw_bus *bus);
>  void sdw_extract_slave_id(struct sdw_bus *bus,
>  			  u64 addr, struct sdw_slave_id *id);
> +int sdw_slave_add(struct sdw_bus *bus, struct sdw_slave_id *id,
> +		  struct fwnode_handle *fwnode);
>  int sdw_master_device_add(struct sdw_bus *bus, struct device *parent,
>  			  struct fwnode_handle *fwnode);
>  int sdw_master_device_del(struct sdw_bus *bus);
> diff --git a/drivers/soundwire/bus_type.c b/drivers/soundwire/bus_type.c
> index 6fba55898cf0..575b9bad99d5 100644
> --- a/drivers/soundwire/bus_type.c
> +++ b/drivers/soundwire/bus_type.c
> @@ -84,6 +84,15 @@ static int sdw_drv_probe(struct device *dev)
>  	const struct sdw_device_id *id;
>  	int ret;
>  
> +	/*
> +	 * fw description is mandatory to bind
> +	 */
> +	if (!dev->fwnode)
> +		return -ENODEV;
> +
> +	if (!IS_ENABLED(CONFIG_ACPI) && !dev->of_node)
> +		return -ENODEV;
> +
>  	id = sdw_get_device_id(slave, drv);
>  	if (!id)
>  		return -ENODEV;
> diff --git a/drivers/soundwire/slave.c b/drivers/soundwire/slave.c
> index 4a250d33de5d..19b012310c29 100644
> --- a/drivers/soundwire/slave.c
> +++ b/drivers/soundwire/slave.c
> @@ -20,8 +20,8 @@ struct device_type sdw_slave_type = {
>  	.uevent =	sdw_slave_uevent,
>  };
>  
> -static int sdw_slave_add(struct sdw_bus *bus,
> -			 struct sdw_slave_id *id, struct fwnode_handle *fwnode)
> +int sdw_slave_add(struct sdw_bus *bus,
> +		  struct sdw_slave_id *id, struct fwnode_handle *fwnode)
>  {
>  	struct sdw_slave *slave;
>  	int ret;
> -- 
> 2.25.1

-- 
~Vinod


More information about the Alsa-devel mailing list