aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/keyboard/matrix_keypad.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index 41614c185918..782dda68d93a 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -407,7 +407,7 @@ matrix_keypad_parse_dt(struct device *dev)
407 struct matrix_keypad_platform_data *pdata; 407 struct matrix_keypad_platform_data *pdata;
408 struct device_node *np = dev->of_node; 408 struct device_node *np = dev->of_node;
409 unsigned int *gpios; 409 unsigned int *gpios;
410 int i, nrow, ncol; 410 int ret, i, nrow, ncol;
411 411
412 if (!np) { 412 if (!np) {
413 dev_err(dev, "device lacks DT data\n"); 413 dev_err(dev, "device lacks DT data\n");
@@ -452,12 +452,19 @@ matrix_keypad_parse_dt(struct device *dev)
452 return ERR_PTR(-ENOMEM); 452 return ERR_PTR(-ENOMEM);
453 } 453 }
454 454
455 for (i = 0; i < pdata->num_row_gpios; i++) 455 for (i = 0; i < nrow; i++) {
456 gpios[i] = of_get_named_gpio(np, "row-gpios", i); 456 ret = of_get_named_gpio(np, "row-gpios", i);
457 if (ret < 0)
458 return ERR_PTR(ret);
459 gpios[i] = ret;
460 }
457 461
458 for (i = 0; i < pdata->num_col_gpios; i++) 462 for (i = 0; i < ncol; i++) {
459 gpios[pdata->num_row_gpios + i] = 463 ret = of_get_named_gpio(np, "col-gpios", i);
460 of_get_named_gpio(np, "col-gpios", i); 464 if (ret < 0)
465 return ERR_PTR(ret);
466 gpios[nrow + i] = ret;
467 }
461 468
462 pdata->row_gpios = gpios; 469 pdata->row_gpios = gpios;
463 pdata->col_gpios = &gpios[pdata->num_row_gpios]; 470 pdata->col_gpios = &gpios[pdata->num_row_gpios];
@@ -484,10 +491,8 @@ static int matrix_keypad_probe(struct platform_device *pdev)
484 pdata = dev_get_platdata(&pdev->dev); 491 pdata = dev_get_platdata(&pdev->dev);
485 if (!pdata) { 492 if (!pdata) {
486 pdata = matrix_keypad_parse_dt(&pdev->dev); 493 pdata = matrix_keypad_parse_dt(&pdev->dev);
487 if (IS_ERR(pdata)) { 494 if (IS_ERR(pdata))
488 dev_err(&pdev->dev, "no platform data defined\n");
489 return PTR_ERR(pdata); 495 return PTR_ERR(pdata);
490 }
491 } else if (!pdata->keymap_data) { 496 } else if (!pdata->keymap_data) {
492 dev_err(&pdev->dev, "no keymap data defined\n"); 497 dev_err(&pdev->dev, "no keymap data defined\n");
493 return -EINVAL; 498 return -EINVAL;