]> git.baikalelectronics.ru Git - kernel.git/commit
opp: Replace list_kref with a local counter
authorViresh Kumar <viresh.kumar@linaro.org>
Mon, 11 Nov 2019 11:05:03 +0000 (16:35 +0530)
committerViresh Kumar <viresh.kumar@linaro.org>
Tue, 10 Dec 2019 10:27:00 +0000 (15:57 +0530)
commit026b83225fcb75c12a54c72b0636c212643f4ce5
treeaaefebef6920281da0e13e7a5f8bab4deb3b3e4e
parentbcc7f535366b28e8f5750a397f93282b8cfff0f9
opp: Replace list_kref with a local counter

A kref or refcount isn't the right tool to be used here for counting
number of devices that are sharing the static OPPs created for the OPP
table. For example, we are reinitializing the kref again, after it
reaches a value of 0 and frees the resources, if the static OPPs get
added for the same OPP table structure (as the OPP table structure was
never freed). That is messy and very unclear.

This patch makes parsed_static_opps an unsigned integer and uses it to
count the number of users of the static OPPs. The increment and
decrement to parsed_static_opps is done under opp_table->lock now to
make sure no races are possible if the OPP table is getting added and
removed in parallel (which doesn't happen in practice, but can in
theory).

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/opp/core.c
drivers/opp/of.c
drivers/opp/opp.h