drivers/usb/typec/ucsi/debugfs.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/ucsi/debugfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/ucsi/debugfs.c- Extension
.c- Size
- 3559 bytes
- Lines
- 145
- Domain
- Driver Families
- Bucket
- drivers/usb
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/debugfs.hlinux/hex.hlinux/slab.hlinux/string.hlinux/types.hlinux/usb.hasm/errno.hucsi.h
Detected Declarations
function ucsi_cmdfunction ucsi_resp_showfunction ucsi_peak_curr_showfunction ucsi_avg_curr_showfunction ucsi_vbus_volt_showfunction ucsi_debugfs_registerfunction ucsi_debugfs_unregisterfunction ucsi_debugfs_initfunction ucsi_debugfs_exit
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* UCSI debugfs interface
*
* Copyright (C) 2023 Intel Corporation
*
* Authors: Rajaram Regupathy <rajaram.regupathy@intel.com>
* Gopal Saranya <saranya.gopal@intel.com>
*/
#include <linux/debugfs.h>
#include <linux/hex.h>
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/types.h>
#include <linux/usb.h>
#include <asm/errno.h>
#include "ucsi.h"
static struct dentry *ucsi_debugfs_root;
static int ucsi_cmd(void *data, u64 val)
{
struct ucsi *ucsi = data;
int ret;
memset(&ucsi->debugfs->response, 0, sizeof(ucsi->debugfs->response));
ucsi->debugfs->status = 0;
switch (UCSI_COMMAND(val)) {
case UCSI_SET_CCOM:
case UCSI_SET_UOR:
case UCSI_SET_PDR:
case UCSI_CONNECTOR_RESET:
case UCSI_SET_SINK_PATH:
case UCSI_SET_NEW_CAM:
case UCSI_SET_USB:
case UCSI_SET_POWER_LEVEL:
case UCSI_READ_POWER_LEVEL:
ret = ucsi_send_command(ucsi, val, NULL, 0);
break;
case UCSI_GET_CAPABILITY:
case UCSI_GET_CONNECTOR_CAPABILITY:
case UCSI_GET_ALTERNATE_MODES:
case UCSI_GET_CAM_SUPPORTED:
case UCSI_GET_CURRENT_CAM:
case UCSI_GET_PDOS:
case UCSI_GET_CABLE_PROPERTY:
case UCSI_GET_CONNECTOR_STATUS:
case UCSI_GET_ERROR_STATUS:
case UCSI_GET_PD_MESSAGE:
case UCSI_GET_ATTENTION_VDO:
case UCSI_GET_CAM_CS:
case UCSI_GET_LPM_PPM_INFO:
ret = ucsi_send_command(ucsi, val,
&ucsi->debugfs->response,
sizeof(ucsi->debugfs->response));
break;
default:
ret = -EOPNOTSUPP;
}
if (ret < 0) {
ucsi->debugfs->status = ret;
return ret;
}
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(ucsi_cmd_fops, NULL, ucsi_cmd, "0x%llx\n");
static int ucsi_resp_show(struct seq_file *s, void *not_used)
{
struct ucsi *ucsi = s->private;
if (ucsi->debugfs->status)
return ucsi->debugfs->status;
seq_printf(s, "0x%016llx%016llx\n", ucsi->debugfs->response.high,
ucsi->debugfs->response.low);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(ucsi_resp);
static int ucsi_peak_curr_show(struct seq_file *m, void *v)
{
struct ucsi *ucsi = m->private;
seq_printf(m, "%u mA\n", ucsi->connector->peak_current);
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/hex.h`, `linux/slab.h`, `linux/string.h`, `linux/types.h`, `linux/usb.h`, `asm/errno.h`, `ucsi.h`.
- Detected declarations: `function ucsi_cmd`, `function ucsi_resp_show`, `function ucsi_peak_curr_show`, `function ucsi_avg_curr_show`, `function ucsi_vbus_volt_show`, `function ucsi_debugfs_register`, `function ucsi_debugfs_unregister`, `function ucsi_debugfs_init`, `function ucsi_debugfs_exit`.
- Atlas domain: Driver Families / drivers/usb.
- 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.