net/bluetooth/hci_sysfs.c
Source file repositories/reference/linux-study-clean/net/bluetooth/hci_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/hci_sysfs.c- Extension
.c- Size
- 2717 bytes
- Lines
- 139
- 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/module.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.h
Detected Declarations
function bt_link_releasefunction hci_conn_init_sysfsfunction hci_conn_add_sysfsfunction hci_conn_del_sysfsfunction bt_host_releasefunction reset_storefunction hci_init_sysfsfunction bt_sysfs_initfunction bt_sysfs_cleanup
Annotated Snippet
if (device_add(&conn->dev) < 0)
bt_dev_err(hdev, "failed to register connection device");
}
void hci_conn_del_sysfs(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
bt_dev_dbg(hdev, "conn %p", conn);
if (!device_is_registered(&conn->dev)) {
/* If device_add() has *not* succeeded, use *only* put_device()
* to drop the reference count.
*/
put_device(&conn->dev);
return;
}
/* If there are devices using the connection as parent reset it to NULL
* before unregistering the device.
*/
while (1) {
struct device *dev;
dev = device_find_any_child(&conn->dev);
if (!dev)
break;
device_move(dev, NULL, DPM_ORDER_DEV_LAST);
put_device(dev);
}
device_unregister(&conn->dev);
}
static void bt_host_release(struct device *dev)
{
struct hci_dev *hdev = to_hci_dev(dev);
if (hci_dev_test_flag(hdev, HCI_UNREGISTER)) {
hci_release_dev(hdev);
} else {
cleanup_srcu_struct(&hdev->srcu);
kfree(hdev);
}
module_put(THIS_MODULE);
}
static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct hci_dev *hdev = to_hci_dev(dev);
if (hdev->reset)
hdev->reset(hdev);
return count;
}
static DEVICE_ATTR_WO(reset);
static struct attribute *bt_host_attrs[] = {
&dev_attr_reset.attr,
NULL,
};
ATTRIBUTE_GROUPS(bt_host);
static const struct device_type bt_host = {
.name = "host",
.release = bt_host_release,
.groups = bt_host_groups,
};
void hci_init_sysfs(struct hci_dev *hdev)
{
struct device *dev = &hdev->dev;
dev->type = &bt_host;
dev->class = &bt_class;
__module_get(THIS_MODULE);
device_initialize(dev);
}
int __init bt_sysfs_init(void)
{
return class_register(&bt_class);
}
void bt_sysfs_cleanup(void)
{
class_unregister(&bt_class);
Annotation
- Immediate include surface: `linux/module.h`, `net/bluetooth/bluetooth.h`, `net/bluetooth/hci_core.h`.
- Detected declarations: `function bt_link_release`, `function hci_conn_init_sysfs`, `function hci_conn_add_sysfs`, `function hci_conn_del_sysfs`, `function bt_host_release`, `function reset_store`, `function hci_init_sysfs`, `function bt_sysfs_init`, `function bt_sysfs_cleanup`.
- 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.