mirror of
https://github.com/torvalds/linux.git
synced 2026-06-01 02:53:36 +02:00
HID: pidff: Refactor field quirks detection
In preparation for additional quirks Co-developed-by: Oleg Makarenko <oleg@makarenk.ooo> Signed-off-by: Oleg Makarenko <oleg@makarenk.ooo> Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
parent
f50822fd86
commit
446e303982
|
|
@ -13,6 +13,7 @@
|
|||
#include <linux/input.h>
|
||||
#include <linux/minmax.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/stringify.h>
|
||||
#include <linux/usb.h>
|
||||
|
||||
#define PID_EFFECTS_MAX 64
|
||||
|
|
@ -1053,6 +1054,11 @@ static int pidff_find_field_with_usage(int *usage_index,
|
|||
return -1;
|
||||
}
|
||||
|
||||
#define PIDFF_MISSING_FIELD(name, quirks) \
|
||||
({ pr_debug("%s field not found, but that's OK\n", __stringify(name)); \
|
||||
pr_debug("Setting MISSING_%s quirk\n", __stringify(name)); \
|
||||
*quirks |= HID_PIDFF_QUIRK_MISSING_ ## name; })
|
||||
|
||||
/*
|
||||
* Find fields from a report and fill a pidff_usage
|
||||
*/
|
||||
|
|
@ -1060,9 +1066,6 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
|
|||
struct hid_report *report, int count, int strict,
|
||||
u32 *quirks)
|
||||
{
|
||||
const u8 block_offset = pidff_set_condition[PID_PARAM_BLOCK_OFFSET];
|
||||
const u8 delay = pidff_set_effect[PID_START_DELAY];
|
||||
|
||||
if (!report) {
|
||||
pr_debug("%s, null report\n", __func__);
|
||||
return -1;
|
||||
|
|
@ -1080,17 +1083,14 @@ static int pidff_find_fields(struct pidff_usage *usage, const u8 *table,
|
|||
continue;
|
||||
}
|
||||
|
||||
if (table[i] == delay) {
|
||||
pr_debug("Delay field not found, but that's OK\n");
|
||||
pr_debug("Setting MISSING_DELAY quirk\n");
|
||||
*quirks |= HID_PIDFF_QUIRK_MISSING_DELAY;
|
||||
/* Field quirks auto-detection */
|
||||
if (table[i] == pidff_set_effect[PID_START_DELAY])
|
||||
PIDFF_MISSING_FIELD(DELAY, quirks);
|
||||
|
||||
} else if (table[i] == block_offset) {
|
||||
pr_debug("PBO field not found, but that's OK\n");
|
||||
pr_debug("Setting MISSING_PBO quirk\n");
|
||||
*quirks |= HID_PIDFF_QUIRK_MISSING_PBO;
|
||||
else if (table[i] == pidff_set_condition[PID_PARAM_BLOCK_OFFSET])
|
||||
PIDFF_MISSING_FIELD(PBO, quirks);
|
||||
|
||||
} else if (strict) {
|
||||
else if (strict) {
|
||||
pr_debug("failed to locate %d\n", i);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user