0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <linux/kernel.h>
0015 #include <linux/dio.h>
0016 #include <linux/stat.h>
0017
0018
0019
0020 static ssize_t dio_show_id(struct device *dev, struct device_attribute *attr, char *buf)
0021 {
0022 struct dio_dev *d;
0023
0024 d = to_dio_dev(dev);
0025 return sprintf(buf, "0x%02x\n", (d->id & 0xff));
0026 }
0027 static DEVICE_ATTR(id, S_IRUGO, dio_show_id, NULL);
0028
0029 static ssize_t dio_show_ipl(struct device *dev, struct device_attribute *attr, char *buf)
0030 {
0031 struct dio_dev *d;
0032
0033 d = to_dio_dev(dev);
0034 return sprintf(buf, "0x%02x\n", d->ipl);
0035 }
0036 static DEVICE_ATTR(ipl, S_IRUGO, dio_show_ipl, NULL);
0037
0038 static ssize_t dio_show_secid(struct device *dev, struct device_attribute *attr, char *buf)
0039 {
0040 struct dio_dev *d;
0041
0042 d = to_dio_dev(dev);
0043 return sprintf(buf, "0x%02x\n", ((d->id >> 8)& 0xff));
0044 }
0045 static DEVICE_ATTR(secid, S_IRUGO, dio_show_secid, NULL);
0046
0047 static ssize_t dio_show_name(struct device *dev, struct device_attribute *attr, char *buf)
0048 {
0049 struct dio_dev *d;
0050
0051 d = to_dio_dev(dev);
0052 return sprintf(buf, "%s\n", d->name);
0053 }
0054 static DEVICE_ATTR(name, S_IRUGO, dio_show_name, NULL);
0055
0056 static ssize_t dio_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
0057 {
0058 struct dio_dev *d = to_dio_dev(dev);
0059
0060 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
0061 (unsigned long)dio_resource_start(d),
0062 (unsigned long)dio_resource_end(d),
0063 dio_resource_flags(d));
0064 }
0065 static DEVICE_ATTR(resource, S_IRUGO, dio_show_resource, NULL);
0066
0067 int dio_create_sysfs_dev_files(struct dio_dev *d)
0068 {
0069 struct device *dev = &d->dev;
0070 int error;
0071
0072
0073 if ((error = device_create_file(dev, &dev_attr_id)) ||
0074 (error = device_create_file(dev, &dev_attr_ipl)) ||
0075 (error = device_create_file(dev, &dev_attr_secid)) ||
0076 (error = device_create_file(dev, &dev_attr_name)) ||
0077 (error = device_create_file(dev, &dev_attr_resource)))
0078 return error;
0079
0080 return 0;
0081 }
0082