1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * File Attributes for DIO Devices
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * Copyright (C) 2004 Jochen Friedrich
5*4882a593Smuzhiyun *
6*4882a593Smuzhiyun * Loosely based on drivers/pci/pci-sysfs.c and drivers/zorro/zorro-sysfs.c
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * This file is subject to the terms and conditions of the GNU General Public
9*4882a593Smuzhiyun * License. See the file COPYING in the main directory of this archive
10*4882a593Smuzhiyun * for more details.
11*4882a593Smuzhiyun */
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun #include <linux/kernel.h>
15*4882a593Smuzhiyun #include <linux/dio.h>
16*4882a593Smuzhiyun #include <linux/stat.h>
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun /* show configuration fields */
19*4882a593Smuzhiyun
dio_show_id(struct device * dev,struct device_attribute * attr,char * buf)20*4882a593Smuzhiyun static ssize_t dio_show_id(struct device *dev, struct device_attribute *attr, char *buf)
21*4882a593Smuzhiyun {
22*4882a593Smuzhiyun struct dio_dev *d;
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun d = to_dio_dev(dev);
25*4882a593Smuzhiyun return sprintf(buf, "0x%02x\n", (d->id & 0xff));
26*4882a593Smuzhiyun }
27*4882a593Smuzhiyun static DEVICE_ATTR(id, S_IRUGO, dio_show_id, NULL);
28*4882a593Smuzhiyun
dio_show_ipl(struct device * dev,struct device_attribute * attr,char * buf)29*4882a593Smuzhiyun static ssize_t dio_show_ipl(struct device *dev, struct device_attribute *attr, char *buf)
30*4882a593Smuzhiyun {
31*4882a593Smuzhiyun struct dio_dev *d;
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun d = to_dio_dev(dev);
34*4882a593Smuzhiyun return sprintf(buf, "0x%02x\n", d->ipl);
35*4882a593Smuzhiyun }
36*4882a593Smuzhiyun static DEVICE_ATTR(ipl, S_IRUGO, dio_show_ipl, NULL);
37*4882a593Smuzhiyun
dio_show_secid(struct device * dev,struct device_attribute * attr,char * buf)38*4882a593Smuzhiyun static ssize_t dio_show_secid(struct device *dev, struct device_attribute *attr, char *buf)
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun struct dio_dev *d;
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun d = to_dio_dev(dev);
43*4882a593Smuzhiyun return sprintf(buf, "0x%02x\n", ((d->id >> 8)& 0xff));
44*4882a593Smuzhiyun }
45*4882a593Smuzhiyun static DEVICE_ATTR(secid, S_IRUGO, dio_show_secid, NULL);
46*4882a593Smuzhiyun
dio_show_name(struct device * dev,struct device_attribute * attr,char * buf)47*4882a593Smuzhiyun static ssize_t dio_show_name(struct device *dev, struct device_attribute *attr, char *buf)
48*4882a593Smuzhiyun {
49*4882a593Smuzhiyun struct dio_dev *d;
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun d = to_dio_dev(dev);
52*4882a593Smuzhiyun return sprintf(buf, "%s\n", d->name);
53*4882a593Smuzhiyun }
54*4882a593Smuzhiyun static DEVICE_ATTR(name, S_IRUGO, dio_show_name, NULL);
55*4882a593Smuzhiyun
dio_show_resource(struct device * dev,struct device_attribute * attr,char * buf)56*4882a593Smuzhiyun static ssize_t dio_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
57*4882a593Smuzhiyun {
58*4882a593Smuzhiyun struct dio_dev *d = to_dio_dev(dev);
59*4882a593Smuzhiyun
60*4882a593Smuzhiyun return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
61*4882a593Smuzhiyun (unsigned long)dio_resource_start(d),
62*4882a593Smuzhiyun (unsigned long)dio_resource_end(d),
63*4882a593Smuzhiyun dio_resource_flags(d));
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL);
66*4882a593Smuzhiyun
dio_create_sysfs_dev_files(struct dio_dev * d)67*4882a593Smuzhiyun int dio_create_sysfs_dev_files(struct dio_dev *d)
68*4882a593Smuzhiyun {
69*4882a593Smuzhiyun struct device *dev = &d->dev;
70*4882a593Smuzhiyun int error;
71*4882a593Smuzhiyun
72*4882a593Smuzhiyun /* current configuration's attributes */
73*4882a593Smuzhiyun if ((error = device_create_file(dev, &dev_attr_id)) ||
74*4882a593Smuzhiyun (error = device_create_file(dev, &dev_attr_ipl)) ||
75*4882a593Smuzhiyun (error = device_create_file(dev, &dev_attr_secid)) ||
76*4882a593Smuzhiyun (error = device_create_file(dev, &dev_attr_name)) ||
77*4882a593Smuzhiyun (error = device_create_file(dev, &dev_attr_resource)))
78*4882a593Smuzhiyun return error;
79*4882a593Smuzhiyun
80*4882a593Smuzhiyun return 0;
81*4882a593Smuzhiyun }
82*4882a593Smuzhiyun
83