Merge branch 'for-6.3/hid-core' into for-linus
[platform/kernel/linux-starfive.git] / drivers / hid / hid-core.c
index 7e7ae20..53e4d58 100644 (file)
@@ -989,8 +989,8 @@ struct hid_report *hid_validate_values(struct hid_device *hid,
                 * Validating on id 0 means we should examine the first
                 * report in the list.
                 */
-               report = list_entry(
-                               hid->report_enum[type].report_list.next,
+               report = list_first_entry_or_null(
+                               &hid->report_enum[type].report_list,
                                struct hid_report, list);
        } else {
                report = hid->report_enum[type].report_id_hash[id];
@@ -1198,6 +1198,7 @@ int hid_open_report(struct hid_device *device)
        __u8 *end;
        __u8 *next;
        int ret;
+       int i;
        static int (*dispatch_type[])(struct hid_parser *parser,
                                      struct hid_item *item) = {
                hid_parser_main,
@@ -1248,6 +1249,8 @@ int hid_open_report(struct hid_device *device)
                goto err;
        }
        device->collection_size = HID_DEFAULT_NUM_COLLECTIONS;
+       for (i = 0; i < HID_DEFAULT_NUM_COLLECTIONS; i++)
+               device->collection[i].parent_idx = -1;
 
        ret = -EINVAL;
        while ((next = fetch_item(start, end, &item)) != NULL) {