diff options
| author | saturneric <[email protected]> | 2025-03-30 23:28:28 +0000 |
|---|---|---|
| committer | saturneric <[email protected]> | 2025-03-30 23:28:28 +0000 |
| commit | 4005cedb116bc25be160fd9f749c1c8f3059057b (patch) | |
| tree | ce3ece0cef561c6e969eca633b2cdb7360255714 /drivers/hwmon/pwm-fan.c | |
| parent | Merge remote-tracking UNTIL 14. Jan 2025 (diff) | |
| parent | Linux 6.14 (diff) | |
| download | kernel-4005cedb116bc25be160fd9f749c1c8f3059057b.tar.gz kernel-4005cedb116bc25be160fd9f749c1c8f3059057b.zip | |
Merge remote-tracking UNTIL 24. Mar 2025
Diffstat (limited to 'drivers/hwmon/pwm-fan.c')
| -rw-r--r-- | drivers/hwmon/pwm-fan.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 0c304ffdd175..dc019c15635a 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -509,7 +509,7 @@ static int pwm_fan_probe(struct platform_device *pdev) struct device *hwmon; int ret; const struct hwmon_channel_info **channels; - u32 pwm_min_from_stopped = 0; + u32 initial_pwm, pwm_min_from_stopped = 0; u32 *fan_channel_config; int channel_count = 1; /* We always have a PWM channel. */ int i; @@ -557,11 +557,21 @@ static int pwm_fan_probe(struct platform_device *pdev) ctx->enable_mode = pwm_disable_reg_enable; + ret = pwm_fan_get_cooling_data(dev, ctx); + if (ret) + return ret; + + /* use maximum cooling level if provided */ + if (ctx->pwm_fan_cooling_levels) + initial_pwm = ctx->pwm_fan_cooling_levels[ctx->pwm_fan_max_state]; + else + initial_pwm = MAX_PWM; + /* * Set duty cycle to maximum allowed and enable PWM output as well as * the regulator. In case of error nothing is changed */ - ret = set_pwm(ctx, MAX_PWM); + ret = set_pwm(ctx, initial_pwm); if (ret) { dev_err(dev, "Failed to configure PWM: %d\n", ret); return ret; @@ -677,16 +687,16 @@ static int pwm_fan_probe(struct platform_device *pdev) channels[1] = &ctx->fan_channel; } - ret = of_property_read_u32(dev->of_node, "fan-stop-to-start-percent", - &pwm_min_from_stopped); + ret = device_property_read_u32(dev, "fan-stop-to-start-percent", + &pwm_min_from_stopped); if (!ret && pwm_min_from_stopped) { ctx->pwm_duty_cycle_from_stopped = DIV_ROUND_UP_ULL(pwm_min_from_stopped * (ctx->pwm_state.period - 1), 100); } - ret = of_property_read_u32(dev->of_node, "fan-stop-to-start-us", - &ctx->pwm_usec_from_stopped); + ret = device_property_read_u32(dev, "fan-stop-to-start-us", + &ctx->pwm_usec_from_stopped); if (ret) ctx->pwm_usec_from_stopped = 250000; @@ -701,10 +711,6 @@ static int pwm_fan_probe(struct platform_device *pdev) goto error; } - ret = pwm_fan_get_cooling_data(dev, ctx); - if (ret) - goto error; - ctx->pwm_fan_state = ctx->pwm_fan_max_state; if (IS_ENABLED(CONFIG_THERMAL)) { cdev = devm_thermal_of_cooling_device_register(dev, |
