Merge branch 'fujitsu' into release
authorLen Brown <len.brown@intel.com>
Sat, 19 Sep 2009 06:09:50 +0000 (02:09 -0400)
committerLen Brown <len.brown@intel.com>
Sat, 19 Sep 2009 06:09:50 +0000 (02:09 -0400)
1  2 
drivers/platform/x86/Kconfig
drivers/platform/x86/fujitsu-laptop.c

index 48315621046d8b6b4fa125a36ee331d6dab83ff4,0b5a85b8048f11e002c1e9c0e09bf5686d2390d4..55ca39dea42e7f4177a3cd9f79f709cfb7dd1a64
@@@ -99,6 -99,7 +99,7 @@@ config FUJITSU_LAPTO
        depends on ACPI
        depends on INPUT
        depends on BACKLIGHT_CLASS_DEVICE
+       depends on LEDS_CLASS || LEDS_CLASS=n
        ---help---
          This is a driver for laptops built by Fujitsu:
  
@@@ -396,15 -397,6 +397,15 @@@ config ACPI_ASU
          NOTE: This driver is deprecated and will probably be removed soon,
          use asus-laptop instead.
  
 +config TOPSTAR_LAPTOP
 +      tristate "Topstar Laptop Extras"
 +      depends on ACPI
 +      depends on INPUT
 +      ---help---
 +        This driver adds support for hotkeys found on Topstar laptops.
 +
 +        If you have a Topstar laptop, say Y or M here.
 +
  config ACPI_TOSHIBA
        tristate "Toshiba Laptop Extras"
        depends on ACPI
index eabddc9c192bc4e317cb8b868927a03202952d06,1ed3513a62a2e07d299632375624b89c338a1aa9..f35aee5c21491ebc763bdff1e5a41a6fdba147dd
  #include <linux/kfifo.h>
  #include <linux/video_output.h>
  #include <linux/platform_device.h>
- #ifdef CONFIG_LEDS_CLASS
+ #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  #include <linux/leds.h>
  #endif
  
- #define FUJITSU_DRIVER_VERSION "0.5.0"
+ #define FUJITSU_DRIVER_VERSION "0.6.0"
  
  #define FUJITSU_LCD_N_LEVELS 8
  
@@@ -96,7 -96,7 +96,7 @@@
  /* FUNC interface - responses */
  #define UNSUPPORTED_CMD 0x80000000
  
- #ifdef CONFIG_LEDS_CLASS
+ #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  /* FUNC interface - LED control */
  #define FUNC_LED_OFF  0x1
  #define FUNC_LED_ON   0x30001
@@@ -176,7 -176,7 +176,7 @@@ static struct fujitsu_hotkey_t *fujitsu
  
  static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event);
  
- #ifdef CONFIG_LEDS_CLASS
+ #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  static enum led_brightness logolamp_get(struct led_classdev *cdev);
  static void logolamp_set(struct led_classdev *cdev,
                               enum led_brightness brightness);
@@@ -257,7 -257,7 +257,7 @@@ static int call_fext_func(int cmd, int 
        return out_obj.integer.value;
  }
  
- #ifdef CONFIG_LEDS_CLASS
+ #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
  /* LED class callbacks */
  
  static void logolamp_set(struct led_classdev *cdev,
@@@ -324,9 -324,6 +324,6 @@@ static int set_lcd_level(int level
        if (level < 0 || level >= fujitsu->max_brightness)
                return -EINVAL;
  
-       if (!fujitsu)
-               return -EINVAL;
        status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle);
        if (ACPI_FAILURE(status)) {
                vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n");
@@@ -355,9 -352,6 +352,6 @@@ static int set_lcd_level_alt(int level
        if (level < 0 || level >= fujitsu->max_brightness)
                return -EINVAL;
  
-       if (!fujitsu)
-               return -EINVAL;
        status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle);
        if (ACPI_FAILURE(status)) {
                vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n");
@@@ -697,10 -691,10 +691,10 @@@ static int acpi_fujitsu_add(struct acpi
        result = acpi_bus_get_power(fujitsu->acpi_handle, &state);
        if (result) {
                printk(KERN_ERR "Error reading power state\n");
-               goto end;
+               goto err_unregister_input_dev;
        }
  
 -      printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
 +      printk(KERN_INFO "ACPI: %s [%s] (%s)\n",
               acpi_device_name(device), acpi_device_bid(device),
               !device->power.state ? "on" : "off");
  
  
        return result;
  
- end:
+ err_unregister_input_dev:
+       input_unregister_device(input);
  err_free_input_dev:
        input_free_device(input);
  err_stop:
        return result;
  }
  
  static int acpi_fujitsu_remove(struct acpi_device *device, int type)
  {
-       struct fujitsu_t *fujitsu = NULL;
+       struct fujitsu_t *fujitsu = acpi_driver_data(device);
+       struct input_dev *input = fujitsu->input;
  
-       if (!device || !acpi_driver_data(device))
-               return -EINVAL;
+       input_unregister_device(input);
  
-       fujitsu = acpi_driver_data(device);
-       if (!device || !acpi_driver_data(device))
-               return -EINVAL;
+       input_free_device(input);
  
        fujitsu->acpi_handle = NULL;
  
@@@ -871,10 -862,10 +862,10 @@@ static int acpi_fujitsu_hotkey_add(stru
        result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state);
        if (result) {
                printk(KERN_ERR "Error reading power state\n");
-               goto end;
+               goto err_unregister_input_dev;
        }
  
 -      printk(KERN_INFO PREFIX "%s [%s] (%s)\n",
 +      printk(KERN_INFO "ACPI: %s [%s] (%s)\n",
               acpi_device_name(device), acpi_device_bid(device),
               !device->power.state ? "on" : "off");
  
        printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
                call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0));
  
-       #ifdef CONFIG_LEDS_CLASS
+ #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
        if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
                result = led_classdev_register(&fujitsu->pf_device->dev,
                                                &logolamp_led);
                        "LED handler for keyboard lamps, error %i\n", result);
                }
        }
      #endif
+ #endif
  
        return result;
  
- end:
+ err_unregister_input_dev:
+       input_unregister_device(input);
  err_free_input_dev:
        input_free_device(input);
  err_free_fifo:
        kfifo_free(fujitsu_hotkey->fifo);
  err_stop:
        return result;
  }
  
  static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type)
  {
-       struct fujitsu_hotkey_t *fujitsu_hotkey = NULL;
+       struct fujitsu_hotkey_t *fujitsu_hotkey = acpi_driver_data(device);
+       struct input_dev *input = fujitsu_hotkey->input;
  
-       if (!device || !acpi_driver_data(device))
-               return -EINVAL;
+ #ifdef CONFIG_LEDS_CLASS
+       if (fujitsu_hotkey->logolamp_registered)
+               led_classdev_unregister(&logolamp_led);
  
-       fujitsu_hotkey = acpi_driver_data(device);
+       if (fujitsu_hotkey->kblamps_registered)
+               led_classdev_unregister(&kblamps_led);
+ #endif
  
-       fujitsu_hotkey->acpi_handle = NULL;
+       input_unregister_device(input);
+       input_free_device(input);
  
        kfifo_free(fujitsu_hotkey->fifo);
  
+       fujitsu_hotkey->acpi_handle = NULL;
        return 0;
  }
  
@@@ -1130,8 -1129,11 +1129,11 @@@ static int __init fujitsu_init(void
                fujitsu->bl_device =
                        backlight_device_register("fujitsu-laptop", NULL, NULL,
                                                  &fujitsubl_ops);
-               if (IS_ERR(fujitsu->bl_device))
-                       return PTR_ERR(fujitsu->bl_device);
+               if (IS_ERR(fujitsu->bl_device)) {
+                       ret = PTR_ERR(fujitsu->bl_device);
+                       fujitsu->bl_device = NULL;
+                       goto fail_sysfs_group;
+               }
                max_brightness = fujitsu->max_brightness;
                fujitsu->bl_device->props.max_brightness = max_brightness - 1;
                fujitsu->bl_device->props.brightness = fujitsu->brightness_level;
        return 0;
  
  fail_hotkey1:
        kfree(fujitsu_hotkey);
  fail_hotkey:
        platform_driver_unregister(&fujitsupf_driver);
  fail_backlight:
        if (fujitsu->bl_device)
                backlight_device_unregister(fujitsu->bl_device);
+ fail_sysfs_group:
+       sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
+                          &fujitsupf_attribute_group);
  fail_platform_device2:
        platform_device_del(fujitsu->pf_device);
  fail_platform_device1:
        platform_device_put(fujitsu->pf_device);
  fail_platform_driver:
        acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  fail_acpi:
        kfree(fujitsu);
  
        return ret;
  
  static void __exit fujitsu_cleanup(void)
  {
-       #ifdef CONFIG_LEDS_CLASS
-       if (fujitsu_hotkey->logolamp_registered != 0)
-               led_classdev_unregister(&logolamp_led);
+       acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver);
  
-       if (fujitsu_hotkey->kblamps_registered != 0)
-               led_classdev_unregister(&kblamps_led);
-       #endif
+       kfree(fujitsu_hotkey);
  
-       sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
-                          &fujitsupf_attribute_group);
-       platform_device_unregister(fujitsu->pf_device);
        platform_driver_unregister(&fujitsupf_driver);
        if (fujitsu->bl_device)
                backlight_device_unregister(fujitsu->bl_device);
  
-       acpi_bus_unregister_driver(&acpi_fujitsu_driver);
+       sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
+                          &fujitsupf_attribute_group);
  
-       kfree(fujitsu);
+       platform_device_unregister(fujitsu->pf_device);
  
-       acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver);
+       acpi_bus_unregister_driver(&acpi_fujitsu_driver);
  
-       kfree(fujitsu_hotkey);
+       kfree(fujitsu);
  
        printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n");
  }