Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: zforce_ts - make parsing of contacts less confusing

Zforce touch data packet consists of a byte representing number of
contacts followed by several chunks with length of 9 bytes representing
each contact. Instead of accounting for the leading byte by increasing
offset of each field in contacts by one introduce a pointer to contact
data and point it appropriately. This avoids awkward constructs like:

point.prblty = payload[9 * i + 9];

which makes it seem like there is off-by-one error, in favor of more
straightforward:

point.prblty = p[8];

Tested-by: Andreas Kemnade <andreas@kemnade.info> # Tolino Shine2HD
Link: https://lore.kernel.org/r/20240824055047.1706392-11-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+12 -11
+12 -11
drivers/input/touchscreen/zforce_ts.c
··· 318 318 struct i2c_client *client = ts->client; 319 319 struct zforce_point point; 320 320 int count, i, num = 0; 321 + u8 *p; 321 322 322 323 count = payload[0]; 323 324 if (count > ZFORCE_REPORT_POINTS) { ··· 329 328 } 330 329 331 330 for (i = 0; i < count; i++) { 332 - point.coord_x = get_unaligned_le16(&payload[9 * i + 1]); 333 - point.coord_y = get_unaligned_le16(&payload[9 * i + 3]); 331 + p = &payload[i * 9 + 1]; 332 + 333 + point.coord_x = get_unaligned_le16(&p[0]); 334 + point.coord_y = get_unaligned_le16(&p[2]); 334 335 335 336 if (point.coord_x > ts->prop.max_x || 336 337 point.coord_y > ts->prop.max_y) { ··· 341 338 point.coord_x = point.coord_y = 0; 342 339 } 343 340 344 - point.state = payload[9 * i + 5] & 0x0f; 345 - point.id = (payload[9 * i + 5] & 0xf0) >> 4; 341 + point.state = p[4] & 0x0f; 342 + point.id = (p[4] & 0xf0) >> 4; 346 343 347 344 /* determine touch major, minor and orientation */ 348 - point.area_major = max(payload[9 * i + 6], 349 - payload[9 * i + 7]); 350 - point.area_minor = min(payload[9 * i + 6], 351 - payload[9 * i + 7]); 352 - point.orientation = payload[9 * i + 6] > payload[9 * i + 7]; 345 + point.area_major = max(p[5], p[6]); 346 + point.area_minor = min(p[5], p[6]); 347 + point.orientation = p[5] > p[6]; 353 348 354 - point.pressure = payload[9 * i + 8]; 355 - point.prblty = payload[9 * i + 9]; 349 + point.pressure = p[7]; 350 + point.prblty = p[8]; 356 351 357 352 dev_dbg(&client->dev, 358 353 "point %d/%d: state %d, id %d, pressure %d, prblty %d, x %d, y %d, amajor %d, aminor %d, ori %d\n",