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

soundwire: return earlier if no slave is attached

If there is no slave attached to soundwire bus, we
can return earlier from sdw_bus_prep_clk_stop() and
sdw_bus_exit_clk_stop(), this saves a redundant value
check.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20210126085439.4349-1-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Chao Song and committed by
Vinod Koul
18de2f72 f1b69026

+9 -12
+9 -12
drivers/soundwire/bus.c
··· 951 951 simple_clk_stop = false; 952 952 } 953 953 954 - if (is_slave && !simple_clk_stop) { 954 + /* Skip remaining clock stop preparation if no Slave is attached */ 955 + if (!is_slave) 956 + return ret; 957 + 958 + if (!simple_clk_stop) { 955 959 ret = sdw_bus_wait_for_clk_prep_deprep(bus, 956 960 SDW_BROADCAST_DEV_NUM); 957 961 if (ret < 0) 958 962 return ret; 959 963 } 960 - 961 - /* Don't need to inform slaves if there is no slave attached */ 962 - if (!is_slave) 963 - return ret; 964 964 965 965 /* Inform slaves that prep is done */ 966 966 list_for_each_entry(slave, &bus->slaves, node) { ··· 1075 1075 "clk stop deprep failed:%d", ret); 1076 1076 } 1077 1077 1078 - if (is_slave && !simple_clk_stop) 1079 - sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM); 1080 - 1081 - /* 1082 - * Don't need to call slave callback function if there is no slave 1083 - * attached 1084 - */ 1078 + /* Skip remaining clock stop de-preparation if no Slave is attached */ 1085 1079 if (!is_slave) 1086 1080 return 0; 1081 + 1082 + if (!simple_clk_stop) 1083 + sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM); 1087 1084 1088 1085 list_for_each_entry(slave, &bus->slaves, node) { 1089 1086 if (!slave->dev_num)