* [PATCH 7/7] input/nomadik-ske: add sysfs file to enable/disble SKE keypad
@ 2012-05-13 12:44 Linus Walleij
2012-05-15 11:57 ` Shubhrajyoti
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2012-05-13 12:44 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, Naveen Kumar Gaddipati, Linus Walleij
From: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
This sysfs file can force the SKE keypad into GPIO mode (low power)
from userspace if the device knows that it is going to go into
a mode where the keyboard is not going to be interactive.
Signed-off-by: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/input/keyboard/nomadik-ske-keypad.c | 62 +++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/drivers/input/keyboard/nomadik-ske-keypad.c b/drivers/input/keyboard/nomadik-ske-keypad.c
index d2cb4df..74ee59d 100644
--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -193,6 +193,58 @@ static void ske_mode_enable(struct ske_keypad *keypad, bool enable)
}
}
+static void ske_enable(struct ske_keypad *keypad, bool enable)
+{
+ keypad->enable = enable;
+ if (keypad->enable) {
+ enable_irq(keypad->irq);
+ ske_mode_enable(keypad, true);
+ } else {
+ ske_mode_enable(keypad, false);
+ disable_irq(keypad->irq);
+ }
+}
+
+static ssize_t ske_show_attr_enable(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct ske_keypad *keypad = platform_get_drvdata(pdev);
+ return sprintf(buf, "%d\n", keypad->enable);
+}
+
+static ssize_t ske_store_attr_enable(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ struct platform_device *pdev = to_platform_device(dev);
+ struct ske_keypad *keypad = platform_get_drvdata(pdev);
+ unsigned long val;
+
+ if (strict_strtoul(buf, 0, &val))
+ return -EINVAL;
+
+ if ((val != 0) && (val != 1))
+ return -EINVAL;
+
+ if (keypad->enable != val) {
+ keypad->enable = val ? true : false;
+ ske_enable(keypad, keypad->enable);
+ }
+ return count;
+}
+
+static DEVICE_ATTR(enable, S_IWUSR | S_IRUGO,
+ ske_show_attr_enable, ske_store_attr_enable);
+
+static struct attribute *ske_keypad_attrs[] = {
+ &dev_attr_enable.attr,
+ NULL,
+};
+
+static struct attribute_group ske_attr_group = {
+ .attrs = ske_keypad_attrs,
+};
+
static void ske_keypad_report(struct ske_keypad *keypad, u8 status, int col)
{
int row = 0, code, pos;
@@ -634,10 +686,19 @@ no_wakeup:
goto out_unregisterinput;
}
+ /* sysfs implementation for dynamic enable/disable the input event */
+ ret = sysfs_create_group(&pdev->dev.kobj, &ske_attr_group);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to create sysfs entries\n");
+ goto out_free_irq;
+ }
+
platform_set_drvdata(pdev, keypad);
return 0;
+out_free_irq:
+ free_irq(keypad->irq, keypad);
out_unregisterinput:
input_unregister_device(input);
input = NULL;
@@ -666,6 +727,7 @@ static int __devexit ske_keypad_remove(struct platform_device *pdev)
cancel_delayed_work_sync(&keypad->scan_work);
input_unregister_device(keypad->input);
+ sysfs_remove_group(&pdev->dev.kobj, &ske_attr_group);
if (keypad->enable)
clk_disable(keypad->clk);
clk_put(keypad->clk);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 7/7] input/nomadik-ske: add sysfs file to enable/disble SKE keypad
2012-05-13 12:44 [PATCH 7/7] input/nomadik-ske: add sysfs file to enable/disble SKE keypad Linus Walleij
@ 2012-05-15 11:57 ` Shubhrajyoti
0 siblings, 0 replies; 2+ messages in thread
From: Shubhrajyoti @ 2012-05-15 11:57 UTC (permalink / raw)
To: Linus Walleij
Cc: Dmitry Torokhov, linux-input, Naveen Kumar Gaddipati,
Linus Walleij
On Sunday 13 May 2012 06:14 PM, Linus Walleij wrote:
> rom: Naveen Kumar Gaddipati <naveen.gaddipati@stericsson.com>
>
> This sysfs file can force the SKE keypad into GPIO mode (low power)
> from userspace if the device knows that it is going to go into
> a mode where the keyboard is not going to be interactive.
How about using the open and close?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-15 11:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-13 12:44 [PATCH 7/7] input/nomadik-ske: add sysfs file to enable/disble SKE keypad Linus Walleij
2012-05-15 11:57 ` Shubhrajyoti
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).