Skip to content

Commit

Permalink
lis3lv02d: merge with leds hp disk
Browse files Browse the repository at this point in the history
Move the second part of the HP laptop disk protection functionality (a red
led) to the same driver.  From a purely Linux developer's point of view,
the led and the accelerometer have nothing related.  However, they
correspond to the same ACPI functionality, and so will always be used
together, moreover as they share the same ACPI PNP alias, there is no
other simple to allow to have same loaded at the same time if they are not
in the same module.  Also make it requires the led class to compile and
update the Kconfig text.

Signed-off-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Eric Piel <eric.piel@tremplin-utc.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Eric Piel authored and Linus Torvalds committed Jan 16, 2009
1 parent 5b019e9 commit 9e0c797
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 150 deletions.
14 changes: 11 additions & 3 deletions drivers/hwmon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ config SENSORS_HDAPS
config SENSORS_LIS3LV02D
tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer"
depends on ACPI && INPUT
select NEW_LEDS
select LEDS_CLASS
default n
help
This driver provides support for the LIS3LV02Dx accelerometer. In
Expand All @@ -872,10 +874,16 @@ config SENSORS_LIS3LV02D
/sys/devices/platform/lis3lv02d.

This driver also provides an absolute input class device, allowing
the laptop to act as a pinball machine-esque joystick.
the laptop to act as a pinball machine-esque joystick. On HP laptops,
if the led infrastructure is activated, support for a led indicating
disk protection will be provided as hp:red:hddprotection.

This driver can also be built as a module. If so, the module
will be called lis3lv02d.
This driver can also be built as modules. If so, the core module
will be called lis3lv02d and a specific module for HP laptops will be
called hp_accel.

Say Y here if you have an applicable laptop and want to experience
the awesome power of lis3lv02d.

config SENSORS_APPLESMC
tristate "Apple SMC (Motion sensor, light sensor, keyboard backlight)"
Expand Down
43 changes: 41 additions & 2 deletions drivers/hwmon/hp_accel.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <linux/freezer.h>
#include <linux/version.h>
#include <linux/uaccess.h>
#include <linux/leds.h>
#include <acpi/acpi_drivers.h>
#include <asm/atomic.h>
#include "lis3lv02d.h"
Expand Down Expand Up @@ -154,10 +155,34 @@ static struct dmi_system_id lis3lv02d_dmi_ids[] = {
*/
};

static acpi_status hpled_acpi_write(acpi_handle handle, int reg)
{
unsigned long long ret; /* Not used when writing */
union acpi_object in_obj[1];
struct acpi_object_list args = { 1, in_obj };

in_obj[0].type = ACPI_TYPE_INTEGER;
in_obj[0].integer.value = reg;

return acpi_evaluate_integer(handle, "ALED", &args, &ret);
}

static void hpled_set(struct led_classdev *led_cdev,
enum led_brightness value)
{
hpled_acpi_write(adev.device->handle, !!value);
}

static struct led_classdev hpled_led = {
.name = "hp:red:hddprotection",
.default_trigger = "none",
.brightness_set = hpled_set,
};

static int lis3lv02d_add(struct acpi_device *device)
{
u8 val;
int ret;

if (!device)
return -EINVAL;
Expand All @@ -183,7 +208,17 @@ static int lis3lv02d_add(struct acpi_device *device)
adev.ac = lis3lv02d_axis_normal;
}

return lis3lv02d_init_device(&adev);
ret = led_classdev_register(NULL, &hpled_led);
if (ret)
return ret;

ret = lis3lv02d_init_device(&adev);
if (ret) {
led_classdev_unregister(&hpled_led);
return ret;
}

return ret;
}

static int lis3lv02d_remove(struct acpi_device *device, int type)
Expand All @@ -194,6 +229,8 @@ static int lis3lv02d_remove(struct acpi_device *device, int type)
lis3lv02d_joystick_disable();
lis3lv02d_poweroff(device->handle);

led_classdev_unregister(&hpled_led);

return lis3lv02d_remove_fs();
}

Expand All @@ -203,6 +240,7 @@ static int lis3lv02d_suspend(struct acpi_device *device, pm_message_t state)
{
/* make sure the device is off when we suspend */
lis3lv02d_poweroff(device->handle);
led_classdev_suspend(&hpled_led);
return 0;
}

Expand All @@ -215,6 +253,7 @@ static int lis3lv02d_resume(struct acpi_device *device)
else
lis3lv02d_poweroff(device->handle);
mutex_unlock(&adev.lock);
led_classdev_resume(&hpled_led);
return 0;
}
#else
Expand Down Expand Up @@ -256,7 +295,7 @@ static void __exit lis3lv02d_exit_module(void)
acpi_bus_unregister_driver(&lis3lv02d_driver);
}

MODULE_DESCRIPTION("Glue between LIS3LV02Dx and HP ACPI BIOS");
MODULE_DESCRIPTION("Glue between LIS3LV02Dx and HP ACPI BIOS and support for disk protection LED.");
MODULE_AUTHOR("Yan Burman, Eric Piel, Pavel Machek");
MODULE_LICENSE("GPL");

Expand Down
7 changes: 0 additions & 7 deletions drivers/leds/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@ config LEDS_GPIO
outputs. To be useful the particular board must have LEDs
and they must be connected to the GPIO lines.

config LEDS_HP_DISK
tristate "LED Support for disk protection LED on HP notebooks"
depends on LEDS_CLASS && ACPI
help
This option enable support for disk protection LED, found on
newer HP notebooks.

config LEDS_CLEVO_MAIL
tristate "Mail LED on Clevo notebook (EXPERIMENTAL)"
depends on LEDS_CLASS && X86 && SERIO_I8042 && DMI && EXPERIMENTAL
Expand Down
1 change: 0 additions & 1 deletion drivers/leds/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ obj-$(CONFIG_LEDS_HP6XX) += leds-hp6xx.o
obj-$(CONFIG_LEDS_FSG) += leds-fsg.o
obj-$(CONFIG_LEDS_PCA955X) += leds-pca955x.o
obj-$(CONFIG_LEDS_DA903X) += leds-da903x.o
obj-$(CONFIG_LEDS_HP_DISK) += leds-hp-disk.o
obj-$(CONFIG_LEDS_WM8350) += leds-wm8350.o

# LED Triggers
Expand Down
137 changes: 0 additions & 137 deletions drivers/leds/leds-hp-disk.c

This file was deleted.

0 comments on commit 9e0c797

Please sign in to comment.