aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/ac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/ac.c')
-rw-r--r--drivers/acpi/ac.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 95223d8c5ecc..36ca365bcead 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -84,19 +84,18 @@ static int acpi_ac_get_state(struct acpi_ac *ac)
84{ 84{
85 acpi_status status = AE_OK; 85 acpi_status status = AE_OK;
86 86
87 ACPI_FUNCTION_TRACE("acpi_ac_get_state");
88 87
89 if (!ac) 88 if (!ac)
90 return_VALUE(-EINVAL); 89 return -EINVAL;
91 90
92 status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state); 91 status = acpi_evaluate_integer(ac->handle, "_PSR", NULL, &ac->state);
93 if (ACPI_FAILURE(status)) { 92 if (ACPI_FAILURE(status)) {
94 ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state")); 93 ACPI_EXCEPTION((AE_INFO, status, "Error reading AC Adapter state"));
95 ac->state = ACPI_AC_STATUS_UNKNOWN; 94 ac->state = ACPI_AC_STATUS_UNKNOWN;
96 return_VALUE(-ENODEV); 95 return -ENODEV;
97 } 96 }
98 97
99 return_VALUE(0); 98 return 0;
100} 99}
101 100
102/* -------------------------------------------------------------------------- 101/* --------------------------------------------------------------------------
@@ -109,14 +108,13 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
109{ 108{
110 struct acpi_ac *ac = (struct acpi_ac *)seq->private; 109 struct acpi_ac *ac = (struct acpi_ac *)seq->private;
111 110
112 ACPI_FUNCTION_TRACE("acpi_ac_seq_show");
113 111
114 if (!ac) 112 if (!ac)
115 return_VALUE(0); 113 return 0;
116 114
117 if (acpi_ac_get_state(ac)) { 115 if (acpi_ac_get_state(ac)) {
118 seq_puts(seq, "ERROR: Unable to read AC Adapter state\n"); 116 seq_puts(seq, "ERROR: Unable to read AC Adapter state\n");
119 return_VALUE(0); 117 return 0;
120 } 118 }
121 119
122 seq_puts(seq, "state: "); 120 seq_puts(seq, "state: ");
@@ -132,7 +130,7 @@ static int acpi_ac_seq_show(struct seq_file *seq, void *offset)
132 break; 130 break;
133 } 131 }
134 132
135 return_VALUE(0); 133 return 0;
136} 134}
137 135
138static int acpi_ac_open_fs(struct inode *inode, struct file *file) 136static int acpi_ac_open_fs(struct inode *inode, struct file *file)
@@ -144,13 +142,12 @@ static int acpi_ac_add_fs(struct acpi_device *device)
144{ 142{
145 struct proc_dir_entry *entry = NULL; 143 struct proc_dir_entry *entry = NULL;
146 144
147 ACPI_FUNCTION_TRACE("acpi_ac_add_fs");
148 145
149 if (!acpi_device_dir(device)) { 146 if (!acpi_device_dir(device)) {
150 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 147 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
151 acpi_ac_dir); 148 acpi_ac_dir);
152 if (!acpi_device_dir(device)) 149 if (!acpi_device_dir(device))
153 return_VALUE(-ENODEV); 150 return -ENODEV;
154 acpi_device_dir(device)->owner = THIS_MODULE; 151 acpi_device_dir(device)->owner = THIS_MODULE;
155 } 152 }
156 153
@@ -158,19 +155,18 @@ static int acpi_ac_add_fs(struct acpi_device *device)
158 entry = create_proc_entry(ACPI_AC_FILE_STATE, 155 entry = create_proc_entry(ACPI_AC_FILE_STATE,
159 S_IRUGO, acpi_device_dir(device)); 156 S_IRUGO, acpi_device_dir(device));
160 if (!entry) 157 if (!entry)
161 return_VALUE(-ENODEV); 158 return -ENODEV;
162 else { 159 else {
163 entry->proc_fops = &acpi_ac_fops; 160 entry->proc_fops = &acpi_ac_fops;
164 entry->data = acpi_driver_data(device); 161 entry->data = acpi_driver_data(device);
165 entry->owner = THIS_MODULE; 162 entry->owner = THIS_MODULE;
166 } 163 }
167 164
168 return_VALUE(0); 165 return 0;
169} 166}
170 167
171static int acpi_ac_remove_fs(struct acpi_device *device) 168static int acpi_ac_remove_fs(struct acpi_device *device)
172{ 169{
173 ACPI_FUNCTION_TRACE("acpi_ac_remove_fs");
174 170
175 if (acpi_device_dir(device)) { 171 if (acpi_device_dir(device)) {
176 remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device)); 172 remove_proc_entry(ACPI_AC_FILE_STATE, acpi_device_dir(device));
@@ -179,7 +175,7 @@ static int acpi_ac_remove_fs(struct acpi_device *device)
179 acpi_device_dir(device) = NULL; 175 acpi_device_dir(device) = NULL;
180 } 176 }
181 177
182 return_VALUE(0); 178 return 0;
183} 179}
184 180
185/* -------------------------------------------------------------------------- 181/* --------------------------------------------------------------------------
@@ -191,13 +187,12 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
191 struct acpi_ac *ac = (struct acpi_ac *)data; 187 struct acpi_ac *ac = (struct acpi_ac *)data;
192 struct acpi_device *device = NULL; 188 struct acpi_device *device = NULL;
193 189
194 ACPI_FUNCTION_TRACE("acpi_ac_notify");
195 190
196 if (!ac) 191 if (!ac)
197 return_VOID; 192 return;
198 193
199 if (acpi_bus_get_device(ac->handle, &device)) 194 if (acpi_bus_get_device(ac->handle, &device))
200 return_VOID; 195 return;
201 196
202 switch (event) { 197 switch (event) {
203 case ACPI_AC_NOTIFY_STATUS: 198 case ACPI_AC_NOTIFY_STATUS:
@@ -210,7 +205,7 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
210 break; 205 break;
211 } 206 }
212 207
213 return_VOID; 208 return;
214} 209}
215 210
216static int acpi_ac_add(struct acpi_device *device) 211static int acpi_ac_add(struct acpi_device *device)
@@ -219,14 +214,13 @@ static int acpi_ac_add(struct acpi_device *device)
219 acpi_status status = AE_OK; 214 acpi_status status = AE_OK;
220 struct acpi_ac *ac = NULL; 215 struct acpi_ac *ac = NULL;
221 216
222 ACPI_FUNCTION_TRACE("acpi_ac_add");
223 217
224 if (!device) 218 if (!device)
225 return_VALUE(-EINVAL); 219 return -EINVAL;
226 220
227 ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL); 221 ac = kmalloc(sizeof(struct acpi_ac), GFP_KERNEL);
228 if (!ac) 222 if (!ac)
229 return_VALUE(-ENOMEM); 223 return -ENOMEM;
230 memset(ac, 0, sizeof(struct acpi_ac)); 224 memset(ac, 0, sizeof(struct acpi_ac));
231 225
232 ac->handle = device->handle; 226 ac->handle = device->handle;
@@ -260,7 +254,7 @@ static int acpi_ac_add(struct acpi_device *device)
260 kfree(ac); 254 kfree(ac);
261 } 255 }
262 256
263 return_VALUE(result); 257 return result;
264} 258}
265 259
266static int acpi_ac_remove(struct acpi_device *device, int type) 260static int acpi_ac_remove(struct acpi_device *device, int type)
@@ -268,10 +262,9 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
268 acpi_status status = AE_OK; 262 acpi_status status = AE_OK;
269 struct acpi_ac *ac = NULL; 263 struct acpi_ac *ac = NULL;
270 264
271 ACPI_FUNCTION_TRACE("acpi_ac_remove");
272 265
273 if (!device || !acpi_driver_data(device)) 266 if (!device || !acpi_driver_data(device))
274 return_VALUE(-EINVAL); 267 return -EINVAL;
275 268
276 ac = (struct acpi_ac *)acpi_driver_data(device); 269 ac = (struct acpi_ac *)acpi_driver_data(device);
277 270
@@ -282,38 +275,36 @@ static int acpi_ac_remove(struct acpi_device *device, int type)
282 275
283 kfree(ac); 276 kfree(ac);
284 277
285 return_VALUE(0); 278 return 0;
286} 279}
287 280
288static int __init acpi_ac_init(void) 281static int __init acpi_ac_init(void)
289{ 282{
290 int result = 0; 283 int result = 0;
291 284
292 ACPI_FUNCTION_TRACE("acpi_ac_init");
293 285
294 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir); 286 acpi_ac_dir = proc_mkdir(ACPI_AC_CLASS, acpi_root_dir);
295 if (!acpi_ac_dir) 287 if (!acpi_ac_dir)
296 return_VALUE(-ENODEV); 288 return -ENODEV;
297 acpi_ac_dir->owner = THIS_MODULE; 289 acpi_ac_dir->owner = THIS_MODULE;
298 290
299 result = acpi_bus_register_driver(&acpi_ac_driver); 291 result = acpi_bus_register_driver(&acpi_ac_driver);
300 if (result < 0) { 292 if (result < 0) {
301 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); 293 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
302 return_VALUE(-ENODEV); 294 return -ENODEV;
303 } 295 }
304 296
305 return_VALUE(0); 297 return 0;
306} 298}
307 299
308static void __exit acpi_ac_exit(void) 300static void __exit acpi_ac_exit(void)
309{ 301{
310 ACPI_FUNCTION_TRACE("acpi_ac_exit");
311 302
312 acpi_bus_unregister_driver(&acpi_ac_driver); 303 acpi_bus_unregister_driver(&acpi_ac_driver);
313 304
314 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir); 305 remove_proc_entry(ACPI_AC_CLASS, acpi_root_dir);
315 306
316 return_VOID; 307 return;
317} 308}
318 309
319module_init(acpi_ac_init); 310module_init(acpi_ac_init);