diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-11-03 15:16:09 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-12-07 05:20:41 -0500 |
commit | 670d20725e4f707feca89769587bd192bc5786ae (patch) | |
tree | 1428296c2569f9785d3f0e02bdaf3c87c29780ab /drivers/input | |
parent | c838cb3d477f79738ee03ede53a3f724021f3ae0 (diff) |
Input: samsung-keypad - favor platform data if present
We should be able to override firmware-provided parameters with in-kernel
data, if needed. To that effect favor platform data, if present, over
devicetree data.
Acked-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/samsung-keypad.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 9ac8a1e0c08e..a7357adeaf24 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c | |||
@@ -244,8 +244,8 @@ static void samsung_keypad_close(struct input_dev *input_dev) | |||
244 | } | 244 | } |
245 | 245 | ||
246 | #ifdef CONFIG_OF | 246 | #ifdef CONFIG_OF |
247 | static struct samsung_keypad_platdata *samsung_keypad_parse_dt( | 247 | static struct samsung_keypad_platdata * |
248 | struct device *dev) | 248 | samsung_keypad_parse_dt(struct device *dev) |
249 | { | 249 | { |
250 | struct samsung_keypad_platdata *pdata; | 250 | struct samsung_keypad_platdata *pdata; |
251 | struct matrix_keymap_data *keymap_data; | 251 | struct matrix_keymap_data *keymap_data; |
@@ -253,17 +253,22 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt( | |||
253 | struct device_node *np = dev->of_node, *key_np; | 253 | struct device_node *np = dev->of_node, *key_np; |
254 | unsigned int key_count; | 254 | unsigned int key_count; |
255 | 255 | ||
256 | if (!np) { | ||
257 | dev_err(dev, "missing device tree data\n"); | ||
258 | return ERR_PTR(-EINVAL); | ||
259 | } | ||
260 | |||
256 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | 261 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); |
257 | if (!pdata) { | 262 | if (!pdata) { |
258 | dev_err(dev, "could not allocate memory for platform data\n"); | 263 | dev_err(dev, "could not allocate memory for platform data\n"); |
259 | return NULL; | 264 | return ERR_PTR(-ENOMEM); |
260 | } | 265 | } |
261 | 266 | ||
262 | of_property_read_u32(np, "samsung,keypad-num-rows", &num_rows); | 267 | of_property_read_u32(np, "samsung,keypad-num-rows", &num_rows); |
263 | of_property_read_u32(np, "samsung,keypad-num-columns", &num_cols); | 268 | of_property_read_u32(np, "samsung,keypad-num-columns", &num_cols); |
264 | if (!num_rows || !num_cols) { | 269 | if (!num_rows || !num_cols) { |
265 | dev_err(dev, "number of keypad rows/columns not specified\n"); | 270 | dev_err(dev, "number of keypad rows/columns not specified\n"); |
266 | return NULL; | 271 | return ERR_PTR(-EINVAL); |
267 | } | 272 | } |
268 | pdata->rows = num_rows; | 273 | pdata->rows = num_rows; |
269 | pdata->cols = num_cols; | 274 | pdata->cols = num_cols; |
@@ -271,7 +276,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt( | |||
271 | keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL); | 276 | keymap_data = devm_kzalloc(dev, sizeof(*keymap_data), GFP_KERNEL); |
272 | if (!keymap_data) { | 277 | if (!keymap_data) { |
273 | dev_err(dev, "could not allocate memory for keymap data\n"); | 278 | dev_err(dev, "could not allocate memory for keymap data\n"); |
274 | return NULL; | 279 | return ERR_PTR(-ENOMEM); |
275 | } | 280 | } |
276 | pdata->keymap_data = keymap_data; | 281 | pdata->keymap_data = keymap_data; |
277 | 282 | ||
@@ -280,7 +285,7 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt( | |||
280 | keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL); | 285 | keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL); |
281 | if (!keymap) { | 286 | if (!keymap) { |
282 | dev_err(dev, "could not allocate memory for keymap\n"); | 287 | dev_err(dev, "could not allocate memory for keymap\n"); |
283 | return NULL; | 288 | return ERR_PTR(-ENOMEM); |
284 | } | 289 | } |
285 | keymap_data->keymap = keymap; | 290 | keymap_data->keymap = keymap; |
286 | 291 | ||
@@ -294,16 +299,19 @@ static struct samsung_keypad_platdata *samsung_keypad_parse_dt( | |||
294 | 299 | ||
295 | if (of_get_property(np, "linux,input-no-autorepeat", NULL)) | 300 | if (of_get_property(np, "linux,input-no-autorepeat", NULL)) |
296 | pdata->no_autorepeat = true; | 301 | pdata->no_autorepeat = true; |
302 | |||
297 | if (of_get_property(np, "linux,input-wakeup", NULL)) | 303 | if (of_get_property(np, "linux,input-wakeup", NULL)) |
298 | pdata->wakeup = true; | 304 | pdata->wakeup = true; |
299 | 305 | ||
300 | return pdata; | 306 | return pdata; |
301 | } | 307 | } |
302 | #else | 308 | #else |
303 | static | 309 | static struct samsung_keypad_platdata * |
304 | struct samsung_keypad_platdata *samsung_keypad_parse_dt(struct device *dev) | 310 | samsung_keypad_parse_dt(struct device *dev) |
305 | { | 311 | { |
306 | return NULL; | 312 | dev_err(dev, "no platform data defined\n"); |
313 | |||
314 | return ERR_PTR(-EINVAL); | ||
307 | } | 315 | } |
308 | #endif | 316 | #endif |
309 | 317 | ||
@@ -318,13 +326,11 @@ static int samsung_keypad_probe(struct platform_device *pdev) | |||
318 | unsigned int keymap_size; | 326 | unsigned int keymap_size; |
319 | int error; | 327 | int error; |
320 | 328 | ||
321 | if (pdev->dev.of_node) | 329 | pdata = dev_get_platdata(&pdev->dev); |
322 | pdata = samsung_keypad_parse_dt(&pdev->dev); | ||
323 | else | ||
324 | pdata = dev_get_platdata(&pdev->dev); | ||
325 | if (!pdata) { | 330 | if (!pdata) { |
326 | dev_err(&pdev->dev, "no platform data defined\n"); | 331 | pdata = samsung_keypad_parse_dt(&pdev->dev); |
327 | return -EINVAL; | 332 | if (IS_ERR(pdata)) |
333 | return PTR_ERR(pdata); | ||
328 | } | 334 | } |
329 | 335 | ||
330 | keymap_data = pdata->keymap_data; | 336 | keymap_data = pdata->keymap_data; |