drivers/gpu/drm/drm_sysfs.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/drm_sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/drm_sysfs.c- Extension
.c- Size
- 15738 bytes
- Lines
- 624
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/acpi.hlinux/component.hlinux/device.hlinux/err.hlinux/export.hlinux/gfp.hlinux/i2c.hlinux/kdev_t.hlinux/pci.hlinux/property.hlinux/slab.hdrm/drm_accel.hdrm/drm_connector.hdrm/drm_device.hdrm/drm_file.hdrm/drm_modes.hdrm/drm_print.hdrm/drm_property.hdrm/drm_sysfs.hasm/video.hdrm_internal.hdrm_crtc_internal.h
Detected Declarations
function drm_connector_acpi_bus_matchfunction drm_sysfs_acpi_registerfunction drm_sysfs_acpi_unregisterfunction drm_sysfs_acpi_registerfunction typec_connector_bindfunction typec_connector_unbindfunction drm_sysfs_destroyfunction drm_sysfs_destroyfunction drm_sysfs_releasefunction status_storefunction status_showfunction dpms_showfunction enabled_showfunction edid_showfunction modes_showfunction connector_id_showfunction drm_sysfs_connector_addfunction drm_sysfs_connector_add_latefunction drm_sysfs_connector_remove_earlyfunction drm_sysfs_connector_removefunction drm_sysfs_lease_eventfunction drm_sysfs_connector_status_eventfunction drm_sysfs_connector_hotplug_eventfunction drm_sysfs_connector_property_eventfunction boot_display_showfunction boot_display_visiblefunction drm_class_device_registerfunction drm_class_device_unregisterexport drm_sysfs_hotplug_eventexport drm_sysfs_connector_hotplug_eventexport drm_sysfs_connector_property_eventexport drm_class_device_registerexport drm_class_device_unregister
Annotated Snippet
r = device_add(kdev);
if (r) {
drm_err(dev, "failed to register connector device: %d\n", r);
goto err_free;
}
connector->kdev = kdev;
if (dev_fwnode(kdev)) {
r = component_add(kdev, &typec_connector_ops);
if (r)
drm_err(dev, "failed to add component to create link to typec connector\n");
}
return 0;
err_free:
put_device(kdev);
return r;
}
int drm_sysfs_connector_add_late(struct drm_connector *connector)
{
if (connector->ddc)
return sysfs_create_link(&connector->kdev->kobj,
&connector->ddc->dev.kobj, "ddc");
return 0;
}
void drm_sysfs_connector_remove_early(struct drm_connector *connector)
{
if (connector->ddc)
sysfs_remove_link(&connector->kdev->kobj, "ddc");
}
void drm_sysfs_connector_remove(struct drm_connector *connector)
{
if (!connector->kdev)
return;
if (dev_fwnode(connector->kdev))
component_del(connector->kdev, &typec_connector_ops);
drm_dbg_kms(connector->dev,
"[CONNECTOR:%d:%s] removing connector from sysfs\n",
connector->base.id, connector->name);
device_unregister(connector->kdev);
connector->kdev = NULL;
}
void drm_sysfs_lease_event(struct drm_device *dev)
{
char *event_string = "LEASE=1";
char *envp[] = { event_string, NULL };
drm_dbg_lease(dev, "generating lease event\n");
kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
}
/**
* drm_sysfs_hotplug_event - generate a DRM uevent
* @dev: DRM device
*
* Send a uevent for the DRM device specified by @dev. Currently we only
* set HOTPLUG=1 in the uevent environment, but this could be expanded to
* deal with other types of events.
*
* Any new uapi should be using the drm_sysfs_connector_status_event()
* for uevents on connector status change.
*/
void drm_sysfs_hotplug_event(struct drm_device *dev)
{
char *event_string = "HOTPLUG=1";
char *envp[] = { event_string, NULL };
drm_dbg_kms(dev, "generating hotplug event\n");
kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
}
EXPORT_SYMBOL(drm_sysfs_hotplug_event);
/**
* drm_sysfs_connector_hotplug_event - generate a DRM uevent for any connector
* change
* @connector: connector which has changed
*
* Send a uevent for the DRM connector specified by @connector. This will send
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/component.h`, `linux/device.h`, `linux/err.h`, `linux/export.h`, `linux/gfp.h`, `linux/i2c.h`, `linux/kdev_t.h`.
- Detected declarations: `function drm_connector_acpi_bus_match`, `function drm_sysfs_acpi_register`, `function drm_sysfs_acpi_unregister`, `function drm_sysfs_acpi_register`, `function typec_connector_bind`, `function typec_connector_unbind`, `function drm_sysfs_destroy`, `function drm_sysfs_destroy`, `function drm_sysfs_release`, `function status_store`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: integration 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.