Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: vivaldi: convert to use dev_groups

There is no need for a driver to individually add/create device groups,
the driver core will do it automatically for you. Convert the
hid-vivaldi core driver to use the dev_groups pointer instead of
manually calling the driver core to create the group and have it be
cleaned up later on by the devm core.

Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Greg Kroah-Hartman and committed by
Jiri Kosina
9f4441fc 8d9420ca

+22 -19
+3 -1
drivers/hid/hid-google-hammer.c
··· 608 608 .probe = hammer_probe, 609 609 .remove = hammer_remove, 610 610 .feature_mapping = vivaldi_feature_mapping, 611 - .input_configured = vivaldi_input_configured, 612 611 .input_mapping = hammer_input_mapping, 613 612 .event = hammer_event, 613 + .driver = { 614 + .dev_groups = vivaldi_attribute_groups, 615 + }, 614 616 }; 615 617 616 618 static int __init hammer_init(void)
+15 -14
drivers/hid/hid-vivaldi-common.c
··· 116 116 NULL 117 117 }; 118 118 119 - static const struct attribute_group vivaldi_attribute_group = { 120 - .attrs = vivaldi_sysfs_attrs, 121 - }; 122 - 123 - /** 124 - * vivaldi_input_configured - Complete initialization of device using vivaldi map 125 - * @hdev: HID device to which vivaldi attributes should be attached 126 - * @hidinput: HID input device (unused) 127 - */ 128 - int vivaldi_input_configured(struct hid_device *hdev, 129 - struct hid_input *hidinput) 119 + static umode_t vivaldi_is_visible(struct kobject *kobj, struct attribute *attr, 120 + int n) 130 121 { 122 + struct hid_device *hdev = to_hid_device(kobj_to_dev(kobj)); 131 123 struct vivaldi_data *data = hid_get_drvdata(hdev); 132 124 133 125 if (!data->num_function_row_keys) 134 126 return 0; 135 - 136 - return devm_device_add_group(&hdev->dev, &vivaldi_attribute_group); 127 + return attr->mode; 137 128 } 138 - EXPORT_SYMBOL_GPL(vivaldi_input_configured); 129 + 130 + static const struct attribute_group vivaldi_attribute_group = { 131 + .attrs = vivaldi_sysfs_attrs, 132 + .is_visible = vivaldi_is_visible, 133 + }; 134 + 135 + const struct attribute_group *vivaldi_attribute_groups[] = { 136 + &vivaldi_attribute_group, 137 + NULL, 138 + }; 139 + EXPORT_SYMBOL_GPL(vivaldi_attribute_groups); 139 140 140 141 MODULE_LICENSE("GPL");
+1 -3
drivers/hid/hid-vivaldi-common.h
··· 4 4 5 5 struct hid_device; 6 6 struct hid_field; 7 - struct hid_input; 8 7 struct hid_usage; 9 8 10 9 void vivaldi_feature_mapping(struct hid_device *hdev, 11 10 struct hid_field *field, struct hid_usage *usage); 12 11 13 - int vivaldi_input_configured(struct hid_device *hdev, 14 - struct hid_input *hidinput); 12 + extern const struct attribute_group *vivaldi_attribute_groups[]; 15 13 16 14 #endif /* _HID_VIVALDI_COMMON_H */
+3 -1
drivers/hid/hid-vivaldi.c
··· 45 45 .id_table = vivaldi_table, 46 46 .probe = vivaldi_probe, 47 47 .feature_mapping = vivaldi_feature_mapping, 48 - .input_configured = vivaldi_input_configured, 48 + .driver = { 49 + .dev_groups = vivaldi_attribute_groups, 50 + }, 49 51 }; 50 52 51 53 module_hid_driver(hid_vivaldi);