linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Boyd <swboyd@chromium.org>
To: benjamin.tissoires@redhat.com,
	Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Jiri Kosina <jikos@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org,
	"Sean O'Brien" <seobrien@chromium.org>,
	Douglas Anderson <dianders@chromium.org>,
	Zhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com>
Subject: [PATCH 1/5] Input: atkbd: Convert function_row_physmap to u16 array
Date: Fri,  4 Feb 2022 12:20:17 -0800	[thread overview]
Message-ID: <20220204202021.895426-2-swboyd@chromium.org> (raw)
In-Reply-To: <20220204202021.895426-1-swboyd@chromium.org>

This is a u32 array because the device property is an array of u32s.
Convert this to a u16 array to save a little space and to ease the
transition to a common physmap function in the next patch.

Cc: Jiri Kosina <jikos@kernel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Sean O'Brien" <seobrien@chromium.org>
Cc: Douglas Anderson <dianders@chromium.org>
Cc: Zhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Note this makes a large array on the stack (32 * 24 = 768 bytes). It
could be moved to the heap with a kmalloc or we could accept the extra
16 * 24 = 384 bytes for the vivaldi_data struct if it has a u32, or we
can be more precise and make that a u16 pointer in vivaldi_data and move 
the array to the heap.

 drivers/input/keyboard/atkbd.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index fbdef95291e9..721cde982637 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -237,7 +237,7 @@ struct atkbd {
 	/* Serializes reconnect(), attr->set() and event work */
 	struct mutex mutex;
 
-	u32 function_row_physmap[MAX_FUNCTION_ROW_KEYS];
+	u16 function_row_physmap[MAX_FUNCTION_ROW_KEYS];
 	int num_function_row_keys;
 };
 
@@ -1202,14 +1202,17 @@ static void atkbd_parse_fwnode_data(struct serio *serio)
 {
 	struct atkbd *atkbd = serio_get_drvdata(serio);
 	struct device *dev = &serio->dev;
-	int n;
+	int i, n;
+	u32 physmap[MAX_FUNCTION_ROW_KEYS];
 
 	/* Parse "function-row-physmap" property */
 	n = device_property_count_u32(dev, "function-row-physmap");
 	if (n > 0 && n <= MAX_FUNCTION_ROW_KEYS &&
 	    !device_property_read_u32_array(dev, "function-row-physmap",
-					    atkbd->function_row_physmap, n)) {
+					    physmap, n)) {
 		atkbd->num_function_row_keys = n;
+		for (i = 0; i < n; i++)
+			atkbd->function_row_physmap[i] = physmap[i];
 		dev_dbg(dev, "FW reported %d function-row key locations\n", n);
 	}
 }
-- 
https://chromeos.dev


  reply	other threads:[~2022-02-04 20:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-04 20:20 [PATCH 0/5] Input/HID: Consolidate ChromeOS Vivaldi keyboard logic Stephen Boyd
2022-02-04 20:20 ` Stephen Boyd [this message]
2022-02-04 20:20 ` [PATCH 2/5] Input: Extract ChromeOS vivaldi physmap show function Stephen Boyd
2022-02-04 20:20 ` [PATCH 3/5] HID: Extract vivaldi hid feature mapping for use in hid-hammer Stephen Boyd
2022-02-05  0:15   ` kernel test robot
2022-02-05  2:19     ` Stephen Boyd
2022-02-05  3:19   ` kernel test robot
2022-02-04 20:20 ` [PATCH 4/5] HID: google: Add support for vivaldi to hid-hammer Stephen Boyd
2022-02-04 20:20 ` [PATCH 5/5] HID: google: modify HID device groups of eel Stephen Boyd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220204202021.895426-2-swboyd@chromium.org \
    --to=swboyd@chromium.org \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dianders@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=seobrien@chromium.org \
    --cc=xiazhengqiao@huaqin.corp-partner.google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).