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

soundwire: sysfs: have the driver core handle the creation of the device groups

The driver core supports the ability to handle the creation and removal
of device-specific sysfs files in a race-free manner. Take advantage of
that by converting this driver to use this by moving the sysfs
attributes into a group and assigning the dev_groups pointer to it.

Cc: Vinod Koul <vkoul@kernel.org>
Cc: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Sanyog Kale <sanyog.r.kale@intel.com>
Cc: alsa-devel@alsa-project.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Tested-By: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Link: https://lore.kernel.org/r/2024013030-worsening-rocket-a3cb@gregkh
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Greg Kroah-Hartman and committed by
Vinod Koul
fc7e5601 3ee43f7c

+5 -5
+1
drivers/soundwire/bus_type.c
··· 221 221 drv->driver.probe = sdw_drv_probe; 222 222 drv->driver.remove = sdw_drv_remove; 223 223 drv->driver.shutdown = sdw_drv_shutdown; 224 + drv->driver.dev_groups = sdw_attr_groups; 224 225 225 226 return driver_register(&drv->driver); 226 227 }
+3
drivers/soundwire/sysfs_local.h
··· 11 11 /* basic attributes to report status of Slave (attachment, dev_num) */ 12 12 extern const struct attribute_group *sdw_slave_status_attr_groups[]; 13 13 14 + /* attributes for all soundwire devices */ 15 + extern const struct attribute_group *sdw_attr_groups[]; 16 + 14 17 /* additional device-managed properties reported after driver probe */ 15 18 int sdw_slave_sysfs_init(struct sdw_slave *slave); 16 19 int sdw_slave_sysfs_dpn_init(struct sdw_slave *slave);
+1 -5
drivers/soundwire/sysfs_slave.c
··· 214 214 .name = "dp0", 215 215 }; 216 216 217 - static const struct attribute_group *slave_groups[] = { 217 + const struct attribute_group *sdw_attr_groups[] = { 218 218 &slave_attr_group, 219 219 &sdw_slave_dev_attr_group, 220 220 &dp0_group, ··· 224 224 int sdw_slave_sysfs_init(struct sdw_slave *slave) 225 225 { 226 226 int ret; 227 - 228 - ret = devm_device_add_groups(&slave->dev, slave_groups); 229 - if (ret < 0) 230 - return ret; 231 227 232 228 if (slave->prop.source_ports || slave->prop.sink_ports) { 233 229 ret = sdw_slave_sysfs_dpn_init(slave);