From patchwork Fri Feb 20 22:21:34 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 8197 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 n1KMLhUF026166 for ; Fri, 20 Feb 2009 22:21:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753281AbZBTWVm (ORCPT ); Fri, 20 Feb 2009 17:21:42 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753471AbZBTWVm (ORCPT ); Fri, 20 Feb 2009 17:21:42 -0500 Received: from ns1.siteground211.com ([209.62.36.12]:58177 "EHLO serv01.siteground211.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753281AbZBTWVl (ORCPT ); Fri, 20 Feb 2009 17:21:41 -0500 Received: from [91.154.126.168] (port=15443 helo=localhost.localdomain) by serv01.siteground211.com with esmtpa (Exim 4.69) (envelope-from ) id 1LadkY-0002ED-4E; Fri, 20 Feb 2009 16:21:38 -0600 From: Felipe Balbi To: linux-omap@vger.kernel.org Cc: Tony Lindgren , Felipe Balbi Subject: [PATCH] input: lm8323: apply comments from mainline Date: Sat, 21 Feb 2009 00:21:34 +0200 Message-Id: <1235168494-20304-1-git-send-email-me@felipebalbi.com> X-Mailer: git-send-email 1.6.1.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - serv01.siteground211.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - felipebalbi.com Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org In order to avoid conflicts later, let's sync omap version with the version accepted by mainline after fixing a few comments. Signed-off-by: Felipe Balbi --- lm8323 was recently added to -mm tree, so I'm sending this patch to avoid conflicts with this driver later The patch titled input: keyboard: introduce lm8323 driver has been added to the -mm tree. Its filename is input-keyboard-introduce-lm8323-driver.patch drivers/input/keyboard/Kconfig | 1 + drivers/input/keyboard/lm8323.c | 47 +++++++++++++++++++++++++------------- include/linux/i2c/lm8323.h | 15 ++++++++++- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 4d64652..2c5b7bc 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -289,6 +289,7 @@ config KEYBOARD_TSC2301 config KEYBOARD_LM8323 tristate "LM8323 keypad chip" depends on I2C + depends on LEDS help If you say yes here you get support for the National Semiconductor LM8323 keypad controller. diff --git a/drivers/input/keyboard/lm8323.c b/drivers/input/keyboard/lm8323.c index 27da93c..a796680 100644 --- a/drivers/input/keyboard/lm8323.c +++ b/drivers/input/keyboard/lm8323.c @@ -1,11 +1,13 @@ /* * drivers/i2c/chips/lm8323.c * - * Copyright (C) 2007 Nokia Corporation + * Copyright (C) 2007-2009 Nokia Corporation * * Written by Daniel Stone * Timo O. Karjalainen * + * Updated by Felipe Balbi + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation (version 2 of the License only). @@ -131,18 +133,20 @@ struct lm8323_pwm { int brightness; int desired_brightness; int running; + /* pwm lock */ struct mutex lock; struct work_struct work; struct led_classdev cdev; }; struct lm8323_chip { + /* device lock */ struct mutex lock; struct i2c_client *client; struct work_struct work; struct input_dev *idev; - unsigned kp_enabled : 1; - unsigned pm_suspend : 1; + unsigned kp_enabled:1; + unsigned pm_suspend:1; unsigned keys_down; char phys[32]; s16 keymap[LM8323_KEYMAP_SIZE]; @@ -328,9 +332,11 @@ static void lm8323_process_error(struct lm8323_chip *lm) if (error & ERR_FIFOOVER) dev_vdbg(&lm->client->dev, "fifo overflow!\n"); if (error & ERR_KEYOVR) - dev_vdbg(&lm->client->dev, "more than two keys pressed\n"); + dev_vdbg(&lm->client->dev, + "more than two keys pressed\n"); if (error & ERR_CMDUNK) - dev_vdbg(&lm->client->dev, "unknown command submitted\n"); + dev_vdbg(&lm->client->dev, + "unknown command submitted\n"); if (error & ERR_BADPAR) dev_vdbg(&lm->client->dev, "bad command parameter\n"); } @@ -510,8 +516,7 @@ static void lm8323_pwm_work(struct work_struct *work) if ((pwm->fade_time / steps) > (32768 / 512)) { div512 = 1; hz = 32768 / 512; - } - else { + } else { div512 = 0; hz = 32768 / 16; } @@ -579,7 +584,7 @@ static ssize_t lm8323_pwm_store_time(struct device *dev, int ret; int time; - ret = sscanf(buf, "%d", &time); + ret = strict_strtoul(buf, 10, &time); /* Numbers only, please. */ if (ret) return -EINVAL; @@ -655,7 +660,7 @@ static ssize_t lm8323_set_disable(struct device *dev, int ret; int i; - i = sscanf(buf, "%d", &ret); + ret = strict_strtoul(buf, 10, &i); mutex_lock(&lm->lock); lm->kp_enabled = !i; @@ -704,7 +709,8 @@ static int lm8323_probe(struct i2c_client *client, goto fail2; } - dev_vdbg(&client->dev, "Keypad size: %d x %d\n", lm->size_x, lm->size_y); + dev_vdbg(&client->dev, "Keypad size: %d x %d\n", + lm->size_x, lm->size_y); lm->debounce_time = pdata->debounce_time; lm->active_time = pdata->active_time; @@ -746,14 +752,15 @@ static int lm8323_probe(struct i2c_client *client, INIT_WORK(&lm->work, lm8323_work); err = request_irq(client->irq, lm8323_irq, - IRQF_TRIGGER_FALLING | IRQF_DISABLED | - IRQF_SAMPLE_RANDOM, "lm8323", lm); + IRQF_TRIGGER_FALLING | IRQF_DISABLED, + "lm8323", lm); if (err) { dev_err(&client->dev, "could not get IRQ %d\n", client->irq); goto fail6; } - set_irq_wake(client->irq, 1); + device_init_wakeup(&client->dev, 1); + enable_irq_wake(client->irq); lm->kp_enabled = 1; err = device_create_file(&client->dev, &dev_attr_disable_kp); @@ -777,13 +784,13 @@ static int lm8323_probe(struct i2c_client *client, idev->evbit[0] = BIT(EV_KEY); for (i = 0; i < LM8323_KEYMAP_SIZE; i++) { if (pdata->keymap[i] > 0) - set_bit(pdata->keymap[i], idev->keybit); + __set_bit(pdata->keymap[i], idev->keybit); lm->keymap[i] = pdata->keymap[i]; } if (pdata->repeat) - set_bit(EV_REP, idev->evbit); + __set_bit(EV_REP, idev->evbit); lm->idev = idev; err = input_register_device(idev); @@ -817,6 +824,7 @@ static int lm8323_remove(struct i2c_client *client) { struct lm8323_chip *lm = i2c_get_clientdata(client); + disable_irq_wake(client->irq); free_irq(client->irq, lm); cancel_work_sync(&lm->work); input_unregister_device(lm->idev); @@ -832,6 +840,7 @@ static int lm8323_remove(struct i2c_client *client) return 0; } +#ifdef CONFIG_PM /* * We don't need to explicitly suspend the chip, as it already switches off * when there's no activity. @@ -877,6 +886,10 @@ static int lm8323_resume(struct i2c_client *client) return 0; } +#else +#define lm8323_suspend NULL +#define lm8323_resume NULL +#endif static const struct i2c_device_id lm8323_id[] = { { "lm8323", 0 }, @@ -907,7 +920,9 @@ static void __exit lm8323_exit(void) } module_exit(lm8323_exit); -MODULE_AUTHOR("Timo O. Karjalainen , Daniel Stone"); +MODULE_AUTHOR("Timo O. Karjalainen "); +MODULE_AUTHOR("Daniel Stone"); +MODULE_AUTHOR("Felipe Balbi "); MODULE_DESCRIPTION("LM8323 keypad driver"); MODULE_LICENSE("GPL"); diff --git a/include/linux/i2c/lm8323.h b/include/linux/i2c/lm8323.h index 5eae5cc..37f819b 100644 --- a/include/linux/i2c/lm8323.h +++ b/include/linux/i2c/lm8323.h @@ -1,7 +1,18 @@ /* - * include/lm8323.h + * lm8323.h - Configuration for LM8323 keypad driver. * - * Configuration for LM8323 keypad driver. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation (version 2 of the License only). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __LINUX_LM8323_H