Skip to content

Commit 76cffc3

Browse files
Srinivas Kandagatlabroonie
authored andcommitted
soundwire: bus: add of_sdw_find_device_by_node helper
There has been more than 3 instances of this helper in multiple codec drivers, it does not make sense to keep duplicating this part of code. Lets add a helper of_sdw_find_device_by_node for codec drivers to use it. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Acked-by: Vinod Koul <vkoul@kernel.org> Link: https://patch.msgid.link/20250909121954.225833-4-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c4bb62e commit 76cffc3

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/soundwire/slave.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,10 @@ int sdw_of_find_slaves(struct sdw_bus *bus)
273273
return 0;
274274
}
275275

276+
struct device *of_sdw_find_device_by_node(struct device_node *np)
277+
{
278+
return bus_find_device_by_of_node(&sdw_bus_type, np);
279+
}
280+
EXPORT_SYMBOL_GPL(of_sdw_find_device_by_node);
281+
276282
MODULE_IMPORT_NS("SND_SOC_SDCA");

include/linux/soundwire/sdw.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
struct dentry;
2121
struct fwnode_handle;
22+
struct device_node;
2223

2324
struct sdw_bus;
2425
struct sdw_slave;
@@ -1086,6 +1087,8 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
10861087
int sdw_stream_remove_slave(struct sdw_slave *slave,
10871088
struct sdw_stream_runtime *stream);
10881089

1090+
struct device *of_sdw_find_device_by_node(struct device_node *np);
1091+
10891092
int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
10901093

10911094
/* messaging and data APIs */
@@ -1119,6 +1122,12 @@ static inline int sdw_stream_remove_slave(struct sdw_slave *slave,
11191122
return -EINVAL;
11201123
}
11211124

1125+
static inline struct device *of_sdw_find_device_by_node(struct device_node *np)
1126+
{
1127+
WARN_ONCE(1, "SoundWire API is disabled");
1128+
return NULL;
1129+
}
1130+
11221131
/* messaging and data APIs */
11231132
static inline int sdw_read(struct sdw_slave *slave, u32 addr)
11241133
{

0 commit comments

Comments
 (0)