ASoC: wm8940: Fix check on error code form snd_soc_codec_set_cache_io
[linux-2.6/mini2440.git] / drivers / zorro / zorro-sysfs.c
blob1d2a772ea14c017419a145ec3a8be582336cda97
1 /*
2 * File Attributes for Zorro Devices
4 * Copyright (C) 2003 Geert Uytterhoeven
6 * Loosely based on drivers/pci/pci-sysfs.c
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.
14 #include <linux/kernel.h>
15 #include <linux/zorro.h>
16 #include <linux/stat.h>
17 #include <linux/string.h>
19 #include "zorro.h"
22 /* show configuration fields */
23 #define zorro_config_attr(name, field, format_string) \
24 static ssize_t \
25 show_##name(struct device *dev, struct device_attribute *attr, char *buf) \
26 { \
27 struct zorro_dev *z; \
29 z = to_zorro_dev(dev); \
30 return sprintf(buf, format_string, z->field); \
31 } \
32 static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL);
34 zorro_config_attr(id, id, "0x%08x\n");
35 zorro_config_attr(type, rom.er_Type, "0x%02x\n");
36 zorro_config_attr(serial, rom.er_SerialNumber, "0x%08x\n");
37 zorro_config_attr(slotaddr, slotaddr, "0x%04x\n");
38 zorro_config_attr(slotsize, slotsize, "0x%04x\n");
40 static ssize_t zorro_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
42 struct zorro_dev *z = to_zorro_dev(dev);
44 return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
45 (unsigned long)zorro_resource_start(z),
46 (unsigned long)zorro_resource_end(z),
47 zorro_resource_flags(z));
50 static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL);
52 static ssize_t zorro_read_config(struct kobject *kobj,
53 struct bin_attribute *bin_attr,
54 char *buf, loff_t off, size_t count)
56 struct zorro_dev *z = to_zorro_dev(container_of(kobj, struct device,
57 kobj));
58 struct ConfigDev cd;
60 /* Construct a ConfigDev */
61 memset(&cd, 0, sizeof(cd));
62 cd.cd_Rom = z->rom;
63 cd.cd_SlotAddr = z->slotaddr;
64 cd.cd_SlotSize = z->slotsize;
65 cd.cd_BoardAddr = (void *)zorro_resource_start(z);
66 cd.cd_BoardSize = zorro_resource_len(z);
68 return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd));
71 static struct bin_attribute zorro_config_attr = {
72 .attr = {
73 .name = "config",
74 .mode = S_IRUGO,
76 .size = sizeof(struct ConfigDev),
77 .read = zorro_read_config,
80 int zorro_create_sysfs_dev_files(struct zorro_dev *z)
82 struct device *dev = &z->dev;
83 int error;
85 /* current configuration's attributes */
86 if ((error = device_create_file(dev, &dev_attr_id)) ||
87 (error = device_create_file(dev, &dev_attr_type)) ||
88 (error = device_create_file(dev, &dev_attr_serial)) ||
89 (error = device_create_file(dev, &dev_attr_slotaddr)) ||
90 (error = device_create_file(dev, &dev_attr_slotsize)) ||
91 (error = device_create_file(dev, &dev_attr_resource)) ||
92 (error = sysfs_create_bin_file(&dev->kobj, &zorro_config_attr)))
93 return error;
95 return 0;