summaryrefslogtreecommitdiff
path: root/drivers/platform/chrome/cros_ec_dev.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2015-02-02 14:26:28 +0300
committerOlof Johansson <olof@lixom.net>2015-02-27 02:45:16 +0300
commitf3f837e52b14bf84c2db65f622b5c31cd261100c (patch)
treeea8c44173cd685e13f683fd63f205b9586a35fa9 /drivers/platform/chrome/cros_ec_dev.c
parent71af4b52cc22a8d0f7b66a51427a804741a045b6 (diff)
downloadlinux-f3f837e52b14bf84c2db65f622b5c31cd261100c.tar.xz
platform/chrome: Expose Chrome OS Lightbar to users
This adds some sysfs entries to provide userspace control of the four-element LED "lightbar" on the Chromebook Pixel. This only instantiates the lightbar controls if the device actually exists. To prevent DoS attacks, this interface is limited to 20 accesses/second, although that rate can be adjusted by a privileged user. On Chromebooks without a lightbar, this should have no effect. On the Chromebook Pixel, you should be able to do things like this: $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar $ echo 0x80 > brightness $ echo 255 > brightness $ $ cat sequence S0 $ echo konami > sequence $ cat sequence KONAMI $ $ cat sequence S0 And $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar $ echo stop > sequence $ echo "4 255 255 255" > led_rgb $ echo "0 255 0 0 1 0 255 0 2 0 0 255 3 255 255 0" > led_rgb $ echo run > sequence Test the DoS prevention with this: $ cd /sys/devices/virtual/chromeos/cros_ec/lightbar $ echo 500 > interval_msec $ time (cat version version version version version version version) Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Olof Johansson <olofj@chromium.org> Tested-by: Doug Anderson <dianders@chromium.org> Reviewed-by: Benson Leung <bleung@chromium.org> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk> Tested-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'drivers/platform/chrome/cros_ec_dev.c')
-rw-r--r--drivers/platform/chrome/cros_ec_dev.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/platform/chrome/cros_ec_dev.c b/drivers/platform/chrome/cros_ec_dev.c
index 33f37ad36892..ce714317a59e 100644
--- a/drivers/platform/chrome/cros_ec_dev.c
+++ b/drivers/platform/chrome/cros_ec_dev.c
@@ -200,6 +200,7 @@ static int ec_device_probe(struct platform_device *pdev)
/* Initialize extra interfaces */
ec_dev_sysfs_init(ec);
+ ec_dev_lightbar_init(ec);
return 0;
}
@@ -208,6 +209,7 @@ static int ec_device_remove(struct platform_device *pdev)
{
struct cros_ec_device *ec = dev_get_drvdata(pdev->dev.parent);
+ ec_dev_lightbar_remove(ec);
ec_dev_sysfs_remove(ec);
device_destroy(cros_class, MKDEV(ec_major, 0));
cdev_del(&ec->cdev);