| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * BGRT boot graphic support |
|---|
| 3 | 4 | * Authors: Matthew Garrett, Josh Triplett <josh@joshtriplett.org> |
|---|
| 4 | 5 | * Copyright 2012 Red Hat, Inc <mjg@redhat.com> |
|---|
| 5 | 6 | * Copyright 2012 Intel Corporation |
|---|
| 6 | | - * |
|---|
| 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. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | |
|---|
| 12 | 9 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 18 | 15 | static void *bgrt_image; |
|---|
| 19 | 16 | static struct kobject *bgrt_kobj; |
|---|
| 20 | 17 | |
|---|
| 21 | | -static ssize_t show_version(struct device *dev, |
|---|
| 22 | | - struct device_attribute *attr, char *buf) |
|---|
| 23 | | -{ |
|---|
| 24 | | - return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.version); |
|---|
| 25 | | -} |
|---|
| 26 | | -static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); |
|---|
| 18 | +#define BGRT_SHOW(_name, _member) \ |
|---|
| 19 | + static ssize_t _name##_show(struct kobject *kobj, \ |
|---|
| 20 | + struct kobj_attribute *attr, char *buf) \ |
|---|
| 21 | + { \ |
|---|
| 22 | + return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab._member); \ |
|---|
| 23 | + } \ |
|---|
| 24 | + struct kobj_attribute bgrt_attr_##_name = __ATTR_RO(_name) |
|---|
| 27 | 25 | |
|---|
| 28 | | -static ssize_t show_status(struct device *dev, |
|---|
| 29 | | - struct device_attribute *attr, char *buf) |
|---|
| 30 | | -{ |
|---|
| 31 | | - return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.status); |
|---|
| 32 | | -} |
|---|
| 33 | | -static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); |
|---|
| 34 | | - |
|---|
| 35 | | -static ssize_t show_type(struct device *dev, |
|---|
| 36 | | - struct device_attribute *attr, char *buf) |
|---|
| 37 | | -{ |
|---|
| 38 | | - return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_type); |
|---|
| 39 | | -} |
|---|
| 40 | | -static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); |
|---|
| 41 | | - |
|---|
| 42 | | -static ssize_t show_xoffset(struct device *dev, |
|---|
| 43 | | - struct device_attribute *attr, char *buf) |
|---|
| 44 | | -{ |
|---|
| 45 | | - return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_offset_x); |
|---|
| 46 | | -} |
|---|
| 47 | | -static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL); |
|---|
| 48 | | - |
|---|
| 49 | | -static ssize_t show_yoffset(struct device *dev, |
|---|
| 50 | | - struct device_attribute *attr, char *buf) |
|---|
| 51 | | -{ |
|---|
| 52 | | - return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab.image_offset_y); |
|---|
| 53 | | -} |
|---|
| 54 | | -static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL); |
|---|
| 26 | +BGRT_SHOW(version, version); |
|---|
| 27 | +BGRT_SHOW(status, status); |
|---|
| 28 | +BGRT_SHOW(type, image_type); |
|---|
| 29 | +BGRT_SHOW(xoffset, image_offset_x); |
|---|
| 30 | +BGRT_SHOW(yoffset, image_offset_y); |
|---|
| 55 | 31 | |
|---|
| 56 | 32 | static ssize_t image_read(struct file *file, struct kobject *kobj, |
|---|
| 57 | 33 | struct bin_attribute *attr, char *buf, loff_t off, size_t count) |
|---|
| .. | .. |
|---|
| 63 | 39 | static BIN_ATTR_RO(image, 0); /* size gets filled in later */ |
|---|
| 64 | 40 | |
|---|
| 65 | 41 | static struct attribute *bgrt_attributes[] = { |
|---|
| 66 | | - &dev_attr_version.attr, |
|---|
| 67 | | - &dev_attr_status.attr, |
|---|
| 68 | | - &dev_attr_type.attr, |
|---|
| 69 | | - &dev_attr_xoffset.attr, |
|---|
| 70 | | - &dev_attr_yoffset.attr, |
|---|
| 42 | + &bgrt_attr_version.attr, |
|---|
| 43 | + &bgrt_attr_status.attr, |
|---|
| 44 | + &bgrt_attr_type.attr, |
|---|
| 45 | + &bgrt_attr_xoffset.attr, |
|---|
| 46 | + &bgrt_attr_yoffset.attr, |
|---|
| 71 | 47 | NULL, |
|---|
| 72 | 48 | }; |
|---|
| 73 | 49 | |
|---|