asoc: swr: Fix logic to retrieve swr slave device handle

Fix issue in the loop logic of retrieving swr slave device handle
by passing device node.

Change-Id: I5c31259b1257de730748b8522537afa9870f24e4
Signed-off-by: Ramprasad Katkam <katkam@codeaurora.org>
This commit is contained in:
Ramprasad Katkam 2018-08-28 02:56:15 +05:30
parent 9c2394a6e4
commit a72eb7843a

View file

@ -796,18 +796,24 @@ struct swr_device *get_matching_swr_slave_device(struct device_node *np)
{ {
struct swr_device *swr = NULL; struct swr_device *swr = NULL;
struct swr_master *master; struct swr_master *master;
bool found = false;
mutex_lock(&board_lock); mutex_lock(&board_lock);
list_for_each_entry(master, &swr_master_list, list) { list_for_each_entry(master, &swr_master_list, list) {
mutex_lock(&master->mlock); mutex_lock(&master->mlock);
list_for_each_entry(swr, &master->devices, dev_list) { list_for_each_entry(swr, &master->devices, dev_list) {
if (swr->dev.of_node == np) if (swr->dev.of_node == np) {
break; found = true;
mutex_unlock(&master->mlock);
goto exit;
}
} }
mutex_unlock(&master->mlock); mutex_unlock(&master->mlock);
} }
exit:
mutex_unlock(&board_lock); mutex_unlock(&board_lock);
if (!found)
return NULL;
return swr; return swr;
} }
EXPORT_SYMBOL(get_matching_swr_slave_device); EXPORT_SYMBOL(get_matching_swr_slave_device);
@ -888,7 +894,6 @@ int swr_register_master(struct swr_master *master)
id = idr_alloc(&master_idr, master, master->bus_num, id = idr_alloc(&master_idr, master, master->bus_num,
master->bus_num + 1, GFP_KERNEL); master->bus_num + 1, GFP_KERNEL);
mutex_unlock(&swr_lock); mutex_unlock(&swr_lock);
if (id < 0) if (id < 0)
return id; return id;