From 9256c4bed64fe29198a922ac2d94cdf27506d47b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:14 +0200 Subject: [PATCH 01/11] HID: universal-pidff: Fix missing blank lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes errors from checkpatch script Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/hid-universal-pidff.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/hid/hid-universal-pidff.c b/drivers/hid/hid-universal-pidff.c index 001a0f5efb9d..dad6c5a6e2df 100644 --- a/drivers/hid/hid-universal-pidff.c +++ b/drivers/hid/hid-universal-pidff.c @@ -57,6 +57,7 @@ static int universal_pidff_probe(struct hid_device *hdev, const struct hid_device_id *id) { int i, error; + error = hid_parse(hdev); if (error) { hid_err(hdev, "HID parse failed\n"); @@ -91,8 +92,8 @@ static int universal_pidff_probe(struct hid_device *hdev, /* Check if HID_PID support is enabled */ int (*init_function)(struct hid_device *, u32); - init_function = hid_pidff_init_with_quirks; + init_function = hid_pidff_init_with_quirks; if (!init_function) { hid_warn(hdev, "HID_PID support not enabled!\n"); return 0; From b913c5c2b4f9f57913f25b439361c4ff2d7a27ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:15 +0200 Subject: [PATCH 02/11] HID: hid-ids.h: Fix LITE_STAR_GT987 device id define MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The name was missing "ID" part Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/hid-ids.h | 2 +- drivers/hid/hid-universal-pidff.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index e3fb4e2fe911..55734db1fb9c 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -842,7 +842,7 @@ #define USB_DEVICE_ID_PXN_V12 0x1212 #define USB_DEVICE_ID_PXN_V12_LITE 0x1112 #define USB_DEVICE_ID_PXN_V12_LITE_2 0x1211 -#define USB_DEVICE_LITE_STAR_GT987_FF 0x2141 +#define USB_DEVICE_ID_LITE_STAR_GT987 0x2141 #define USB_VENDOR_ID_LOGITECH 0x046d #define USB_DEVICE_ID_LOGITECH_Z_10_SPK 0x0a07 diff --git a/drivers/hid/hid-universal-pidff.c b/drivers/hid/hid-universal-pidff.c index dad6c5a6e2df..554a6559aeb7 100644 --- a/drivers/hid/hid-universal-pidff.c +++ b/drivers/hid/hid-universal-pidff.c @@ -178,7 +178,7 @@ static const struct hid_device_id universal_pidff_devices[] = { .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V12_LITE_2), .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, - { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_LITE_STAR_GT987_FF), + { HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_LITE_STAR_GT987), .driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY }, { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_INVICTA) }, { HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_FORTE) }, From 18243efd7134ff461a4b1a795fbdef1d9b336b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:16 +0200 Subject: [PATCH 03/11] HID: hid-pidff.h: Fix comment styling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warnings Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.h b/drivers/hid/usbhid/hid-pidff.h index dda571e0a5bd..a53a8b436baa 100644 --- a/drivers/hid/usbhid/hid-pidff.h +++ b/drivers/hid/usbhid/hid-pidff.h @@ -9,8 +9,7 @@ /* Delay field (0xA7) missing. Skip it during set effect report upload */ #define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0) -/* Missing Paramter block offset (0x23). Skip it during SET_CONDITION - report upload */ +/* Missing Paramter block offset (0x23). Skip it during SET_CONDITION upload */ #define HID_PIDFF_QUIRK_MISSING_PBO BIT(1) /* Initialise device control field even if logical_minimum != 1 */ From 42a2bd61650f13605f9283b5a9e6b1a26b7d4ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:17 +0200 Subject: [PATCH 04/11] HID: pidff: Fix missing blank lines after declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes chackpatch.pl warnings Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 8dfd2c554a27..3c2b20cf7853 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -241,8 +241,8 @@ static u32 pidff_rescale_time(u16 time, struct hid_field *field) { u32 scaled_time = time; int exponent = field->unit_exponent; - pr_debug("time field exponent: %d\n", exponent); + pr_debug("time field exponent: %d\n", exponent); for (;exponent < FF_TIME_EXPONENT; exponent++) scaled_time *= 10; for (;exponent > FF_TIME_EXPONENT; exponent--) @@ -332,6 +332,7 @@ static int pidff_needs_set_envelope(struct ff_envelope *envelope, struct ff_envelope *old) { bool needs_new_envelope; + needs_new_envelope = envelope->attack_level != 0 || envelope->fade_level != 0 || envelope->attack_length != 0 || @@ -715,6 +716,7 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n) static int pidff_playback(struct input_dev *dev, int effect_id, int value) { struct pidff_device *pidff = dev->ff->private; + pidff_playback_pid(pidff, pidff->pid_id[effect_id], value); return 0; } @@ -1207,6 +1209,7 @@ static int pidff_find_effects(struct pidff_device *pidff, for (i = 0; i < sizeof(pidff_effect_types); i++) { int pidff_type = pidff->type_id[i]; + if (pidff->set_effect_type->usage[pidff_type].hid != pidff->create_new_effect_type->usage[pidff_type].hid) { hid_err(pidff->hid, From a0ea54654dd7b53df85d81f5201a78f842ea713f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:18 +0200 Subject: [PATCH 05/11] HID: pidff: Remove unneeded debug from pidff_clamp() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes chechpatch.pl warning about missing blank line Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 3c2b20cf7853..44cbd2a0461a 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -210,9 +210,7 @@ struct pidff_device { */ static s32 pidff_clamp(s32 i, struct hid_field *field) { - s32 clamped = clamp(i, field->logical_minimum, field->logical_maximum); - pr_debug("clamped from %d to %d", i, clamped); - return clamped; + return (s32)clamp(i, field->logical_minimum, field->logical_maximum); } /* From bed72bd240ce77623845853397b89a08f6dc5770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:19 +0200 Subject: [PATCH 06/11] HID: pidff: Rework pidff_set_time() to fix warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes blank line warning from checkpatch.pl script Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 44cbd2a0461a..743b76c8d3b2 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -273,8 +273,8 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value) static void pidff_set_time(struct pidff_usage *usage, u16 time) { - u32 modified_time = pidff_rescale_time(time, usage->field); - usage->value[0] = pidff_clamp(modified_time, usage->field); + usage->value[0] = pidff_clamp( + pidff_rescale_time(time, usage->field), usage->field); } static void pidff_set_duration(struct pidff_usage *usage, u16 duration) From 3ab6f57dbebb007c177168be0011238fe8fddcee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:20 +0200 Subject: [PATCH 07/11] HID: pidff: Use __func__ in debugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warnings Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 743b76c8d3b2..88eb832265a4 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -940,7 +940,7 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table, struct hid_report *report, int count, int strict) { if (!report) { - pr_debug("pidff_find_fields, null report\n"); + pr_debug("%s, null report\n", __func__); return -1; } @@ -1069,7 +1069,7 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report, int usage, int enforce_min) { if (!report) { - pr_debug("pidff_find_special_field, null report\n"); + pr_debug("%s, null report\n", __func__); return NULL; } From 9c2f3ecd37ddcd714e4a476a5469d9b6663992ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:21 +0200 Subject: [PATCH 08/11] HID: pidff: Remove unneeded else in pidff_find_special_field() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 88eb832265a4..6f25490ce464 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -1081,10 +1081,9 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report, if (!enforce_min || report->field[i]->logical_minimum == 1) return report->field[i]; - else { - pr_err("logical_minimum is not 1 as it should be\n"); - return NULL; - } + + pr_err("logical_minimum is not 1 as it should be\n"); + return NULL; } } return NULL; From 3f7fd8cb8f408095ff97276d4e30ff87c112018e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:22 +0200 Subject: [PATCH 09/11] HID: pidff: Move trailing statements in pidff_rescale_signed() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds newline before trailing if statements. Fixes checkpatch.pl errors Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 6f25490ce464..0e19d61f4936 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -227,8 +227,10 @@ static int pidff_rescale(int i, int max, struct hid_field *field) */ static int pidff_rescale_signed(int i, struct hid_field *field) { - if (i > 0) return i * field->logical_maximum / S16_MAX; - if (i < 0) return i * field->logical_minimum / S16_MIN; + if (i > 0) + return i * field->logical_maximum / S16_MAX; + if (i < 0) + return i * field->logical_minimum / S16_MIN; return 0; } From 61ea33ded9327a07d9ef85a6933cb6316e2f185f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:23 +0200 Subject: [PATCH 10/11] HID: pidff: Add missing spaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl errors Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index 0e19d61f4936..a07c5efddbe4 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -243,9 +243,9 @@ static u32 pidff_rescale_time(u16 time, struct hid_field *field) int exponent = field->unit_exponent; pr_debug("time field exponent: %d\n", exponent); - for (;exponent < FF_TIME_EXPONENT; exponent++) + for (; exponent < FF_TIME_EXPONENT; exponent++) scaled_time *= 10; - for (;exponent > FF_TIME_EXPONENT; exponent--) + for (; exponent > FF_TIME_EXPONENT; exponent--) scaled_time /= 10; pr_debug("time calculated from %d to %d\n", time, scaled_time); @@ -569,7 +569,7 @@ static void pidff_set_device_control(struct pidff_device *pidff, int field) hid_dbg(pidff->hid, "DEVICE_CONTROL is a bitmask\n"); /* Clear current bitmask */ - for(i = 0; i < sizeof(pidff_device_control); i++) { + for (i = 0; i < sizeof(pidff_device_control); i++) { index = pidff->control_id[i]; if (index < 1) continue; @@ -620,7 +620,7 @@ static void pidff_fetch_pool(struct pidff_device *pidff) struct hid_device *hid = pidff->hid; /* Repeat if PID_SIMULTANEOUS_MAX < 2 to make sure it's correct */ - for(i = 0; i < 20; i++) { + for (i = 0; i < 20; i++) { hid_hw_request(hid, pidff->reports[PID_POOL], HID_REQ_GET_REPORT); hid_hw_wait(hid); @@ -851,7 +851,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect, case FF_INERTIA: case FF_FRICTION: if (!old) { - switch(effect->type) { + switch (effect->type) { case FF_SPRING: type_id = PID_SPRING; break; From 703e55aacbf73da570cc276e69ec6cbe16198376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Paku=C5=82a?= Date: Sat, 24 May 2025 19:47:24 +0200 Subject: [PATCH 11/11] HID: pidff: Move else if statements to follow closing braces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl errors Signed-off-by: Tomasz Pakuła Signed-off-by: Jiri Kosina --- drivers/hid/usbhid/hid-pidff.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c index a07c5efddbe4..614a20b62023 100644 --- a/drivers/hid/usbhid/hid-pidff.c +++ b/drivers/hid/usbhid/hid-pidff.c @@ -976,13 +976,11 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table, pr_debug("Delay field not found, but that's OK\n"); pr_debug("Setting MISSING_DELAY quirk\n"); return_value |= HID_PIDFF_QUIRK_MISSING_DELAY; - } - else if (!found && table[k] == pidff_set_condition[PID_PARAM_BLOCK_OFFSET]) { + } else if (!found && table[k] == pidff_set_condition[PID_PARAM_BLOCK_OFFSET]) { pr_debug("PBO field not found, but that's OK\n"); pr_debug("Setting MISSING_PBO quirk\n"); return_value |= HID_PIDFF_QUIRK_MISSING_PBO; - } - else if (!found && strict) { + } else if (!found && strict) { pr_debug("failed to locate %d\n", k); return -1; }