drivers/ufs/core/ufs-sysfs.c
Source file repositories/reference/linux-study-clean/drivers/ufs/core/ufs-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/ufs/core/ufs-sysfs.c- Extension
.c- Size
- 63114 bytes
- Lines
- 2164
- Domain
- Driver Families
- Bucket
- drivers/ufs
- 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/err.hlinux/string.hlinux/bitfield.hlinux/unaligned.hlinux/string_choices.hufs/ufs.hufs/unipro.hufs-sysfs.hufshcd-priv.h
Detected Declarations
function ufs_sysfs_pm_lvl_storefunction rpm_lvl_showfunction rpm_lvl_storefunction rpm_target_dev_state_showfunction rpm_target_link_state_showfunction spm_lvl_showfunction spm_lvl_storefunction spm_target_dev_state_showfunction spm_target_link_state_showfunction ufshcd_ahit_to_usfunction ufshcd_us_to_ahitfunction ufshcd_read_hci_regfunction auto_hibern8_showfunction auto_hibern8_storefunction wb_on_showfunction wb_on_storefunction rtc_update_ms_showfunction rtc_update_ms_storefunction enable_wb_buf_flush_showfunction enable_wb_buf_flush_storefunction wb_flush_threshold_showfunction wb_flush_threshold_storefunction wb_resize_enable_storefunction pm_qos_enable_showfunction pm_qos_enable_storefunction critical_health_showfunction device_lvl_exception_count_showfunction device_lvl_exception_count_storefunction device_lvl_exception_id_showfunction dme_qos_notification_showfunction dme_qos_notification_storefunction clock_scaling_showfunction write_booster_showfunction version_showfunction product_id_showfunction man_id_showfunction monitor_enable_showfunction monitor_enable_storefunction monitor_chunk_size_showfunction monitor_chunk_size_storefunction read_total_sectors_showfunction read_total_busy_showfunction read_nr_requests_showfunction read_req_latency_avg_showfunction read_req_latency_max_showfunction read_req_latency_min_showfunction read_req_latency_sum_showfunction write_total_sectors_show
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
// Copyright (C) 2018 Western Digital Corporation
#include <linux/err.h>
#include <linux/string.h>
#include <linux/bitfield.h>
#include <linux/unaligned.h>
#include <linux/string_choices.h>
#include <ufs/ufs.h>
#include <ufs/unipro.h>
#include "ufs-sysfs.h"
#include "ufshcd-priv.h"
static const char *ufs_pa_pwr_mode_to_string(enum ufs_pa_pwr_mode mode)
{
switch (mode) {
case FAST_MODE: return "FAST_MODE";
case SLOW_MODE: return "SLOW_MODE";
case FASTAUTO_MODE: return "FASTAUTO_MODE";
case SLOWAUTO_MODE: return "SLOWAUTO_MODE";
default: return "UNKNOWN";
}
}
static const char *ufs_hs_gear_rate_to_string(enum ufs_hs_gear_rate rate)
{
switch (rate) {
case PA_HS_MODE_A: return "HS_RATE_A";
case PA_HS_MODE_B: return "HS_RATE_B";
default: return "UNKNOWN";
}
}
static const char *ufs_pwm_gear_to_string(enum ufs_pwm_gear_tag gear)
{
switch (gear) {
case UFS_PWM_G1: return "PWM_GEAR1";
case UFS_PWM_G2: return "PWM_GEAR2";
case UFS_PWM_G3: return "PWM_GEAR3";
case UFS_PWM_G4: return "PWM_GEAR4";
case UFS_PWM_G5: return "PWM_GEAR5";
case UFS_PWM_G6: return "PWM_GEAR6";
case UFS_PWM_G7: return "PWM_GEAR7";
default: return "UNKNOWN";
}
}
static const char *ufs_hs_gear_to_string(enum ufs_hs_gear_tag gear)
{
switch (gear) {
case UFS_HS_G1: return "HS_GEAR1";
case UFS_HS_G2: return "HS_GEAR2";
case UFS_HS_G3: return "HS_GEAR3";
case UFS_HS_G4: return "HS_GEAR4";
case UFS_HS_G5: return "HS_GEAR5";
default: return "UNKNOWN";
}
}
static const char *ufs_wb_resize_hint_to_string(enum wb_resize_hint hint)
{
switch (hint) {
case WB_RESIZE_HINT_KEEP:
return "keep";
case WB_RESIZE_HINT_DECREASE:
return "decrease";
case WB_RESIZE_HINT_INCREASE:
return "increase";
default:
return "unknown";
}
}
static const char *ufs_wb_resize_status_to_string(enum wb_resize_status status)
{
switch (status) {
case WB_RESIZE_STATUS_IDLE:
return "idle";
case WB_RESIZE_STATUS_IN_PROGRESS:
return "in_progress";
case WB_RESIZE_STATUS_COMPLETE_SUCCESS:
return "complete_success";
case WB_RESIZE_STATUS_GENERAL_FAILURE:
return "general_failure";
default:
return "unknown";
}
}
Annotation
- Immediate include surface: `linux/err.h`, `linux/string.h`, `linux/bitfield.h`, `linux/unaligned.h`, `linux/string_choices.h`, `ufs/ufs.h`, `ufs/unipro.h`, `ufs-sysfs.h`.
- Detected declarations: `function ufs_sysfs_pm_lvl_store`, `function rpm_lvl_show`, `function rpm_lvl_store`, `function rpm_target_dev_state_show`, `function rpm_target_link_state_show`, `function spm_lvl_show`, `function spm_lvl_store`, `function spm_target_dev_state_show`, `function spm_target_link_state_show`, `function ufshcd_ahit_to_us`.
- Atlas domain: Driver Families / drivers/ufs.
- 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.