]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: cros_ec_keyb - do not allocate keyboard state separately
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Feb 2026 21:30:19 +0000 (13:30 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Feb 2026 21:47:52 +0000 (13:47 -0800)
Now that we know the upper bound for the number of columns, and know
that it is pretty small, there is no point in allocating it separately.
We are wasting more memory tracking the allocations.

Embed valid_keys and old_kb_state directly into cros_ec_keyb structure.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260222003717.471977-6-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/cros_ec_keyb.c

index 16bb0d0a0e740789c8020b7cc138d2627de6a09a..d11c9d4940040c35d79236c50ce4d1b6c77fdc3a 100644 (file)
@@ -59,8 +59,8 @@ struct cros_ec_keyb {
        unsigned int cols;
        int row_shift;
        bool ghost_filter;
-       u8 *valid_keys;
-       u8 *old_kb_state;
+       u8 valid_keys[CROS_EC_KEYBOARD_COLS_MAX];
+       u8 old_kb_state[CROS_EC_KEYBOARD_COLS_MAX];
 
        struct device *dev;
        struct cros_ec_device *ec;
@@ -750,14 +750,6 @@ static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev)
                return -EINVAL;
        }
 
-       ckdev->valid_keys = devm_kzalloc(dev, ckdev->cols, GFP_KERNEL);
-       if (!ckdev->valid_keys)
-               return -ENOMEM;
-
-       ckdev->old_kb_state = devm_kzalloc(dev, ckdev->cols, GFP_KERNEL);
-       if (!ckdev->old_kb_state)
-               return -ENOMEM;
-
        /*
         * We call the keyboard matrix 'input0'. Allocate phys before input
         * dev, to ensure correct tear-down ordering.