116 lines
3.6 KiB
Diff
116 lines
3.6 KiB
Diff
|
From 6f93fd0c592ac63ee7e6c037248d52ab398c0fe0 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
|
||
|
Date: Wed, 8 Jul 2020 12:21:14 +0200
|
||
|
Subject: [PATCH] thermal: sun8i: Be loud when probe fails
|
||
|
|
||
|
I noticed several mobile Linux distributions failing to enable the
|
||
|
thermal regulation correctly, because the kernel is silent
|
||
|
when thermal driver fails to probe. Add enough error reporting
|
||
|
to debug issues and warn users in case thermal sensor is failing
|
||
|
to probe.
|
||
|
|
||
|
Signed-off-by: Ondrej Jirman <megi@xff.cz>
|
||
|
---
|
||
|
drivers/thermal/sun8i_thermal.c | 35 +++++++++++++++++++++++++++------
|
||
|
1 file changed, 29 insertions(+), 6 deletions(-)
|
||
|
|
||
|
diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c
|
||
|
index b17fd7c7ca58..42b1d8112ee6 100644
|
||
|
--- a/drivers/thermal/sun8i_thermal.c
|
||
|
+++ b/drivers/thermal/sun8i_thermal.c
|
||
|
@@ -379,8 +379,13 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev)
|
||
|
|
||
|
calcell = devm_nvmem_cell_get(dev, "calibration");
|
||
|
if (IS_ERR(calcell)) {
|
||
|
+ dev_err_probe(dev, PTR_ERR(calcell),
|
||
|
+ "Failed to get calibration nvmem cell (%pe)\n",
|
||
|
+ calcell);
|
||
|
+
|
||
|
if (PTR_ERR(calcell) == -EPROBE_DEFER)
|
||
|
return -EPROBE_DEFER;
|
||
|
+
|
||
|
/*
|
||
|
* Even if the external calibration data stored in sid is
|
||
|
* not accessible, the THS hardware can still work, although
|
||
|
@@ -400,6 +405,8 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev)
|
||
|
caldata = nvmem_cell_read(calcell, &callen);
|
||
|
if (IS_ERR(caldata)) {
|
||
|
ret = PTR_ERR(caldata);
|
||
|
+ dev_err(dev, "Failed to read calibration data (%pe)\n",
|
||
|
+ caldata);
|
||
|
goto out;
|
||
|
}
|
||
|
|
||
|
@@ -427,13 +434,17 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev)
|
||
|
return PTR_ERR(base);
|
||
|
|
||
|
tmdev->regmap = devm_regmap_init_mmio(dev, base, &config);
|
||
|
- if (IS_ERR(tmdev->regmap))
|
||
|
+ if (IS_ERR(tmdev->regmap)) {
|
||
|
+ dev_err(dev, "Failed to init regmap (%pe)\n", tmdev->regmap);
|
||
|
return PTR_ERR(tmdev->regmap);
|
||
|
+ }
|
||
|
|
||
|
if (tmdev->chip->has_bus_clk_reset) {
|
||
|
tmdev->reset = devm_reset_control_get(dev, NULL);
|
||
|
- if (IS_ERR(tmdev->reset))
|
||
|
+ if (IS_ERR(tmdev->reset)) {
|
||
|
+ dev_err(dev, "Failed to get reset (%pe)\n", tmdev->reset);
|
||
|
return PTR_ERR(tmdev->reset);
|
||
|
+ }
|
||
|
|
||
|
ret = reset_control_deassert(tmdev->reset);
|
||
|
if (ret)
|
||
|
@@ -445,14 +456,20 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev)
|
||
|
return ret;
|
||
|
|
||
|
tmdev->bus_clk = devm_clk_get_enabled(&pdev->dev, "bus");
|
||
|
- if (IS_ERR(tmdev->bus_clk))
|
||
|
+ if (IS_ERR(tmdev->bus_clk)) {
|
||
|
+ dev_err(dev, "Failed to get bus clock (%pe)\n",
|
||
|
+ tmdev->bus_clk);
|
||
|
return PTR_ERR(tmdev->bus_clk);
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
if (tmdev->chip->has_mod_clk) {
|
||
|
tmdev->mod_clk = devm_clk_get_enabled(&pdev->dev, "mod");
|
||
|
- if (IS_ERR(tmdev->mod_clk))
|
||
|
+ if (IS_ERR(tmdev->mod_clk)) {
|
||
|
+ dev_err(dev, "Failed to get mod clock (%pe)\n",
|
||
|
+ tmdev->mod_clk);
|
||
|
return PTR_ERR(tmdev->mod_clk);
|
||
|
+ }
|
||
|
}
|
||
|
|
||
|
ret = clk_set_rate(tmdev->mod_clk, 24000000);
|
||
|
@@ -580,8 +597,12 @@ static int sun8i_ths_register(struct ths_device *tmdev)
|
||
|
i,
|
||
|
&tmdev->sensor[i],
|
||
|
&ths_ops);
|
||
|
- if (IS_ERR(tmdev->sensor[i].tzd))
|
||
|
+ if (IS_ERR(tmdev->sensor[i].tzd)) {
|
||
|
+ dev_err(tmdev->dev,
|
||
|
+ "Failed to register sensor %d (%pe)\n",
|
||
|
+ i, tmdev->sensor[i].tzd);
|
||
|
return PTR_ERR(tmdev->sensor[i].tzd);
|
||
|
+ }
|
||
|
|
||
|
if (devm_thermal_add_hwmon_sysfs(tmdev->sensor[i].tzd))
|
||
|
dev_warn(tmdev->dev,
|
||
|
@@ -632,8 +653,10 @@ static int sun8i_ths_probe(struct platform_device *pdev)
|
||
|
ret = devm_request_threaded_irq(dev, irq, NULL,
|
||
|
sun8i_irq_thread,
|
||
|
IRQF_ONESHOT, "ths", tmdev);
|
||
|
- if (ret)
|
||
|
+ if (ret) {
|
||
|
+ dev_err(dev, "Failed to request irq (%d)\n", ret);
|
||
|
return ret;
|
||
|
+ }
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
--
|
||
|
2.34.1
|
||
|
|