net/atm/atm_sysfs.c
Source file repositories/reference/linux-study-clean/net/atm/atm_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
net/atm/atm_sysfs.c- Extension
.c- Size
- 3275 bytes
- Lines
- 159
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/slab.hlinux/init.hlinux/kobject.hlinux/atmdev.hcommon.hresources.h
Detected Declarations
function type_showfunction address_showfunction atmindex_showfunction carrier_showfunction link_rate_showfunction atm_ueventfunction atm_releasefunction atm_register_sysfsfunction atm_unregister_sysfsfunction atm_sysfs_initfunction atm_sysfs_exit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* ATM driver model support. */
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/kobject.h>
#include <linux/atmdev.h>
#include "common.h"
#include "resources.h"
#define to_atm_dev(cldev) container_of(cldev, struct atm_dev, class_dev)
static ssize_t type_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);
return scnprintf(buf, PAGE_SIZE, "%s\n", adev->type);
}
static ssize_t address_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);
return scnprintf(buf, PAGE_SIZE, "%pM\n", adev->esi);
}
static ssize_t atmindex_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);
return scnprintf(buf, PAGE_SIZE, "%d\n", adev->number);
}
static ssize_t carrier_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);
return scnprintf(buf, PAGE_SIZE, "%d\n",
adev->signal == ATM_PHY_SIG_LOST ? 0 : 1);
}
static ssize_t link_rate_show(struct device *cdev,
struct device_attribute *attr, char *buf)
{
struct atm_dev *adev = to_atm_dev(cdev);
int link_rate;
/* show the link rate, not the data rate */
switch (adev->link_rate) {
case ATM_OC3_PCR:
link_rate = 155520000;
break;
case ATM_OC12_PCR:
link_rate = 622080000;
break;
case ATM_25_PCR:
link_rate = 25600000;
break;
default:
link_rate = adev->link_rate * 8 * 53;
}
return scnprintf(buf, PAGE_SIZE, "%d\n", link_rate);
}
static DEVICE_ATTR_RO(address);
static DEVICE_ATTR_RO(atmindex);
static DEVICE_ATTR_RO(carrier);
static DEVICE_ATTR_RO(type);
static DEVICE_ATTR_RO(link_rate);
static struct device_attribute *atm_attrs[] = {
&dev_attr_address,
&dev_attr_atmindex,
&dev_attr_carrier,
&dev_attr_type,
&dev_attr_link_rate,
NULL
};
static int atm_uevent(const struct device *cdev, struct kobj_uevent_env *env)
{
const struct atm_dev *adev;
if (!cdev)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/init.h`, `linux/kobject.h`, `linux/atmdev.h`, `common.h`, `resources.h`.
- Detected declarations: `function type_show`, `function address_show`, `function atmindex_show`, `function carrier_show`, `function link_rate_show`, `function atm_uevent`, `function atm_release`, `function atm_register_sysfs`, `function atm_unregister_sysfs`, `function atm_sysfs_init`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.