diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-07-23 00:51:40 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-07-23 01:33:47 -0400 |
commit | 52ec7752b457311f10f5a8d16faa8ac2e684eb65 (patch) | |
tree | 431921f714d53c8ebcb089458aa3c049e3841def /drivers/input/keyboard/pxa27x_keypad.c | |
parent | bd072111e7319d90a7b8127f91c2806b9a6f279e (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.c | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c index 0d2fc64a5e1c..094323819398 100644 --- a/drivers/input/keyboard/pxa27x_keypad.c +++ b/drivers/input/keyboard/pxa27x_keypad.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
26 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
28 | #include <linux/input/matrix_keypad.h> | ||
28 | 29 | ||
29 | #include <asm/mach/arch.h> | 30 | #include <asm/mach/arch.h> |
30 | #include <asm/mach/map.h> | 31 | #include <asm/mach/map.h> |
@@ -107,7 +108,7 @@ struct pxa27x_keypad { | |||
107 | int irq; | 108 | int irq; |
108 | 109 | ||
109 | /* matrix key code map */ | 110 | /* matrix key code map */ |
110 | unsigned int matrix_keycodes[MAX_MATRIX_KEY_NUM]; | 111 | unsigned short matrix_keycodes[MAX_MATRIX_KEY_NUM]; |
111 | 112 | ||
112 | /* state row bits of each column scan */ | 113 | /* state row bits of each column scan */ |
113 | uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS]; | 114 | uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS]; |
@@ -124,21 +125,21 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) | |||
124 | { | 125 | { |
125 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; | 126 | struct pxa27x_keypad_platform_data *pdata = keypad->pdata; |
126 | struct input_dev *input_dev = keypad->input_dev; | 127 | struct input_dev *input_dev = keypad->input_dev; |
127 | unsigned int *key; | ||
128 | int i; | 128 | int i; |
129 | 129 | ||
130 | key = &pdata->matrix_key_map[0]; | 130 | for (i = 0; i < pdata->matrix_key_map_size; i++) { |
131 | for (i = 0; i < pdata->matrix_key_map_size; i++, key++) { | 131 | unsigned int key = pdata->matrix_key_map[i]; |
132 | int row = ((*key) >> 28) & 0xf; | 132 | unsigned int row = KEY_ROW(key); |
133 | int col = ((*key) >> 24) & 0xf; | 133 | unsigned int col = KEY_COL(key); |
134 | int code = (*key) & 0xffffff; | 134 | unsigned short code = KEY_VAL(key); |
135 | 135 | ||
136 | keypad->matrix_keycodes[(row << 3) + col] = code; | 136 | keypad->matrix_keycodes[(row << 3) + col] = code; |
137 | set_bit(code, input_dev->keybit); | 137 | __set_bit(code, input_dev->keybit); |
138 | } | 138 | } |
139 | __clear_bit(KEY_RESERVED, input_dev->keybit); | ||
139 | 140 | ||
140 | for (i = 0; i < pdata->direct_key_num; i++) | 141 | for (i = 0; i < pdata->direct_key_num; i++) |
141 | set_bit(pdata->direct_key_map[i], input_dev->keybit); | 142 | __set_bit(pdata->direct_key_map[i], input_dev->keybit); |
142 | 143 | ||
143 | keypad->rotary_up_key[0] = pdata->rotary0_up_key; | 144 | keypad->rotary_up_key[0] = pdata->rotary0_up_key; |
144 | keypad->rotary_up_key[1] = pdata->rotary1_up_key; | 145 | keypad->rotary_up_key[1] = pdata->rotary1_up_key; |
@@ -149,18 +150,18 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) | |||
149 | 150 | ||
150 | if (pdata->enable_rotary0) { | 151 | if (pdata->enable_rotary0) { |
151 | if (pdata->rotary0_up_key && pdata->rotary0_down_key) { | 152 | if (pdata->rotary0_up_key && pdata->rotary0_down_key) { |
152 | set_bit(pdata->rotary0_up_key, input_dev->keybit); | 153 | __set_bit(pdata->rotary0_up_key, input_dev->keybit); |
153 | set_bit(pdata->rotary0_down_key, input_dev->keybit); | 154 | __set_bit(pdata->rotary0_down_key, input_dev->keybit); |
154 | } else | 155 | } else |
155 | set_bit(pdata->rotary0_rel_code, input_dev->relbit); | 156 | __set_bit(pdata->rotary0_rel_code, input_dev->relbit); |
156 | } | 157 | } |
157 | 158 | ||
158 | if (pdata->enable_rotary1) { | 159 | if (pdata->enable_rotary1) { |
159 | if (pdata->rotary1_up_key && pdata->rotary1_down_key) { | 160 | if (pdata->rotary1_up_key && pdata->rotary1_down_key) { |
160 | set_bit(pdata->rotary1_up_key, input_dev->keybit); | 161 | __set_bit(pdata->rotary1_up_key, input_dev->keybit); |
161 | set_bit(pdata->rotary1_down_key, input_dev->keybit); | 162 | __set_bit(pdata->rotary1_down_key, input_dev->keybit); |
162 | } else | 163 | } else |
163 | set_bit(pdata->rotary1_rel_code, input_dev->relbit); | 164 | __set_bit(pdata->rotary1_rel_code, input_dev->relbit); |
164 | } | 165 | } |
165 | } | 166 | } |
166 | 167 | ||
@@ -425,8 +426,6 @@ static int pxa27x_keypad_resume(struct platform_device *pdev) | |||
425 | #define pxa27x_keypad_resume NULL | 426 | #define pxa27x_keypad_resume NULL |
426 | #endif | 427 | #endif |
427 | 428 | ||
428 | #define res_size(res) ((res)->end - (res)->start + 1) | ||
429 | |||
430 | static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) | 429 | static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) |
431 | { | 430 | { |
432 | struct pxa27x_keypad *keypad; | 431 | struct pxa27x_keypad *keypad; |
@@ -461,14 +460,14 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) | |||
461 | goto failed_free; | 460 | goto failed_free; |
462 | } | 461 | } |
463 | 462 | ||
464 | res = request_mem_region(res->start, res_size(res), pdev->name); | 463 | res = request_mem_region(res->start, resource_size(res), pdev->name); |
465 | if (res == NULL) { | 464 | if (res == NULL) { |
466 | dev_err(&pdev->dev, "failed to request I/O memory\n"); | 465 | dev_err(&pdev->dev, "failed to request I/O memory\n"); |
467 | error = -EBUSY; | 466 | error = -EBUSY; |
468 | goto failed_free; | 467 | goto failed_free; |
469 | } | 468 | } |
470 | 469 | ||
471 | keypad->mmio_base = ioremap(res->start, res_size(res)); | 470 | keypad->mmio_base = ioremap(res->start, resource_size(res)); |
472 | if (keypad->mmio_base == NULL) { | 471 | if (keypad->mmio_base == NULL) { |
473 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); | 472 | dev_err(&pdev->dev, "failed to remap I/O memory\n"); |
474 | error = -ENXIO; | 473 | error = -ENXIO; |
@@ -540,7 +539,7 @@ failed_put_clk: | |||
540 | failed_free_io: | 539 | failed_free_io: |
541 | iounmap(keypad->mmio_base); | 540 | iounmap(keypad->mmio_base); |
542 | failed_free_mem: | 541 | failed_free_mem: |
543 | release_mem_region(res->start, res_size(res)); | 542 | release_mem_region(res->start, resource_size(res)); |
544 | failed_free: | 543 | failed_free: |
545 | kfree(keypad); | 544 | kfree(keypad); |
546 | return error; | 545 | return error; |
@@ -552,8 +551,6 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) | |||
552 | struct resource *res; | 551 | struct resource *res; |
553 | 552 | ||
554 | free_irq(keypad->irq, pdev); | 553 | free_irq(keypad->irq, pdev); |
555 | |||
556 | clk_disable(keypad->clk); | ||
557 | clk_put(keypad->clk); | 554 | clk_put(keypad->clk); |
558 | 555 | ||
559 | input_unregister_device(keypad->input_dev); | 556 | input_unregister_device(keypad->input_dev); |
@@ -562,7 +559,7 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) | |||
562 | iounmap(keypad->mmio_base); | 559 | iounmap(keypad->mmio_base); |
563 | 560 | ||
564 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 561 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
565 | release_mem_region(res->start, res_size(res)); | 562 | release_mem_region(res->start, resource_size(res)); |
566 | 563 | ||
567 | platform_set_drvdata(pdev, NULL); | 564 | platform_set_drvdata(pdev, NULL); |
568 | kfree(keypad); | 565 | kfree(keypad); |