linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] input: syfs switches for SKE keypad
@ 2010-10-05 16:54 Sundar R IYER
  2010-10-05 17:41 ` Dmitry Torokhov
  0 siblings, 1 reply; 55+ messages in thread
From: Sundar R IYER @ 2010-10-05 16:54 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Naveen Kumar GADDIPATI, Linus WALLEIJ,
	linux-input@vger.kernel.org, Jayeeta BANDYOPADHYAY

Hi Dmitry,

Meego folks have a requirement for dynamic sysfs switches
for input drivers. I saw a patch from Samu (Nokia) for the same but which
lost its way out.  Here is a small modified patch set for the SKE
driver *only* which completes this requirement and hence a question for
you. (The idea is only a sysfs implemention; its not yet synced in with the
mainline code)

Would you be okay to accept a stand-alone patch like the below for all the
input drivers that we would be pushing in or do you have some comments
or improvements suggested to be folded in the original patch set from Nokia,
so that it can get through into the generic tree?

Regards,
Sundar

--- a/drivers/input/keyboard/nomadik-ske-keypad.c
+++ b/drivers/input/keyboard/nomadik-ske-keypad.c
@@ -47,6 +47,7 @@
  * @board:     keypad platform device
  * @keymap:    matrix scan code table for keycodes
  * @clk:       clock structure pointer
+ * @enable:    flag to enable the driver event
  */
 struct ske_keypad {
        int irq;
@@ -55,9 +56,11 @@ struct ske_keypad {
        struct ske_keypad_platform_data *board;
        unsigned short keymap[SKE_KPD_KEYMAP_SIZE];
        struct clk *clk;
+       bool enable;
 };
 
+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 (keypad->enable != val) {
+               keypad->enable = val;
+               if (!val) {
+                       disable_irq(keypad->irq);
+                       ske_keypad_set_bits(keypad, SKE_IMSC, ~SKE_KPIMA, 0x0);
+                       clk_disable(keypad->clk);
+               } else {
+                       clk_enable(keypad->clk);
+                       enable_irq(keypad->irq);
+                       ske_keypad_set_bits(keypad, SKE_IMSC, 0x0, SKE_KPIMA);
+               }
+       }
+       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,
+};
+
 /*
  * ske_keypad_chip_init : init keypad controller configuration
  *
@@ -186,7 +234,7 @@ static int __devinit ske_keypad_probe(struct platform_device *pdev)
        struct input_dev *input;
        struct clk *clk;
        void __iomem *reg_base;
-       int ret;
+       int ret = 0;
        int irq;
        struct ske_keypad_platform_data *plat = pdev->dev.platform_data;
 
@@ -250,6 +298,7 @@ static int __devinit ske_keypad_probe(struct platform_device *pdev)
        input->keycodemax = ARRAY_SIZE(keypad->keymap);
 
        input_set_capability(input, EV_MSC, MSC_SCAN);
+       input_set_drvdata(input, keypad);
 
        __set_bit(EV_KEY, input->evbit);
        if (!plat->no_autorepeat)
@@ -271,6 +320,7 @@ static int __devinit ske_keypad_probe(struct platform_device *pdev)
        keypad->input   = input;
        keypad->reg_base = reg_base;
        keypad->clk     = clk;
+       keypad->enable  = 1;
 
        /* allocations are sane, we begin HW initialization */
        clk_enable(keypad->clk);
@@ -300,12 +350,21 @@ static int __devinit ske_keypad_probe(struct platform_device *pdev)
                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;
+       }
+
        device_init_wakeup(&pdev->dev, true);
 
        platform_set_drvdata(pdev, keypad);
 
        return 0;
 
+out_free_irq:
+       free_irq(keypad->irq, keypad);
 out_unregisterinput:
        input_unregister_device(input);
        input = NULL;
@@ -330,6 +389,7 @@ static int __devexit ske_keypad_remove(struct platform_device *pdev)
 
        input_unregister_device(keypad->input);
 
+       sysfs_remove_group(&pdev->dev.kobj, &ske_attr_group);
        free_irq(keypad->irq, keypad);
 
        clk_disable(keypad->clk);

^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2010-10-15 16:04 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-05 16:54 [RFC] input: syfs switches for SKE keypad Sundar R IYER
2010-10-05 17:41 ` Dmitry Torokhov
2010-10-06  8:32   ` Trilok Soni
2010-10-06  8:56     ` Sundar R IYER
2010-10-06  9:48       ` Onkalo Samu
2010-10-06 11:41         ` Trilok Soni
2010-10-06 11:58           ` Sundar R IYER
2010-10-06 15:43           ` Dmitry Torokhov
2010-10-06 16:19             ` [linux-pm] " Alan Stern
2010-10-06 17:18               ` Dmitry Torokhov
2010-10-06 18:19                 ` Alan Stern
2010-10-06 18:26                   ` Dmitry Torokhov
2010-10-06 18:51                     ` Alan Stern
2010-10-06 19:08                     ` Rafael J. Wysocki
2010-10-06 20:08                       ` Alan Stern
2010-10-09 10:52                         ` Rafael J. Wysocki
2010-10-09 22:46                           ` Alan Stern
2010-10-09 23:02                             ` Rafael J. Wysocki
2010-10-10 20:34                               ` Alan Stern
2010-10-10 20:51                                 ` Dmitry Torokhov
2010-10-10 21:09                                   ` Alan Stern
2010-10-10 22:24                                     ` Rafael J. Wysocki
2010-10-11 15:56                                       ` Alan Stern
2010-10-11 22:33                                         ` Rafael J. Wysocki
2010-10-12  0:08                                           ` Alan Stern
2010-10-12 18:46                                             ` Rafael J. Wysocki
2010-10-11  3:16                                     ` Dmitry Torokhov
2010-10-11 16:06                                       ` Alan Stern
2010-10-11 16:15                                         ` Dmitry Torokhov
2010-10-11 16:53                                           ` Alan Stern
2010-10-11 17:07                                             ` Dmitry Torokhov
2010-10-11 21:54                                               ` Alan Stern
2010-10-11 22:08                                                 ` Dmitry Torokhov
2010-10-12  7:25                                                   ` Sundar R IYER
2010-10-12 15:34                                                     ` Alan Stern
2010-10-12 15:53                                                       ` Dmitry Torokhov
2010-10-12 17:45                                                         ` Alan Stern
2010-10-12 16:32                                                       ` Sundar R IYER
2010-10-12 17:49                                                       ` Mark Brown
2010-10-12 18:27                                                         ` Alan Stern
2010-10-12 18:30                                                           ` Mark Brown
2010-10-13  6:16                                                           ` Sundar R IYER
2010-10-13  9:57                                                             ` Mark Brown
2010-10-13 14:10                                                               ` Alan Stern
2010-10-13 17:25                                                                 ` Sundar
2010-10-13 17:37                                                                   ` Alan Stern
2010-10-13 17:42                                                                     ` Sundar
2010-10-13 18:00                                                                       ` Sundar
2010-10-13 20:26                                                                         ` Rafael J. Wysocki
2010-10-14 13:50                                                                           ` Alan Stern
2010-10-14 19:00                                                                             ` Rafael J. Wysocki
2010-10-15 16:04                                                                               ` Sundar
2010-10-13  7:11         ` Pavel Machek
2010-10-13 17:35           ` Ferenc Wagner
2010-10-13 19:20             ` [linux-pm] " Pavel Machek

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).