drivers/zorro/zorro-sysfs.c
Source file repositories/reference/linux-study-clean/drivers/zorro/zorro-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/zorro/zorro-sysfs.c- Extension
.c- Size
- 3241 bytes
- Lines
- 125
- Domain
- Driver Families
- Bucket
- drivers/zorro
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/zorro.hlinux/stat.hlinux/string.hlinux/sysfs.hasm/byteorder.hzorro.h
Detected Declarations
function serial_showfunction resource_showfunction modalias_showfunction zorro_read_config
Annotated Snippet
#include <linux/kernel.h>
#include <linux/zorro.h>
#include <linux/stat.h>
#include <linux/string.h>
#include <linux/sysfs.h>
#include <asm/byteorder.h>
#include "zorro.h"
/* show configuration fields */
#define zorro_config_attr(name, field, format_string) \
static ssize_t name##_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct zorro_dev *z; \
\
z = to_zorro_dev(dev); \
return sysfs_emit(buf, format_string, z->field); \
} \
static DEVICE_ATTR_RO(name);
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");
static ssize_t serial_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct zorro_dev *z;
z = to_zorro_dev(dev);
return sysfs_emit(buf, "0x%08x\n", be32_to_cpu(z->rom.er_SerialNumber));
}
static DEVICE_ATTR_RO(serial);
static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct zorro_dev *z = to_zorro_dev(dev);
return sysfs_emit(buf, "0x%08lx 0x%08lx 0x%08lx\n",
(unsigned long)zorro_resource_start(z),
(unsigned long)zorro_resource_end(z),
zorro_resource_flags(z));
}
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);
return sysfs_emit(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
};
static ssize_t zorro_read_config(struct file *filp, struct kobject *kobj,
const struct bin_attribute *bin_attr,
char *buf, loff_t off, size_t count)
{
struct zorro_dev *z = to_zorro_dev(kobj_to_dev(kobj));
struct ConfigDev cd;
/* Construct a ConfigDev */
memset(&cd, 0, sizeof(cd));
cd.cd_Rom = z->rom;
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));
return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd));
}
static const struct bin_attribute zorro_config_attr = {
.attr = {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/zorro.h`, `linux/stat.h`, `linux/string.h`, `linux/sysfs.h`, `asm/byteorder.h`, `zorro.h`.
- Detected declarations: `function serial_show`, `function resource_show`, `function modalias_show`, `function zorro_read_config`.
- Atlas domain: Driver Families / drivers/zorro.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.