aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2007-02-07 15:34:02 -0500
committerLen Brown <len.brown@intel.com>2007-02-13 03:07:20 -0500
commita02d1c1d2aa8ad4b2ed8da25e234c8962973f1b8 (patch)
treeef7b41471822d6213f42cc972c14a858d30bf076 /drivers/misc
parentd78865cdb096781382074943c1b7781696b178a6 (diff)
sony-laptop: Lindent
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/sony-laptop.c151
1 files changed, 78 insertions, 73 deletions
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 4a69ce7cc6be..d7b5330a7bcd 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -52,21 +52,23 @@ MODULE_LICENSE("GPL");
52static int debug; 52static int debug;
53module_param(debug, int, 0); 53module_param(debug, int, 0);
54MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help " 54MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help "
55 "the development of this driver"); 55 "the development of this driver");
56 56
57static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *); 57static ssize_t sony_acpi_show(struct device *, struct device_attribute *,
58static ssize_t sony_acpi_store(struct device *, struct device_attribute *, const char *, size_t); 58 char *);
59static ssize_t sony_acpi_store(struct device *, struct device_attribute *,
60 const char *, size_t);
59 61
60struct sony_acpi_value { 62struct sony_acpi_value {
61 char *name; /* name of the entry */ 63 char *name; /* name of the entry */
62 char **acpiget; /* names of the ACPI get function */ 64 char **acpiget; /* names of the ACPI get function */
63 char **acpiset; /* names of the ACPI set function */ 65 char **acpiset; /* names of the ACPI set function */
64 int min; /* minimum allowed value or -1 */ 66 int min; /* minimum allowed value or -1 */
65 int max; /* maximum allowed value or -1 */ 67 int max; /* maximum allowed value or -1 */
66 int value; /* current setting */ 68 int value; /* current setting */
67 int valid; /* Has ever been set */ 69 int valid; /* Has ever been set */
68 int debug; /* active only in debug mode ? */ 70 int debug; /* active only in debug mode ? */
69 struct device_attribute devattr; /* sysfs atribute */ 71 struct device_attribute devattr; /* sysfs atribute */
70}; 72};
71 73
72#define HANDLE_NAMES(_name, _values...) \ 74#define HANDLE_NAMES(_name, _values...) \
@@ -111,16 +113,18 @@ HANDLE_NAMES(CMI_get, "GCMI");
111HANDLE_NAMES(CMI_set, "SCMI"); 113HANDLE_NAMES(CMI_set, "SCMI");
112 114
113static struct sony_acpi_value sony_acpi_values[] = { 115static struct sony_acpi_value sony_acpi_values[] = {
114 SONY_ACPI_VALUE(brightness_default, snc_brightness_def_get, snc_brightness_def_set, 1, SONY_MAX_BRIGHTNESS, 0), 116 SONY_ACPI_VALUE(brightness_default, snc_brightness_def_get,
115 SONY_ACPI_VALUE(fnkey, snc_fnkey_get, NULL, -1, -1, 0), 117 snc_brightness_def_set, 1, SONY_MAX_BRIGHTNESS, 0),
116 SONY_ACPI_VALUE(cdpower, snc_cdpower_get, snc_cdpower_set, 0, 1, 0), 118 SONY_ACPI_VALUE(fnkey, snc_fnkey_get, NULL, -1, -1, 0),
117 SONY_ACPI_VALUE(audiopower, snc_audiopower_get, snc_audiopower_set, 0, 1, 0), 119 SONY_ACPI_VALUE(cdpower, snc_cdpower_get, snc_cdpower_set, 0, 1, 0),
118 SONY_ACPI_VALUE(lanpower, snc_lanpower_get, snc_lanpower_set, 0, 1, 1), 120 SONY_ACPI_VALUE(audiopower, snc_audiopower_get, snc_audiopower_set, 0,
121 1, 0),
122 SONY_ACPI_VALUE(lanpower, snc_lanpower_get, snc_lanpower_set, 0, 1, 1),
119 /* unknown methods */ 123 /* unknown methods */
120 SONY_ACPI_VALUE(PID, snc_PID_get, NULL, -1, -1, 1), 124 SONY_ACPI_VALUE(PID, snc_PID_get, NULL, -1, -1, 1),
121 SONY_ACPI_VALUE(CTR, snc_CTR_get, snc_CTR_set, -1, -1, 1), 125 SONY_ACPI_VALUE(CTR, snc_CTR_get, snc_CTR_set, -1, -1, 1),
122 SONY_ACPI_VALUE(PCR, snc_PCR_get, snc_PCR_set, -1, -1, 1), 126 SONY_ACPI_VALUE(PCR, snc_PCR_get, snc_PCR_set, -1, -1, 1),
123 SONY_ACPI_VALUE(CMI, snc_CMI_get, snc_CMI_set, -1, -1, 1), 127 SONY_ACPI_VALUE(CMI, snc_CMI_get, snc_CMI_set, -1, -1, 1),
124 SONY_ACPI_VALUE_NULL 128 SONY_ACPI_VALUE_NULL
125}; 129};
126 130
@@ -189,10 +193,11 @@ static int acpi_callsetfunc(acpi_handle handle, char *name, int value,
189 * Sysfs show/store common to all sony_acpi_values 193 * Sysfs show/store common to all sony_acpi_values
190 */ 194 */
191static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr, 195static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr,
192 char *buffer) 196 char *buffer)
193{ 197{
194 int value; 198 int value;
195 struct sony_acpi_value *item = container_of(attr, struct sony_acpi_value, devattr); 199 struct sony_acpi_value *item =
200 container_of(attr, struct sony_acpi_value, devattr);
196 201
197 if (!*item->acpiget) 202 if (!*item->acpiget)
198 return -EIO; 203 return -EIO;
@@ -203,11 +208,13 @@ static ssize_t sony_acpi_show(struct device *dev, struct device_attribute *attr,
203 return snprintf(buffer, PAGE_SIZE, "%d\n", value); 208 return snprintf(buffer, PAGE_SIZE, "%d\n", value);
204} 209}
205 210
206static ssize_t sony_acpi_store(struct device *dev, struct device_attribute *attr, 211static ssize_t sony_acpi_store(struct device *dev,
207 const char *buffer, size_t count) 212 struct device_attribute *attr,
213 const char *buffer, size_t count)
208{ 214{
209 int value; 215 int value;
210 struct sony_acpi_value *item = container_of(attr, struct sony_acpi_value, devattr); 216 struct sony_acpi_value *item =
217 container_of(attr, struct sony_acpi_value, devattr);
211 218
212 if (!item->acpiset) 219 if (!item->acpiset)
213 return -EIO; 220 return -EIO;
@@ -234,9 +241,9 @@ static ssize_t sony_acpi_store(struct device *dev, struct device_attribute *attr
234 */ 241 */
235static struct platform_driver sncpf_driver = { 242static struct platform_driver sncpf_driver = {
236 .driver = { 243 .driver = {
237 .name = "sony-laptop", 244 .name = "sony-laptop",
238 .owner = THIS_MODULE, 245 .owner = THIS_MODULE,
239 } 246 }
240}; 247};
241static struct platform_device *sncpf_device; 248static struct platform_device *sncpf_device;
242 249
@@ -268,12 +275,11 @@ static int sony_snc_pf_add(void)
268 /* find the available acpiget as described in the DSDT */ 275 /* find the available acpiget as described in the DSDT */
269 for (; item->acpiget && *item->acpiget; ++item->acpiget) { 276 for (; item->acpiget && *item->acpiget; ++item->acpiget) {
270 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, 277 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
271 *item->acpiget, 278 *item->acpiget,
272 &handle))) { 279 &handle))) {
273 if (debug) 280 if (debug)
274 printk(LOG_PFX "Found %s getter: %s\n", 281 printk(LOG_PFX "Found %s getter: %s\n",
275 item->name, 282 item->name, *item->acpiget);
276 *item->acpiget);
277 item->devattr.attr.mode |= S_IRUGO; 283 item->devattr.attr.mode |= S_IRUGO;
278 break; 284 break;
279 } 285 }
@@ -282,36 +288,37 @@ static int sony_snc_pf_add(void)
282 /* find the available acpiset as described in the DSDT */ 288 /* find the available acpiset as described in the DSDT */
283 for (; item->acpiset && *item->acpiset; ++item->acpiset) { 289 for (; item->acpiset && *item->acpiset; ++item->acpiset) {
284 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, 290 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle,
285 *item->acpiset, 291 *item->acpiset,
286 &handle))) { 292 &handle))) {
287 if (debug) 293 if (debug)
288 printk(LOG_PFX "Found %s setter: %s\n", 294 printk(LOG_PFX "Found %s setter: %s\n",
289 item->name, 295 item->name, *item->acpiset);
290 *item->acpiset);
291 item->devattr.attr.mode |= S_IWUSR; 296 item->devattr.attr.mode |= S_IWUSR;
292 break; 297 break;
293 } 298 }
294 } 299 }
295 300
296 if (item->devattr.attr.mode != 0) { 301 if (item->devattr.attr.mode != 0) {
297 ret = device_create_file(&sncpf_device->dev, &item->devattr); 302 ret =
298 if (ret) 303 device_create_file(&sncpf_device->dev,
299 goto out_sysfs; 304 &item->devattr);
300 } 305 if (ret)
306 goto out_sysfs;
307 }
301 } 308 }
302 309
303 return 0; 310 return 0;
304 311
305out_sysfs: 312 out_sysfs:
306 for (item = sony_acpi_values; item->name; ++item) { 313 for (item = sony_acpi_values; item->name; ++item) {
307 device_remove_file(&sncpf_device->dev, &item->devattr); 314 device_remove_file(&sncpf_device->dev, &item->devattr);
308 } 315 }
309 platform_device_del(sncpf_device); 316 platform_device_del(sncpf_device);
310out_platform_alloced: 317 out_platform_alloced:
311 platform_device_put(sncpf_device); 318 platform_device_put(sncpf_device);
312out_platform_registered: 319 out_platform_registered:
313 platform_driver_unregister(&sncpf_driver); 320 platform_driver_unregister(&sncpf_driver);
314out: 321 out:
315 return ret; 322 return ret;
316} 323}
317 324
@@ -334,8 +341,7 @@ static void sony_snc_pf_remove(void)
334static int sony_backlight_update_status(struct backlight_device *bd) 341static int sony_backlight_update_status(struct backlight_device *bd)
335{ 342{
336 return acpi_callsetfunc(sony_acpi_handle, "SBRT", 343 return acpi_callsetfunc(sony_acpi_handle, "SBRT",
337 bd->props->brightness + 1, 344 bd->props->brightness + 1, NULL);
338 NULL);
339} 345}
340 346
341static int sony_backlight_get_brightness(struct backlight_device *bd) 347static int sony_backlight_get_brightness(struct backlight_device *bd)
@@ -350,10 +356,10 @@ static int sony_backlight_get_brightness(struct backlight_device *bd)
350 356
351static struct backlight_device *sony_backlight_device; 357static struct backlight_device *sony_backlight_device;
352static struct backlight_properties sony_backlight_properties = { 358static struct backlight_properties sony_backlight_properties = {
353 .owner = THIS_MODULE, 359 .owner = THIS_MODULE,
354 .update_status = sony_backlight_update_status, 360 .update_status = sony_backlight_update_status,
355 .get_brightness = sony_backlight_get_brightness, 361 .get_brightness = sony_backlight_get_brightness,
356 .max_brightness = SONY_MAX_BRIGHTNESS - 1, 362 .max_brightness = SONY_MAX_BRIGHTNESS - 1,
357}; 363};
358 364
359/* 365/*
@@ -372,8 +378,8 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
372 struct acpi_namespace_node *node; 378 struct acpi_namespace_node *node;
373 union acpi_operand_object *operand; 379 union acpi_operand_object *operand;
374 380
375 node = (struct acpi_namespace_node *) handle; 381 node = (struct acpi_namespace_node *)handle;
376 operand = (union acpi_operand_object *) node->object; 382 operand = (union acpi_operand_object *)node->object;
377 383
378 printk(LOG_PFX "method: name: %4.4s, args %X\n", node->name.ascii, 384 printk(LOG_PFX "method: name: %4.4s, args %X\n", node->name.ascii,
379 (u32) operand->method.param_count); 385 (u32) operand->method.param_count);
@@ -394,7 +400,7 @@ static int sony_acpi_resume(struct acpi_device *device)
394 if (!item->valid) 400 if (!item->valid)
395 continue; 401 continue;
396 ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset, 402 ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset,
397 item->value, NULL); 403 item->value, NULL);
398 if (ret < 0) { 404 if (ret < 0) {
399 printk("%s: %d\n", __FUNCTION__, ret); 405 printk("%s: %d\n", __FUNCTION__, ret);
400 break; 406 break;
@@ -425,8 +431,7 @@ static int sony_acpi_add(struct acpi_device *device)
425 431
426 status = acpi_install_notify_handler(sony_acpi_handle, 432 status = acpi_install_notify_handler(sony_acpi_handle,
427 ACPI_DEVICE_NOTIFY, 433 ACPI_DEVICE_NOTIFY,
428 sony_acpi_notify, 434 sony_acpi_notify, NULL);
429 NULL);
430 if (ACPI_FAILURE(status)) { 435 if (ACPI_FAILURE(status)) {
431 printk(LOG_PFX "unable to install notify handler\n"); 436 printk(LOG_PFX "unable to install notify handler\n");
432 result = -ENODEV; 437 result = -ENODEV;
@@ -435,15 +440,16 @@ static int sony_acpi_add(struct acpi_device *device)
435 440
436 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) { 441 if (ACPI_SUCCESS(acpi_get_handle(sony_acpi_handle, "GBRT", &handle))) {
437 sony_backlight_device = backlight_device_register("sony", NULL, 442 sony_backlight_device = backlight_device_register("sony", NULL,
438 NULL, &sony_backlight_properties); 443 NULL,
444 &sony_backlight_properties);
439 445
440 if (IS_ERR(sony_backlight_device)) { 446 if (IS_ERR(sony_backlight_device)) {
441 printk(LOG_PFX "unable to register backlight device\n"); 447 printk(LOG_PFX "unable to register backlight device\n");
442 sony_backlight_device = NULL; 448 sony_backlight_device = NULL;
443 } 449 } else
444 else
445 sony_backlight_properties.brightness = 450 sony_backlight_properties.brightness =
446 sony_backlight_get_brightness(sony_backlight_device); 451 sony_backlight_get_brightness
452 (sony_backlight_device);
447 } 453 }
448 454
449 if (sony_snc_pf_add()) 455 if (sony_snc_pf_add())
@@ -453,7 +459,7 @@ static int sony_acpi_add(struct acpi_device *device)
453 459
454 return 0; 460 return 0;
455 461
456outbacklight: 462 outbacklight:
457 if (sony_backlight_device) 463 if (sony_backlight_device)
458 backlight_device_unregister(sony_backlight_device); 464 backlight_device_unregister(sony_backlight_device);
459 465
@@ -462,7 +468,7 @@ outbacklight:
462 sony_acpi_notify); 468 sony_acpi_notify);
463 if (ACPI_FAILURE(status)) 469 if (ACPI_FAILURE(status))
464 printk(LOG_PFX "unable to remove notify handler\n"); 470 printk(LOG_PFX "unable to remove notify handler\n");
465outwalk: 471 outwalk:
466 return result; 472 return result;
467} 473}
468 474
@@ -489,14 +495,14 @@ static int sony_acpi_remove(struct acpi_device *device, int type)
489} 495}
490 496
491static struct acpi_driver sony_acpi_driver = { 497static struct acpi_driver sony_acpi_driver = {
492 .name = ACPI_SNC_DRIVER_NAME, 498 .name = ACPI_SNC_DRIVER_NAME,
493 .class = ACPI_SNC_CLASS, 499 .class = ACPI_SNC_CLASS,
494 .ids = ACPI_SNC_HID, 500 .ids = ACPI_SNC_HID,
495 .ops = { 501 .ops = {
496 .add = sony_acpi_add, 502 .add = sony_acpi_add,
497 .remove = sony_acpi_remove, 503 .remove = sony_acpi_remove,
498 .resume = sony_acpi_resume, 504 .resume = sony_acpi_resume,
499 }, 505 },
500}; 506};
501 507
502static int __init sony_acpi_init(void) 508static int __init sony_acpi_init(void)
@@ -504,7 +510,6 @@ static int __init sony_acpi_init(void)
504 return acpi_bus_register_driver(&sony_acpi_driver); 510 return acpi_bus_register_driver(&sony_acpi_driver);
505} 511}
506 512
507
508static void __exit sony_acpi_exit(void) 513static void __exit sony_acpi_exit(void)
509{ 514{
510 acpi_bus_unregister_driver(&sony_acpi_driver); 515 acpi_bus_unregister_driver(&sony_acpi_driver);