Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal
Pull thermal soc updates from Eduardo Valentin: - thermal core has a new devm_* API for registering cooling devices. I took the entire series, that is why you see changes on drivers/hwmon in this pull (Guenter Roeck) - rockchip thermal driver gains support to PX30 SoC (Elaine Zhang) - the generic-adc thermal driver now considers the lookup table DT property as optional (Jean-Francois Dagenais) - Refactoring of tsens thermal driver (Amit Kucheria) - Cleanups on cpu cooling driver (Daniel Lezcano) - broadcom thermal driver dropped support to ACPI (Srinath Mannam) - tegra thermal driver gains support to OC hw throttle and GPU throtle (Wei Ni) - Fixes in several thermal drivers. * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal: (59 commits) hwmon: (pwm-fan) Use devm_thermal_of_cooling_device_register hwmon: (npcm750-pwm-fan) Use devm_thermal_of_cooling_device_register hwmon: (mlxreg-fan) Use devm_thermal_of_cooling_device_register hwmon: (gpio-fan) Use devm_thermal_of_cooling_device_register hwmon: (aspeed-pwm-tacho) Use devm_thermal_of_cooling_device_register thermal: rcar_gen3_thermal: Fix to show correct trip points number thermal: rcar_thermal: update calculation formula for R-Car Gen3 SoCs thermal: cpu_cooling: Actually trace CPU load in thermal_power_cpu_get_power thermal: rockchip: Support the PX30 SoC in thermal driver dt-bindings: rockchip-thermal: Support the PX30 SoC compatible thermal: rockchip: fix up the tsadc pinctrl setting error thermal: broadcom: Remove ACPI support thermal: Fix build error of missing devm_ioremap_resource on UM thermal/drivers/cpu_cooling: Remove pointless field thermal/drivers/cpu_cooling: Add Software Package Data Exchange (SPDX) thermal/drivers/cpu_cooling: Fixup the header and copyright thermal/drivers/cpu_cooling: Remove pointless test in power2state() thermal: rcar_gen3_thermal: disable interrupt in .remove thermal: rcar_gen3_thermal: fix interrupt type thermal: Introduce devm_thermal_of_cooling_device_register ...
This commit is contained in:
@@ -273,27 +273,40 @@ static int pwm_fan_of_get_cooling_data(struct device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pwm_fan_regulator_disable(void *data)
|
||||
{
|
||||
regulator_disable(data);
|
||||
}
|
||||
|
||||
static void pwm_fan_pwm_disable(void *__ctx)
|
||||
{
|
||||
struct pwm_fan_ctx *ctx = __ctx;
|
||||
pwm_disable(ctx->pwm);
|
||||
del_timer_sync(&ctx->rpm_timer);
|
||||
}
|
||||
|
||||
static int pwm_fan_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct thermal_cooling_device *cdev;
|
||||
struct device *dev = &pdev->dev;
|
||||
struct pwm_fan_ctx *ctx;
|
||||
struct device *hwmon;
|
||||
int ret;
|
||||
struct pwm_state state = { };
|
||||
u32 ppr = 2;
|
||||
|
||||
ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
|
||||
ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
|
||||
if (!ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
mutex_init(&ctx->lock);
|
||||
|
||||
ctx->pwm = devm_of_pwm_get(&pdev->dev, pdev->dev.of_node, NULL);
|
||||
ctx->pwm = devm_of_pwm_get(dev, dev->of_node, NULL);
|
||||
if (IS_ERR(ctx->pwm)) {
|
||||
ret = PTR_ERR(ctx->pwm);
|
||||
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(&pdev->dev, "Could not get PWM: %d\n", ret);
|
||||
dev_err(dev, "Could not get PWM: %d\n", ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -304,7 +317,7 @@ static int pwm_fan_probe(struct platform_device *pdev)
|
||||
if (ctx->irq == -EPROBE_DEFER)
|
||||
return ctx->irq;
|
||||
|
||||
ctx->reg_en = devm_regulator_get_optional(&pdev->dev, "fan");
|
||||
ctx->reg_en = devm_regulator_get_optional(dev, "fan");
|
||||
if (IS_ERR(ctx->reg_en)) {
|
||||
if (PTR_ERR(ctx->reg_en) != -ENODEV)
|
||||
return PTR_ERR(ctx->reg_en);
|
||||
@@ -313,10 +326,11 @@ static int pwm_fan_probe(struct platform_device *pdev)
|
||||
} else {
|
||||
ret = regulator_enable(ctx->reg_en);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to enable fan supply: %d\n", ret);
|
||||
dev_err(dev, "Failed to enable fan supply: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
devm_add_action_or_reset(dev, pwm_fan_regulator_disable,
|
||||
ctx->reg_en);
|
||||
}
|
||||
|
||||
ctx->pwm_value = MAX_PWM;
|
||||
@@ -328,91 +342,57 @@ static int pwm_fan_probe(struct platform_device *pdev)
|
||||
|
||||
ret = pwm_apply_state(ctx->pwm, &state);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Failed to configure PWM: %d\n", ret);
|
||||
goto err_reg_disable;
|
||||
dev_err(dev, "Failed to configure PWM: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
timer_setup(&ctx->rpm_timer, sample_timer, 0);
|
||||
devm_add_action_or_reset(dev, pwm_fan_pwm_disable, ctx);
|
||||
|
||||
of_property_read_u32(pdev->dev.of_node, "pulses-per-revolution", &ppr);
|
||||
of_property_read_u32(dev->of_node, "pulses-per-revolution", &ppr);
|
||||
ctx->pulses_per_revolution = ppr;
|
||||
if (!ctx->pulses_per_revolution) {
|
||||
dev_err(&pdev->dev, "pulses-per-revolution can't be zero.\n");
|
||||
ret = -EINVAL;
|
||||
goto err_pwm_disable;
|
||||
dev_err(dev, "pulses-per-revolution can't be zero.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (ctx->irq > 0) {
|
||||
ret = devm_request_irq(&pdev->dev, ctx->irq, pulse_handler, 0,
|
||||
ret = devm_request_irq(dev, ctx->irq, pulse_handler, 0,
|
||||
pdev->name, ctx);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to request interrupt: %d\n", ret);
|
||||
goto err_pwm_disable;
|
||||
dev_err(dev, "Failed to request interrupt: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
ctx->sample_start = ktime_get();
|
||||
mod_timer(&ctx->rpm_timer, jiffies + HZ);
|
||||
}
|
||||
|
||||
hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, "pwmfan",
|
||||
hwmon = devm_hwmon_device_register_with_groups(dev, "pwmfan",
|
||||
ctx, pwm_fan_groups);
|
||||
if (IS_ERR(hwmon)) {
|
||||
ret = PTR_ERR(hwmon);
|
||||
dev_err(&pdev->dev,
|
||||
"Failed to register hwmon device: %d\n", ret);
|
||||
goto err_del_timer;
|
||||
dev_err(dev, "Failed to register hwmon device\n");
|
||||
return PTR_ERR(hwmon);
|
||||
}
|
||||
|
||||
ret = pwm_fan_of_get_cooling_data(&pdev->dev, ctx);
|
||||
ret = pwm_fan_of_get_cooling_data(dev, ctx);
|
||||
if (ret)
|
||||
goto err_del_timer;
|
||||
return ret;
|
||||
|
||||
ctx->pwm_fan_state = ctx->pwm_fan_max_state;
|
||||
if (IS_ENABLED(CONFIG_THERMAL)) {
|
||||
cdev = thermal_of_cooling_device_register(pdev->dev.of_node,
|
||||
"pwm-fan", ctx,
|
||||
&pwm_fan_cooling_ops);
|
||||
cdev = devm_thermal_of_cooling_device_register(dev,
|
||||
dev->of_node, "pwm-fan", ctx, &pwm_fan_cooling_ops);
|
||||
if (IS_ERR(cdev)) {
|
||||
ret = PTR_ERR(cdev);
|
||||
dev_err(&pdev->dev,
|
||||
dev_err(dev,
|
||||
"Failed to register pwm-fan as cooling device: %d\n",
|
||||
ret);
|
||||
goto err_del_timer;
|
||||
return ret;
|
||||
}
|
||||
ctx->cdev = cdev;
|
||||
thermal_cdev_update(cdev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_del_timer:
|
||||
del_timer_sync(&ctx->rpm_timer);
|
||||
|
||||
err_pwm_disable:
|
||||
state.enabled = false;
|
||||
pwm_apply_state(ctx->pwm, &state);
|
||||
|
||||
err_reg_disable:
|
||||
if (ctx->reg_en)
|
||||
regulator_disable(ctx->reg_en);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int pwm_fan_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct pwm_fan_ctx *ctx = platform_get_drvdata(pdev);
|
||||
|
||||
thermal_cooling_device_unregister(ctx->cdev);
|
||||
del_timer_sync(&ctx->rpm_timer);
|
||||
|
||||
if (ctx->pwm_value)
|
||||
pwm_disable(ctx->pwm);
|
||||
|
||||
if (ctx->reg_en)
|
||||
regulator_disable(ctx->reg_en);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
@@ -480,7 +460,6 @@ MODULE_DEVICE_TABLE(of, of_pwm_fan_match);
|
||||
|
||||
static struct platform_driver pwm_fan_driver = {
|
||||
.probe = pwm_fan_probe,
|
||||
.remove = pwm_fan_remove,
|
||||
.driver = {
|
||||
.name = "pwm-fan",
|
||||
.pm = &pwm_fan_pm,
|
||||
|
Reference in New Issue
Block a user