aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/zorro/zorro-sysfs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/zorro/zorro-sysfs.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/zorro/zorro-sysfs.c')
-rw-r--r--drivers/zorro/zorro-sysfs.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/drivers/zorro/zorro-sysfs.c b/drivers/zorro/zorro-sysfs.c
new file mode 100644
index 000000000000..dad03fc33a44
--- /dev/null
+++ b/drivers/zorro/zorro-sysfs.c
@@ -0,0 +1,98 @@
1/*
2 * File Attributes for Zorro Devices
3 *
4 * Copyright (C) 2003 Geert Uytterhoeven
5 *
6 * Loosely based on drivers/pci/pci-sysfs.c
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
13
14#include <linux/kernel.h>
15#include <linux/zorro.h>
16#include <linux/stat.h>
17
18#include "zorro.h"
19
20
21/* show configuration fields */
22#define zorro_config_attr(name, field, format_string) \
23static ssize_t \
24show_##name(struct device *dev, char *buf) \
25{ \
26 struct zorro_dev *z; \
27 \
28 z = to_zorro_dev(dev); \
29 return sprintf(buf, format_string, z->field); \
30} \
31static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
32
33zorro_config_attr(id, id, "0x%08x\n");
34zorro_config_attr(type, rom.er_Type, "0x%02x\n");
35zorro_config_attr(serial, rom.er_SerialNumber, "0x%08x\n");
36zorro_config_attr(slotaddr, slotaddr, "0x%04x\n");
37zorro_config_attr(slotsize, slotsize, "0x%04x\n");
38
39static ssize_t zorro_show_resource(struct device *dev, char *buf)
40{
41 struct zorro_dev *z = to_zorro_dev(dev);
42
43 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
44 zorro_resource_start(z), zorro_resource_end(z),
45 zorro_resource_flags(z));
46}
47
48static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL);
49
50static ssize_t zorro_read_config(struct kobject *kobj, char *buf, loff_t off,
51 size_t count)
52{
53 struct zorro_dev *z = to_zorro_dev(container_of(kobj, struct device,
54 kobj));
55 struct ConfigDev cd;
56 unsigned int size = sizeof(cd);
57
58 if (off > size)
59 return 0;
60 if (off+count > size)
61 count = size-off;
62
63 /* Construct a ConfigDev */
64 memset(&cd, 0, sizeof(cd));
65 cd.cd_Rom = z->rom;
66 cd.cd_SlotAddr = z->slotaddr;
67 cd.cd_SlotSize = z->slotsize;
68 cd.cd_BoardAddr = (void *)zorro_resource_start(z);
69 cd.cd_BoardSize = zorro_resource_len(z);
70
71 memcpy(buf, (void *)&cd+off, count);
72 return count;
73}
74
75static struct bin_attribute zorro_config_attr = {
76 .attr = {
77 .name = "config",
78 .mode = S_IRUGO | S_IWUSR,
79 .owner = THIS_MODULE
80 },
81 .size = sizeof(struct ConfigDev),
82 .read = zorro_read_config,
83};
84
85void zorro_create_sysfs_dev_files(struct zorro_dev *z)
86{
87 struct device *dev = &z->dev;
88
89 /* current configuration's attributes */
90 device_create_file(dev, &dev_attr_id);
91 device_create_file(dev, &dev_attr_type);
92 device_create_file(dev, &dev_attr_serial);
93 device_create_file(dev, &dev_attr_slotaddr);
94 device_create_file(dev, &dev_attr_slotsize);
95 device_create_file(dev, &dev_attr_resource);
96 sysfs_create_bin_file(&dev->kobj, &zorro_config_attr);
97}
98