mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
Input: ipaq-micro-keys - simplify allocation
Embed the keycode array in the struct to have a single allocation. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20260609213532.25181-1-rosenp@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
d4579af29e
commit
ead5622914
|
|
@ -20,12 +20,6 @@
|
|||
#include <linux/platform_device.h>
|
||||
#include <linux/mfd/ipaq-micro.h>
|
||||
|
||||
struct ipaq_micro_keys {
|
||||
struct ipaq_micro *micro;
|
||||
struct input_dev *input;
|
||||
u16 *codes;
|
||||
};
|
||||
|
||||
static const u16 micro_keycodes[] = {
|
||||
KEY_RECORD, /* 1: Record button */
|
||||
KEY_CALENDAR, /* 2: Calendar */
|
||||
|
|
@ -38,6 +32,12 @@ static const u16 micro_keycodes[] = {
|
|||
KEY_DOWN, /* 9: Down */
|
||||
};
|
||||
|
||||
struct ipaq_micro_keys {
|
||||
struct ipaq_micro *micro;
|
||||
struct input_dev *input;
|
||||
u16 codes[ARRAY_SIZE(micro_keycodes)];
|
||||
};
|
||||
|
||||
static void micro_key_receive(void *data, int len, unsigned char *msg)
|
||||
{
|
||||
struct ipaq_micro_keys *keys = data;
|
||||
|
|
@ -102,10 +102,7 @@ static int micro_key_probe(struct platform_device *pdev)
|
|||
|
||||
keys->input->keycodesize = sizeof(micro_keycodes[0]);
|
||||
keys->input->keycodemax = ARRAY_SIZE(micro_keycodes);
|
||||
keys->codes = devm_kmemdup_array(&pdev->dev, micro_keycodes, keys->input->keycodemax,
|
||||
keys->input->keycodesize, GFP_KERNEL);
|
||||
if (!keys->codes)
|
||||
return -ENOMEM;
|
||||
memcpy(keys->codes, micro_keycodes, sizeof(keys->codes));
|
||||
|
||||
keys->input->keycode = keys->codes;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user