spi: imx: fix error return code in spi_imx_probe()
[linux-2.6/btrfs-unstable.git] / drivers / acpi / bgrt.c
blob75f128e766a979e38a3a91ca00ec8fbde5b686dc
1 /*
2 * BGRT boot graphic support
3 * Authors: Matthew Garrett, Josh Triplett <josh@joshtriplett.org>
4 * Copyright 2012 Red Hat, Inc <mjg@redhat.com>
5 * Copyright 2012 Intel Corporation
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/device.h>
15 #include <linux/sysfs.h>
16 #include <linux/efi-bgrt.h>
18 static struct kobject *bgrt_kobj;
20 static ssize_t show_version(struct device *dev,
21 struct device_attribute *attr, char *buf)
23 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->version);
25 static DEVICE_ATTR(version, S_IRUGO, show_version, NULL);
27 static ssize_t show_status(struct device *dev,
28 struct device_attribute *attr, char *buf)
30 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->status);
32 static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
34 static ssize_t show_type(struct device *dev,
35 struct device_attribute *attr, char *buf)
37 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_type);
39 static DEVICE_ATTR(type, S_IRUGO, show_type, NULL);
41 static ssize_t show_xoffset(struct device *dev,
42 struct device_attribute *attr, char *buf)
44 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_x);
46 static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL);
48 static ssize_t show_yoffset(struct device *dev,
49 struct device_attribute *attr, char *buf)
51 return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_y);
53 static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL);
55 static ssize_t image_read(struct file *file, struct kobject *kobj,
56 struct bin_attribute *attr, char *buf, loff_t off, size_t count)
58 memcpy(buf, attr->private + off, count);
59 return count;
62 static BIN_ATTR_RO(image, 0); /* size gets filled in later */
64 static struct attribute *bgrt_attributes[] = {
65 &dev_attr_version.attr,
66 &dev_attr_status.attr,
67 &dev_attr_type.attr,
68 &dev_attr_xoffset.attr,
69 &dev_attr_yoffset.attr,
70 NULL,
73 static struct bin_attribute *bgrt_bin_attributes[] = {
74 &bin_attr_image,
75 NULL,
78 static struct attribute_group bgrt_attribute_group = {
79 .attrs = bgrt_attributes,
80 .bin_attrs = bgrt_bin_attributes,
83 static int __init bgrt_init(void)
85 int ret;
87 if (!bgrt_image)
88 return -ENODEV;
90 bin_attr_image.private = bgrt_image;
91 bin_attr_image.size = bgrt_image_size;
93 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
94 if (!bgrt_kobj)
95 return -EINVAL;
97 ret = sysfs_create_group(bgrt_kobj, &bgrt_attribute_group);
98 if (ret)
99 goto out_kobject;
101 return 0;
103 out_kobject:
104 kobject_put(bgrt_kobj);
105 return ret;
107 device_initcall(bgrt_init);