linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/5] Input: Set EV_ABS in dev->evbit even if input_alloc_absinfo() fails
@ 2022-01-31 14:35 Hans de Goede
  2022-01-31 14:35 ` [PATCH v2 2/5] Input: Add input_copy_abs() function Hans de Goede
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Hans de Goede @ 2022-01-31 14:35 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Hans de Goede, Bastien Nocera, linux-input

The input core's error handling for input_alloc_absinfo() failures
is based on ignoring the error until input_register_device() runs
and then checks for the failure like this:

        if (test_bit(EV_ABS, dev->evbit) && !dev->absinfo) {
                dev_err(&dev->dev, ...);
                return -EINVAL;
        }

This relies on EV_ABS actually getting set in dev->evbit even
if input_alloc_absinfo() fails, change input_set_abs_params() and
input_set_capability() to actually adhere to this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
- New patch in v2 of this patch-set
---
 drivers/input/input.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/input/input.c b/drivers/input/input.c
index ccaeb2426385..3a5156012fb8 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -511,6 +511,9 @@ void input_set_abs_params(struct input_dev *dev, unsigned int axis,
 {
 	struct input_absinfo *absinfo;
 
+	__set_bit(EV_ABS, dev->evbit);
+	__set_bit(axis, dev->absbit);
+
 	input_alloc_absinfo(dev);
 	if (!dev->absinfo)
 		return;
@@ -520,9 +523,6 @@ void input_set_abs_params(struct input_dev *dev, unsigned int axis,
 	absinfo->maximum = max;
 	absinfo->fuzz = fuzz;
 	absinfo->flat = flat;
-
-	__set_bit(EV_ABS, dev->evbit);
-	__set_bit(axis, dev->absbit);
 }
 EXPORT_SYMBOL(input_set_abs_params);
 
@@ -2085,9 +2085,6 @@ void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int
 
 	case EV_ABS:
 		input_alloc_absinfo(dev);
-		if (!dev->absinfo)
-			return;
-
 		__set_bit(code, dev->absbit);
 		break;
 
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-03-01  7:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-31 14:35 [PATCH v2 1/5] Input: Set EV_ABS in dev->evbit even if input_alloc_absinfo() fails Hans de Goede
2022-01-31 14:35 ` [PATCH v2 2/5] Input: Add input_copy_abs() function Hans de Goede
2022-03-01  7:03   ` Dmitry Torokhov
2022-01-31 14:35 ` [PATCH v2 3/5] Input: goodix - Use input_copy_abs() helper Hans de Goede
2022-03-01  7:04   ` Dmitry Torokhov
2022-01-31 14:35 ` [PATCH v2 4/5] Input: goodix - Fix race on driver unbind Hans de Goede
2022-03-01  7:04   ` Dmitry Torokhov
2022-01-31 14:35 ` [PATCH v2 5/5] Input: goodix - Use the new soc_intel_is_byt() helper Hans de Goede
2022-03-01  7:01   ` Dmitry Torokhov
2022-03-01  7:03 ` [PATCH v2 1/5] Input: Set EV_ABS in dev->evbit even if input_alloc_absinfo() fails Dmitry Torokhov

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).