Message ID | 20230720054100.9940-9-manivannan.sadhasivam@linaro.org (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | UFS: Add OPP and interconnect support | expand |
Hi Manivannan, kernel test robot noticed the following build warnings: https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Manivannan-Sadhasivam/dt-bindings-ufs-common-add-OPP-table/20230720-134720 base: https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next patch link: https://lore.kernel.org/r/20230720054100.9940-9-manivannan.sadhasivam%40linaro.org patch subject: [PATCH v2 08/15] OPP: Introduce dev_pm_opp_get_freq_indexed() API config: i386-randconfig-m041-20230720 (https://download.01.org/0day-ci/archive/20230721/202307210431.3S4SeXVw-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230721/202307210431.3S4SeXVw-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org> | Closes: https://lore.kernel.org/r/202307210431.3S4SeXVw-lkp@intel.com/ New smatch warnings: drivers/opp/core.c:213 dev_pm_opp_get_freq_indexed() warn: variable dereferenced before IS_ERR check 'opp' (see line 211) Old smatch warnings: drivers/opp/core.c:254 dev_pm_opp_get_required_pstate() warn: variable dereferenced before IS_ERR check 'opp' (see line 252) drivers/opp/core.c:2458 _opp_attach_genpd() warn: passing zero to 'PTR_ERR' vim +/opp +213 drivers/opp/core.c a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 209 unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index) a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 210 { a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 @211 struct opp_table *opp_table = opp->opp_table; ^^^^^^^^^^^^^^^ Dereference a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 212 a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 @213 if (IS_ERR_OR_NULL(opp) || index >= opp_table->clk_count) { ^^^ Checked too late a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 214 pr_err("%s: Invalid parameters\n", __func__); This should be a dev_err(), btw. a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 215 return 0; a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 216 } a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 217 a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 218 return opp->rates[index]; a772c36cb3fb41 drivers/opp/core.c Manivannan Sadhasivam 2023-07-20 219 }
diff --git a/drivers/opp/core.c b/drivers/opp/core.c index a6d0b6b18e0e..66dc0d0cfaed 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -197,6 +197,28 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); +/** + * dev_pm_opp_get_freq_indexed() - Gets the frequency corresponding to an + * available opp with specified index + * @opp: opp for which frequency has to be returned for + * @index: index of the frequency within the required opp + * + * Return: frequency in hertz corresponding to the opp with specified index, + * else return 0 + */ +unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index) +{ + struct opp_table *opp_table = opp->opp_table; + + if (IS_ERR_OR_NULL(opp) || index >= opp_table->clk_count) { + pr_err("%s: Invalid parameters\n", __func__); + return 0; + } + + return opp->rates[index]; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq_indexed); + /** * dev_pm_opp_get_level() - Gets the level corresponding to an available opp * @opp: opp for which level value has to be returned for diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 991f54da79b5..97eb6159fb93 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -105,6 +105,8 @@ unsigned long dev_pm_opp_get_power(struct dev_pm_opp *opp); unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); +unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, u32 index); + unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp); unsigned int dev_pm_opp_get_required_pstate(struct dev_pm_opp *opp, @@ -211,6 +213,12 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) return 0; } +static inline unsigned long dev_pm_opp_get_freq_indexed(struct dev_pm_opp *opp, + u32 index) +{ + return 0; +} + static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp) { return 0;
In the case of devices with multiple clocks, drivers need to specify the frequency index for the OPP framework to get the specific frequency within the required OPP. So let's introduce the dev_pm_opp_get_freq_indexed() API accepting the frequency index as an argument. Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> --- drivers/opp/core.c | 22 ++++++++++++++++++++++ include/linux/pm_opp.h | 8 ++++++++ 2 files changed, 30 insertions(+)