On Fri, May 10, 2019 at 9:27 PM michael.kao <michael.kao@xxxxxxxxxxxx> wrote: > - tzdev = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, mt, > - &mtk_thermal_ops); > - if (IS_ERR(tzdev)) { > - ret = PTR_ERR(tzdev); > - goto err_disable_clk_peri_therm; > + for (i = 0; i < mt->conf->num_sensors + 1; i++) { > + tz = kmalloc(sizeof(*tz), GFP_KERNEL); > + if (!tz) > + return -ENOMEM; > + > + tz->mt = mt; > + tz->id = i; > + > + tzdev = devm_thermal_zone_of_sensor_register(&pdev->dev, i, > + tz, (i == 0) ? > + &mtk_thermal_ops : &mtk_thermal_sensor_ops); > + > + if (IS_ERR(tzdev)) { > + if (IS_ERR(tzdev) != -EACCES) { PTR_ERR(tzdev) > + ret = PTR_ERR(tzdev); > + goto err_disable_clk_peri_therm; > + } > + } This for loop adding thermal zone sensors will not work for mt8173. It assumes that thermal-zones in dts have subnodes (eg. cpu_thermal, tzts..) amount equal to num_sensors+1. Otherwise tzdev would be -ENODEV and thermal failed to be probed. In mt8183 this is fine, since each thermal zone only has one sensor, but in mt8173, some sensor appears in multiple thermal zones. In order to let the change also works for 8173, I think if the error is -ENODEV, and the id is not 0 (0 is cpu_thermal), prompt a warning instead of failing. Eg. if (IS_ERR(tzdev)) { + if (i > 0 && PTR_ERR(tzdev) == -ENODEV) { + dev_warn(&pdev->dev, "can't find thermal sensor %d\n", i); + continue; + } if (PTR_ERR(tzdev) != -EACCES) {