aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/fan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/fan.c')
-rw-r--r--drivers/acpi/fan.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c
index 65bdcde2c4e3..38acc69b21bc 100644
--- a/drivers/acpi/fan.c
+++ b/drivers/acpi/fan.c
@@ -78,7 +78,6 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)
78 struct acpi_fan *fan = seq->private; 78 struct acpi_fan *fan = seq->private;
79 int state = 0; 79 int state = 0;
80 80
81 ACPI_FUNCTION_TRACE("acpi_fan_read_state");
82 81
83 if (fan) { 82 if (fan) {
84 if (acpi_bus_get_power(fan->handle, &state)) 83 if (acpi_bus_get_power(fan->handle, &state))
@@ -87,7 +86,7 @@ static int acpi_fan_read_state(struct seq_file *seq, void *offset)
87 seq_printf(seq, "status: %s\n", 86 seq_printf(seq, "status: %s\n",
88 !state ? "on" : "off"); 87 !state ? "on" : "off");
89 } 88 }
90 return_VALUE(0); 89 return 0;
91} 90}
92 91
93static int acpi_fan_state_open_fs(struct inode *inode, struct file *file) 92static int acpi_fan_state_open_fs(struct inode *inode, struct file *file)
@@ -104,22 +103,21 @@ acpi_fan_write_state(struct file *file, const char __user * buffer,
104 struct acpi_fan *fan = (struct acpi_fan *)m->private; 103 struct acpi_fan *fan = (struct acpi_fan *)m->private;
105 char state_string[12] = { '\0' }; 104 char state_string[12] = { '\0' };
106 105
107 ACPI_FUNCTION_TRACE("acpi_fan_write_state");
108 106
109 if (!fan || (count > sizeof(state_string) - 1)) 107 if (!fan || (count > sizeof(state_string) - 1))
110 return_VALUE(-EINVAL); 108 return -EINVAL;
111 109
112 if (copy_from_user(state_string, buffer, count)) 110 if (copy_from_user(state_string, buffer, count))
113 return_VALUE(-EFAULT); 111 return -EFAULT;
114 112
115 state_string[count] = '\0'; 113 state_string[count] = '\0';
116 114
117 result = acpi_bus_set_power(fan->handle, 115 result = acpi_bus_set_power(fan->handle,
118 simple_strtoul(state_string, NULL, 0)); 116 simple_strtoul(state_string, NULL, 0));
119 if (result) 117 if (result)
120 return_VALUE(result); 118 return result;
121 119
122 return_VALUE(count); 120 return count;
123} 121}
124 122
125static struct file_operations acpi_fan_state_ops = { 123static struct file_operations acpi_fan_state_ops = {
@@ -135,16 +133,15 @@ static int acpi_fan_add_fs(struct acpi_device *device)
135{ 133{
136 struct proc_dir_entry *entry = NULL; 134 struct proc_dir_entry *entry = NULL;
137 135
138 ACPI_FUNCTION_TRACE("acpi_fan_add_fs");
139 136
140 if (!device) 137 if (!device)
141 return_VALUE(-EINVAL); 138 return -EINVAL;
142 139
143 if (!acpi_device_dir(device)) { 140 if (!acpi_device_dir(device)) {
144 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 141 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
145 acpi_fan_dir); 142 acpi_fan_dir);
146 if (!acpi_device_dir(device)) 143 if (!acpi_device_dir(device))
147 return_VALUE(-ENODEV); 144 return -ENODEV;
148 acpi_device_dir(device)->owner = THIS_MODULE; 145 acpi_device_dir(device)->owner = THIS_MODULE;
149 } 146 }
150 147
@@ -153,19 +150,18 @@ static int acpi_fan_add_fs(struct acpi_device *device)
153 S_IFREG | S_IRUGO | S_IWUSR, 150 S_IFREG | S_IRUGO | S_IWUSR,
154 acpi_device_dir(device)); 151 acpi_device_dir(device));
155 if (!entry) 152 if (!entry)
156 return_VALUE(-ENODEV); 153 return -ENODEV;
157 else { 154 else {
158 entry->proc_fops = &acpi_fan_state_ops; 155 entry->proc_fops = &acpi_fan_state_ops;
159 entry->data = acpi_driver_data(device); 156 entry->data = acpi_driver_data(device);
160 entry->owner = THIS_MODULE; 157 entry->owner = THIS_MODULE;
161 } 158 }
162 159
163 return_VALUE(0); 160 return 0;
164} 161}
165 162
166static int acpi_fan_remove_fs(struct acpi_device *device) 163static int acpi_fan_remove_fs(struct acpi_device *device)
167{ 164{
168 ACPI_FUNCTION_TRACE("acpi_fan_remove_fs");
169 165
170 if (acpi_device_dir(device)) { 166 if (acpi_device_dir(device)) {
171 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device)); 167 remove_proc_entry(ACPI_FAN_FILE_STATE, acpi_device_dir(device));
@@ -173,7 +169,7 @@ static int acpi_fan_remove_fs(struct acpi_device *device)
173 acpi_device_dir(device) = NULL; 169 acpi_device_dir(device) = NULL;
174 } 170 }
175 171
176 return_VALUE(0); 172 return 0;
177} 173}
178 174
179/* -------------------------------------------------------------------------- 175/* --------------------------------------------------------------------------
@@ -186,14 +182,13 @@ static int acpi_fan_add(struct acpi_device *device)
186 struct acpi_fan *fan = NULL; 182 struct acpi_fan *fan = NULL;
187 int state = 0; 183 int state = 0;
188 184
189 ACPI_FUNCTION_TRACE("acpi_fan_add");
190 185
191 if (!device) 186 if (!device)
192 return_VALUE(-EINVAL); 187 return -EINVAL;
193 188
194 fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL); 189 fan = kmalloc(sizeof(struct acpi_fan), GFP_KERNEL);
195 if (!fan) 190 if (!fan)
196 return_VALUE(-ENOMEM); 191 return -ENOMEM;
197 memset(fan, 0, sizeof(struct acpi_fan)); 192 memset(fan, 0, sizeof(struct acpi_fan));
198 193
199 fan->handle = device->handle; 194 fan->handle = device->handle;
@@ -223,17 +218,16 @@ static int acpi_fan_add(struct acpi_device *device)
223 if (result) 218 if (result)
224 kfree(fan); 219 kfree(fan);
225 220
226 return_VALUE(result); 221 return result;
227} 222}
228 223
229static int acpi_fan_remove(struct acpi_device *device, int type) 224static int acpi_fan_remove(struct acpi_device *device, int type)
230{ 225{
231 struct acpi_fan *fan = NULL; 226 struct acpi_fan *fan = NULL;
232 227
233 ACPI_FUNCTION_TRACE("acpi_fan_remove");
234 228
235 if (!device || !acpi_driver_data(device)) 229 if (!device || !acpi_driver_data(device))
236 return_VALUE(-EINVAL); 230 return -EINVAL;
237 231
238 fan = (struct acpi_fan *)acpi_driver_data(device); 232 fan = (struct acpi_fan *)acpi_driver_data(device);
239 233
@@ -241,7 +235,7 @@ static int acpi_fan_remove(struct acpi_device *device, int type)
241 235
242 kfree(fan); 236 kfree(fan);
243 237
244 return_VALUE(0); 238 return 0;
245} 239}
246 240
247static int acpi_fan_suspend(struct acpi_device *device, int state) 241static int acpi_fan_suspend(struct acpi_device *device, int state)
@@ -280,31 +274,29 @@ static int __init acpi_fan_init(void)
280{ 274{
281 int result = 0; 275 int result = 0;
282 276
283 ACPI_FUNCTION_TRACE("acpi_fan_init");
284 277
285 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir); 278 acpi_fan_dir = proc_mkdir(ACPI_FAN_CLASS, acpi_root_dir);
286 if (!acpi_fan_dir) 279 if (!acpi_fan_dir)
287 return_VALUE(-ENODEV); 280 return -ENODEV;
288 acpi_fan_dir->owner = THIS_MODULE; 281 acpi_fan_dir->owner = THIS_MODULE;
289 282
290 result = acpi_bus_register_driver(&acpi_fan_driver); 283 result = acpi_bus_register_driver(&acpi_fan_driver);
291 if (result < 0) { 284 if (result < 0) {
292 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); 285 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
293 return_VALUE(-ENODEV); 286 return -ENODEV;
294 } 287 }
295 288
296 return_VALUE(0); 289 return 0;
297} 290}
298 291
299static void __exit acpi_fan_exit(void) 292static void __exit acpi_fan_exit(void)
300{ 293{
301 ACPI_FUNCTION_TRACE("acpi_fan_exit");
302 294
303 acpi_bus_unregister_driver(&acpi_fan_driver); 295 acpi_bus_unregister_driver(&acpi_fan_driver);
304 296
305 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir); 297 remove_proc_entry(ACPI_FAN_CLASS, acpi_root_dir);
306 298
307 return_VOID; 299 return;
308} 300}
309 301
310module_init(acpi_fan_init); 302module_init(acpi_fan_init);