diff options
author | Aaron Lu <aaron.lu@intel.com> | 2013-11-19 03:59:20 -0500 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2014-10-10 01:57:13 -0400 |
commit | 19593a1fb1f6718406afca5b867dab184289d406 (patch) | |
tree | 6adcd574baea9bc4cb7121edb6ab4c66167581f7 /drivers/acpi | |
parent | 2bb3a2bf9939f3361e25045f4ef7b136b864c3b8 (diff) |
ACPI / fan: convert to platform driver
Convert ACPI fan driver to a platform driver for the purpose of phasing
out ACPI bus.
Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/fan.c | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index fff9696bea25..8a5b450576df 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
@@ -30,17 +30,14 @@ | |||
30 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
31 | #include <linux/thermal.h> | 31 | #include <linux/thermal.h> |
32 | #include <linux/acpi.h> | 32 | #include <linux/acpi.h> |
33 | 33 | #include <linux/platform_device.h> | |
34 | #define PREFIX "ACPI: " | ||
35 | |||
36 | #define ACPI_FAN_CLASS "fan" | ||
37 | 34 | ||
38 | MODULE_AUTHOR("Paul Diefenbaugh"); | 35 | MODULE_AUTHOR("Paul Diefenbaugh"); |
39 | MODULE_DESCRIPTION("ACPI Fan Driver"); | 36 | MODULE_DESCRIPTION("ACPI Fan Driver"); |
40 | MODULE_LICENSE("GPL"); | 37 | MODULE_LICENSE("GPL"); |
41 | 38 | ||
42 | static int acpi_fan_add(struct acpi_device *device); | 39 | static int acpi_fan_probe(struct platform_device *pdev); |
43 | static int acpi_fan_remove(struct acpi_device *device); | 40 | static int acpi_fan_remove(struct platform_device *pdev); |
44 | 41 | ||
45 | static const struct acpi_device_id fan_device_ids[] = { | 42 | static const struct acpi_device_id fan_device_ids[] = { |
46 | {"PNP0C0B", 0}, | 43 | {"PNP0C0B", 0}, |
@@ -62,15 +59,14 @@ static struct dev_pm_ops acpi_fan_pm = { | |||
62 | #define FAN_PM_OPS_PTR NULL | 59 | #define FAN_PM_OPS_PTR NULL |
63 | #endif | 60 | #endif |
64 | 61 | ||
65 | static struct acpi_driver acpi_fan_driver = { | 62 | static struct platform_driver acpi_fan_driver = { |
66 | .name = "fan", | 63 | .probe = acpi_fan_probe, |
67 | .class = ACPI_FAN_CLASS, | 64 | .remove = acpi_fan_remove, |
68 | .ids = fan_device_ids, | 65 | .driver = { |
69 | .ops = { | 66 | .name = "acpi-fan", |
70 | .add = acpi_fan_add, | 67 | .acpi_match_table = fan_device_ids, |
71 | .remove = acpi_fan_remove, | 68 | .pm = FAN_PM_OPS_PTR, |
72 | }, | 69 | }, |
73 | .drv.pm = FAN_PM_OPS_PTR, | ||
74 | }; | 70 | }; |
75 | 71 | ||
76 | /* thermal cooling device callbacks */ | 72 | /* thermal cooling device callbacks */ |
@@ -126,17 +122,15 @@ static const struct thermal_cooling_device_ops fan_cooling_ops = { | |||
126 | Driver Interface | 122 | Driver Interface |
127 | -------------------------------------------------------------------------- */ | 123 | -------------------------------------------------------------------------- */ |
128 | 124 | ||
129 | static int acpi_fan_add(struct acpi_device *device) | 125 | static int acpi_fan_probe(struct platform_device *pdev) |
130 | { | 126 | { |
131 | int result = 0; | 127 | int result = 0; |
132 | struct thermal_cooling_device *cdev; | 128 | struct thermal_cooling_device *cdev; |
133 | 129 | struct acpi_device *device = ACPI_COMPANION(&pdev->dev); | |
134 | strcpy(acpi_device_name(device), "Fan"); | ||
135 | strcpy(acpi_device_class(device), ACPI_FAN_CLASS); | ||
136 | 130 | ||
137 | result = acpi_device_update_power(device, NULL); | 131 | result = acpi_device_update_power(device, NULL); |
138 | if (result) { | 132 | if (result) { |
139 | printk(KERN_ERR PREFIX "Setting initial power state\n"); | 133 | dev_err(&pdev->dev, "Setting initial power state\n"); |
140 | goto end; | 134 | goto end; |
141 | } | 135 | } |
142 | 136 | ||
@@ -147,24 +141,24 @@ static int acpi_fan_add(struct acpi_device *device) | |||
147 | goto end; | 141 | goto end; |
148 | } | 142 | } |
149 | 143 | ||
150 | dev_dbg(&device->dev, "registered as cooling_device%d\n", cdev->id); | 144 | dev_dbg(&pdev->dev, "registered as cooling_device%d\n", cdev->id); |
151 | 145 | ||
152 | device->driver_data = cdev; | 146 | platform_set_drvdata(pdev, cdev); |
153 | result = sysfs_create_link(&device->dev.kobj, | 147 | result = sysfs_create_link(&pdev->dev.kobj, |
154 | &cdev->device.kobj, | 148 | &cdev->device.kobj, |
155 | "thermal_cooling"); | 149 | "thermal_cooling"); |
156 | if (result) | 150 | if (result) |
157 | dev_err(&device->dev, "Failed to create sysfs link " | 151 | dev_err(&pdev->dev, "Failed to create sysfs link " |
158 | "'thermal_cooling'\n"); | 152 | "'thermal_cooling'\n"); |
159 | 153 | ||
160 | result = sysfs_create_link(&cdev->device.kobj, | 154 | result = sysfs_create_link(&cdev->device.kobj, |
161 | &device->dev.kobj, | 155 | &pdev->dev.kobj, |
162 | "device"); | 156 | "device"); |
163 | if (result) | 157 | if (result) |
164 | dev_err(&device->dev, "Failed to create sysfs link " | 158 | dev_err(&pdev->dev, "Failed to create sysfs link " |
165 | "'device'\n"); | 159 | "'device'\n"); |
166 | 160 | ||
167 | printk(KERN_INFO PREFIX "%s [%s] (%s)\n", | 161 | dev_info(&pdev->dev, "%s [%s] (%s)\n", |
168 | acpi_device_name(device), acpi_device_bid(device), | 162 | acpi_device_name(device), acpi_device_bid(device), |
169 | !device->power.state ? "on" : "off"); | 163 | !device->power.state ? "on" : "off"); |
170 | 164 | ||
@@ -172,11 +166,11 @@ end: | |||
172 | return result; | 166 | return result; |
173 | } | 167 | } |
174 | 168 | ||
175 | static int acpi_fan_remove(struct acpi_device *device) | 169 | static int acpi_fan_remove(struct platform_device *pdev) |
176 | { | 170 | { |
177 | struct thermal_cooling_device *cdev = acpi_driver_data(device); | 171 | struct thermal_cooling_device *cdev = platform_get_drvdata(pdev); |
178 | 172 | ||
179 | sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); | 173 | sysfs_remove_link(&pdev->dev.kobj, "thermal_cooling"); |
180 | sysfs_remove_link(&cdev->device.kobj, "device"); | 174 | sysfs_remove_link(&cdev->device.kobj, "device"); |
181 | thermal_cooling_device_unregister(cdev); | 175 | thermal_cooling_device_unregister(cdev); |
182 | 176 | ||
@@ -186,7 +180,7 @@ static int acpi_fan_remove(struct acpi_device *device) | |||
186 | #ifdef CONFIG_PM_SLEEP | 180 | #ifdef CONFIG_PM_SLEEP |
187 | static int acpi_fan_suspend(struct device *dev) | 181 | static int acpi_fan_suspend(struct device *dev) |
188 | { | 182 | { |
189 | acpi_device_set_power(to_acpi_device(dev), ACPI_STATE_D0); | 183 | acpi_device_set_power(ACPI_COMPANION(dev), ACPI_STATE_D0); |
190 | 184 | ||
191 | return AE_OK; | 185 | return AE_OK; |
192 | } | 186 | } |
@@ -195,12 +189,12 @@ static int acpi_fan_resume(struct device *dev) | |||
195 | { | 189 | { |
196 | int result; | 190 | int result; |
197 | 191 | ||
198 | result = acpi_device_update_power(to_acpi_device(dev), NULL); | 192 | result = acpi_device_update_power(ACPI_COMPANION(dev), NULL); |
199 | if (result) | 193 | if (result) |
200 | printk(KERN_ERR PREFIX "Error updating fan power state\n"); | 194 | dev_err(dev, "Error updating fan power state\n"); |
201 | 195 | ||
202 | return result; | 196 | return result; |
203 | } | 197 | } |
204 | #endif | 198 | #endif |
205 | 199 | ||
206 | module_acpi_driver(acpi_fan_driver); | 200 | module_platform_driver(acpi_fan_driver); |