aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi
diff options
context:
space:
mode:
authorGreg KH <gregkh@linuxfoundation.org>2013-08-20 20:11:49 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-08-21 13:52:25 -0400
commit65f44679580de05d267f026ed8164539ec5c7a88 (patch)
tree20b01d30397e27fbcf15f0d21e252b88d5149bf0 /drivers/acpi
parenta749245168ccda07b4200a8d55e2042679b7ecd4 (diff)
ACPI: bgrt: take advantage of binary sysfs groups
Attribute groups now can handle binary sysfs attributes, so clean up the code here by using a binary attribute array. This saves us the extra call to create the binary attribute at saves 6 lines overall. Cc: Len Brown <lenb@kernel.org> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -- I can take this in my driver-core tree if someone from ACPI acks it, otherwise, feel free to take it through the ACPI trees instead, just let me know. drivers/acpi/bgrt.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
Diffstat (limited to 'drivers/acpi')
-rw-r--r--drivers/acpi/bgrt.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
index be6039958545..7a4128d96117 100644
--- a/drivers/acpi/bgrt.c
+++ b/drivers/acpi/bgrt.c
@@ -51,20 +51,14 @@ static ssize_t show_yoffset(struct device *dev,
51} 51}
52static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL); 52static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL);
53 53
54static ssize_t show_image(struct file *file, struct kobject *kobj, 54static ssize_t image_read(struct file *file, struct kobject *kobj,
55 struct bin_attribute *attr, char *buf, loff_t off, size_t count) 55 struct bin_attribute *attr, char *buf, loff_t off, size_t count)
56{ 56{
57 memcpy(buf, attr->private + off, count); 57 memcpy(buf, attr->private + off, count);
58 return count; 58 return count;
59} 59}
60 60
61static struct bin_attribute image_attr = { 61static BIN_ATTR_RO(image, 0); /* size gets filled in later */
62 .attr = {
63 .name = "image",
64 .mode = S_IRUGO,
65 },
66 .read = show_image,
67};
68 62
69static struct attribute *bgrt_attributes[] = { 63static struct attribute *bgrt_attributes[] = {
70 &dev_attr_version.attr, 64 &dev_attr_version.attr,
@@ -75,8 +69,14 @@ static struct attribute *bgrt_attributes[] = {
75 NULL, 69 NULL,
76}; 70};
77 71
72static struct bin_attribute *bgrt_bin_attributes[] = {
73 &bin_attr_image,
74 NULL,
75};
76
78static struct attribute_group bgrt_attribute_group = { 77static struct attribute_group bgrt_attribute_group = {
79 .attrs = bgrt_attributes, 78 .attrs = bgrt_attributes,
79 .bin_attrs = bgrt_bin_attributes,
80}; 80};
81 81
82static int __init bgrt_init(void) 82static int __init bgrt_init(void)
@@ -87,8 +87,8 @@ static int __init bgrt_init(void)
87 return -ENODEV; 87 return -ENODEV;
88 88
89 sysfs_bin_attr_init(&image_attr); 89 sysfs_bin_attr_init(&image_attr);
90 image_attr.private = bgrt_image; 90 bin_attr_image.private = bgrt_image;
91 image_attr.size = bgrt_image_size; 91 bin_attr_image.size = bgrt_image_size;
92 92
93 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj); 93 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
94 if (!bgrt_kobj) 94 if (!bgrt_kobj)
@@ -98,14 +98,8 @@ static int __init bgrt_init(void)
98 if (ret) 98 if (ret)
99 goto out_kobject; 99 goto out_kobject;
100 100
101 ret = sysfs_create_bin_file(bgrt_kobj, &image_attr);
102 if (ret)
103 goto out_group;
104
105 return 0; 101 return 0;
106 102
107out_group:
108 sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group);
109out_kobject: 103out_kobject:
110 kobject_put(bgrt_kobj); 104 kobject_put(bgrt_kobj);
111 return ret; 105 return ret;