[U-Boot] [PATCH] input: simplify key_matrix_decode_fdt()

Stephen Warren swarren at wwwdotorg.org
Tue May 28 06:05:47 CEST 2013


On 05/26/2013 01:31 PM, Simon Glass wrote:
> Hi Stephen,
> 
> On Thu, May 23, 2013 at 3:09 PM, Stephen Warren <swarren at wwwdotorg.org
> <mailto:swarren at wwwdotorg.org>> wrote:
> 
>     From: Stephen Warren <swarren at nvidia.com <mailto:swarren at nvidia.com>>
> 
>     We know the exact property names that the code wants to process. Look
>     these up directly with fdt_get_property(), rather than iterating over
>     all properties within the node, and checking each property's name, in
>     a convoluted fashion, against the expected name.
>     +       plain_keycode = create_keymap(config, (u32 *)prop->data,
>     +               proplen, KEY_FN, &config->fn_pos);
> 
> Probably don't need plain_keycode variable at all.

This is required because the variable is passed to free() later, and
config->plain_keycode is marked const, whereas free isn't prototyped to
take a const. I figured that it was simplest to use a separate variable
here rather than cast away the const when calling free(). Now, if C had
const_cast<>, then I would have made a different decision:-)


More information about the U-Boot mailing list