Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/hid/hid

Pull HID fixes from Jiri Kosina:

 - descriptor parsing regression fix for devices that have more than 16
   collections, from Peter Hutterer (and followup cleanup from Philipp
   Zabel)

 - quirk for Goodix touchpad

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid:
  HID: core: simplify active collection tracking
  HID: i2c-hid: Disable runtime PM on Goodix touchpad
  HID: core: replace the collection tree pointers with indices
  • Loading branch information
Linus Torvalds committed Jan 22, 2019
2 parents 48b1619 + 1950f46 commit 787a3b4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
23 changes: 12 additions & 11 deletions drivers/hid/hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ static int open_collection(struct hid_parser *parser, unsigned type)
{
struct hid_collection *collection;
unsigned usage;
int collection_index;

usage = parser->local.usage[0];

Expand Down Expand Up @@ -167,13 +168,13 @@ static int open_collection(struct hid_parser *parser, unsigned type)
parser->collection_stack[parser->collection_stack_ptr++] =
parser->device->maxcollection;

collection = parser->device->collection +
parser->device->maxcollection++;
collection_index = parser->device->maxcollection++;
collection = parser->device->collection + collection_index;
collection->type = type;
collection->usage = usage;
collection->level = parser->collection_stack_ptr - 1;
collection->parent = parser->active_collection;
parser->active_collection = collection;
collection->parent_idx = (collection->level == 0) ? -1 :
parser->collection_stack[collection->level - 1];

if (type == HID_COLLECTION_APPLICATION)
parser->device->maxapplication++;
Expand All @@ -192,8 +193,6 @@ static int close_collection(struct hid_parser *parser)
return -EINVAL;
}
parser->collection_stack_ptr--;
if (parser->active_collection)
parser->active_collection = parser->active_collection->parent;
return 0;
}

Expand Down Expand Up @@ -1006,10 +1005,12 @@ static void hid_apply_multiplier_to_field(struct hid_device *hid,
usage = &field->usage[i];

collection = &hid->collection[usage->collection_index];
while (collection && collection != multiplier_collection)
collection = collection->parent;
while (collection->parent_idx != -1 &&
collection != multiplier_collection)
collection = &hid->collection[collection->parent_idx];

if (collection || multiplier_collection == NULL)
if (collection->parent_idx != -1 ||
multiplier_collection == NULL)
usage->resolution_multiplier = effective_multiplier;

}
Expand Down Expand Up @@ -1044,9 +1045,9 @@ static void hid_apply_multiplier(struct hid_device *hid,
* applicable fields later.
*/
multiplier_collection = &hid->collection[multiplier->usage->collection_index];
while (multiplier_collection &&
while (multiplier_collection->parent_idx != -1 &&
multiplier_collection->type != HID_COLLECTION_LOGICAL)
multiplier_collection = multiplier_collection->parent;
multiplier_collection = &hid->collection[multiplier_collection->parent_idx];

effective_multiplier = hid_calculate_multiplier(hid, multiplier);

Expand Down
3 changes: 3 additions & 0 deletions drivers/hid/hid-ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@
#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_010A 0x010a
#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PIT_E100 0xe100

#define I2C_VENDOR_ID_GOODIX 0x27c6
#define I2C_DEVICE_ID_GOODIX_01F0 0x01f0

#define USB_VENDOR_ID_GOODTOUCH 0x1aad
#define USB_DEVICE_ID_GOODTOUCH_000f 0x000f

Expand Down
2 changes: 2 additions & 0 deletions drivers/hid/i2c-hid/i2c-hid-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ static const struct i2c_hid_quirks {
I2C_HID_QUIRK_DELAY_AFTER_SLEEP },
{ USB_VENDOR_ID_LG, I2C_DEVICE_ID_LG_8001,
I2C_HID_QUIRK_NO_RUNTIME_PM },
{ I2C_VENDOR_ID_GOODIX, I2C_DEVICE_ID_GOODIX_01F0,
I2C_HID_QUIRK_NO_RUNTIME_PM },
{ 0, 0 }
};

Expand Down
3 changes: 1 addition & 2 deletions include/linux/hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ struct hid_local {
*/

struct hid_collection {
struct hid_collection *parent;
int parent_idx; /* device->collection */
unsigned type;
unsigned usage;
unsigned level;
Expand Down Expand Up @@ -658,7 +658,6 @@ struct hid_parser {
unsigned int *collection_stack;
unsigned int collection_stack_ptr;
unsigned int collection_stack_size;
struct hid_collection *active_collection;
struct hid_device *device;
unsigned int scan_flags;
};
Expand Down

0 comments on commit 787a3b4

Please sign in to comment.