Thread (6 messages) flat view 6 messages, 2 authors, 2021-01-15

Re: [PATCH v5 2/2] Input: cros-ec-keyb - Expose function row physical map to userspace

From: Philip Chen <hidden>
Date: 2021-01-15 02:33:39
Also in: lkml

On Wed, Jan 13, 2021 at 5:36 PM Stephen Boyd [off-list ref] wrote:
Quoting Philip Chen (2021-01-13 17:25:13)
quoted
diff --git a/drivers/input/keyboard/cros_ec_keyb.c b/drivers/input/keyboard/cros_ec_keyb.c
index b379ed7628781..273e3c9ba0b03 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -578,6 +590,19 @@ static int cros_ec_keyb_register_matrix(struct cros_ec_keyb *ckdev)
        ckdev->idev = idev;
        cros_ec_keyb_compute_valid_keys(ckdev);

+       of_property_for_each_u32(dev->of_node, "function-row-physmap",
+                                prop, p, key_pos) {
+               if (i >= MAX_NUM_TOP_ROW_KEYS) {
+                       dev_err(dev, "Only support up to %d top row keys.\n",
dev_warn? And drop the period please as we don't add them in the kernel
usually.
Done.
quoted
+                               MAX_NUM_TOP_ROW_KEYS);
+                       break;
+               }
+               ckdev->function_row_physmap[i] = MATRIX_SCAN_CODE(
Maybe grow some more local variables, like for function_row_physmap so
this can fit on one line?
Done. Please take a look at v6.
                row = KEY_ROW(key_pos);
                col = KEY_COL(key_pos);
                map[i] = MATRIX_SCAN_CODE(row, col, ckdev->row_shift);
quoted
+                       KEY_ROW(key_pos), KEY_COL(key_pos), ckdev->row_shift);
+               i++;
We could remove this and just increment num_function_row_keys instead.
Then that condition check may be a little longer but probably still ok.
Done. Please take a look at v6.
quoted
+       }
+       ckdev->num_function_row_keys = i;
+
        err = input_register_device(ckdev->idev);
        if (err) {
                dev_err(dev, "cannot register input device\n");
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help