* [bug report] net: pse-pd: Avoid setting max_uA in regulator constraints
@ 2025-09-23 11:21 Dan Carpenter
2025-09-23 12:56 ` Kory Maincent
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-09-23 11:21 UTC (permalink / raw)
To: Kory Maincent; +Cc: kernel-janitors
Hello Kory Maincent,
Commit 675d0e3cacc3 ("net: pse-pd: Avoid setting max_uA in regulator
constraints") from Jan 10, 2025 (linux-next), leads to the following
Smatch static checker warning:
drivers/net/pse-pd/pse_core.c:810 pse_pi_set_current_limit()
warn: AAA no lower bound on 'max_uA' rl='s32min-(-1),1-1920000'
drivers/net/pse-pd/pse_core.c
783 static int pse_pi_set_current_limit(struct regulator_dev *rdev, int min_uA,
784 int max_uA)
785 {
786 struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev);
787 const struct pse_controller_ops *ops;
788 int id, mW, ret;
789 s64 tmp_64;
790
791 ops = pcdev->ops;
792 if (!ops->pi_set_pw_limit || !ops->pi_get_voltage)
793 return -EOPNOTSUPP;
794
795 if (max_uA > MAX_PI_CURRENT)
Do we need this? Shouldn't it be checked in regulator_check_current_limit()
instead? max_uA is an int. Do we need to check for negatives?
796 return -ERANGE;
797
798 id = rdev_get_id(rdev);
799 mutex_lock(&pcdev->lock);
800 ret = _pse_pi_get_voltage(rdev);
801 if (!ret) {
802 dev_err(pcdev->dev, "Voltage null\n");
803 ret = -ERANGE;
804 goto out;
805 }
806 if (ret < 0)
807 goto out;
808
809 tmp_64 = ret;
--> 810 tmp_64 *= max_uA;
811 /* mW = uA * uV / 1000000000 */
812 mW = DIV_ROUND_CLOSEST_ULL(tmp_64, 1000000000);
813 ret = ops->pi_set_pw_limit(pcdev, id, mW);
814 out:
815 mutex_unlock(&pcdev->lock);
816
817 return ret;
818 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] net: pse-pd: Avoid setting max_uA in regulator constraints
2025-09-23 11:21 [bug report] net: pse-pd: Avoid setting max_uA in regulator constraints Dan Carpenter
@ 2025-09-23 12:56 ` Kory Maincent
0 siblings, 0 replies; 2+ messages in thread
From: Kory Maincent @ 2025-09-23 12:56 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors
On Tue, 23 Sep 2025 14:21:03 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> Hello Kory Maincent,
>
> Commit 675d0e3cacc3 ("net: pse-pd: Avoid setting max_uA in regulator
> constraints") from Jan 10, 2025 (linux-next), leads to the following
> Smatch static checker warning:
>
> drivers/net/pse-pd/pse_core.c:810 pse_pi_set_current_limit()
> warn: AAA no lower bound on 'max_uA' rl='s32min-(-1),1-1920000'
>
> drivers/net/pse-pd/pse_core.c
> 783 static int pse_pi_set_current_limit(struct regulator_dev *rdev, int
> min_uA, 784 int max_uA)
> 785 {
> 786 struct pse_controller_dev *pcdev = rdev_get_drvdata(rdev);
> 787 const struct pse_controller_ops *ops;
> 788 int id, mW, ret;
> 789 s64 tmp_64;
> 790
> 791 ops = pcdev->ops;
> 792 if (!ops->pi_set_pw_limit || !ops->pi_get_voltage)
> 793 return -EOPNOTSUPP;
> 794
> 795 if (max_uA > MAX_PI_CURRENT)
>
> Do we need this? Shouldn't it be checked in regulator_check_current_limit()
> instead? max_uA is an int. Do we need to check for negatives?
No we can't use max_uA in the regulator constraints as I wrote it in the commit
message:
"Setting the max_uA constraint in the regulator API imposes a current
limit during the regulator registration process. This behavior conflicts
with preserving the maximum PI power budget configuration across reboots."
Maybe we need to add a negative check to remove this smatch warning.
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-23 12:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-23 11:21 [bug report] net: pse-pd: Avoid setting max_uA in regulator constraints Dan Carpenter
2025-09-23 12:56 ` Kory Maincent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox