drivers/net/wireless/broadcom/b43legacy/sysfs.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/broadcom/b43legacy/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/broadcom/b43legacy/sysfs.c- Extension
.c- Size
- 4873 bytes
- Lines
- 223
- Domain
- Driver Families
- Bucket
- drivers/net
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
sysfs.hb43legacy.hmain.hphy.hradio.hlinux/capability.h
Detected Declarations
function Copyrightfunction get_booleanfunction b43legacy_attr_interfmode_showfunction b43legacy_attr_interfmode_storefunction b43legacy_attr_preamble_showfunction b43legacy_attr_preamble_storefunction b43legacy_sysfs_registerfunction b43legacy_sysfs_unregister
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
Broadcom B43legacy wireless driver
SYSFS support routines
Copyright (c) 2006 Michael Buesch <m@bues.ch>
*/
#include "sysfs.h"
#include "b43legacy.h"
#include "main.h"
#include "phy.h"
#include "radio.h"
#include <linux/capability.h>
#define GENERIC_FILESIZE 64
static int get_integer(const char *buf, size_t count)
{
char tmp[10 + 1] = { 0 };
int ret = -EINVAL, res;
if (count == 0)
goto out;
count = min_t(size_t, count, 10);
memcpy(tmp, buf, count);
ret = kstrtoint(tmp, 10, &res);
if (!ret)
return res;
out:
return ret;
}
static int get_boolean(const char *buf, size_t count)
{
if (count != 0) {
if (buf[0] == '1')
return 1;
if (buf[0] == '0')
return 0;
if (count >= 4 && memcmp(buf, "true", 4) == 0)
return 1;
if (count >= 5 && memcmp(buf, "false", 5) == 0)
return 0;
if (count >= 3 && memcmp(buf, "yes", 3) == 0)
return 1;
if (count >= 2 && memcmp(buf, "no", 2) == 0)
return 0;
if (count >= 2 && memcmp(buf, "on", 2) == 0)
return 1;
if (count >= 3 && memcmp(buf, "off", 3) == 0)
return 0;
}
return -EINVAL;
}
static ssize_t b43legacy_attr_interfmode_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct b43legacy_wldev *wldev = dev_to_b43legacy_wldev(dev);
ssize_t count = 0;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
mutex_lock(&wldev->wl->mutex);
switch (wldev->phy.interfmode) {
case B43legacy_INTERFMODE_NONE:
count = sysfs_emit(buf, "0 (No Interference Mitigation)\n");
break;
case B43legacy_INTERFMODE_NONWLAN:
count = sysfs_emit(buf,
"1 (Non-WLAN Interference Mitigation)\n");
break;
case B43legacy_INTERFMODE_MANUALWLAN:
count = sysfs_emit(buf, "2 (WLAN Interference Mitigation)\n");
break;
default:
B43legacy_WARN_ON(1);
}
Annotation
- Immediate include surface: `sysfs.h`, `b43legacy.h`, `main.h`, `phy.h`, `radio.h`, `linux/capability.h`.
- Detected declarations: `function Copyright`, `function get_boolean`, `function b43legacy_attr_interfmode_show`, `function b43legacy_attr_interfmode_store`, `function b43legacy_attr_preamble_show`, `function b43legacy_attr_preamble_store`, `function b43legacy_sysfs_register`, `function b43legacy_sysfs_unregister`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.