mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
Input: rmi4 - use unaligned access helpers in F12
Use get_unaligned_le16() instead of manual bit shifts to construct 16-bit values for max_x, max_y, pitch_x, pitch_y, and object coordinates in the F12 parsing logic. This simplifies the code and makes the endianness explicit. Assisted-by: Gemini:gemini-3.1-pro Link: https://patch.msgid.link/20260505045952.1570713-14-dmitry.torokhov@gmail.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
5fcb6013dd
commit
f764f0f98c
|
|
@ -6,6 +6,7 @@
|
|||
#include <linux/input/mt.h>
|
||||
#include <linux/rmi.h>
|
||||
#include <linux/sizes.h>
|
||||
#include <linux/unaligned.h>
|
||||
#include "rmi_driver.h"
|
||||
#include "rmi_2d_sensor.h"
|
||||
|
||||
|
|
@ -131,8 +132,8 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12)
|
|||
|
||||
offset = 0;
|
||||
if (rmi_register_desc_has_subpacket(item, 0)) {
|
||||
sensor->max_x = (buf[offset + 1] << 8) | buf[offset];
|
||||
sensor->max_y = (buf[offset + 3] << 8) | buf[offset + 2];
|
||||
sensor->max_x = get_unaligned_le16(&buf[offset]);
|
||||
sensor->max_y = get_unaligned_le16(&buf[offset + 2]);
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +141,8 @@ static int rmi_f12_read_sensor_tuning(struct f12_data *f12)
|
|||
sensor->max_x, sensor->max_y);
|
||||
|
||||
if (rmi_register_desc_has_subpacket(item, 1)) {
|
||||
pitch_x = (buf[offset + 1] << 8) | buf[offset];
|
||||
pitch_y = (buf[offset + 3] << 8) | buf[offset + 2];
|
||||
pitch_x = get_unaligned_le16(&buf[offset]);
|
||||
pitch_y = get_unaligned_le16(&buf[offset + 2]);
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
|
|
@ -227,8 +228,8 @@ static void rmi_f12_process_objects(struct f12_data *f12, u8 *data1, int size)
|
|||
break;
|
||||
}
|
||||
|
||||
obj->x = (data1[2] << 8) | data1[1];
|
||||
obj->y = (data1[4] << 8) | data1[3];
|
||||
obj->x = get_unaligned_le16(&data1[1]);
|
||||
obj->y = get_unaligned_le16(&data1[3]);
|
||||
obj->z = data1[5];
|
||||
obj->wx = data1[6];
|
||||
obj->wy = data1[7];
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user