drivers/usb/typec/pd.c
Source file repositories/reference/linux-study-clean/drivers/usb/typec/pd.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/usb/typec/pd.c- Extension
.c- Size
- 20810 bytes
- Lines
- 798
- Domain
- Driver Families
- Bucket
- drivers/usb
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/slab.hlinux/usb/pd.hpd.h
Detected Declarations
struct pdofunction pdo_releasefunction dual_role_power_showfunction usb_suspend_supported_showfunction higher_capability_showfunction unconstrained_power_showfunction usb_communication_capable_showfunction dual_role_data_showfunction unchunked_extended_messages_supported_showfunction peak_current_showfunction fast_role_swap_current_showfunction voltage_showfunction current_showfunction fixed_attr_is_visiblefunction maximum_voltage_showfunction minimum_voltage_showfunction maximum_power_showfunction operational_power_showfunction pps_power_limited_showfunction pps_max_voltage_showfunction pps_min_voltage_showfunction pps_max_current_showfunction spr_avs_9v_to_15v_max_current_showfunction spr_avs_15v_to_20v_max_current_showfunction spr_avs_src_peak_current_showfunction add_pdofunction remove_pdofunction pd_capabilities_releasefunction ERR_PRTfunction usb_power_delivery_unregister_capabilitiesfunction revision_showfunction version_showfunction pd_attr_is_visiblefunction pd_releasefunction usb_power_delivery_registerfunction usb_power_delivery_unregisterfunction usb_power_delivery_link_devicefunction pd_link_devicefunction usb_power_delivery_initfunction usb_power_delivery_exitexport usb_power_delivery_register_capabilitiesexport usb_power_delivery_unregister_capabilitiesexport usb_power_delivery_registerexport usb_power_delivery_unregisterexport usb_power_delivery_link_deviceexport usb_power_delivery_unlink_device
Annotated Snippet
struct pdo {
struct device dev;
int object_position;
u32 pdo;
};
static void pdo_release(struct device *dev)
{
kfree(to_pdo(dev));
}
/* -------------------------------------------------------------------------- */
/* Fixed Supply */
static ssize_t
dual_role_power_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_DUAL_ROLE));
}
static DEVICE_ATTR_RO(dual_role_power);
static ssize_t
usb_suspend_supported_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_SUSPEND));
}
static DEVICE_ATTR_RO(usb_suspend_supported);
static ssize_t
higher_capability_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_HIGHER_CAP));
}
static DEVICE_ATTR_RO(higher_capability);
static ssize_t
unconstrained_power_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_EXTPOWER));
}
static DEVICE_ATTR_RO(unconstrained_power);
static ssize_t
usb_communication_capable_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_USB_COMM));
}
static DEVICE_ATTR_RO(usb_communication_capable);
static ssize_t
dual_role_data_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_DATA_SWAP));
}
static DEVICE_ATTR_RO(dual_role_data);
static ssize_t
unchunked_extended_messages_supported_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", !!(to_pdo(dev)->pdo & PDO_FIXED_UNCHUNK_EXT));
}
static DEVICE_ATTR_RO(unchunked_extended_messages_supported);
static ssize_t
peak_current_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", (to_pdo(dev)->pdo >> PDO_FIXED_PEAK_CURR_SHIFT) & 3);
}
static DEVICE_ATTR_RO(peak_current);
static ssize_t
fast_role_swap_current_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%u\n", (to_pdo(dev)->pdo >> PDO_FIXED_FRS_CURR_SHIFT) & 3);
}
static DEVICE_ATTR_RO(fast_role_swap_current);
static ssize_t voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%umV\n", pdo_fixed_voltage(to_pdo(dev)->pdo));
}
static DEVICE_ATTR_RO(voltage);
/* Shared with Variable supplies, both source and sink */
static ssize_t current_show(struct device *dev, struct device_attribute *attr, char *buf)
{
return sysfs_emit(buf, "%umA\n", pdo_max_current(to_pdo(dev)->pdo));
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/usb/pd.h`, `pd.h`.
- Detected declarations: `struct pdo`, `function pdo_release`, `function dual_role_power_show`, `function usb_suspend_supported_show`, `function higher_capability_show`, `function unconstrained_power_show`, `function usb_communication_capable_show`, `function dual_role_data_show`, `function unchunked_extended_messages_supported_show`, `function peak_current_show`.
- Atlas domain: Driver Families / drivers/usb.
- Implementation status: integration 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.