drivers/misc/ocxl/sysfs.c
Source file repositories/reference/linux-study-clean/drivers/misc/ocxl/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/misc/ocxl/sysfs.c- Extension
.c- Size
- 4707 bytes
- Lines
- 187
- Domain
- Driver Families
- Bucket
- drivers/misc
- 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/sysfs.hocxl_internal.h
Detected Declarations
function global_mmio_size_showfunction pp_mmio_size_showfunction afu_version_showfunction contexts_showfunction reload_on_reset_showfunction reload_on_reset_storefunction global_mmio_readfunction global_mmio_faultfunction global_mmio_mmapfunction ocxl_sysfs_register_afufunction ocxl_sysfs_unregister_afu
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
// Copyright 2017 IBM Corp.
#include <linux/sysfs.h>
#include "ocxl_internal.h"
static inline struct ocxl_afu *to_afu(struct device *device)
{
struct ocxl_file_info *info = container_of(device, struct ocxl_file_info, dev);
return info->afu;
}
static ssize_t global_mmio_size_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct ocxl_afu *afu = to_afu(device);
return sysfs_emit(buf, "%d\n",
afu->config.global_mmio_size);
}
static ssize_t pp_mmio_size_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct ocxl_afu *afu = to_afu(device);
return sysfs_emit(buf, "%d\n",
afu->config.pp_mmio_stride);
}
static ssize_t afu_version_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct ocxl_afu *afu = to_afu(device);
return sysfs_emit(buf, "%hhu:%hhu\n",
afu->config.version_major,
afu->config.version_minor);
}
static ssize_t contexts_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct ocxl_afu *afu = to_afu(device);
return sysfs_emit(buf, "%d/%d\n",
afu->pasid_count, afu->pasid_max);
}
static ssize_t reload_on_reset_show(struct device *device,
struct device_attribute *attr,
char *buf)
{
struct ocxl_afu *afu = to_afu(device);
struct ocxl_fn *fn = afu->fn;
struct pci_dev *pci_dev = to_pci_dev(fn->dev.parent);
int val;
if (ocxl_config_get_reset_reload(pci_dev, &val))
return sysfs_emit(buf, "unavailable\n");
return sysfs_emit(buf, "%d\n", val);
}
static ssize_t reload_on_reset_store(struct device *device,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct ocxl_afu *afu = to_afu(device);
struct ocxl_fn *fn = afu->fn;
struct pci_dev *pci_dev = to_pci_dev(fn->dev.parent);
int rc, val;
rc = kstrtoint(buf, 0, &val);
if (rc || (val != 0 && val != 1))
return -EINVAL;
if (ocxl_config_set_reset_reload(pci_dev, val))
return -ENODEV;
return count;
}
static struct device_attribute afu_attrs[] = {
__ATTR_RO(global_mmio_size),
__ATTR_RO(pp_mmio_size),
Annotation
- Immediate include surface: `linux/sysfs.h`, `ocxl_internal.h`.
- Detected declarations: `function global_mmio_size_show`, `function pp_mmio_size_show`, `function afu_version_show`, `function contexts_show`, `function reload_on_reset_show`, `function reload_on_reset_store`, `function global_mmio_read`, `function global_mmio_fault`, `function global_mmio_mmap`, `function ocxl_sysfs_register_afu`.
- Atlas domain: Driver Families / drivers/misc.
- 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.