Commit d281a982 authored by Jakob Koschel's avatar Jakob Koschel Committed by Nishanth Menon

soc: ti: replace usage of found with dedicated list iterator variable

To move the list iterator variable into the list_for_each_entry_*()
macro in the future it should be avoided to use the list iterator
variable after the loop body.

To *never* use the list iterator variable after the loop it was
concluded to use a separate iterator variable instead of a
found boolean [1].

This removes the need to use a found variable and simply checking if
the variable was set, can determine if the break/goto was hit.
Signed-off-by: default avatarJakob Koschel <jakobkoschel@gmail.com>
Signed-off-by: default avatarNishanth Menon <nm@ti.com>
Reviewed-by: default avatarVignesh Raghavendra <vigneshr@ti.com>
Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/
Link: https://lore.kernel.org/r/20220324072503.63244-1-jakobkoschel@gmail.com
parent c2b03901
...@@ -415,9 +415,8 @@ static int of_channel_match_helper(struct device_node *np, const char *name, ...@@ -415,9 +415,8 @@ static int of_channel_match_helper(struct device_node *np, const char *name,
void *knav_dma_open_channel(struct device *dev, const char *name, void *knav_dma_open_channel(struct device *dev, const char *name,
struct knav_dma_cfg *config) struct knav_dma_cfg *config)
{ {
struct knav_dma_chan *chan; struct knav_dma_device *dma = NULL, *iter1;
struct knav_dma_device *dma; struct knav_dma_chan *chan = NULL, *iter2;
bool found = false;
int chan_num = -1; int chan_num = -1;
const char *instance; const char *instance;
...@@ -444,33 +443,32 @@ void *knav_dma_open_channel(struct device *dev, const char *name, ...@@ -444,33 +443,32 @@ void *knav_dma_open_channel(struct device *dev, const char *name,
} }
/* Look for correct dma instance */ /* Look for correct dma instance */
list_for_each_entry(dma, &kdev->list, list) { list_for_each_entry(iter1, &kdev->list, list) {
if (!strcmp(dma->name, instance)) { if (!strcmp(iter1->name, instance)) {
found = true; dma = iter1;
break; break;
} }
} }
if (!found) { if (!dma) {
dev_err(kdev->dev, "No DMA instance with name %s\n", instance); dev_err(kdev->dev, "No DMA instance with name %s\n", instance);
return (void *)-EINVAL; return (void *)-EINVAL;
} }
/* Look for correct dma channel from dma instance */ /* Look for correct dma channel from dma instance */
found = false; list_for_each_entry(iter2, &dma->chan_list, list) {
list_for_each_entry(chan, &dma->chan_list, list) {
if (config->direction == DMA_MEM_TO_DEV) { if (config->direction == DMA_MEM_TO_DEV) {
if (chan->channel == chan_num) { if (iter2->channel == chan_num) {
found = true; chan = iter2;
break; break;
} }
} else { } else {
if (chan->flow == chan_num) { if (iter2->flow == chan_num) {
found = true; chan = iter2;
break; break;
} }
} }
} }
if (!found) { if (!chan) {
dev_err(kdev->dev, "channel %d is not in DMA %s\n", dev_err(kdev->dev, "channel %d is not in DMA %s\n",
chan_num, instance); chan_num, instance);
return (void *)-EINVAL; return (void *)-EINVAL;
......
...@@ -758,10 +758,9 @@ void *knav_pool_create(const char *name, ...@@ -758,10 +758,9 @@ void *knav_pool_create(const char *name,
int num_desc, int region_id) int num_desc, int region_id)
{ {
struct knav_region *reg_itr, *region = NULL; struct knav_region *reg_itr, *region = NULL;
struct knav_pool *pool, *pi; struct knav_pool *pool, *pi = NULL, *iter;
struct list_head *node; struct list_head *node;
unsigned last_offset; unsigned last_offset;
bool slot_found;
int ret; int ret;
if (!kdev) if (!kdev)
...@@ -816,18 +815,17 @@ void *knav_pool_create(const char *name, ...@@ -816,18 +815,17 @@ void *knav_pool_create(const char *name,
* the request * the request
*/ */
last_offset = 0; last_offset = 0;
slot_found = false;
node = &region->pools; node = &region->pools;
list_for_each_entry(pi, &region->pools, region_inst) { list_for_each_entry(iter, &region->pools, region_inst) {
if ((pi->region_offset - last_offset) >= num_desc) { if ((iter->region_offset - last_offset) >= num_desc) {
slot_found = true; pi = iter;
break; break;
} }
last_offset = pi->region_offset + pi->num_desc; last_offset = iter->region_offset + iter->num_desc;
} }
node = &pi->region_inst;
if (slot_found) { if (pi) {
node = &pi->region_inst;
pool->region = region; pool->region = region;
pool->num_desc = num_desc; pool->num_desc = num_desc;
pool->region_offset = last_offset; pool->region_offset = last_offset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment