In device tree enabled setups requiring preallocated memory for storing keymap
is quite often awkward, so let's provide an option of allocating it directly
in matrix_keypad_build_keymap().
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/matrix-keymap.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
@@ -122,6 +122,11 @@ static int matrix_keypad_parse_of_keymap(const char *propname,*itwillattemptloadthekeymapfrompropertyspecifiedby@keymap_name*argument(or"linux,keymap"if@keymap_nameis%NULL).*+*If@keymapis%NULLthefunctionwillautomaticallyallocatemanaged+*blockofmemorytostorethekeymap.Thismemorywillbeassociatedwith+*theparentdeviceandautomaticallyfreedwhendeviceunbindsfromthe+*driver.+**Callersareexpectedtosetupinput_dev->dev.parentbeforecallingthis*function.*/
@@ -132,12 +137,27 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,structinput_dev*input_dev){unsignedintrow_shift=get_count_order(cols);+size_tmax_keys=rows<<row_shift;inti;interror;+if(WARN_ON(!input_dev->dev.parent))+return-EINVAL;++if(!keymap){+keymap=devm_kzalloc(input_dev->dev.parent,+max_keys*sizeof(*keymap),+GFP_KERNEL);+if(!keymap){+dev_err(input_dev->dev.parent,+"Unable to allocate memory for keymap");+return-ENOMEM;+}+}+input_dev->keycode=keymap;input_dev->keycodesize=sizeof(*keymap);-input_dev->keycodemax=rows<<row_shift;+input_dev->keycodemax=max_keys;__set_bit(EV_KEY,input_dev->evbit);
From: Alban Bedel <hidden> Date: 2012-11-14 09:41:03
On Thu, 8 Nov 2012 08:45:21 -0800
Dmitry Torokhov [off-list ref] wrote:
quoted hunk
In device tree enabled setups requiring preallocated memory for storing keymap
is quite often awkward, so let's provide an option of allocating it directly
in matrix_keypad_build_keymap().
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/input/matrix-keymap.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)