Skip to content

Commit 725bf3d

Browse files
t-8chJiri Kosina
authored andcommitted
HID: core: use utility macros to define sysfs attributes
Save some lines of code and prepare for the constification of 'struct bin_attribute'. Also align the definitions within the source file. Signed-off-by: Thomas Weißschuh <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 2a770b4 commit 725bf3d

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

drivers/hid/hid-core.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,9 +2174,9 @@ static bool hid_hiddev(struct hid_device *hdev)
21742174

21752175

21762176
static ssize_t
2177-
read_report_descriptor(struct file *filp, struct kobject *kobj,
2178-
struct bin_attribute *attr,
2179-
char *buf, loff_t off, size_t count)
2177+
report_descriptor_read(struct file *filp, struct kobject *kobj,
2178+
struct bin_attribute *attr,
2179+
char *buf, loff_t off, size_t count)
21802180
{
21812181
struct device *dev = kobj_to_dev(kobj);
21822182
struct hid_device *hdev = to_hid_device(dev);
@@ -2193,24 +2193,17 @@ read_report_descriptor(struct file *filp, struct kobject *kobj,
21932193
}
21942194

21952195
static ssize_t
2196-
show_country(struct device *dev, struct device_attribute *attr,
2197-
char *buf)
2196+
country_show(struct device *dev, struct device_attribute *attr,
2197+
char *buf)
21982198
{
21992199
struct hid_device *hdev = to_hid_device(dev);
22002200

22012201
return sprintf(buf, "%02x\n", hdev->country & 0xff);
22022202
}
22032203

2204-
static struct bin_attribute dev_bin_attr_report_desc = {
2205-
.attr = { .name = "report_descriptor", .mode = 0444 },
2206-
.read = read_report_descriptor,
2207-
.size = HID_MAX_DESCRIPTOR_SIZE,
2208-
};
2204+
static BIN_ATTR_RO(report_descriptor, HID_MAX_DESCRIPTOR_SIZE);
22092205

2210-
static const struct device_attribute dev_attr_country = {
2211-
.attr = { .name = "country", .mode = 0444 },
2212-
.show = show_country,
2213-
};
2206+
static const DEVICE_ATTR_RO(country);
22142207

22152208
int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
22162209
{
@@ -2801,7 +2794,7 @@ static struct attribute *hid_dev_attrs[] = {
28012794
NULL,
28022795
};
28032796
static struct bin_attribute *hid_dev_bin_attrs[] = {
2804-
&dev_bin_attr_report_desc,
2797+
&bin_attr_report_descriptor,
28052798
NULL
28062799
};
28072800
static const struct attribute_group hid_dev_group = {

0 commit comments

Comments
 (0)