input: gpio-matrix-keypad: Accept device name from device node

The device name is not properly set if the platform device
is created from device tree.  Read "input-name" property to
set the device name.

Change-Id: Ib348df17f2222d88032435424cfcff9d37054ddd
Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
Signed-off-by: Chetan C R <cchinnad@codeaurora.org>
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index e4703eb..4a39c6c 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -446,6 +446,8 @@
 	if (of_get_property(np, "gpio-activelow", NULL))
 		pdata->active_low = true;
 
+	pdata->name = of_get_property(np, "input-name", NULL);
+
 	of_property_read_u32(np, "debounce-delay-ms", &pdata->debounce_ms);
 	of_property_read_u32(np, "col-scan-delay-us",
 						&pdata->col_scan_delay_us);
@@ -511,7 +513,6 @@
 		err = -ENOMEM;
 		goto err_free_mem;
 	}
-
 	keypad->input_dev = input_dev;
 	keypad->pdata = pdata;
 	keypad->row_shift = get_count_order(pdata->num_col_gpios);
@@ -519,7 +520,7 @@
 	INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan);
 	spin_lock_init(&keypad->lock);
 
-	input_dev->name		= pdev->name;
+	input_dev->name		= pdata->name ? : pdev->name;
 	input_dev->id.bustype	= BUS_HOST;
 	input_dev->dev.parent	= &pdev->dev;
 	input_dev->open		= matrix_keypad_start;
diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
index 27e06ac..ed39560 100644
--- a/include/linux/input/matrix_keypad.h
+++ b/include/linux/input/matrix_keypad.h
@@ -73,6 +73,7 @@
 	bool		active_low;
 	bool		wakeup;
 	bool		no_autorepeat;
+	const char	*name; /* input device name */
 };
 
 int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,