]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
soundwire: bus: add sdw_slave_get_current_bank helper
authorSrinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>
Tue, 9 Sep 2025 12:19:45 +0000 (13:19 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 18 Sep 2025 21:24:27 +0000 (22:24 +0100)
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>
drivers/soundwire/bus.c
include/linux/soundwire/sdw.h

index 4fd5cac799c547d35cf15bee554408a987ea4d6c..55c1db81653400e36a9ad9a5f4394f23a49e1bbe 100644 (file)
@@ -1360,6 +1360,18 @@ int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base)
 }
 EXPORT_SYMBOL(sdw_slave_get_scale_index);
 
+int sdw_slave_get_current_bank(struct sdw_slave *slave)
+{
+       int tmp;
+
+       tmp = sdw_read(slave, SDW_SCP_CTRL);
+       if (tmp < 0)
+               return tmp;
+
+       return FIELD_GET(SDW_SCP_STAT_CURR_BANK, tmp);
+}
+EXPORT_SYMBOL_GPL(sdw_slave_get_current_bank);
+
 static int sdw_slave_set_frequency(struct sdw_slave *slave)
 {
        int scale_index;
index 096213956d311cf44d2f212dc9d969a8b21aff41..e6a3476bcef1ae99973728690d32bd4e6a73e2a3 100644 (file)
@@ -1089,6 +1089,8 @@ int sdw_stream_remove_slave(struct sdw_slave *slave,
 
 struct device *of_sdw_find_device_by_node(struct device_node *np);
 
+int sdw_slave_get_current_bank(struct sdw_slave *sdev);
+
 int sdw_slave_get_scale_index(struct sdw_slave *slave, u8 *base);
 
 /* messaging and data APIs */
@@ -1128,6 +1130,12 @@ static inline struct device *of_sdw_find_device_by_node(struct device_node *np)
        return NULL;
 }
 
+static inline int sdw_slave_get_current_bank(struct sdw_slave *sdev)
+{
+       WARN_ONCE(1, "SoundWire API is disabled");
+       return -EINVAL;
+}
+
 /* messaging and data APIs */
 static inline int sdw_read(struct sdw_slave *slave, u32 addr)
 {