Commit 669b4e04 authored by Len Brown's avatar Len Brown

Merge branch 'fujitsu' into test

parents f05b10e1 84a6ce26
...@@ -99,6 +99,7 @@ config FUJITSU_LAPTOP ...@@ -99,6 +99,7 @@ config FUJITSU_LAPTOP
depends on ACPI depends on ACPI
depends on INPUT depends on INPUT
depends on BACKLIGHT_CLASS_DEVICE depends on BACKLIGHT_CLASS_DEVICE
depends on LEDS_CLASS || LEDS_CLASS=n
---help--- ---help---
This is a driver for laptops built by Fujitsu: This is a driver for laptops built by Fujitsu:
......
...@@ -66,11 +66,11 @@ ...@@ -66,11 +66,11 @@
#include <linux/kfifo.h> #include <linux/kfifo.h>
#include <linux/video_output.h> #include <linux/video_output.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#ifdef CONFIG_LEDS_CLASS #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
#include <linux/leds.h> #include <linux/leds.h>
#endif #endif
#define FUJITSU_DRIVER_VERSION "0.5.0" #define FUJITSU_DRIVER_VERSION "0.6.0"
#define FUJITSU_LCD_N_LEVELS 8 #define FUJITSU_LCD_N_LEVELS 8
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
/* FUNC interface - responses */ /* FUNC interface - responses */
#define UNSUPPORTED_CMD 0x80000000 #define UNSUPPORTED_CMD 0x80000000
#ifdef CONFIG_LEDS_CLASS #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
/* FUNC interface - LED control */ /* FUNC interface - LED control */
#define FUNC_LED_OFF 0x1 #define FUNC_LED_OFF 0x1
#define FUNC_LED_ON 0x30001 #define FUNC_LED_ON 0x30001
...@@ -176,7 +176,7 @@ static struct fujitsu_hotkey_t *fujitsu_hotkey; ...@@ -176,7 +176,7 @@ static struct fujitsu_hotkey_t *fujitsu_hotkey;
static void acpi_fujitsu_hotkey_notify(struct acpi_device *device, u32 event); 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 enum led_brightness logolamp_get(struct led_classdev *cdev);
static void logolamp_set(struct led_classdev *cdev, static void logolamp_set(struct led_classdev *cdev,
enum led_brightness brightness); enum led_brightness brightness);
...@@ -257,7 +257,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2) ...@@ -257,7 +257,7 @@ static int call_fext_func(int cmd, int arg0, int arg1, int arg2)
return out_obj.integer.value; return out_obj.integer.value;
} }
#ifdef CONFIG_LEDS_CLASS #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
/* LED class callbacks */ /* LED class callbacks */
static void logolamp_set(struct led_classdev *cdev, static void logolamp_set(struct led_classdev *cdev,
...@@ -324,9 +324,6 @@ static int set_lcd_level(int level) ...@@ -324,9 +324,6 @@ static int set_lcd_level(int level)
if (level < 0 || level >= fujitsu->max_brightness) if (level < 0 || level >= fujitsu->max_brightness)
return -EINVAL; return -EINVAL;
if (!fujitsu)
return -EINVAL;
status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle); status = acpi_get_handle(fujitsu->acpi_handle, "SBLL", &handle);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n"); vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBLL not present\n");
...@@ -355,9 +352,6 @@ static int set_lcd_level_alt(int level) ...@@ -355,9 +352,6 @@ static int set_lcd_level_alt(int level)
if (level < 0 || level >= fujitsu->max_brightness) if (level < 0 || level >= fujitsu->max_brightness)
return -EINVAL; return -EINVAL;
if (!fujitsu)
return -EINVAL;
status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle); status = acpi_get_handle(fujitsu->acpi_handle, "SBL2", &handle);
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n"); vdbg_printk(FUJLAPTOP_DBG_ERROR, "SBL2 not present\n");
...@@ -697,7 +691,7 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -697,7 +691,7 @@ static int acpi_fujitsu_add(struct acpi_device *device)
result = acpi_bus_get_power(fujitsu->acpi_handle, &state); result = acpi_bus_get_power(fujitsu->acpi_handle, &state);
if (result) { if (result) {
printk(KERN_ERR "Error reading power state\n"); printk(KERN_ERR "Error reading power state\n");
goto end; goto err_unregister_input_dev;
} }
printk(KERN_INFO "ACPI: %s [%s] (%s)\n", printk(KERN_INFO "ACPI: %s [%s] (%s)\n",
...@@ -728,25 +722,22 @@ static int acpi_fujitsu_add(struct acpi_device *device) ...@@ -728,25 +722,22 @@ static int acpi_fujitsu_add(struct acpi_device *device)
return result; return result;
end: err_unregister_input_dev:
input_unregister_device(input);
err_free_input_dev: err_free_input_dev:
input_free_device(input); input_free_device(input);
err_stop: err_stop:
return result; return result;
} }
static int acpi_fujitsu_remove(struct acpi_device *device, int type) 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)) input_unregister_device(input);
return -EINVAL;
fujitsu = acpi_driver_data(device); input_free_device(input);
if (!device || !acpi_driver_data(device))
return -EINVAL;
fujitsu->acpi_handle = NULL; fujitsu->acpi_handle = NULL;
...@@ -871,7 +862,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -871,7 +862,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state); result = acpi_bus_get_power(fujitsu_hotkey->acpi_handle, &state);
if (result) { if (result) {
printk(KERN_ERR "Error reading power state\n"); printk(KERN_ERR "Error reading power state\n");
goto end; goto err_unregister_input_dev;
} }
printk(KERN_INFO "ACPI: %s [%s] (%s)\n", printk(KERN_INFO "ACPI: %s [%s] (%s)\n",
...@@ -911,7 +902,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -911,7 +902,7 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n", printk(KERN_INFO "fujitsu-laptop: BTNI: [0x%x]\n",
call_fext_func(FUNC_BUTTONS, 0x0, 0x0, 0x0)); 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) { if (call_fext_func(FUNC_LEDS, 0x0, 0x0, 0x0) & LOGOLAMP_POWERON) {
result = led_classdev_register(&fujitsu->pf_device->dev, result = led_classdev_register(&fujitsu->pf_device->dev,
&logolamp_led); &logolamp_led);
...@@ -934,33 +925,41 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device) ...@@ -934,33 +925,41 @@ static int acpi_fujitsu_hotkey_add(struct acpi_device *device)
"LED handler for keyboard lamps, error %i\n", result); "LED handler for keyboard lamps, error %i\n", result);
} }
} }
#endif #endif
return result; return result;
end: err_unregister_input_dev:
input_unregister_device(input);
err_free_input_dev: err_free_input_dev:
input_free_device(input); input_free_device(input);
err_free_fifo: err_free_fifo:
kfifo_free(fujitsu_hotkey->fifo); kfifo_free(fujitsu_hotkey->fifo);
err_stop: err_stop:
return result; return result;
} }
static int acpi_fujitsu_hotkey_remove(struct acpi_device *device, int type) 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)) #ifdef CONFIG_LEDS_CLASS
return -EINVAL; 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); kfifo_free(fujitsu_hotkey->fifo);
fujitsu_hotkey->acpi_handle = NULL;
return 0; return 0;
} }
...@@ -1130,8 +1129,11 @@ static int __init fujitsu_init(void) ...@@ -1130,8 +1129,11 @@ static int __init fujitsu_init(void)
fujitsu->bl_device = fujitsu->bl_device =
backlight_device_register("fujitsu-laptop", NULL, NULL, backlight_device_register("fujitsu-laptop", NULL, NULL,
&fujitsubl_ops); &fujitsubl_ops);
if (IS_ERR(fujitsu->bl_device)) if (IS_ERR(fujitsu->bl_device)) {
return PTR_ERR(fujitsu->bl_device); ret = PTR_ERR(fujitsu->bl_device);
fujitsu->bl_device = NULL;
goto fail_sysfs_group;
}
max_brightness = fujitsu->max_brightness; max_brightness = fujitsu->max_brightness;
fujitsu->bl_device->props.max_brightness = max_brightness - 1; fujitsu->bl_device->props.max_brightness = max_brightness - 1;
fujitsu->bl_device->props.brightness = fujitsu->brightness_level; fujitsu->bl_device->props.brightness = fujitsu->brightness_level;
...@@ -1171,32 +1173,22 @@ static int __init fujitsu_init(void) ...@@ -1171,32 +1173,22 @@ static int __init fujitsu_init(void)
return 0; return 0;
fail_hotkey1: fail_hotkey1:
kfree(fujitsu_hotkey); kfree(fujitsu_hotkey);
fail_hotkey: fail_hotkey:
platform_driver_unregister(&fujitsupf_driver); platform_driver_unregister(&fujitsupf_driver);
fail_backlight: fail_backlight:
if (fujitsu->bl_device) if (fujitsu->bl_device)
backlight_device_unregister(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: fail_platform_device2:
platform_device_del(fujitsu->pf_device); platform_device_del(fujitsu->pf_device);
fail_platform_device1: fail_platform_device1:
platform_device_put(fujitsu->pf_device); platform_device_put(fujitsu->pf_device);
fail_platform_driver: fail_platform_driver:
acpi_bus_unregister_driver(&acpi_fujitsu_driver); acpi_bus_unregister_driver(&acpi_fujitsu_driver);
fail_acpi: fail_acpi:
kfree(fujitsu); kfree(fujitsu);
return ret; return ret;
...@@ -1204,28 +1196,23 @@ fail_acpi: ...@@ -1204,28 +1196,23 @@ fail_acpi:
static void __exit fujitsu_cleanup(void) static void __exit fujitsu_cleanup(void)
{ {
#ifdef CONFIG_LEDS_CLASS acpi_bus_unregister_driver(&acpi_fujitsu_hotkey_driver);
if (fujitsu_hotkey->logolamp_registered != 0)
led_classdev_unregister(&logolamp_led);
if (fujitsu_hotkey->kblamps_registered != 0) kfree(fujitsu_hotkey);
led_classdev_unregister(&kblamps_led);
#endif
sysfs_remove_group(&fujitsu->pf_device->dev.kobj,
&fujitsupf_attribute_group);
platform_device_unregister(fujitsu->pf_device);
platform_driver_unregister(&fujitsupf_driver); platform_driver_unregister(&fujitsupf_driver);
if (fujitsu->bl_device) if (fujitsu->bl_device)
backlight_device_unregister(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"); printk(KERN_INFO "fujitsu-laptop: driver unloaded.\n");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment