Skip to content

Commit fc7e560

Browse files
gregkhvinodkoul
authored andcommitted
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 <[email protected]> Cc: Bard Liao <[email protected]> Cc: Pierre-Louis Bossart <[email protected]> Cc: Sanyog Kale <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Dan Williams <[email protected]> Tested-By: Vijendar Mukunda <[email protected]> Link: https://lore.kernel.org/r/2024013030-worsening-rocket-a3cb@gregkh Signed-off-by: Vinod Koul <[email protected]>
1 parent 3ee43f7 commit fc7e560

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

drivers/soundwire/bus_type.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ int __sdw_register_driver(struct sdw_driver *drv, struct module *owner)
221221
drv->driver.probe = sdw_drv_probe;
222222
drv->driver.remove = sdw_drv_remove;
223223
drv->driver.shutdown = sdw_drv_shutdown;
224+
drv->driver.dev_groups = sdw_attr_groups;
224225

225226
return driver_register(&drv->driver);
226227
}

drivers/soundwire/sysfs_local.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
/* basic attributes to report status of Slave (attachment, dev_num) */
1212
extern const struct attribute_group *sdw_slave_status_attr_groups[];
1313

14+
/* attributes for all soundwire devices */
15+
extern const struct attribute_group *sdw_attr_groups[];
16+
1417
/* additional device-managed properties reported after driver probe */
1518
int sdw_slave_sysfs_init(struct sdw_slave *slave);
1619
int sdw_slave_sysfs_dpn_init(struct sdw_slave *slave);

drivers/soundwire/sysfs_slave.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static const struct attribute_group dp0_group = {
214214
.name = "dp0",
215215
};
216216

217-
static const struct attribute_group *slave_groups[] = {
217+
const struct attribute_group *sdw_attr_groups[] = {
218218
&slave_attr_group,
219219
&sdw_slave_dev_attr_group,
220220
&dp0_group,
@@ -225,10 +225,6 @@ int sdw_slave_sysfs_init(struct sdw_slave *slave)
225225
{
226226
int ret;
227227

228-
ret = devm_device_add_groups(&slave->dev, slave_groups);
229-
if (ret < 0)
230-
return ret;
231-
232228
if (slave->prop.source_ports || slave->prop.sink_ports) {
233229
ret = sdw_slave_sysfs_dpn_init(slave);
234230
if (ret < 0)

0 commit comments

Comments
 (0)