diff mbox series

[for-5.18/uclogic,1/9] HID: uclogic: Remove pen usage masking

Message ID 20220219100157.41920-2-jose.exposito89@gmail.com
State New
Headers show
Series [for-5.18/uclogic,1/9] HID: uclogic: Remove pen usage masking | expand

Commit Message

José Expósito Feb. 19, 2022, 10:01 a.m. UTC
From: Nikolai Kondrashov <spbnick@gmail.com>

Remove support for pen usage masking from hid-uclogic. Disable whole
interfaces instead. Most of those interfaces are useless, and if there
is one which has an unused pen usage, but also has useful reports, its
report descriptor should be rewritten instead.

This simplifies the code and the data structures.

Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-uclogic-core.c   | 23 +----------------------
 drivers/hid/hid-uclogic-params.c | 29 +++++------------------------
 drivers/hid/hid-uclogic-params.h |  9 +--------
 3 files changed, 7 insertions(+), 54 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index 73d79d149869..26849f1f5459 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -81,24 +81,6 @@  static __u8 *uclogic_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	return rdesc;
 }
 
-static int uclogic_input_mapping(struct hid_device *hdev,
-				 struct hid_input *hi,
-				 struct hid_field *field,
-				 struct hid_usage *usage,
-				 unsigned long **bit,
-				 int *max)
-{
-	struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
-	struct uclogic_params *params = &drvdata->params;
-
-	/* discard the unused pen interface */
-	if (params->pen_unused && (field->application == HID_DG_PEN))
-		return -1;
-
-	/* let hid-core decide what to do */
-	return 0;
-}
-
 static int uclogic_input_configured(struct hid_device *hdev,
 		struct hid_input *hi)
 {
@@ -374,9 +356,7 @@  static int uclogic_raw_event(struct hid_device *hdev,
 		return 0;
 
 	/* Tweak pen reports, if necessary */
-	if (!params->pen_unused &&
-	    (report_id == params->pen.id) &&
-	    (size >= 2)) {
+	if ((report_id == params->pen.id) && (size >= 2)) {
 		/* If it's the "virtual" frame controls report */
 		if (params->frame.id != 0 &&
 		    data[1] & params->pen_frame_flag) {
@@ -464,7 +444,6 @@  static struct hid_driver uclogic_driver = {
 	.remove = uclogic_remove,
 	.report_fixup = uclogic_report_fixup,
 	.raw_event = uclogic_raw_event,
-	.input_mapping = uclogic_input_mapping,
 	.input_configured = uclogic_input_configured,
 #ifdef CONFIG_PM
 	.resume	          = uclogic_resume,
diff --git a/drivers/hid/hid-uclogic-params.c b/drivers/hid/hid-uclogic-params.c
index 98910d8dae92..71496735cbf0 100644
--- a/drivers/hid/hid-uclogic-params.c
+++ b/drivers/hid/hid-uclogic-params.c
@@ -514,8 +514,7 @@  void uclogic_params_cleanup(struct uclogic_params *params)
 {
 	if (!params->invalid) {
 		kfree(params->desc_ptr);
-		if (!params->pen_unused)
-			uclogic_params_pen_cleanup(&params->pen);
+		uclogic_params_pen_cleanup(&params->pen);
 		uclogic_params_frame_cleanup(&params->frame);
 		memset(params, 0, sizeof(*params));
 	}
@@ -557,7 +556,7 @@  int uclogic_params_get_desc(const struct uclogic_params *params,
 	size = 0;
 
 	common_present = (params->desc_ptr != NULL);
-	pen_present = (!params->pen_unused && params->pen.desc_ptr != NULL);
+	pen_present = (params->pen.desc_ptr != NULL);
 	frame_present = (params->frame.desc_ptr != NULL);
 
 	if (common_present)
@@ -680,21 +679,6 @@  static int uclogic_params_init_with_opt_desc(struct uclogic_params *params,
 	return rc;
 }
 
-/**
- * uclogic_params_init_with_pen_unused() - initialize tablet interface
- * parameters preserving original reports and generic HID processing, but
- * disabling pen usage.
- *
- * @params:		Parameters to initialize (to be cleaned with
- *			uclogic_params_cleanup()). Not modified in case of
- *			error. Cannot be NULL.
- */
-static void uclogic_params_init_with_pen_unused(struct uclogic_params *params)
-{
-	memset(params, 0, sizeof(*params));
-	params->pen_unused = true;
-}
-
 /**
  * uclogic_params_huion_init() - initialize a Huion tablet interface and discover
  * its parameters.
@@ -734,8 +718,7 @@  static int uclogic_params_huion_init(struct uclogic_params *params,
 
 	/* If it's not a pen interface */
 	if (bInterfaceNumber != 0) {
-		/* TODO: Consider marking the interface invalid */
-		uclogic_params_init_with_pen_unused(&p);
+		uclogic_params_init_invalid(&p);
 		goto output;
 	}
 
@@ -1033,8 +1016,7 @@  int uclogic_params_init(struct uclogic_params *params,
 				uclogic_params_init_invalid(&p);
 			}
 		} else {
-			/* TODO: Consider marking the interface invalid */
-			uclogic_params_init_with_pen_unused(&p);
+			uclogic_params_init_invalid(&p);
 		}
 		break;
 	case VID_PID(USB_VENDOR_ID_UGEE,
@@ -1056,8 +1038,7 @@  int uclogic_params_init(struct uclogic_params *params,
 			if (rc != 0)
 				goto cleanup;
 		} else {
-			/* TODO: Consider marking the interface invalid */
-			uclogic_params_init_with_pen_unused(&p);
+			uclogic_params_init_invalid(&p);
 		}
 		break;
 	case VID_PID(USB_VENDOR_ID_TRUST,
diff --git a/drivers/hid/hid-uclogic-params.h b/drivers/hid/hid-uclogic-params.h
index e8381bb77bd0..48b974943bb9 100644
--- a/drivers/hid/hid-uclogic-params.h
+++ b/drivers/hid/hid-uclogic-params.h
@@ -138,14 +138,9 @@  struct uclogic_params {
 	 * Only valid, if "desc_ptr" is not NULL.
 	 */
 	unsigned int desc_size;
-	/*
-	 * True, if pen usage in report descriptor is invalid, when present.
-	 * Only valid, if "invalid" is false.
-	 */
-	bool pen_unused;
 	/*
 	 * Pen parameters and optional report descriptor part.
-	 * Only valid if "pen_unused" is valid and false.
+	 * Only valid, if "invalid" is false.
 	 */
 	struct uclogic_params_pen pen;
 	/*
@@ -171,7 +166,6 @@  extern int uclogic_params_init(struct uclogic_params *params,
 		".invalid = %s\n"                   \
 		".desc_ptr = %p\n"                  \
 		".desc_size = %u\n"                 \
-		".pen_unused = %s\n"                \
 		".pen.desc_ptr = %p\n"              \
 		".pen.desc_size = %u\n"             \
 		".pen.id = %u\n"                    \
@@ -190,7 +184,6 @@  extern int uclogic_params_init(struct uclogic_params *params,
 		((_params)->invalid ? "true" : "false"),                    \
 		(_params)->desc_ptr,                                        \
 		(_params)->desc_size,                                       \
-		((_params)->pen_unused ? "true" : "false"),                 \
 		(_params)->pen.desc_ptr,                                    \
 		(_params)->pen.desc_size,                                   \
 		(_params)->pen.id,                                          \