From patchwork Wed Nov 25 14:22:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: samu.p.onkalo@nokia.com X-Patchwork-Id: 62828 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAPEMfYZ007114 for ; Wed, 25 Nov 2009 14:22:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934703AbZKYOWd (ORCPT ); Wed, 25 Nov 2009 09:22:33 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S934690AbZKYOWd (ORCPT ); Wed, 25 Nov 2009 09:22:33 -0500 Received: from smtp.nokia.com ([192.100.105.134]:37575 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934703AbZKYOWd (ORCPT ); Wed, 25 Nov 2009 09:22:33 -0500 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nAPELn1m000506; Wed, 25 Nov 2009 08:22:34 -0600 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 25 Nov 2009 16:22:19 +0200 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 25 Nov 2009 16:22:20 +0200 Received: from [172.22.144.188] (4fid08082.ntc.nokia.com [172.22.144.188]) by mgw-sa02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nAPEMIvd032180; Wed, 25 Nov 2009 16:22:18 +0200 Subject: Re: [PATCH 1/1] TWL4030 keypad: keypad lock / unlock From: Onkalo Samu Reply-To: samu.p.onkalo@nokia.com To: ext Mark Brown Cc: ext Dmitry Torokhov , "linux-input@vger.kernel.org" In-Reply-To: <20091123135435.GG24326@rakim.wolfsonmicro.main> References: <1257841448-12757-1-git-send-email-samu.p.onkalo@nokia.com> <1257841448-12757-2-git-send-email-samu.p.onkalo@nokia.com> <20091110134329.GB30911@sirena.org.uk> <20091110172637.GB15263@core.coreip.homeip.net> <1257933456.3507.42.camel@4fid08082> <20091111100837.GA6263@rakim.wolfsonmicro.main> <1258977955.5272.37.camel@4fid08082> <20091123135435.GG24326@rakim.wolfsonmicro.main> Organization: Nokia Oyj Date: Wed, 25 Nov 2009 16:22:17 +0200 Message-Id: <1259158937.9055.6.camel@4fid08082> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 X-OriginalArrivalTime: 25 Nov 2009 14:22:20.0069 (UTC) FILETIME=[B2A13D50:01CA6DDA] X-Nokia-AV: Clean Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org diff --git a/drivers/input/input.c b/drivers/input/input.c index cc763c9..94824a4 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1305,6 +1305,49 @@ static int input_dev_uevent(struct device *device, struct kobj_uevent_env *env) } \ } while (0) +/* SYSFS */ +static ssize_t input_dev_get_disable(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct input_dev *input_dev = to_input_dev(dev); + return sprintf(buf, "%u\n", input_dev->disabled); +} + +static ssize_t input_dev_set_disable(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct input_dev *input_dev = to_input_dev(dev); + long i = 0; + int ret; + + if (!(input_dev->disable && input_dev->enable)) + return 0; + + ret = strict_strtoul(buf, 0, &i); + if (ret) + return -EINVAL; + i = !!i; + + mutex_lock(&input_dev->mutex); + if (input_dev->disabled == i) { + mutex_unlock(&input_dev->mutex); + return count; + } + input_dev->disabled = i; should this be a counter or boolean? Or should this be in driver itself and not in input system. + + if (i) + input_dev->disable(input_dev); + else + input_dev->enable(input_dev); + + mutex_unlock(&input_dev->mutex); + return count; +} + +static DEVICE_ATTR(disable, S_IRUGO | S_IWUSR, input_dev_get_disable, + input_dev_set_disable); + #ifdef CONFIG_PM static void input_dev_reset(struct input_dev *dev, bool activate) { @@ -1539,6 +1582,13 @@ int input_register_device(struct input_dev *dev) return error; } + error = device_create_file(&dev->dev, &dev_attr_disable); + if (error < 0) { + device_del(&dev->dev); + mutex_unlock(&input_mutex); + return error; + } + list_add_tail(&dev->node, &input_dev_list); list_for_each_entry(handler, &input_handler_list, node) @@ -1578,6 +1628,8 @@ void input_unregister_device(struct input_dev *dev) mutex_unlock(&input_mutex); + device_remove_file(&dev->dev, &dev_attr_disable); + device_unregister(&dev->dev); } EXPORT_SYMBOL(input_unregister_device); diff --git a/include/linux/input.h b/include/linux/input.h index 0ccfc30..e6e1098 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -1048,6 +1048,11 @@ struct ff_effect { * or EV_SND. The device is expected to carry out the requested * action (turn on a LED, play sound, etc.) The call is protected * by @event_lock and must not sleep + * @enable: method is called when user wants to enable driver which was + * disabled using disable-method (optional). + * @disable: method is called when user wants to temporarily disable the + * driver (example: tell keyboard driver to disable scanning at + * HW level) (optional). * @grab: input handle that currently has the device grabbed (via * EVIOCGRAB ioctl). When a handle grabs a device it becomes sole