Skip to content

Commit

Permalink
soundwire: test is_slave before list_for_each_entry(slave, &bus->slav…
Browse files Browse the repository at this point in the history
…es, node)

We don't need to test each slave's status if we already know there
is no slave attached.

Signed-off-by: Bard Liao <[email protected]>
  • Loading branch information
bardliao authored and plbossart committed Dec 13, 2019
1 parent 791e176 commit 07ac7cd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/soundwire/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,10 @@ int sdw_bus_prep_clk_stop(struct sdw_bus *bus)
return ret;
}

/* Don't need to inform slaves if there is no slave attached */
if (!is_slave)
return ret;

/* Inform slaves that prep is done */
list_for_each_entry(slave, &bus->slaves, node) {
if (!slave->dev_num)
Expand Down Expand Up @@ -1006,6 +1010,13 @@ int sdw_bus_exit_clk_stop(struct sdw_bus *bus)
if (is_slave && !simple_clk_stop)
sdw_bus_wait_for_clk_prep_deprep(bus, SDW_BROADCAST_DEV_NUM);

/*
* Don't need to call slave callback function if there is no slave
* attached
*/
if (!is_slave)
return 0;

list_for_each_entry(slave, &bus->slaves, node) {
if (!slave->dev_num)
continue;
Expand Down

0 comments on commit 07ac7cd

Please sign in to comment.