/* Register with the in-kernel thermal management */ static int amlogic_register_thermal(struct amlogic_thermal_platform_data *pdata, struct platform_device *pdev) { int ret=0, j; struct cpumask mask_val; memset(&mask_val,0,sizeof(struct cpumask)); cpumask_set_cpu(0, &mask_val); pdata->cpu_cool_dev= cpufreq_cooling_register(&mask_val); if (IS_ERR(pdata->cpu_cool_dev)) { THERMAL_ERR("Failed to register cpufreq cooling device\n"); ret = -EINVAL; goto err_unregister; } pdata->cpucore_cool_dev = cpucore_cooling_register(); if (IS_ERR(pdata->cpucore_cool_dev)) { THERMAL_ERR("Failed to register cpufreq cooling device\n"); ret = -EINVAL; goto err_unregister; } pdata->therm_dev = thermal_zone_device_register(pdata->name, pdata->temp_trip_count, ((1 << pdata->temp_trip_count) - 1), pdata, &amlogic_dev_ops, NULL, 0, pdata->idle_interval); if (IS_ERR(pdata->therm_dev)) { THERMAL_ERR("Failed to register thermal zone device, err:%p\n", pdata->therm_dev); ret = -EINVAL; goto err_unregister; } if (pdata->keep_mode) { // create sysfs for keep_mode for (j = 0; j < ARRAY_SIZE(amlogic_thermal_attr); j++) { device_create_file(&pdata->therm_dev->device, &amlogic_thermal_attr[j]); } } return 0; err_unregister: amlogic_unregister_thermal(pdata); return ret; }
/* Register with the in-kernel thermal management */ static int amlogic_register_thermal(struct amlogic_thermal_platform_data *pdata) { int ret=0; struct cpumask mask_val; memset(&mask_val,0,sizeof(struct cpumask)); cpumask_set_cpu(0, &mask_val); pdata->cpu_cool_dev= cpufreq_cooling_register(&mask_val); if (IS_ERR(pdata->cpu_cool_dev)) { pr_err("Failed to register cpufreq cooling device\n"); ret = -EINVAL; goto err_unregister; } pdata->cpucore_cool_dev = cpucore_cooling_register(); if (IS_ERR(pdata->cpucore_cool_dev)) { pr_err("Failed to register cpufreq cooling device\n"); ret = -EINVAL; goto err_unregister; } pdata->therm_dev = thermal_zone_device_register(pdata->name, pdata->temp_trip_count, 7, pdata, &amlogic_dev_ops, NULL, 0, pdata->idle_interval); if (IS_ERR(pdata->therm_dev)) { pr_err("Failed to register thermal zone device\n"); ret = -EINVAL; goto err_unregister; } pr_info("amlogic: Kernel Thermal management registered\n"); return 0; err_unregister: amlogic_unregister_thermal(pdata); return ret; }