Commit 52ec7752 authored by Dmitry Torokhov's avatar Dmitry Torokhov

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: default avatarMike Rapoport <mike@compulab.co.il>
Acked-by: default avatarEric Miao <eric.y.miao@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
parent bd072111
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define __ASM_ARCH_PXA27x_KEYPAD_H #define __ASM_ARCH_PXA27x_KEYPAD_H
#include <linux/input.h> #include <linux/input.h>
#include <linux/input/matrix_keypad.h>
#define MAX_MATRIX_KEY_ROWS (8) #define MAX_MATRIX_KEY_ROWS (8)
#define MAX_MATRIX_KEY_COLS (8) #define MAX_MATRIX_KEY_COLS (8)
...@@ -51,8 +52,6 @@ struct pxa27x_keypad_platform_data { ...@@ -51,8 +52,6 @@ struct pxa27x_keypad_platform_data {
unsigned int debounce_interval; unsigned int debounce_interval;
}; };
#define KEY(row, col, val) (((row) << 28) | ((col) << 24) | (val))
extern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info); extern void pxa_set_keypad_info(struct pxa27x_keypad_platform_data *info);
#endif /* __ASM_ARCH_PXA27x_KEYPAD_H */ #endif /* __ASM_ARCH_PXA27x_KEYPAD_H */
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/input/matrix_keypad.h>
#include <asm/mach/arch.h> #include <asm/mach/arch.h>
#include <asm/mach/map.h> #include <asm/mach/map.h>
...@@ -107,7 +108,7 @@ struct pxa27x_keypad { ...@@ -107,7 +108,7 @@ struct pxa27x_keypad {
int irq; int irq;
/* matrix key code map */ /* 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 */ /* state row bits of each column scan */
uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS]; uint32_t matrix_key_state[MAX_MATRIX_KEY_COLS];
...@@ -124,21 +125,21 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) ...@@ -124,21 +125,21 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
{ {
struct pxa27x_keypad_platform_data *pdata = keypad->pdata; struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
struct input_dev *input_dev = keypad->input_dev; struct input_dev *input_dev = keypad->input_dev;
unsigned int *key;
int i; int i;
key = &pdata->matrix_key_map[0]; for (i = 0; i < pdata->matrix_key_map_size; i++) {
for (i = 0; i < pdata->matrix_key_map_size; i++, key++) { unsigned int key = pdata->matrix_key_map[i];
int row = ((*key) >> 28) & 0xf; unsigned int row = KEY_ROW(key);
int col = ((*key) >> 24) & 0xf; unsigned int col = KEY_COL(key);
int code = (*key) & 0xffffff; unsigned short code = KEY_VAL(key);
keypad->matrix_keycodes[(row << 3) + col] = code; 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++) 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[0] = pdata->rotary0_up_key;
keypad->rotary_up_key[1] = pdata->rotary1_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) ...@@ -149,18 +150,18 @@ static void pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
if (pdata->enable_rotary0) { if (pdata->enable_rotary0) {
if (pdata->rotary0_up_key && pdata->rotary0_down_key) { if (pdata->rotary0_up_key && pdata->rotary0_down_key) {
set_bit(pdata->rotary0_up_key, input_dev->keybit); __set_bit(pdata->rotary0_up_key, input_dev->keybit);
set_bit(pdata->rotary0_down_key, input_dev->keybit); __set_bit(pdata->rotary0_down_key, input_dev->keybit);
} else } 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->enable_rotary1) {
if (pdata->rotary1_up_key && pdata->rotary1_down_key) { if (pdata->rotary1_up_key && pdata->rotary1_down_key) {
set_bit(pdata->rotary1_up_key, input_dev->keybit); __set_bit(pdata->rotary1_up_key, input_dev->keybit);
set_bit(pdata->rotary1_down_key, input_dev->keybit); __set_bit(pdata->rotary1_down_key, input_dev->keybit);
} else } 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) ...@@ -425,8 +426,6 @@ static int pxa27x_keypad_resume(struct platform_device *pdev)
#define pxa27x_keypad_resume NULL #define pxa27x_keypad_resume NULL
#endif #endif
#define res_size(res) ((res)->end - (res)->start + 1)
static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) static int __devinit pxa27x_keypad_probe(struct platform_device *pdev)
{ {
struct pxa27x_keypad *keypad; struct pxa27x_keypad *keypad;
...@@ -461,14 +460,14 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) ...@@ -461,14 +460,14 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev)
goto failed_free; 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) { if (res == NULL) {
dev_err(&pdev->dev, "failed to request I/O memory\n"); dev_err(&pdev->dev, "failed to request I/O memory\n");
error = -EBUSY; error = -EBUSY;
goto failed_free; 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) { if (keypad->mmio_base == NULL) {
dev_err(&pdev->dev, "failed to remap I/O memory\n"); dev_err(&pdev->dev, "failed to remap I/O memory\n");
error = -ENXIO; error = -ENXIO;
...@@ -540,7 +539,7 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev) ...@@ -540,7 +539,7 @@ static int __devinit pxa27x_keypad_probe(struct platform_device *pdev)
failed_free_io: failed_free_io:
iounmap(keypad->mmio_base); iounmap(keypad->mmio_base);
failed_free_mem: failed_free_mem:
release_mem_region(res->start, res_size(res)); release_mem_region(res->start, resource_size(res));
failed_free: failed_free:
kfree(keypad); kfree(keypad);
return error; return error;
...@@ -552,8 +551,6 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) ...@@ -552,8 +551,6 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev)
struct resource *res; struct resource *res;
free_irq(keypad->irq, pdev); free_irq(keypad->irq, pdev);
clk_disable(keypad->clk);
clk_put(keypad->clk); clk_put(keypad->clk);
input_unregister_device(keypad->input_dev); input_unregister_device(keypad->input_dev);
...@@ -562,7 +559,7 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev) ...@@ -562,7 +559,7 @@ static int __devexit pxa27x_keypad_remove(struct platform_device *pdev)
iounmap(keypad->mmio_base); iounmap(keypad->mmio_base);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 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); platform_set_drvdata(pdev, NULL);
kfree(keypad); kfree(keypad);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment