Commit 9f4441fc authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Jiri Kosina

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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 8d9420ca
...@@ -608,9 +608,11 @@ static struct hid_driver hammer_driver = { ...@@ -608,9 +608,11 @@ static struct hid_driver hammer_driver = {
.probe = hammer_probe, .probe = hammer_probe,
.remove = hammer_remove, .remove = hammer_remove,
.feature_mapping = vivaldi_feature_mapping, .feature_mapping = vivaldi_feature_mapping,
.input_configured = vivaldi_input_configured,
.input_mapping = hammer_input_mapping, .input_mapping = hammer_input_mapping,
.event = hammer_event, .event = hammer_event,
.driver = {
.dev_groups = vivaldi_attribute_groups,
},
}; };
static int __init hammer_init(void) static int __init hammer_init(void)
......
...@@ -116,25 +116,26 @@ static struct attribute *vivaldi_sysfs_attrs[] = { ...@@ -116,25 +116,26 @@ static struct attribute *vivaldi_sysfs_attrs[] = {
NULL NULL
}; };
static const struct attribute_group vivaldi_attribute_group = { static umode_t vivaldi_is_visible(struct kobject *kobj, struct attribute *attr,
.attrs = vivaldi_sysfs_attrs, int n)
};
/**
* vivaldi_input_configured - Complete initialization of device using vivaldi map
* @hdev: HID device to which vivaldi attributes should be attached
* @hidinput: HID input device (unused)
*/
int vivaldi_input_configured(struct hid_device *hdev,
struct hid_input *hidinput)
{ {
struct hid_device *hdev = to_hid_device(kobj_to_dev(kobj));
struct vivaldi_data *data = hid_get_drvdata(hdev); struct vivaldi_data *data = hid_get_drvdata(hdev);
if (!data->num_function_row_keys) if (!data->num_function_row_keys)
return 0; return 0;
return attr->mode;
return devm_device_add_group(&hdev->dev, &vivaldi_attribute_group);
} }
EXPORT_SYMBOL_GPL(vivaldi_input_configured);
static const struct attribute_group vivaldi_attribute_group = {
.attrs = vivaldi_sysfs_attrs,
.is_visible = vivaldi_is_visible,
};
const struct attribute_group *vivaldi_attribute_groups[] = {
&vivaldi_attribute_group,
NULL,
};
EXPORT_SYMBOL_GPL(vivaldi_attribute_groups);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -4,13 +4,11 @@ ...@@ -4,13 +4,11 @@
struct hid_device; struct hid_device;
struct hid_field; struct hid_field;
struct hid_input;
struct hid_usage; struct hid_usage;
void vivaldi_feature_mapping(struct hid_device *hdev, void vivaldi_feature_mapping(struct hid_device *hdev,
struct hid_field *field, struct hid_usage *usage); struct hid_field *field, struct hid_usage *usage);
int vivaldi_input_configured(struct hid_device *hdev, extern const struct attribute_group *vivaldi_attribute_groups[];
struct hid_input *hidinput);
#endif /* _HID_VIVALDI_COMMON_H */ #endif /* _HID_VIVALDI_COMMON_H */
...@@ -45,7 +45,9 @@ static struct hid_driver hid_vivaldi = { ...@@ -45,7 +45,9 @@ static struct hid_driver hid_vivaldi = {
.id_table = vivaldi_table, .id_table = vivaldi_table,
.probe = vivaldi_probe, .probe = vivaldi_probe,
.feature_mapping = vivaldi_feature_mapping, .feature_mapping = vivaldi_feature_mapping,
.input_configured = vivaldi_input_configured, .driver = {
.dev_groups = vivaldi_attribute_groups,
},
}; };
module_hid_driver(hid_vivaldi); module_hid_driver(hid_vivaldi);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment