RE: Re : [PATCH v5 3/5] thermal: renesas: rzg3e: Add thermal driver for the Renesas RZ/G3E SoC
From: John Madieu
Date: Wed Apr 02 2025 - 15:23:07 EST
Hi Alok,
> -----Original Message-----
> From: ALOK TIWARI <alok.a.tiwari@xxxxxxxxxx>
> Sent: Tuesday, April 1, 2025 8:24 PM
> To: John Madieu <john.madieu.xa@xxxxxxxxxxxxxx>; geert+renesas@xxxxxxxxx;
> conor+dt@xxxxxxxxxx; krzk+dt@xxxxxxxxxx; robh@xxxxxxxxxx;
> rafael@xxxxxxxxxx; daniel.lezcano@xxxxxxxxxx
> Subject: Re : [PATCH v5 3/5] thermal: renesas: rzg3e: Add thermal driver
> for the Renesas RZ/G3E SoC
>
> Hi John,
>
> Thanks for your reply.
>
> On 01-04-2025 17:35, John Madieu wrote:
> > Hi Alok,
> >
> > Thanks for your feedback.
> >
> >> -----Original Message-----
> >> From: ALOK TIWARI <alok.a.tiwari@xxxxxxxxxx>
> >> Sent: Monday, March 31, 2025 8:11 PM
> >> To: John Madieu <john.madieu.xa@xxxxxxxxxxxxxx>;
> >> geert+renesas@xxxxxxxxx;
> >> conor+dt@xxxxxxxxxx; krzk+dt@xxxxxxxxxx; robh@xxxxxxxxxx;
> >> rafael@xxxxxxxxxx; daniel.lezcano@xxxxxxxxxx
> >> Subject: Re : [PATCH v5 3/5] thermal: renesas: rzg3e: Add thermal
> >> driver for the Renesas RZ/G3E SoC
> >>
> >>
> >>
> >> On 31-03-2025 03:19, John Madieu wrote:
> >>> The RZ/G3E SoC integrates a Temperature Sensor Unit (TSU) block
>
> >>> +static int rzg3e_thermal_change_mode(struct thermal_zone_device *tz,
> >>> + enum thermal_device_mode mode) {
> >>> + struct rzg3e_thermal_priv *priv = thermal_zone_device_priv(tz);
> >>> +
> >>> + if (mode == THERMAL_DEVICE_DISABLED)
> >>> + rzg3e_thermal_hw_disable(priv);
> >>> + else
> >>> + rzg3e_thermal_hw_enable(priv);
> >>> +
> >>> + priv->mode = mode;
> >>> + return 0;
> >>> +}
> >>> +
> >> always return 0 here ? what, if (!priv) return -EINVAL; ?
> >
> > priv cannot be NULL here, guaranteed from probe().
> > Returning 0 here is expected by the thermal framework to notify ops
> > success.
> >
>
> I agreed. priv cannot be NULL.
> It appears that return 0 is deliberate in this case. can we add Meaningful
> comment which help to code readability.
>
This is a standard tzd ops, which expects 0 to be returned
for disabling/enabling success. This is how it's implemented
in every Thermal driver I've gone through in the -next tree.
> not sure if user call ioctl(fd, THERMAL_IOC_SET_MODE, 2) and it returns
> 0 with thermal enable.
> that create possibility to thermal_core call thermal_notify_tz_disable if
> any case
>
Am I missing something ?
> >>> +static const struct thermal_zone_device_ops rzg3e_tz_ops = {
> >>> + .get_temp = rzg3e_thermal_get_temp,
> >>> + .set_trips = rzg3e_thermal_set_trips,
> >>> + .change_mode = rzg3e_thermal_change_mode, };
> >> other renesas driver defined as rzg2l_tz_of_ops, can be used similar
> >> one rzg3e_tz_of_ops for consistency!
> >
> > Thanks for pointing it out. Makes sense. Will double check and update
> > accordingly.
> >
> >>> +
> >>> +static int rzg3e_thermal_probe(struct platform_device *pdev) {
> >>> + struct device *dev = &pdev->dev;
> >>> + struct rzg3e_thermal_priv *priv;
> >>> + struct reset_control *rstc;
> >>
Regards,
John