2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* File Attributes for Zorro Devices
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Geert Uytterhoeven
|
|
|
|
*
|
|
|
|
* Loosely based on drivers/pci/pci-sysfs.c
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file COPYING in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/zorro.h>
|
|
|
|
#include <linux/stat.h>
|
2005-10-31 02:03:48 +03:00
|
|
|
#include <linux/string.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2013-10-04 11:38:53 +04:00
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
#include "zorro.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* show configuration fields */
|
|
|
|
#define zorro_config_attr(name, field, format_string) \
|
2017-02-14 23:24:09 +03:00
|
|
|
static ssize_t name##_show(struct device *dev, \
|
|
|
|
struct device_attribute *attr, char *buf) \
|
2005-04-17 02:20:36 +04:00
|
|
|
{ \
|
|
|
|
struct zorro_dev *z; \
|
|
|
|
\
|
|
|
|
z = to_zorro_dev(dev); \
|
|
|
|
return sprintf(buf, format_string, z->field); \
|
|
|
|
} \
|
2017-02-14 23:24:09 +03:00
|
|
|
static DEVICE_ATTR_RO(name);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
zorro_config_attr(id, id, "0x%08x\n");
|
|
|
|
zorro_config_attr(type, rom.er_Type, "0x%02x\n");
|
|
|
|
zorro_config_attr(slotaddr, slotaddr, "0x%04x\n");
|
|
|
|
zorro_config_attr(slotsize, slotsize, "0x%04x\n");
|
|
|
|
|
2017-02-14 23:24:09 +03:00
|
|
|
static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
2013-10-04 11:38:53 +04:00
|
|
|
{
|
|
|
|
struct zorro_dev *z;
|
|
|
|
|
|
|
|
z = to_zorro_dev(dev);
|
|
|
|
return sprintf(buf, "0x%08x\n", be32_to_cpu(z->rom.er_SerialNumber));
|
|
|
|
}
|
2017-02-14 23:24:09 +03:00
|
|
|
static DEVICE_ATTR_RO(serial);
|
2013-10-04 11:38:53 +04:00
|
|
|
|
2017-02-14 23:24:09 +03:00
|
|
|
static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
|
|
|
struct zorro_dev *z = to_zorro_dev(dev);
|
|
|
|
|
|
|
|
return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
|
2007-05-02 00:33:04 +04:00
|
|
|
(unsigned long)zorro_resource_start(z),
|
|
|
|
(unsigned long)zorro_resource_end(z),
|
2005-04-17 02:20:36 +04:00
|
|
|
zorro_resource_flags(z));
|
|
|
|
}
|
2017-02-14 23:24:09 +03:00
|
|
|
static DEVICE_ATTR_RO(resource);
|
|
|
|
|
|
|
|
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
|
|
|
{
|
|
|
|
struct zorro_dev *z = to_zorro_dev(dev);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2017-02-14 23:24:09 +03:00
|
|
|
return sprintf(buf, ZORRO_DEVICE_MODALIAS_FMT "\n", z->id);
|
|
|
|
}
|
|
|
|
static DEVICE_ATTR_RO(modalias);
|
|
|
|
|
|
|
|
static struct attribute *zorro_device_attrs[] = {
|
|
|
|
&dev_attr_id.attr,
|
|
|
|
&dev_attr_type.attr,
|
|
|
|
&dev_attr_serial.attr,
|
|
|
|
&dev_attr_slotaddr.attr,
|
|
|
|
&dev_attr_slotsize.attr,
|
|
|
|
&dev_attr_resource.attr,
|
|
|
|
&dev_attr_modalias.attr,
|
|
|
|
NULL
|
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2010-05-13 05:28:57 +04:00
|
|
|
static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj,
|
2007-06-09 09:57:22 +04:00
|
|
|
struct bin_attribute *bin_attr,
|
|
|
|
char *buf, loff_t off, size_t count)
|
2005-04-17 02:20:36 +04:00
|
|
|
{
|
2016-01-06 18:28:39 +03:00
|
|
|
struct zorro_dev *z = to_zorro_dev(kobj_to_dev(kobj));
|
2005-04-17 02:20:36 +04:00
|
|
|
struct ConfigDev cd;
|
|
|
|
|
|
|
|
/* Construct a ConfigDev */
|
|
|
|
memset(&cd, 0, sizeof(cd));
|
|
|
|
cd.cd_Rom = z->rom;
|
2013-10-04 11:38:53 +04:00
|
|
|
cd.cd_SlotAddr = cpu_to_be16(z->slotaddr);
|
|
|
|
cd.cd_SlotSize = cpu_to_be16(z->slotsize);
|
|
|
|
cd.cd_BoardAddr = cpu_to_be32(zorro_resource_start(z));
|
|
|
|
cd.cd_BoardSize = cpu_to_be32(zorro_resource_len(z));
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2008-07-17 23:16:17 +04:00
|
|
|
return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd));
|
2005-04-17 02:20:36 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct bin_attribute zorro_config_attr = {
|
|
|
|
.attr = {
|
|
|
|
.name = "config",
|
2007-08-23 01:01:34 +04:00
|
|
|
.mode = S_IRUGO,
|
2005-04-17 02:20:36 +04:00
|
|
|
},
|
|
|
|
.size = sizeof(struct ConfigDev),
|
|
|
|
.read = zorro_read_config,
|
|
|
|
};
|
|
|
|
|
2017-02-14 23:24:09 +03:00
|
|
|
static struct bin_attribute *zorro_device_bin_attrs[] = {
|
|
|
|
&zorro_config_attr,
|
|
|
|
NULL
|
|
|
|
};
|
2008-11-18 23:13:53 +03:00
|
|
|
|
2017-02-14 23:24:09 +03:00
|
|
|
static const struct attribute_group zorro_device_attr_group = {
|
|
|
|
.attrs = zorro_device_attrs,
|
|
|
|
.bin_attrs = zorro_device_bin_attrs,
|
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2017-02-14 23:24:09 +03:00
|
|
|
const struct attribute_group *zorro_device_attribute_groups[] = {
|
|
|
|
&zorro_device_attr_group,
|
|
|
|
NULL
|
|
|
|
};
|