Skip to content

Commit bf0c349

Browse files
authored
Merge pull request #513 from Joshua-Dickens/master
Backports for Input Wacom 1.7.0 Release
2 parents 44cea06 + 4d66e50 commit bf0c349

8 files changed

Lines changed: 217 additions & 25 deletions

File tree

.github/workflows/main.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-24.04
1313
strategy:
1414
matrix:
15-
kernel: ["6.12", "6.10", "6.3", "5.15", "5.10", "5.4", "5.0", "4.19"]
15+
kernel: ["7.0", "6.17", "6.12", "6.10", "6.5", "6.3", "5.17", "5.15", "5.10", "5.4", "5.0", "4.19"]
1616
include:
1717
- kernel: "4.19"
1818
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
@@ -24,15 +24,26 @@ jobs:
2424
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
2525
- kernel: "5.15"
2626
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
27+
- kernel: "5.17"
28+
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
2729
- kernel: "6.3"
2830
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
2931
build_makeflags: KBUILD_MODPOST_WARN=1
32+
- kernel: "6.5"
33+
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
34+
build_makeflags: KBUILD_MODPOST_WARN=1
3035
- kernel: "6.10"
3136
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
3237
build_makeflags: KBUILD_MODPOST_WARN=1
3338
- kernel: "6.12"
3439
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
3540
build_makeflags: KBUILD_MODPOST_WARN=1
41+
- kernel: "6.17"
42+
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
43+
build_makeflags: KBUILD_MODPOST_WARN=1
44+
- kernel: "7.0"
45+
compile_cflags: -Wno-error=format-truncation -Wno-error=pointer-sign
46+
build_makeflags: KBUILD_MODPOST_WARN=1
3647
steps:
3748
- name: Install dependencies
3849
run: |
@@ -41,7 +52,7 @@ jobs:
4152
gcc -print-file-name=plugin
4253
4354
- name: Checkout the repo
44-
uses: actions/checkout@v4
55+
uses: actions/checkout@v7
4556

4657
- name: Download and extract v${{ matrix.kernel }} kernel
4758
run: |
@@ -94,7 +105,7 @@ jobs:
94105
95106
- name: Save build directory as artifact
96107
if: '!cancelled()'
97-
uses: actions/upload-artifact@v4
108+
uses: actions/upload-artifact@v7
98109
with:
99110
name: input-wacom-${{ matrix.kernel }}
100111
retention-days: 7

.github/workflows/tagged-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
# ...
21-
- uses: actions/checkout@v4
21+
- uses: actions/checkout@v7
2222
with:
2323
ref: ${{ github.ref }}
2424
fetch-tags: 'true'

4.18/wacom_i2c.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,11 @@ static int wacom_i2c_probe(struct i2c_client *client)
338338
return 0;
339339
}
340340

341+
#ifdef WACOM_DEFINE_SIMPLE_DEV_PM_OPS
342+
static int wacom_i2c_suspend(struct device *dev)
343+
#else
341344
static int __maybe_unused wacom_i2c_suspend(struct device *dev)
345+
#endif
342346
{
343347
struct i2c_client *client = to_i2c_client(dev);
344348

@@ -347,7 +351,11 @@ static int __maybe_unused wacom_i2c_suspend(struct device *dev)
347351
return 0;
348352
}
349353

354+
#ifdef WACOM_DEFINE_SIMPLE_DEV_PM_OPS
355+
static int wacom_i2c_resume(struct device *dev)
356+
#else
350357
static int __maybe_unused wacom_i2c_resume(struct device *dev)
358+
#endif
351359
{
352360
struct i2c_client *client = to_i2c_client(dev);
353361

@@ -356,11 +364,15 @@ static int __maybe_unused wacom_i2c_resume(struct device *dev)
356364
return 0;
357365
}
358366

367+
#ifdef WACOM_DEFINE_SIMPLE_DEV_PM_OPS
368+
static DEFINE_SIMPLE_DEV_PM_OPS(wacom_i2c_pm, wacom_i2c_suspend, wacom_i2c_resume);
369+
#else
359370
static SIMPLE_DEV_PM_OPS(wacom_i2c_pm, wacom_i2c_suspend, wacom_i2c_resume);
371+
#endif
360372

361373
static const struct i2c_device_id wacom_i2c_id[] = {
362-
{ "WAC_I2C_EMR", 0 },
363-
{ },
374+
{ "WAC_I2C_EMR" },
375+
{ }
364376
};
365377
MODULE_DEVICE_TABLE(i2c, wacom_i2c_id);
366378

@@ -375,7 +387,11 @@ MODULE_DEVICE_TABLE(of, wacom_i2c_of_match_table);
375387
static struct i2c_driver wacom_i2c_driver = {
376388
.driver = {
377389
.name = "wacom_i2c",
378-
.pm = &wacom_i2c_pm,
390+
#ifdef WACOM_DEFINE_SIMPLE_DEV_PM_OPS
391+
.pm = pm_sleep_ptr(&wacom_i2c_pm),
392+
#else
393+
.pm = &wacom_i2c_pm,
394+
#endif
379395

380396
#ifdef CONFIG_OF
381397
.of_match_table = of_match_ptr(wacom_i2c_of_match_table),

4.18/wacom_sys.c

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,41 @@ static void wacom_wac_queue_insert(struct hid_device *hdev,
6060
{
6161
bool warned = false;
6262

63-
while (kfifo_avail(fifo) < size) {
63+
while (kfifo_avail(fifo) < size && !kfifo_is_empty(fifo)) {
6464
if (!warned)
6565
hid_warn(hdev, "%s: kfifo has filled, starting to drop events\n", __func__);
6666
warned = true;
6767

6868
kfifo_skip(fifo);
6969
}
7070

71+
#ifdef WACOM_HID_WARN_RATELIMITED
72+
if (!kfifo_in(fifo, raw_data, size))
73+
hid_warn_ratelimited(hdev, "%s: report is too large (%d)\n",
74+
__func__, size);
75+
#else
7176
kfifo_in(fifo, raw_data, size);
77+
#endif
7278
}
7379

7480
static void wacom_wac_queue_flush(struct hid_device *hdev,
7581
struct kfifo_rec_ptr_2 *fifo)
7682
{
7783
while (!kfifo_is_empty(fifo)) {
7884
int size = kfifo_peek_len(fifo);
85+
#ifdef WACOM_CLEANUP_FREE
86+
u8 *buf __free(kfree) = kzalloc(size, GFP_ATOMIC);
87+
#else
7988
u8 *buf;
89+
#endif
8090
unsigned int count;
8191
int err;
8292

83-
buf = kzalloc(size, GFP_KERNEL);
93+
#ifdef WACOM_CLEANUP_FREE
94+
#else
95+
buf = kzalloc(size, GFP_ATOMIC);
96+
#endif
97+
8498
if (!buf) {
8599
kfifo_skip(fifo);
86100
continue;
@@ -91,9 +105,12 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
91105
// Hard to say what is the "right" action in this
92106
// circumstance. Skipping the entry and continuing
93107
// to flush seems reasonable enough, however.
94-
hid_warn(hdev, "%s: removed fifo entry with unexpected size\n",
108+
hid_warn(hdev, "%s: removed fifo entry with unexpected size\n",
95109
__func__);
110+
#ifdef WACOM_CLEANUP_FREE
111+
#else
96112
kfree(buf);
113+
#endif
97114
continue;
98115
}
99116
#ifdef WACOM_HID_REPORT_RAW_EVENT_BUFSIZE
@@ -105,8 +122,10 @@ static void wacom_wac_queue_flush(struct hid_device *hdev,
105122
hid_warn(hdev, "%s: unable to flush event due to error %d\n",
106123
__func__, err);
107124
}
108-
125+
#ifdef WACOM_CLEANUP_FREE
126+
#else
109127
kfree(buf);
128+
#endif
110129
}
111130
}
112131

@@ -371,6 +390,7 @@ static void wacom_feature_mapping(struct hid_device *hdev,
371390

372391
hid_data->inputmode = field->report->id;
373392
hid_data->inputmode_index = usage->usage_index;
393+
hid_data->inputmode_field_index = field->index;
374394
break;
375395

376396
case HID_UP_DIGITIZER:
@@ -591,9 +611,14 @@ static int wacom_hid_set_device_mode(struct hid_device *hdev)
591611

592612
re = &(hdev->report_enum[HID_FEATURE_REPORT]);
593613
r = re->report_id_hash[hid_data->inputmode];
594-
if (r) {
595-
r->field[0]->value[hid_data->inputmode_index] = 2;
596-
hid_hw_request(hdev, r, HID_REQ_SET_REPORT);
614+
if (r && hid_data->inputmode_field_index >= 0 &&
615+
hid_data->inputmode_field_index < r->maxfield) {
616+
struct hid_field *field = r->field[hid_data->inputmode_field_index];
617+
618+
if (field && hid_data->inputmode_index < field->report_count) {
619+
field->value[hid_data->inputmode_index] = 2;
620+
hid_hw_request(hdev, r, HID_REQ_SET_REPORT);
621+
}
597622
}
598623
return 0;
599624
}
@@ -928,7 +953,11 @@ static int wacom_add_shared_data(struct hid_device *hdev)
928953

929954
data = wacom_get_hdev_data(hdev);
930955
if (!data) {
956+
#ifdef WACOM_KZALLOC_OBJ
957+
data = kzalloc_obj(struct wacom_hdev_data);
958+
#else
931959
data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL);
960+
#endif
932961
if (!data) {
933962
mutex_unlock(&wacom_udev_list_lock);
934963
return -ENOMEM;
@@ -2487,16 +2516,16 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
24872516

24882517
error = wacom_register_inputs(wacom);
24892518
if (error)
2490-
goto fail;
2519+
goto fail_hw_stop;
24912520

24922521
if (wacom->wacom_wac.features.device_type & WACOM_DEVICETYPE_PAD) {
24932522
error = wacom_initialize_leds(wacom);
24942523
if (error)
2495-
goto fail;
2524+
goto fail_hw_stop;
24962525

24972526
error = wacom_initialize_remotes(wacom);
24982527
if (error)
2499-
goto fail;
2528+
goto fail_hw_stop;
25002529
}
25012530

25022531
if (!wireless) {
@@ -2510,14 +2539,14 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
25102539
cancel_delayed_work_sync(&wacom->init_work);
25112540
_wacom_query_tablet_data(wacom);
25122541
error = -ENODEV;
2513-
goto fail_quirks;
2542+
goto fail_hw_stop;
25142543
}
25152544

25162545
if (features->device_type & WACOM_DEVICETYPE_WL_MONITOR) {
25172546
error = hid_hw_open(hdev);
25182547
if (error) {
25192548
hid_err(hdev, "hw open failed\n");
2520-
goto fail_quirks;
2549+
goto fail_hw_stop;
25212550
}
25222551
}
25232552

@@ -2526,7 +2555,7 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
25262555

25272556
return 0;
25282557

2529-
fail_quirks:
2558+
fail_hw_stop:
25302559
hid_hw_stop(hdev);
25312560
fail:
25322561
wacom_release_resources(wacom);
@@ -2877,6 +2906,7 @@ static int wacom_probe(struct hid_device *hdev,
28772906
return -ENODEV;
28782907

28792908
wacom_wac->hid_data.inputmode = -1;
2909+
wacom_wac->hid_data.inputmode_field_index = -1;
28802910
wacom_wac->mode_report = -1;
28812911

28822912
if (wacom_is_using_usb_driver(hdev)) {

4.18/wacom_w8001.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,26 @@ static int w8001_command(struct w8001 *w8001, unsigned char command,
375375
return rc;
376376
}
377377

378+
#ifdef WACOM_SCOPED_GUARD
379+
static int w8001_open(struct input_dev *dev)
380+
{
381+
struct w8001 *w8001 = input_get_drvdata(dev);
382+
int err;
383+
384+
scoped_guard(mutex_intr, &w8001->mutex) {
385+
if (w8001->open_count == 0) {
386+
err = w8001_command(w8001, W8001_CMD_START, false);
387+
if (err)
388+
return err;
389+
}
390+
391+
w8001->open_count++;
392+
return 0;
393+
}
394+
395+
return -EINTR;
396+
}
397+
#else
378398
static int w8001_open(struct input_dev *dev)
379399
{
380400
struct w8001 *w8001 = input_get_drvdata(dev);
@@ -393,17 +413,23 @@ static int w8001_open(struct input_dev *dev)
393413
mutex_unlock(&w8001->mutex);
394414
return err;
395415
}
416+
#endif
396417

397418
static void w8001_close(struct input_dev *dev)
398419
{
399420
struct w8001 *w8001 = input_get_drvdata(dev);
400-
421+
#ifdef WACOM_GUARD
422+
guard(mutex)(&w8001->mutex);
423+
#else
401424
mutex_lock(&w8001->mutex);
425+
#endif
402426

403427
if (--w8001->open_count == 0)
404428
w8001_command(w8001, W8001_CMD_STOP, false);
405-
429+
#ifdef WACOM_GUARD
430+
#else
406431
mutex_unlock(&w8001->mutex);
432+
#endif
407433
}
408434

409435
static int w8001_detect(struct w8001 *w8001)
@@ -598,7 +624,11 @@ static int w8001_connect(struct serio *serio, struct serio_driver *drv)
598624
char basename[64] = "Wacom Serial";
599625
int err, err_pen, err_touch;
600626

627+
#ifdef WACOM_KZALLOC_OBJ
628+
w8001 = kzalloc_obj(*w8001);
629+
#else
601630
w8001 = kzalloc(sizeof(*w8001), GFP_KERNEL);
631+
#endif
602632
input_dev_pen = input_allocate_device();
603633
input_dev_touch = input_allocate_device();
604634
if (!w8001 || !input_dev_pen || !input_dev_touch) {

4.18/wacom_wac.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,8 +1208,11 @@ static int int_dist(int x1, int y1, int x2, int y2)
12081208
static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
12091209
unsigned char *data)
12101210
{
1211-
memcpy(wacom->data, data, 10);
1211+
u8 *saved_data = wacom->data;
1212+
1213+
wacom->data = data;
12121214
wacom_intuos_irq(wacom);
1215+
wacom->data = saved_data;
12131216

12141217
input_sync(wacom->pen_input);
12151218
if (wacom->pad_input)
@@ -1218,7 +1221,7 @@ static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
12181221

12191222
static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
12201223
{
1221-
u8 *data = kmemdup(wacom->data, len, GFP_KERNEL);
1224+
u8 *data = wacom->data;
12221225
int i = 1;
12231226
unsigned power_raw, battery_capacity, bat_charging, ps_connected;
12241227

@@ -1258,7 +1261,6 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
12581261
break;
12591262
}
12601263

1261-
kfree(data);
12621264
return 0;
12631265
}
12641266

4.18/wacom_wac.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ struct wacom_shared {
322322
struct hid_data {
323323
__s16 inputmode; /* InputMode HID feature, -1 if non-existent */
324324
__s16 inputmode_index; /* InputMode HID feature index in the report */
325+
__s16 inputmode_field_index; /* InputMode HID feature field index in the report */
325326
bool sense_state;
326327
bool inrange_state;
327328
bool eraser;

0 commit comments

Comments
 (0)