From patchwork Tue Oct 5 16:54:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sundar Iyer X-Patchwork-Id: 233271 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o95GtICi014842 for ; Tue, 5 Oct 2010 16:55:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755776Ab0JEQy4 (ORCPT ); Tue, 5 Oct 2010 12:54:56 -0400 Received: from eu1sys200aog111.obsmtp.com ([207.126.144.131]:47292 "EHLO eu1sys200aog111.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754880Ab0JEQyz convert rfc822-to-8bit (ORCPT ); Tue, 5 Oct 2010 12:54:55 -0400 Received: from source ([167.4.1.35]) (using TLSv1) by eu1sys200aob111.postini.com ([207.126.147.11]) with SMTP ID DSNKTKtYW40KwAO7WQrRCWyBV25hEZj+OzKW@postini.com; Tue, 05 Oct 2010 16:54:54 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.80.115]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 475D3A0; Tue, 5 Oct 2010 16:51:33 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 779F95FC; Tue, 5 Oct 2010 16:54:48 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 265C3A8074; Tue, 5 Oct 2010 18:54:40 +0200 (CEST) Received: from EXDCVYMBSTM006.EQ1STM.local ([10.6.6.68]) by exdcvycastm022.EQ1STM.local ([10.230.100.30]) with mapi; Tue, 5 Oct 2010 18:54:47 +0200 From: Sundar R IYER To: Dmitry Torokhov Cc: Naveen Kumar GADDIPATI , Linus WALLEIJ , "linux-input@vger.kernel.org" , Jayeeta BANDYOPADHYAY Date: Tue, 5 Oct 2010 18:54:42 +0200 Subject: [RFC] input: syfs switches for SKE keypad Thread-Topic: [RFC] input: syfs switches for SKE keypad Thread-Index: ActkrgFcpakdOxsMSAa8pqp4MOj9kg== Message-ID: <33A307AF30D7BF4F811B1568FE7A9B180460D32FE2@EXDCVYMBSTM006.EQ1STM.local> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-cr-hashedpuzzle: CMQ= ATyW Dtqk FSw1 Fih0 G8Ic JH/3 JunU K+wk MnaK RUAZ RfiR San5 S3mG T2uV UznQ; 2; ZABtAGkAdAByAHkALgB0AG8AcgBvAGsAaABvAHYAQABnAG0AYQBpAGwALgBjAG8AbQA7AGwAaQBuAHUAeAAtAGkAbgBwAHUAdABAAHYAZwBlAHIALgBrAGUAcgBuAGUAbAAuAG8AcgBnAA==; Sosha1_v1; 7; {14F24152-FA74-42EF-BB61-E32A94F92DC7}; cwB1AG4AZABhAHIALgBpAHkAZQByAEAAcwB0AGUAcgBpAGMAcwBzAG8AbgAuAGMAbwBtAA==; Tue, 05 Oct 2010 16:54:42 GMT; WwBSAEYAQwBdACAAaQBuAHAAdQB0ADoAIABzAHkAZgBzACAAcwB3AGkAdABjAGgAZQBzACAAZgBvAHIAIABTAEsARQAgAGsAZQB5AHAAYQBkAA== x-cr-puzzleid: {14F24152-FA74-42EF-BB61-E32A94F92DC7} acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 05 Oct 2010 16:55:18 +0000 (UTC) --- 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)