aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2013-06-11 01:16:29 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-06-19 01:56:52 -0400
commit9eb521394ea9a50feaf8a9c70b689e4b86ff1b93 (patch)
tree7a7bd0debc332c30871e1d6e8fff221d430f5784 /drivers/input
parentf9f6def88ace892f9f90f639664f0e203bafdb22 (diff)
Input: pxa27x-keypad - make platform data const
It should not be changed by the driver, so let's make it const pointer. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/keyboard/pxa27x_keypad.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/drivers/input/keyboard/pxa27x_keypad.c b/drivers/input/keyboard/pxa27x_keypad.c
index aa17cf269aa8..134c3b404a54 100644
--- a/drivers/input/keyboard/pxa27x_keypad.c
+++ b/drivers/input/keyboard/pxa27x_keypad.c
@@ -100,7 +100,7 @@
100#define MAX_KEYPAD_KEYS (MAX_MATRIX_KEY_NUM + MAX_DIRECT_KEY_NUM) 100#define MAX_KEYPAD_KEYS (MAX_MATRIX_KEY_NUM + MAX_DIRECT_KEY_NUM)
101 101
102struct pxa27x_keypad { 102struct pxa27x_keypad {
103 struct pxa27x_keypad_platform_data *pdata; 103 const struct pxa27x_keypad_platform_data *pdata;
104 104
105 struct clk *clk; 105 struct clk *clk;
106 struct input_dev *input_dev; 106 struct input_dev *input_dev;
@@ -119,11 +119,11 @@ struct pxa27x_keypad {
119}; 119};
120 120
121#ifdef CONFIG_OF 121#ifdef CONFIG_OF
122static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad) 122static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad,
123 struct pxa27x_keypad_platform_data *pdata)
123{ 124{
124 struct input_dev *input_dev = keypad->input_dev; 125 struct input_dev *input_dev = keypad->input_dev;
125 struct device *dev = input_dev->dev.parent; 126 struct device *dev = input_dev->dev.parent;
126 struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
127 u32 rows, cols; 127 u32 rows, cols;
128 int error; 128 int error;
129 129
@@ -149,11 +149,11 @@ static int pxa27x_keypad_matrix_key_parse_dt(struct pxa27x_keypad *keypad)
149 return 0; 149 return 0;
150} 150}
151 151
152static int pxa27x_keypad_direct_key_parse_dt(struct pxa27x_keypad *keypad) 152static int pxa27x_keypad_direct_key_parse_dt(struct pxa27x_keypad *keypad,
153 struct pxa27x_keypad_platform_data *pdata)
153{ 154{
154 struct input_dev *input_dev = keypad->input_dev; 155 struct input_dev *input_dev = keypad->input_dev;
155 struct device *dev = input_dev->dev.parent; 156 struct device *dev = input_dev->dev.parent;
156 struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
157 struct device_node *np = dev->of_node; 157 struct device_node *np = dev->of_node;
158 const __be16 *prop; 158 const __be16 *prop;
159 unsigned short code; 159 unsigned short code;
@@ -209,7 +209,8 @@ static int pxa27x_keypad_direct_key_parse_dt(struct pxa27x_keypad *keypad)
209 return 0; 209 return 0;
210} 210}
211 211
212static int pxa27x_keypad_rotary_parse_dt(struct pxa27x_keypad *keypad) 212static int pxa27x_keypad_rotary_parse_dt(struct pxa27x_keypad *keypad,
213 struct pxa27x_keypad_platform_data *pdata)
213{ 214{
214 const __be32 *prop; 215 const __be32 *prop;
215 int i, relkey_ret; 216 int i, relkey_ret;
@@ -219,7 +220,6 @@ static int pxa27x_keypad_rotary_parse_dt(struct pxa27x_keypad *keypad)
219 const char relkeyname[] = {"marvell,rotary-rel-key"}; 220 const char relkeyname[] = {"marvell,rotary-rel-key"};
220 struct input_dev *input_dev = keypad->input_dev; 221 struct input_dev *input_dev = keypad->input_dev;
221 struct device *dev = input_dev->dev.parent; 222 struct device *dev = input_dev->dev.parent;
222 struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
223 struct device_node *np = dev->of_node; 223 struct device_node *np = dev->of_node;
224 224
225 relkey_ret = of_property_read_u32(np, relkeyname, &code); 225 relkey_ret = of_property_read_u32(np, relkeyname, &code);
@@ -287,35 +287,35 @@ static int pxa27x_keypad_build_keycode_from_dt(struct pxa27x_keypad *keypad)
287 struct input_dev *input_dev = keypad->input_dev; 287 struct input_dev *input_dev = keypad->input_dev;
288 struct device *dev = input_dev->dev.parent; 288 struct device *dev = input_dev->dev.parent;
289 struct device_node *np = dev->of_node; 289 struct device_node *np = dev->of_node;
290 struct pxa27x_keypad_platform_data *pdata;
290 int error; 291 int error;
291 292
292 keypad->pdata = devm_kzalloc(dev, sizeof(*keypad->pdata), 293 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
293 GFP_KERNEL); 294 if (!pdata) {
294 if (!keypad->pdata) {
295 dev_err(dev, "failed to allocate memory for pdata\n"); 295 dev_err(dev, "failed to allocate memory for pdata\n");
296 return -ENOMEM; 296 return -ENOMEM;
297 } 297 }
298 298
299 error = pxa27x_keypad_matrix_key_parse_dt(keypad); 299 error = pxa27x_keypad_matrix_key_parse_dt(keypad, pdata);
300 if (error) { 300 if (error) {
301 dev_err(dev, "failed to parse matrix key\n"); 301 dev_err(dev, "failed to parse matrix key\n");
302 return error; 302 return error;
303 } 303 }
304 304
305 error = pxa27x_keypad_direct_key_parse_dt(keypad); 305 error = pxa27x_keypad_direct_key_parse_dt(keypad, pdata);
306 if (error) { 306 if (error) {
307 dev_err(dev, "failed to parse direct key\n"); 307 dev_err(dev, "failed to parse direct key\n");
308 return error; 308 return error;
309 } 309 }
310 310
311 error = pxa27x_keypad_rotary_parse_dt(keypad); 311 error = pxa27x_keypad_rotary_parse_dt(keypad, pdata);
312 if (error) { 312 if (error) {
313 dev_err(dev, "failed to parse rotary key\n"); 313 dev_err(dev, "failed to parse rotary key\n");
314 return error; 314 return error;
315 } 315 }
316 316
317 error = of_property_read_u32(np, "marvell,debounce-interval", 317 error = of_property_read_u32(np, "marvell,debounce-interval",
318 &keypad->pdata->debounce_interval); 318 &pdata->debounce_interval);
319 if (error) { 319 if (error) {
320 dev_err(dev, "failed to parse debpunce-interval\n"); 320 dev_err(dev, "failed to parse debpunce-interval\n");
321 return error; 321 return error;
@@ -327,6 +327,7 @@ static int pxa27x_keypad_build_keycode_from_dt(struct pxa27x_keypad *keypad)
327 */ 327 */
328 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes); 328 input_dev->keycodemax = ARRAY_SIZE(keypad->keycodes);
329 329
330 keypad->pdata = pdata;
330 return 0; 331 return 0;
331} 332}
332 333
@@ -343,7 +344,7 @@ static int pxa27x_keypad_build_keycode_from_dt(struct pxa27x_keypad *keypad)
343 344
344static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad) 345static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
345{ 346{
346 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 347 const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
347 struct input_dev *input_dev = keypad->input_dev; 348 struct input_dev *input_dev = keypad->input_dev;
348 const struct matrix_keymap_data *keymap_data = 349 const struct matrix_keymap_data *keymap_data =
349 pdata ? pdata->matrix_keymap_data : NULL; 350 pdata ? pdata->matrix_keymap_data : NULL;
@@ -412,7 +413,7 @@ static int pxa27x_keypad_build_keycode(struct pxa27x_keypad *keypad)
412 413
413static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad) 414static void pxa27x_keypad_scan_matrix(struct pxa27x_keypad *keypad)
414{ 415{
415 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 416 const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
416 struct input_dev *input_dev = keypad->input_dev; 417 struct input_dev *input_dev = keypad->input_dev;
417 int row, col, num_keys_pressed = 0; 418 int row, col, num_keys_pressed = 0;
418 uint32_t new_state[MAX_MATRIX_KEY_COLS]; 419 uint32_t new_state[MAX_MATRIX_KEY_COLS];
@@ -514,7 +515,7 @@ static void report_rotary_event(struct pxa27x_keypad *keypad, int r, int delta)
514 515
515static void pxa27x_keypad_scan_rotary(struct pxa27x_keypad *keypad) 516static void pxa27x_keypad_scan_rotary(struct pxa27x_keypad *keypad)
516{ 517{
517 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 518 const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
518 uint32_t kprec; 519 uint32_t kprec;
519 520
520 /* read and reset to default count value */ 521 /* read and reset to default count value */
@@ -530,7 +531,7 @@ static void pxa27x_keypad_scan_rotary(struct pxa27x_keypad *keypad)
530 531
531static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad) 532static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad)
532{ 533{
533 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 534 const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
534 struct input_dev *input_dev = keypad->input_dev; 535 struct input_dev *input_dev = keypad->input_dev;
535 unsigned int new_state; 536 unsigned int new_state;
536 uint32_t kpdk, bits_changed; 537 uint32_t kpdk, bits_changed;
@@ -570,7 +571,7 @@ static void pxa27x_keypad_scan_direct(struct pxa27x_keypad *keypad)
570 571
571static void clear_wakeup_event(struct pxa27x_keypad *keypad) 572static void clear_wakeup_event(struct pxa27x_keypad *keypad)
572{ 573{
573 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 574 const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
574 575
575 if (pdata->clear_wakeup_event) 576 if (pdata->clear_wakeup_event)
576 (pdata->clear_wakeup_event)(); 577 (pdata->clear_wakeup_event)();
@@ -594,7 +595,7 @@ static irqreturn_t pxa27x_keypad_irq_handler(int irq, void *dev_id)
594 595
595static void pxa27x_keypad_config(struct pxa27x_keypad *keypad) 596static void pxa27x_keypad_config(struct pxa27x_keypad *keypad)
596{ 597{
597 struct pxa27x_keypad_platform_data *pdata = keypad->pdata; 598 const struct pxa27x_keypad_platform_data *pdata = keypad->pdata;
598 unsigned int mask = 0, direct_key_num = 0; 599 unsigned int mask = 0, direct_key_num = 0;
599 unsigned long kpc = 0; 600 unsigned long kpc = 0;
600 601
@@ -713,7 +714,8 @@ static SIMPLE_DEV_PM_OPS(pxa27x_keypad_pm_ops,
713 714
714static int pxa27x_keypad_probe(struct platform_device *pdev) 715static int pxa27x_keypad_probe(struct platform_device *pdev)
715{ 716{
716 struct pxa27x_keypad_platform_data *pdata = pdev->dev.platform_data; 717 const struct pxa27x_keypad_platform_data *pdata =
718 dev_get_platdata(&pdev->dev);
717 struct device_node *np = pdev->dev.of_node; 719 struct device_node *np = pdev->dev.of_node;
718 struct pxa27x_keypad *keypad; 720 struct pxa27x_keypad *keypad;
719 struct input_dev *input_dev; 721 struct input_dev *input_dev;
@@ -793,9 +795,6 @@ static int pxa27x_keypad_probe(struct platform_device *pdev)
793 goto failed_put_clk; 795 goto failed_put_clk;
794 } 796 }
795 797
796 /* If device tree is supported, pdata will be allocated. */
797 pdata = keypad->pdata;
798
799 if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) || 798 if ((pdata->enable_rotary0 && keypad->rotary_rel_code[0] != -1) ||
800 (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) { 799 (pdata->enable_rotary1 && keypad->rotary_rel_code[1] != -1)) {
801 input_dev->evbit[0] |= BIT_MASK(EV_REL); 800 input_dev->evbit[0] |= BIT_MASK(EV_REL);