aboutsummaryrefslogtreecommitdiff
path: root/drivers/input/keyboard/pxa27x_keypad.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2009-07-22 21:51:40 -0700
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2009-07-22 22:33:47 -0700
commit52ec7752b457311f10f5a8d16faa8ac2e684eb65 (patch)
tree431921f714d53c8ebcb089458aa3c049e3841def /drivers/input/keyboard/pxa27x_keypad.c
parentbd072111e7319d90a7b8127f91c2806b9a6f279e (diff)
Input: pxa27x_keypad - remove extra clk_disable
clk_disable() in remove method is not needed since we already have clk_disable in pxa27x_keypad_close(). Also make sure the driver uses resource_size() and helpers from include/input/matrix_keypad.h Tested-by: Mike Rapoport <mike@compulab.co.il> Acked-by: Eric Miao <eric.y.miao@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/pxa27x_keypad.c')
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index 0d2fc64a5e1..09432381939 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -25,6 +25,7 @@
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/err.h>
+#include <linux/input/matrix_keypad.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
@@ -107,7 +108,7 @@ struct pxa27x_keypad {
int irq;
/* matrix key code map */
- unsigned int matrix_keycodes[MAX_MATRIX_KEY_NUM];
+ unsigned short matrix_keycodes[MAX_MATRIX_KEY_NUM];
/* state row bits of each column scan */
uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS];
@@ -124,21 +125,21 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
{
struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
struct input_dev *input_dev = keypad->input_dev;
- unsigned int *key;
int i;
- key = &pdata->matrix_key_map[0];
- for (i = 0; i < pdata->matrix_key_map_size; i++, key++) {
- int row = ((*key) >> 28) & 0xf;
- int col = ((*key) >> 24) & 0xf;
- int code = (*key) & 0xffffff;
+ for (i = 0; i < pdata->matrix_key_map_size; i++) {
+ unsigned int key = pdata->matrix_key_map[i];
+ unsigned int row = KEY_ROW(key);
+ unsigned int col = KEY_COL(key);
+ unsigned short code = KEY_VAL(key);
keypad->matrix_keycodes[(row << 3) + col] = code;
- set_bit(code, input_dev->keybit);
+ __set_bit(code, input_dev->keybit);
}
+ __clear_bit(KEY_RESERVED, input_dev->keybit);
for (i = 0; i < pdata->direct_key_num; i++)
- set_bit(pdata->direct_key_map[i], input_dev->keybit);
+ __set_bit(pdata->direct_key_map[i], input_dev->keybit);
keypad->rotary_up_key[0] = pdata->rotary0_up_key;
keypad->rotary_up_key[1] = pdata->rotary1_up_key;
@@ -149,18 +150,18 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
if (pdata->enable_rotary0) {
if (pdata->rotary0_up_key && pdata->rotary0_down_key) {
- set_bit(pdata->rotary0_up_key, input_dev->keybit);
- set_bit(pdata->rotary0_down_key, input_dev->keybit);
+ __set_bit(pdata->rotary0_up_key, input_dev->keybit);
+ __set_bit(pdata->rotary0_down_key, input_dev->keybit);
} else
- set_bit(pdata->rotary0_rel_code, input_dev->relbit);
+ __set_bit(pdata->rotary0_rel_code, input_dev->relbit);
}
if (pdata->enable_rotary1) {
if (pdata->rotary1_up_key && pdata->rotary1_down_key) {
- set_bit(pdata->rotary1_up_key, input_dev->keybit);
- set_bit(pdata->rotary1_down_key, input_dev->keybit);
+ __set_bit(pdata->rotary1_up_key, input_dev->keybit);
+ __set_bit(pdata->rotary1_down_key, input_dev->keybit);
} else
- set_bit(pdata->rotary1_rel_code, input_dev->relbit);
+ __set_bit(pdata->rotary1_rel_code, input_dev->relbit);
}
}
@@ -425,8 +426,6 @@ static int pxa27x_keypad_resume(struct platform_device *pdev)
#define pxa27x_keypad_resume NULL
#endif
-#define res_size(res) ((res)->end - (res)->start + 1)
-
static int __devinit pxa27x_keypad_probe(struct platform_device *pdev)
{
struct pxa27x_keypad *keypad;
@@ -461,14 +460,14 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev)
goto failed_free;
}
- res = request_mem_region(res->start, res_size(res), pdev->name);
+ res = request_mem_region(res->start, resource_size(res), pdev->name);
if (res == NULL) {
dev_err(&pdev->dev, "failed to request I/O memory\n");
error = -EBUSY;
goto failed_free;
}
- keypad->mmio_base = ioremap(res->start, res_size(res));
+ keypad->mmio_base = ioremap(res->start, resource_size(res));
if (keypad->mmio_base == NULL) {
dev_err(&pdev->dev, "failed to remap I/O memory\n");
error = -ENXIO;
@@ -540,7 +539,7 @@ failed_put_clk:
failed_free_io:
iounmap(keypad->mmio_base);
failed_free_mem:
- release_mem_region(res->start, res_size(res));
+ release_mem_region(res->start, resource_size(res));
failed_free:
kfree(keypad);
return error;
@@ -552,8 +551,6 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev)
struct resource *res;
free_irq(keypad->irq, pdev);
-
- clk_disable(keypad->clk);
clk_put(keypad->clk);
input_unregister_device(keypad->input_dev);
@@ -562,7 +559,7 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev)
iounmap(keypad->mmio_base);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- release_mem_region(res->start, res_size(res));
+ release_mem_region(res->start, resource_size(res));
platform_set_drvdata(pdev, NULL);
kfree(keypad);