drivers/hwmon/pmbus/dps920ab.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/dps920ab.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/dps920ab.c- Extension
.c- Size
- 5104 bytes
- Lines
- 214
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- 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/i2c.hlinux/module.hlinux/of.hpmbus.h
Detected Declarations
struct dps920ab_datafunction dps920ab_read_word_datafunction dps920ab_write_word_datafunction dps920ab_mfr_id_showfunction dps920ab_mfr_model_showfunction dps920ab_init_debugfsfunction dps920ab_probe
Annotated Snippet
struct dps920ab_data {
char *mfr_model;
char *mfr_id;
};
static int dps920ab_read_word_data(struct i2c_client *client, int page, int phase, int reg)
{
/*
* This masks commands which are not supported.
* PSU advertises that all features are supported,
* in reality that unfortunately is not true.
* So enable only those that the datasheet confirms.
*/
switch (reg) {
case PMBUS_FAN_COMMAND_1:
case PMBUS_IOUT_OC_WARN_LIMIT:
case PMBUS_STATUS_WORD:
case PMBUS_READ_VIN:
case PMBUS_READ_IIN:
case PMBUS_READ_VOUT:
case PMBUS_READ_IOUT:
case PMBUS_READ_TEMPERATURE_1:
case PMBUS_READ_TEMPERATURE_2:
case PMBUS_READ_TEMPERATURE_3:
case PMBUS_READ_FAN_SPEED_1:
case PMBUS_READ_POUT:
case PMBUS_READ_PIN:
case PMBUS_MFR_VOUT_MIN:
case PMBUS_MFR_VOUT_MAX:
case PMBUS_MFR_IOUT_MAX:
case PMBUS_MFR_POUT_MAX:
return pmbus_read_word_data(client, page, phase, reg);
default:
return -ENXIO;
}
}
static int dps920ab_write_word_data(struct i2c_client *client, int page, int reg,
u16 word)
{
/*
* This masks commands which are not supported.
* PSU only has one R/W register and that is
* for the fan.
*/
switch (reg) {
case PMBUS_FAN_COMMAND_1:
return pmbus_write_word_data(client, page, reg, word);
default:
return -EACCES;
}
}
static struct pmbus_driver_info dps920ab_info = {
.pages = 1,
.format[PSC_VOLTAGE_IN] = linear,
.format[PSC_VOLTAGE_OUT] = linear,
.format[PSC_CURRENT_IN] = linear,
.format[PSC_CURRENT_OUT] = linear,
.format[PSC_POWER] = linear,
.format[PSC_FAN] = linear,
.format[PSC_TEMPERATURE] = linear,
.func[0] =
PMBUS_HAVE_VIN | PMBUS_HAVE_IIN | PMBUS_HAVE_PIN |
PMBUS_HAVE_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_POUT |
PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | PMBUS_HAVE_TEMP3 |
PMBUS_HAVE_FAN12 | PMBUS_HAVE_STATUS_FAN12 |
PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_STATUS_IOUT |
PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP,
.read_word_data = dps920ab_read_word_data,
.write_word_data = dps920ab_write_word_data,
};
static int dps920ab_mfr_id_show(struct seq_file *s, void *data)
{
struct dps920ab_data *priv = s->private;
seq_printf(s, "%s\n", priv->mfr_id);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(dps920ab_mfr_id);
static int dps920ab_mfr_model_show(struct seq_file *s, void *data)
{
struct dps920ab_data *priv = s->private;
Annotation
- Immediate include surface: `linux/debugfs.h`, `linux/i2c.h`, `linux/module.h`, `linux/of.h`, `pmbus.h`.
- Detected declarations: `struct dps920ab_data`, `function dps920ab_read_word_data`, `function dps920ab_write_word_data`, `function dps920ab_mfr_id_show`, `function dps920ab_mfr_model_show`, `function dps920ab_init_debugfs`, `function dps920ab_probe`.
- Atlas domain: Driver Families / drivers/hwmon.
- 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.