Re: [PATCH v5 11/12] powercap: arm_scmi: Add get_power_uw to synthetic node

Philip Radford
2026-05-06T10:37:22Z

On Tue, May 05, 2026 at 11:13:44PM +0100, Cristian Marussi wrote:
> On Tue, Apr 28, 2026 at 10:09:20AM +0100, Philip Radford wrote:
> > Exposes the current power usage from the immediate children of
> > the synthetic (root) powercap node. Iterates over pr->spzones and
> > sums per-zone power.
> >

Hi,

> > Signed-off-by: Philip Radford <philip.radford@arm.com>
> > ---
> > drivers/powercap/arm_scmi_powercap.c | 29 ++++++++++++++++++++++++++--
> > 1 file changed, 27 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/powercap/arm_scmi_powercap.c b/drivers/powercap/arm_scmi_powercap.c
> > index d74869af1633..81b5214acda4 100644
> > --- a/drivers/powercap/arm_scmi_powercap.c
> > +++ b/drivers/powercap/arm_scmi_powercap.c
> > @@ -270,9 +270,34 @@ static int instance_root_release(struct powercap_zone *pz)
> > return 0;
> > }
> >
> > -static int instance_root_get_power_uw(struct powercap_zone *pz, u64 *v)
> > +static int instance_root_get_power_uw(struct powercap_zone *pz, u64 *power_uw)
> > {
> > - *v = 0;
> > + struct scmi_powercap_zone *root = to_scmi_powercap_zone(pz);
> > + struct scmi_powercap_zone *child;
> > + struct scmi_powercap_root *pr;
> > + u64 acc = 0;
> > + u64 p;
>
> These u64 can live on a single line...
>

No probs.

> > + int ret;
> > +
> > + if (!pz || !power_uw)
> > + return -EINVAL;
> > +
> > + pr = container_of(root, struct scmi_powercap_root, instance_root);
>
> usually we define macros to wrap this like to_scmi_powercap_zone()...
> ...even if used only once...this could be a new to_scmi_powercap_root()
>

Will do.

> > + if (!pr)
> > + return -ENODEV;
> > +
> > + list_for_each_entry(child, &pr->registered_zones[0], node) {
> > + if (child == &pr->instance_root)
> > + continue;
>
> You'll need to check this in light of the fixes of previous patch
>

No worries.

Regards,
Phil