Hi Wolfram, Thanks for your review. On 2023-02-08 08:58:33 +0100, Wolfram Sang wrote: > On Tue, Feb 07, 2023 at 06:10:11PM +0100, Niklas Söderlund wrote: > > The thermal zone is registered before the device is register and the > > thermal coefficients are calculated, providing a window for very > > incorrect readings. > > While I could never actually be in this race window, the patch makes a > lot of sense to me. > > > The reason why the zone was register before the device was fully > > initialized was that the presence of the set_trips() callback is used to > > determine if the driver supports interrupt or not, as it is not defined > > if the device is incapable of interrupts. > > > > Fix this by using the operations structure in the private data instead > > of the zone to determine if interrupts are available or not, and > > initialize the device before registering the zone. > > > > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@xxxxxxxxxxxx> > > Reviewed-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx> > > One minor question: > > > - if (status) > > + if (status && priv->tscs[i]->zone) > > thermal_zone_device_update(priv->tscs[i]->zone, > > THERMAL_EVENT_UNSPECIFIED); > > Isn't this a seperate change? Not really. This patch changes the driver to enable interrupts just before the zone is created. So this just guards from the very small window where an interrupt could be fired and the zone is created, which if it would happen would cause a null pointer dereference. While not updating a not yet created zone is fine. But this should never happen (tm) as the trip points have not been set when this window exists, but better safe then sorry. -- Kind Regards, Niklas Söderlund