Skip to content

Commit 2e07017

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

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

  • drivers/soundwire
  • include/linux/soundwire

drivers/soundwire/bus.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,18 @@ int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base)
13601360
}
13611361
EXPORT_SYMBOL(sdw_slave_get_scale_index);
13621362

1363+
int sdw_slave_get_current_bank(struct sdw_slave *slave)
1364+
{
1365+
int tmp;
1366+
1367+
tmp = sdw_read(slave, SDW_SCP_CTRL);
1368+
if (tmp < 0)
1369+
return tmp;
1370+
1371+
return FIELD_GET(SDW_SCP_STAT_CURR_BANK, tmp);
1372+
}
1373+
EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank);
1374+
13631375
static int sdw_slave_set_frequency(struct sdw_slave *slave)
13641376
{
13651377
int scale_index;

include/linux/soundwire/sdw.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,8 @@ int sdw_stream_remove_slave(struct sdw_slave *slave,
10891089

10901090
struct device *of_sdw_find_device_by_node(struct device_node *np);
10911091

1092+
int sdw_slave_get_current_bank(struct sdw_slave *sdev);
1093+
10921094
int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
10931095

10941096
/* messaging and data APIs */
@@ -1128,6 +1130,12 @@ static inline struct device *of_sdw_find_device_by_node(struct device_node *np)
11281130
return NULL;
11291131
}
11301132

1133+
static inline int sdw_slave_get_current_bank(struct sdw_slave *sdev)
1134+
{
1135+
WARN_ONCE(1, "SoundWire API is disabled");
1136+
return -EINVAL;
1137+
}
1138+
11311139
/* messaging and data APIs */
11321140
static inline int sdw_read(struct sdw_slave *slave, u32 addr)
11331141
{

0 commit comments

Comments
 (0)