On Tue, 19 May 2020 11:45:55 +0000 Peng Fan peng....@nxp.com wrote: ... > Do you have more insights about uclass_get_device and > uclass_get_device_byname? > uclass_get_device not work, but uclass_get_device_byname work.
well, we have three thermal uclass devices on i.MX8QXP: thermal 0 [ ] imx_sc_thermal |-- thermal-sensor thermal 1 [ ] imx_sc_thermal | |-- cpu-thermal0 thermal 2 [ ] imx_sc_thermal | `-- drc-thermal0 when using uclass_get_device(UCLASS_THERMAL, 0, &thermal_dev), the first device ("thermal-sensor") is matching and for this device imx_sc_thermal_ofdata_to_platdata() will be called, it then tries to get the "thermal-sensors" list in the node of "thermal-sensor" device (dev_of_offset(dev)), but this is wrong, since this list is a property of the "cpu-thermal0" node according to bindings. Therefore ofdata_to_platdata() can't find the "thermal-sensors" list and does not initialize alert/critical pdata values. When uclass_get_device_by_name() is used, then imx_sc_thermal_ofdata_to_platdata() is called for "cpu-thermal0" device, here getting the list works and alert/critical pdata values are initialized properly. -- Anatolij