Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/sh/superhyway/superhyway-sysfs.c |
| 3 | * |
| 4 | * SuperHyway Bus sysfs interface |
| 5 | * |
| 6 | * Copyright (C) 2004, 2005 Paul Mundt <lethal@linux-sh.org> |
| 7 | * |
| 8 | * This file is subject to the terms and conditions of the GNU General Public |
| 9 | * License. See the file "COPYING" in the main directory of this archive |
| 10 | * for more details. |
| 11 | */ |
| 12 | #include <linux/kernel.h> |
| 13 | #include <linux/device.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/superhyway.h> |
| 16 | |
| 17 | #define superhyway_ro_attr(name, fmt, field) \ |
Yani Ioannou | 10523b3 | 2005-05-17 06:43:37 -0400 | [diff] [blame] | 18 | static ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | { \ |
| 20 | struct superhyway_device *s = to_superhyway_device(dev); \ |
| 21 | return sprintf(buf, fmt, s->field); \ |
Greg Kroah-Hartman | 9f4ac34 | 2017-06-06 14:17:02 +0200 | [diff] [blame] | 22 | } \ |
| 23 | static DEVICE_ATTR_RO(name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | /* VCR flags */ |
| 26 | superhyway_ro_attr(perr_flags, "0x%02x\n", vcr.perr_flags); |
| 27 | superhyway_ro_attr(merr_flags, "0x%02x\n", vcr.merr_flags); |
| 28 | superhyway_ro_attr(mod_vers, "0x%04x\n", vcr.mod_vers); |
| 29 | superhyway_ro_attr(mod_id, "0x%04x\n", vcr.mod_id); |
| 30 | superhyway_ro_attr(bot_mb, "0x%02x\n", vcr.bot_mb); |
| 31 | superhyway_ro_attr(top_mb, "0x%02x\n", vcr.top_mb); |
| 32 | |
| 33 | /* Misc */ |
Paul Mundt | 055a251 | 2005-11-07 00:58:21 -0800 | [diff] [blame] | 34 | superhyway_ro_attr(resource, "0x%08lx\n", resource[0].start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Greg Kroah-Hartman | 9f4ac34 | 2017-06-06 14:17:02 +0200 | [diff] [blame] | 36 | static struct attribute *superhyway_dev_attrs[] = { |
| 37 | &dev_attr_perr_flags.attr, |
| 38 | &dev_attr_merr_flags.attr, |
| 39 | &dev_attr_mod_vers.attr, |
| 40 | &dev_attr_mod_id.attr, |
| 41 | &dev_attr_bot_mb.attr, |
| 42 | &dev_attr_top_mb.attr, |
| 43 | &dev_attr_resource.attr, |
| 44 | NULL, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Greg Kroah-Hartman | 9f4ac34 | 2017-06-06 14:17:02 +0200 | [diff] [blame] | 47 | static const struct attribute_group superhyway_dev_group = { |
| 48 | .attrs = superhyway_dev_attrs, |
| 49 | }; |
| 50 | |
| 51 | const struct attribute_group *superhyway_dev_groups[] = { |
| 52 | &superhyway_dev_group, |
| 53 | NULL, |
| 54 | }; |