Skip to content

Commit

Permalink
hwmon: (axi-fan-control) Make sure the clock is enabled
Browse files Browse the repository at this point in the history
The core will only work if it's clock is enabled. This patch is a
minor enhancement to make sure that's the case.

Signed-off-by: Nuno Sá <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
nunojsa authored and groeck committed Aug 17, 2021
1 parent 76b7273 commit a393362
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions drivers/hwmon/axi-fan-control.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ static int axi_fan_control_init(struct axi_fan_control_data *ctl,
return ret;
}

static void axi_fan_control_clk_disable(void *clk)
{
clk_disable_unprepare(clk);
}

static const struct hwmon_channel_info *axi_fan_control_info[] = {
HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT),
HWMON_CHANNEL_INFO(fan, HWMON_F_INPUT | HWMON_F_FAULT | HWMON_F_LABEL),
Expand Down Expand Up @@ -406,6 +411,14 @@ static int axi_fan_control_probe(struct platform_device *pdev)
return PTR_ERR(clk);
}

ret = clk_prepare_enable(clk);
if (ret)
return ret;

ret = devm_add_action_or_reset(&pdev->dev, axi_fan_control_clk_disable, clk);
if (ret)
return ret;

ctl->clk_rate = clk_get_rate(clk);
if (!ctl->clk_rate)
return -EINVAL;
Expand Down

0 comments on commit a393362

Please sign in to comment.