| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * SPEAr thermal driver. |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2011-2012 ST Microelectronics |
|---|
| 5 | 6 | * 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 | | - * |
|---|
| 16 | 7 | */ |
|---|
| 17 | 8 | |
|---|
| 18 | 9 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 56 | 47 | |
|---|
| 57 | 48 | static int __maybe_unused spear_thermal_suspend(struct device *dev) |
|---|
| 58 | 49 | { |
|---|
| 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); |
|---|
| 61 | 51 | struct spear_thermal_dev *stdev = spear_thermal->devdata; |
|---|
| 62 | 52 | unsigned int actual_mask = 0; |
|---|
| 63 | 53 | |
|---|
| .. | .. |
|---|
| 73 | 63 | |
|---|
| 74 | 64 | static int __maybe_unused spear_thermal_resume(struct device *dev) |
|---|
| 75 | 65 | { |
|---|
| 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); |
|---|
| 78 | 67 | struct spear_thermal_dev *stdev = spear_thermal->devdata; |
|---|
| 79 | 68 | unsigned int actual_mask = 0; |
|---|
| 80 | 69 | int ret = 0; |
|---|
| 81 | 70 | |
|---|
| 82 | 71 | ret = clk_enable(stdev->clk); |
|---|
| 83 | 72 | if (ret) { |
|---|
| 84 | | - dev_err(&pdev->dev, "Can't enable clock\n"); |
|---|
| 73 | + dev_err(dev, "Can't enable clock\n"); |
|---|
| 85 | 74 | return ret; |
|---|
| 86 | 75 | } |
|---|
| 87 | 76 | |
|---|
| .. | .. |
|---|
| 142 | 131 | ret = PTR_ERR(spear_thermal); |
|---|
| 143 | 132 | goto disable_clk; |
|---|
| 144 | 133 | } |
|---|
| 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 | + } |
|---|
| 145 | 139 | |
|---|
| 146 | 140 | platform_set_drvdata(pdev, spear_thermal); |
|---|
| 147 | 141 | |
|---|
| .. | .. |
|---|
| 150 | 144 | |
|---|
| 151 | 145 | return 0; |
|---|
| 152 | 146 | |
|---|
| 147 | +unregister_tzd: |
|---|
| 148 | + thermal_zone_device_unregister(spear_thermal); |
|---|
| 153 | 149 | disable_clk: |
|---|
| 154 | 150 | clk_disable(stdev->clk); |
|---|
| 155 | 151 | |
|---|