sound/hda/common/sysfs.c
Source file repositories/reference/linux-study-clean/sound/hda/common/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
sound/hda/common/sysfs.c- Extension
.c- Size
- 18486 bytes
- Lines
- 766
- Domain
- Driver Families
- Bucket
- sound/hda
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/init.hlinux/slab.hlinux/compat.hlinux/mutex.hlinux/ctype.hlinux/string.hlinux/export.hsound/core.hsound/hda_codec.hhda_local.hsound/hda_hwdep.hsound/minors.h
Detected Declarations
struct hda_hintstruct hda_patch_itemfunction power_on_acct_showfunction power_off_acct_showfunction pin_configs_showfunction init_pin_configs_showfunction driver_pin_configs_showfunction clear_codecfunction reconfig_codecfunction init_verbs_showfunction parse_init_verbsfunction init_verbs_storefunction hints_showfunction snd_array_for_eachfunction remove_trail_spacesfunction parse_hintsfunction hints_storefunction user_pin_configs_showfunction parse_user_pin_configsfunction user_pin_configs_storefunction snd_hda_get_bool_hintfunction snd_hda_get_int_hintfunction strmatchfunction parse_codec_modefunction list_for_each_codecfunction helperfunction parse_verb_modefunction parse_hint_modefunction parse_model_modefunction parse_chip_name_modefunction parse_line_modefunction get_line_from_fwfunction snd_hda_load_patchfunction snd_hda_sysfs_initfunction snd_hda_sysfs_clearexport snd_hda_get_hintexport snd_hda_get_bool_hintexport snd_hda_get_int_hintexport snd_hda_load_patch
Annotated Snippet
struct hda_hint {
const char *key;
const char *val; /* contained in the same alloc as key */
};
static ssize_t power_on_acct_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hda_codec *codec = dev_get_drvdata(dev);
snd_hda_update_power_acct(codec);
return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_on_acct));
}
static ssize_t power_off_acct_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hda_codec *codec = dev_get_drvdata(dev);
snd_hda_update_power_acct(codec);
return sysfs_emit(buf, "%u\n", jiffies_to_msecs(codec->power_off_acct));
}
static DEVICE_ATTR_RO(power_on_acct);
static DEVICE_ATTR_RO(power_off_acct);
#define CODEC_INFO_SHOW(type, field) \
static ssize_t type##_show(struct device *dev, \
struct device_attribute *attr, \
char *buf) \
{ \
struct hda_codec *codec = dev_get_drvdata(dev); \
return sysfs_emit(buf, "0x%x\n", codec->field); \
}
#define CODEC_INFO_STR_SHOW(type, field) \
static ssize_t type##_show(struct device *dev, \
struct device_attribute *attr, \
char *buf) \
{ \
struct hda_codec *codec = dev_get_drvdata(dev); \
return sysfs_emit(buf, "%s\n", \
codec->field ? codec->field : ""); \
}
CODEC_INFO_SHOW(vendor_id, core.vendor_id);
CODEC_INFO_SHOW(subsystem_id, core.subsystem_id);
CODEC_INFO_SHOW(revision_id, core.revision_id);
CODEC_INFO_SHOW(afg, core.afg);
CODEC_INFO_SHOW(mfg, core.mfg);
CODEC_INFO_STR_SHOW(vendor_name, core.vendor_name);
CODEC_INFO_STR_SHOW(chip_name, core.chip_name);
CODEC_INFO_STR_SHOW(modelname, modelname);
static ssize_t pin_configs_show(struct hda_codec *codec,
struct snd_array *list,
char *buf)
{
const struct hda_pincfg *pin;
int i, len = 0;
guard(mutex)(&codec->user_mutex);
snd_array_for_each(list, i, pin) {
len += sysfs_emit_at(buf, len, "0x%02x 0x%08x\n",
pin->nid, pin->cfg);
}
return len;
}
static ssize_t init_pin_configs_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hda_codec *codec = dev_get_drvdata(dev);
return pin_configs_show(codec, &codec->init_pins, buf);
}
static ssize_t driver_pin_configs_show(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct hda_codec *codec = dev_get_drvdata(dev);
return pin_configs_show(codec, &codec->driver_pins, buf);
}
#ifdef CONFIG_SND_HDA_RECONFIG
/*
* sysfs interface
*/
Annotation
- Immediate include surface: `linux/init.h`, `linux/slab.h`, `linux/compat.h`, `linux/mutex.h`, `linux/ctype.h`, `linux/string.h`, `linux/export.h`, `sound/core.h`.
- Detected declarations: `struct hda_hint`, `struct hda_patch_item`, `function power_on_acct_show`, `function power_off_acct_show`, `function pin_configs_show`, `function init_pin_configs_show`, `function driver_pin_configs_show`, `function clear_codec`, `function reconfig_codec`, `function init_verbs_show`.
- Atlas domain: Driver Families / sound/hda.
- 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.