diff mbox series

[RFC,1/6] hwmon: axi-fan-control: make sure the clock is enabled

Message ID 20210708120111.519444-2-nuno.sa@analog.com
State Accepted
Commit a3933625de28e730c7822d2b14f896125577abe8
Headers show
Series AXI FAN new features and improvements | expand

Commit Message

Nuno Sa July 8, 2021, 12:01 p.m. UTC
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á <nuno.sa@analog.com>
---
 drivers/hwmon/axi-fan-control.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

Comments

Guenter Roeck July 17, 2021, 5:24 p.m. UTC | #1
On Thu, Jul 08, 2021 at 02:01:06PM +0200, Nuno Sá wrote:
> 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á <nuno.sa@analog.com>


Can I apply this patch as well as patches 4/6 and 5/6 as-is, or
do they depend on patches 2/6 and 3/6 ?

Thanks,
Guenter
Nuno Sa July 19, 2021, 7:27 a.m. UTC | #2
> -----Original Message-----

> From: Guenter Roeck <groeck7@gmail.com> On Behalf Of Guenter

> Roeck

> Sent: Saturday, July 17, 2021 7:25 PM

> To: Sa, Nuno <Nuno.Sa@analog.com>

> Cc: linux-hwmon@vger.kernel.org; devicetree@vger.kernel.org; Rob

> Herring <robh+dt@kernel.org>; Jean Delvare <jdelvare@suse.com>

> Subject: Re: [RFC PATCH 1/6] hwmon: axi-fan-control: make sure the

> clock is enabled

> 

> 

> On Thu, Jul 08, 2021 at 02:01:06PM +0200, Nuno Sá wrote:

> > 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á <nuno.sa@analog.com>

> 

> Can I apply this patch as well as patches 4/6 and 5/6 as-is, or

> do they depend on patches 2/6 and 3/6 ?

> 

> Thanks,

> Guenter


I think patch 5/6 only makes sense with patch 2/6. If we do not set
the tacho evaluation parameters, clearing the fan fault irq has no effect...

- Nuno Sá
diff mbox series

Patch

diff --git a/drivers/hwmon/axi-fan-control.c b/drivers/hwmon/axi-fan-control.c
index e3f6b03e6764..901d1588234d 100644
--- a/drivers/hwmon/axi-fan-control.c
+++ b/drivers/hwmon/axi-fan-control.c
@@ -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),
@@ -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;