Skip to content

Commit 95073b7

Browse files
Jakob-Koschelvireshk
authored andcommitted
opp: 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. Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
1 parent 543256d commit 95073b7

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

drivers/opp/core.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,26 +1486,25 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_put);
14861486
*/
14871487
void dev_pm_opp_remove(struct device *dev, unsigned long freq)
14881488
{
1489-
struct dev_pm_opp *opp;
1489+
struct dev_pm_opp *opp = NULL, *iter;
14901490
struct opp_table *opp_table;
1491-
bool found = false;
14921491

14931492
opp_table = _find_opp_table(dev);
14941493
if (IS_ERR(opp_table))
14951494
return;
14961495

14971496
mutex_lock(&opp_table->lock);
14981497

1499-
list_for_each_entry(opp, &opp_table->opp_list, node) {
1500-
if (opp->rate == freq) {
1501-
found = true;
1498+
list_for_each_entry(iter, &opp_table->opp_list, node) {
1499+
if (iter->rate == freq) {
1500+
opp = iter;
15021501
break;
15031502
}
15041503
}
15051504

15061505
mutex_unlock(&opp_table->lock);
15071506

1508-
if (found) {
1507+
if (opp) {
15091508
dev_pm_opp_put(opp);
15101509

15111510
/* Drop the reference taken by dev_pm_opp_add() */

0 commit comments

Comments
 (0)