Skip to content

Commit 4859d6f

Browse files
author
Jiri Kosina
committed
Merge branch 'for-6.17/pidff' into for-linus
- bunch of checkpatch fixes for hid-pidff (Tomasz Pakuła)
2 parents bfc7f7b + 703e55a commit 4859d6f

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

drivers/hid/hid-ids.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@
849849
#define USB_DEVICE_ID_PXN_V12 0x1212
850850
#define USB_DEVICE_ID_PXN_V12_LITE 0x1112
851851
#define USB_DEVICE_ID_PXN_V12_LITE_2 0x1211
852-
#define USB_DEVICE_LITE_STAR_GT987_FF 0x2141
852+
#define USB_DEVICE_ID_LITE_STAR_GT987 0x2141
853853

854854
#define USB_VENDOR_ID_LOGITECH 0x046d
855855
#define USB_DEVICE_ID_LOGITECH_Z_10_SPK 0x0a07

drivers/hid/hid-universal-pidff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ static int universal_pidff_probe(struct hid_device *hdev,
5757
const struct hid_device_id *id)
5858
{
5959
int i, error;
60+
6061
error = hid_parse(hdev);
6162
if (error) {
6263
hid_err(hdev, "HID parse failed\n");
@@ -91,8 +92,8 @@ static int universal_pidff_probe(struct hid_device *hdev,
9192

9293
/* Check if HID_PID support is enabled */
9394
int (*init_function)(struct hid_device *, u32);
94-
init_function = hid_pidff_init_with_quirks;
9595

96+
init_function = hid_pidff_init_with_quirks;
9697
if (!init_function) {
9798
hid_warn(hdev, "HID_PID support not enabled!\n");
9899
return 0;
@@ -177,7 +178,7 @@ static const struct hid_device_id universal_pidff_devices[] = {
177178
.driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY },
178179
{ HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_PXN_V12_LITE_2),
179180
.driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY },
180-
{ HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_LITE_STAR_GT987_FF),
181+
{ HID_USB_DEVICE(USB_VENDOR_ID_LITE_STAR, USB_DEVICE_ID_LITE_STAR_GT987),
181182
.driver_data = HID_PIDFF_QUIRK_PERIODIC_SINE_ONLY },
182183
{ HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_INVICTA) },
183184
{ HID_USB_DEVICE(USB_VENDOR_ID_ASETEK, USB_DEVICE_ID_ASETEK_FORTE) },

drivers/hid/usbhid/hid-pidff.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ struct pidff_device {
210210
*/
211211
static s32 pidff_clamp(s32 i, struct hid_field *field)
212212
{
213-
s32 clamped = clamp(i, field->logical_minimum, field->logical_maximum);
214-
pr_debug("clamped from %d to %d", i, clamped);
215-
return clamped;
213+
return (s32)clamp(i, field->logical_minimum, field->logical_maximum);
216214
}
217215

218216
/*
@@ -229,8 +227,10 @@ static int pidff_rescale(int i, int max, struct hid_field *field)
229227
*/
230228
static int pidff_rescale_signed(int i, struct hid_field *field)
231229
{
232-
if (i > 0) return i * field->logical_maximum / S16_MAX;
233-
if (i < 0) return i * field->logical_minimum / S16_MIN;
230+
if (i > 0)
231+
return i * field->logical_maximum / S16_MAX;
232+
if (i < 0)
233+
return i * field->logical_minimum / S16_MIN;
234234
return 0;
235235
}
236236

@@ -241,11 +241,11 @@ static u32 pidff_rescale_time(u16 time, struct hid_field *field)
241241
{
242242
u32 scaled_time = time;
243243
int exponent = field->unit_exponent;
244-
pr_debug("time field exponent: %d\n", exponent);
245244

246-
for (;exponent < FF_TIME_EXPONENT; exponent++)
245+
pr_debug("time field exponent: %d\n", exponent);
246+
for (; exponent < FF_TIME_EXPONENT; exponent++)
247247
scaled_time *= 10;
248-
for (;exponent > FF_TIME_EXPONENT; exponent--)
248+
for (; exponent > FF_TIME_EXPONENT; exponent--)
249249
scaled_time /= 10;
250250

251251
pr_debug("time calculated from %d to %d\n", time, scaled_time);
@@ -275,8 +275,8 @@ static void pidff_set_signed(struct pidff_usage *usage, s16 value)
275275

276276
static void pidff_set_time(struct pidff_usage *usage, u16 time)
277277
{
278-
u32 modified_time = pidff_rescale_time(time, usage->field);
279-
usage->value[0] = pidff_clamp(modified_time, usage->field);
278+
usage->value[0] = pidff_clamp(
279+
pidff_rescale_time(time, usage->field), usage->field);
280280
}
281281

282282
static void pidff_set_duration(struct pidff_usage *usage, u16 duration)
@@ -332,6 +332,7 @@ static int pidff_needs_set_envelope(struct ff_envelope *envelope,
332332
struct ff_envelope *old)
333333
{
334334
bool needs_new_envelope;
335+
335336
needs_new_envelope = envelope->attack_level != 0 ||
336337
envelope->fade_level != 0 ||
337338
envelope->attack_length != 0 ||
@@ -568,7 +569,7 @@ static void pidff_set_device_control(struct pidff_device *pidff, int field)
568569
hid_dbg(pidff->hid, "DEVICE_CONTROL is a bitmask\n");
569570

570571
/* Clear current bitmask */
571-
for(i = 0; i < sizeof(pidff_device_control); i++) {
572+
for (i = 0; i < sizeof(pidff_device_control); i++) {
572573
index = pidff->control_id[i];
573574
if (index < 1)
574575
continue;
@@ -619,7 +620,7 @@ static void pidff_fetch_pool(struct pidff_device *pidff)
619620
struct hid_device *hid = pidff->hid;
620621

621622
/* Repeat if PID_SIMULTANEOUS_MAX < 2 to make sure it's correct */
622-
for(i = 0; i < 20; i++) {
623+
for (i = 0; i < 20; i++) {
623624
hid_hw_request(hid, pidff->reports[PID_POOL], HID_REQ_GET_REPORT);
624625
hid_hw_wait(hid);
625626

@@ -715,6 +716,7 @@ static void pidff_playback_pid(struct pidff_device *pidff, int pid_id, int n)
715716
static int pidff_playback(struct input_dev *dev, int effect_id, int value)
716717
{
717718
struct pidff_device *pidff = dev->ff->private;
719+
718720
pidff_playback_pid(pidff, pidff->pid_id[effect_id], value);
719721
return 0;
720722
}
@@ -849,7 +851,7 @@ static int pidff_upload_effect(struct input_dev *dev, struct ff_effect *effect,
849851
case FF_INERTIA:
850852
case FF_FRICTION:
851853
if (!old) {
852-
switch(effect->type) {
854+
switch (effect->type) {
853855
case FF_SPRING:
854856
type_id = PID_SPRING;
855857
break;
@@ -940,7 +942,7 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
940942
struct hid_report *report, int count, int strict)
941943
{
942944
if (!report) {
943-
pr_debug("pidff_find_fields, null report\n");
945+
pr_debug("%s, null report\n", __func__);
944946
return -1;
945947
}
946948

@@ -974,13 +976,11 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
974976
pr_debug("Delay field not found, but that's OK\n");
975977
pr_debug("Setting MISSING_DELAY quirk\n");
976978
return_value |= HID_PIDFF_QUIRK_MISSING_DELAY;
977-
}
978-
else if (!found && table[k] == pidff_set_condition[PID_PARAM_BLOCK_OFFSET]) {
979+
} else if (!found && table[k] == pidff_set_condition[PID_PARAM_BLOCK_OFFSET]) {
979980
pr_debug("PBO field not found, but that's OK\n");
980981
pr_debug("Setting MISSING_PBO quirk\n");
981982
return_value |= HID_PIDFF_QUIRK_MISSING_PBO;
982-
}
983-
else if (!found && strict) {
983+
} else if (!found && strict) {
984984
pr_debug("failed to locate %d\n", k);
985985
return -1;
986986
}
@@ -1069,7 +1069,7 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report,
10691069
int usage, int enforce_min)
10701070
{
10711071
if (!report) {
1072-
pr_debug("pidff_find_special_field, null report\n");
1072+
pr_debug("%s, null report\n", __func__);
10731073
return NULL;
10741074
}
10751075

@@ -1081,10 +1081,9 @@ static struct hid_field *pidff_find_special_field(struct hid_report *report,
10811081
if (!enforce_min ||
10821082
report->field[i]->logical_minimum == 1)
10831083
return report->field[i];
1084-
else {
1085-
pr_err("logical_minimum is not 1 as it should be\n");
1086-
return NULL;
1087-
}
1084+
1085+
pr_err("logical_minimum is not 1 as it should be\n");
1086+
return NULL;
10881087
}
10891088
}
10901089
return NULL;
@@ -1207,6 +1206,7 @@ static int pidff_find_effects(struct pidff_device *pidff,
12071206

12081207
for (i = 0; i < sizeof(pidff_effect_types); i++) {
12091208
int pidff_type = pidff->type_id[i];
1209+
12101210
if (pidff->set_effect_type->usage[pidff_type].hid !=
12111211
pidff->create_new_effect_type->usage[pidff_type].hid) {
12121212
hid_err(pidff->hid,

drivers/hid/usbhid/hid-pidff.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
/* Delay field (0xA7) missing. Skip it during set effect report upload */
1010
#define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0)
1111

12-
/* Missing Paramter block offset (0x23). Skip it during SET_CONDITION
13-
report upload */
12+
/* Missing Paramter block offset (0x23). Skip it during SET_CONDITION upload */
1413
#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1)
1514

1615
/* Initialise device control field even if logical_minimum != 1 */

0 commit comments

Comments
 (0)