arch/sh/drivers/dma/dma-sysfs.c
Source file repositories/reference/linux-study-clean/arch/sh/drivers/dma/dma-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
arch/sh/drivers/dma/dma-sysfs.c- Extension
.c- Size
- 4296 bytes
- Lines
- 171
- Domain
- Architecture Layer
- Bucket
- arch/sh
- Inferred role
- Architecture Layer: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/init.hlinux/stat.hlinux/device.hlinux/platform_device.hlinux/err.hlinux/string.hasm/dma.h
Detected Declarations
function dma_show_devicesfunction dma_subsys_initfunction dma_show_dev_idfunction dma_store_dev_idfunction dma_store_configfunction dma_show_modefunction dma_store_modefunction dma_create_sysfs_filesfunction dma_remove_sysfs_files
Annotated Snippet
static const struct bus_type dma_subsys = {
.name = "dma",
.dev_name = "dma",
};
static ssize_t dma_show_devices(struct device *dev,
struct device_attribute *attr, char *buf)
{
ssize_t len = 0;
int i;
for (i = 0; i < 16; i++) {
struct dma_info *info = get_dma_info(i);
struct dma_channel *channel = get_dma_channel(i);
if (unlikely(!info) || !channel)
continue;
len += sprintf(buf + len, "%2d: %14s %s\n",
channel->chan, info->name,
channel->dev_id);
}
return len;
}
static DEVICE_ATTR(devices, S_IRUGO, dma_show_devices, NULL);
static int __init dma_subsys_init(void)
{
struct device *dev_root;
int ret;
ret = subsys_system_register(&dma_subsys, NULL);
if (unlikely(ret))
return ret;
dev_root = bus_get_dev_root(&dma_subsys);
if (dev_root) {
ret = device_create_file(dev_root, &dev_attr_devices);
put_device(dev_root);
}
return ret;
}
postcore_initcall(dma_subsys_init);
static ssize_t dma_show_dev_id(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct dma_channel *channel = to_dma_channel(dev);
return sprintf(buf, "%s\n", channel->dev_id);
}
static ssize_t dma_store_dev_id(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct dma_channel *channel = to_dma_channel(dev);
strcpy(channel->dev_id, buf);
return count;
}
static DEVICE_ATTR(dev_id, S_IRUGO | S_IWUSR, dma_show_dev_id, dma_store_dev_id);
static ssize_t dma_store_config(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct dma_channel *channel = to_dma_channel(dev);
unsigned long config;
config = simple_strtoul(buf, NULL, 0);
dma_configure_channel(channel->vchan, config);
return count;
}
static DEVICE_ATTR(config, S_IWUSR, NULL, dma_store_config);
static ssize_t dma_show_mode(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct dma_channel *channel = to_dma_channel(dev);
return sprintf(buf, "0x%08x\n", channel->mode);
}
static ssize_t dma_store_mode(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/stat.h`, `linux/device.h`, `linux/platform_device.h`, `linux/err.h`, `linux/string.h`, `asm/dma.h`.
- Detected declarations: `function dma_show_devices`, `function dma_subsys_init`, `function dma_show_dev_id`, `function dma_store_dev_id`, `function dma_store_config`, `function dma_show_mode`, `function dma_store_mode`, `function dma_create_sysfs_files`, `function dma_remove_sysfs_files`.
- Atlas domain: Architecture Layer / arch/sh.
- Implementation status: pattern 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.