Thread (4 messages) 4 messages, 2 authors, 2024-06-07

Re: [PATCH v3] Input: adc-joystick: Handle inverted axes

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2024-06-07 19:31:46

On Sat, Jan 20, 2024 at 01:10:18AM -0800, Dmitry Torokhov wrote:
quoted hunk ↗ jump to hunk
On Fri, Jan 19, 2024 at 12:29:54AM -0800, Dmitry Torokhov wrote:
quoted
Hi Chris,

On Mon, Jan 15, 2024 at 01:27:52PM -0600, Chris Morgan wrote:
quoted
 
+static int adc_joystick_invert(struct input_dev *dev,
+			       unsigned int axis, int val)
+{
+	int min = dev->absinfo[axis].minimum;
+	int max = dev->absinfo[axis].maximum;
I changed this to input_abs_get_[min|max](dev, axis) to avoid peeking
into absinfo and applied.
Apparently min_array() and max_array() are a bit too new. Also I am not
sure if they are actually needed. Can we do it like this:
diff --git a/drivers/input/joystick/adc-joystick.c b/drivers/input/joystick/adc-joystick.c
index 10ee13465cfe..916e78e4dc9f 100644
--- a/drivers/input/joystick/adc-joystick.c
+++ b/drivers/input/joystick/adc-joystick.c
@@ -185,14 +185,14 @@ static int adc_joystick_set_axes(struct device *dev, struct adc_joystick *joy)
 		if (axes[i].range[0] > axes[i].range[1]) {
 			dev_dbg(dev, "abs-axis %d inverted\n", i);
 			axes[i].inverted = true;
+			swap(axes[i].range[0], axes[i].range[1]);
 		}
 
 		fwnode_property_read_u32(child, "abs-fuzz", &axes[i].fuzz);
 		fwnode_property_read_u32(child, "abs-flat", &axes[i].flat);
 
 		input_set_abs_params(joy->input, axes[i].code,
-				     min_array(axes[i].range, 2),
-				     max_array(axes[i].range, 2),
+				     axes[i].range[0], axes[i].range[1],
 				     axes[i].fuzz, axes[i].flat);
 		input_set_capability(joy->input, EV_ABS, axes[i].code);
 	}
OK, I went ahead and folded this into the original patch and applied.

Thanks.

-- 
Dmitry
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help