hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/thermal/spear_thermal.c
....@@ -1,18 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * SPEAr thermal driver.
34 *
45 * Copyright (C) 2011-2012 ST Microelectronics
56 * Author: Vincenzo Frascino <vincenzo.frascino@st.com>
6
- *
7
- * This software is licensed under the terms of the GNU General Public
8
- * License version 2, as published by the Free Software Foundation, and
9
- * may be copied, distributed, and modified under those terms.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
167 */
178
189 #include <linux/clk.h>
....@@ -56,8 +47,7 @@
5647
5748 static int __maybe_unused spear_thermal_suspend(struct device *dev)
5849 {
59
- struct platform_device *pdev = to_platform_device(dev);
60
- struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev);
50
+ struct thermal_zone_device *spear_thermal = dev_get_drvdata(dev);
6151 struct spear_thermal_dev *stdev = spear_thermal->devdata;
6252 unsigned int actual_mask = 0;
6353
....@@ -73,15 +63,14 @@
7363
7464 static int __maybe_unused spear_thermal_resume(struct device *dev)
7565 {
76
- struct platform_device *pdev = to_platform_device(dev);
77
- struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev);
66
+ struct thermal_zone_device *spear_thermal = dev_get_drvdata(dev);
7867 struct spear_thermal_dev *stdev = spear_thermal->devdata;
7968 unsigned int actual_mask = 0;
8069 int ret = 0;
8170
8271 ret = clk_enable(stdev->clk);
8372 if (ret) {
84
- dev_err(&pdev->dev, "Can't enable clock\n");
73
+ dev_err(dev, "Can't enable clock\n");
8574 return ret;
8675 }
8776
....@@ -142,6 +131,11 @@
142131 ret = PTR_ERR(spear_thermal);
143132 goto disable_clk;
144133 }
134
+ ret = thermal_zone_device_enable(spear_thermal);
135
+ if (ret) {
136
+ dev_err(&pdev->dev, "Cannot enable thermal zone\n");
137
+ goto unregister_tzd;
138
+ }
145139
146140 platform_set_drvdata(pdev, spear_thermal);
147141
....@@ -150,6 +144,8 @@
150144
151145 return 0;
152146
147
+unregister_tzd:
148
+ thermal_zone_device_unregister(spear_thermal);
153149 disable_clk:
154150 clk_disable(stdev->clk);
155151