Skip to content

Commit 7f12dd2

Browse files
spbnickJiri Kosina
authored andcommitted
HID: uclogic: Access pen/frame params directly in raw_event handling
Simplify the raw event handling code by accessing the uclogic_params_pen/uclogic_params_frame structs directly. Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com> Signed-off-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 7e41866 commit 7f12dd2

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

drivers/hid/hid-uclogic-core.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ static int uclogic_resume(struct hid_device *hdev)
259259
static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
260260
u8 *data, int size)
261261
{
262-
struct uclogic_params *params = &drvdata->params;
262+
struct uclogic_params_pen *pen = &drvdata->params.pen;
263263

264264
WARN_ON(drvdata == NULL);
265265
WARN_ON(data == NULL && size != 0);
266266

267267
/* If in-range reports are inverted */
268-
if (params->pen.inrange ==
268+
if (pen->inrange ==
269269
UCLOGIC_PARAMS_PEN_INRANGE_INVERTED) {
270270
/* Invert the in-range bit */
271271
data[1] ^= 0x40;
@@ -274,7 +274,7 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
274274
* If report contains fragmented high-resolution pen
275275
* coordinates
276276
*/
277-
if (size >= 10 && params->pen.fragmented_hires) {
277+
if (size >= 10 && pen->fragmented_hires) {
278278
u8 pressure_low_byte;
279279
u8 pressure_high_byte;
280280

@@ -296,15 +296,15 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
296296
data[9] = pressure_high_byte;
297297
}
298298
/* If we need to emulate in-range detection */
299-
if (params->pen.inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
299+
if (pen->inrange == UCLOGIC_PARAMS_PEN_INRANGE_NONE) {
300300
/* Set in-range bit */
301301
data[1] |= 0x40;
302302
/* (Re-)start in-range timeout */
303303
mod_timer(&drvdata->inrange_timer,
304304
jiffies + msecs_to_jiffies(100));
305305
}
306306
/* If we report tilt and Y direction is flipped */
307-
if (size >= 12 && params->pen.tilt_y_flipped)
307+
if (size >= 12 && pen->tilt_y_flipped)
308308
data[11] = -data[11];
309309

310310
return 0;
@@ -323,21 +323,19 @@ static int uclogic_raw_event_pen(struct uclogic_drvdata *drvdata,
323323
static int uclogic_raw_event_frame(struct uclogic_drvdata *drvdata,
324324
u8 *data, int size)
325325
{
326-
struct uclogic_params *params = &drvdata->params;
326+
struct uclogic_params_frame *frame = &drvdata->params.frame;
327327

328328
WARN_ON(drvdata == NULL);
329329
WARN_ON(data == NULL && size != 0);
330330

331331
/* If need to, and can, set pad device ID for Wacom drivers */
332-
if (params->frame.dev_id_byte > 0 &&
333-
params->frame.dev_id_byte < size) {
334-
data[params->frame.dev_id_byte] = 0xf;
332+
if (frame->dev_id_byte > 0 && frame->dev_id_byte < size) {
333+
data[frame->dev_id_byte] = 0xf;
335334
}
336335
/* If need to, and can, read rotary encoder state change */
337-
if (params->frame.re_lsb > 0 &&
338-
params->frame.re_lsb / 8 < size) {
339-
unsigned int byte = params->frame.re_lsb / 8;
340-
unsigned int bit = params->frame.re_lsb % 8;
336+
if (frame->re_lsb > 0 && frame->re_lsb / 8 < size) {
337+
unsigned int byte = frame->re_lsb / 8;
338+
unsigned int bit = frame->re_lsb % 8;
341339

342340
u8 change;
343341
u8 prev_state = drvdata->re_state;

0 commit comments

Comments
 (0)