From: "José Expósito" <jose.exposito89@gmail.com>
To: jikos@kernel.org
Cc: benjamin.tissoires@redhat.com, spbnick@gmail.com,
j.witteveen@gmail.com, nathan@kernel.org,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
kunit-dev@googlegroups.com,
"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH v4 3/8] HID: uclogic: Refactor UGEE v2 frame initialization
Date: Mon, 15 Aug 2022 16:29:51 +0200 [thread overview]
Message-ID: <20220815142956.19180-4-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20220815142956.19180-1-jose.exposito89@gmail.com>
At the moment, the driver only supports UGEE v2 devices that have
buttons in their frames.
In order to support other types of frames in the future, move the code
used to initialize this kind of frames to its own function.
Tested-by: Jouke Witteveen <j.witteveen@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-uclogic-params.c | 56 ++++++++++++++++++++++----------
1 file changed, 38 insertions(+), 18 deletions(-)
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 07c5a21112ce..182e6f8f027a 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -1112,6 +1112,41 @@ static int uclogic_params_parse_ugee_v2_desc(const __u8 *str_desc,
return 0;
}
+/**
+ * uclogic_params_ugee_v2_init_frame_buttons() - initialize a UGEE v2 frame with
+ * buttons.
+ * @p: Parameters to fill in, cannot be NULL.
+ * @desc_params: Device description params list.
+ * @desc_params_size: Size of the description params list.
+ *
+ * Returns:
+ * Zero, if successful. A negative errno code on error.
+ */
+static int uclogic_params_ugee_v2_init_frame_buttons(struct uclogic_params *p,
+ const s32 *desc_params,
+ size_t desc_params_size)
+{
+ __u8 *rdesc_frame = NULL;
+ int rc = 0;
+
+ if (!p || desc_params_size != UCLOGIC_RDESC_PH_ID_NUM)
+ return -EINVAL;
+
+ rdesc_frame = uclogic_rdesc_template_apply(
+ uclogic_rdesc_ugee_v2_frame_btn_template_arr,
+ uclogic_rdesc_ugee_v2_frame_btn_template_size,
+ desc_params, UCLOGIC_RDESC_PH_ID_NUM);
+ if (!rdesc_frame)
+ return -ENOMEM;
+
+ rc = uclogic_params_frame_init_with_desc(&p->frame_list[0],
+ rdesc_frame,
+ uclogic_rdesc_ugee_v2_frame_btn_template_size,
+ UCLOGIC_RDESC_V1_FRAME_ID);
+ kfree(rdesc_frame);
+ return rc;
+}
+
/**
* uclogic_params_ugee_v2_init() - initialize a UGEE graphics tablets by
* discovering their parameters.
@@ -1140,7 +1175,6 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
const int str_desc_len = 12;
__u8 *str_desc = NULL;
__u8 *rdesc_pen = NULL;
- __u8 *rdesc_frame = NULL;
s32 desc_params[UCLOGIC_RDESC_PH_ID_NUM];
__u8 magic_arr[] = {
0x02, 0xb0, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
@@ -1209,24 +1243,10 @@ static int uclogic_params_ugee_v2_init(struct uclogic_params *params,
p.pen.subreport_list[0].id = UCLOGIC_RDESC_V1_FRAME_ID;
/* Initialize the frame interface */
- rdesc_frame = uclogic_rdesc_template_apply(
- uclogic_rdesc_ugee_v2_frame_btn_template_arr,
- uclogic_rdesc_ugee_v2_frame_btn_template_size,
- desc_params, ARRAY_SIZE(desc_params));
- if (!rdesc_frame) {
- rc = -ENOMEM;
+ rc = uclogic_params_ugee_v2_init_frame_buttons(&p, desc_params,
+ ARRAY_SIZE(desc_params));
+ if (rc)
goto cleanup;
- }
-
- rc = uclogic_params_frame_init_with_desc(&p.frame_list[0],
- rdesc_frame,
- uclogic_rdesc_ugee_v2_frame_btn_template_size,
- UCLOGIC_RDESC_V1_FRAME_ID);
- kfree(rdesc_frame);
- if (rc) {
- uclogic_params_init_invalid(&p);
- goto output;
- }
output:
/* Output parameters */
--
2.25.1
next prev parent reply other threads:[~2022-08-15 14:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-15 14:29 [PATCH v4 0/8] XP-PEN Deco Pro S support José Expósito
2022-08-15 14:29 ` [PATCH v4 1/8] HID: uclogic: KUnit best practices and naming conventions José Expósito
2022-08-15 14:29 ` [PATCH v4 2/8] HID: uclogic: Refactor UGEE v2 string descriptor parsing José Expósito
2022-08-15 14:29 ` José Expósito [this message]
2022-08-15 14:29 ` [PATCH v4 4/8] HID: uclogic: Parse the UGEE v2 frame type José Expósito
2022-08-15 14:29 ` [PATCH v4 5/8] HID: uclogic: Add support for UGEE v2 dial frames José Expósito
2022-08-15 14:29 ` [PATCH v4 6/8] HID: uclogic: Add support for UGEE v2 mouse frames José Expósito
2022-08-15 14:29 ` [PATCH v4 7/8] HID: uclogic: Add support for XP-PEN Deco Pro S José Expósito
2022-08-15 14:29 ` [PATCH v4 8/8] HID: uclogic: Add support for Parblo A610 PRO José Expósito
2022-08-25 8:28 ` [PATCH v4 0/8] XP-PEN Deco Pro S support Jiri Kosina
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=20220815142956.19180-4-jose.exposito89@gmail.com \
--to=jose.exposito89@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=j.witteveen@gmail.com \
--cc=jikos@kernel.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=spbnick@gmail.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).