drivers/hwmon/pmbus/hac300s.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/pmbus/hac300s.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/pmbus/hac300s.c- Extension
.c- Size
- 3648 bytes
- Lines
- 135
- 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/bitfield.hlinux/bits.hlinux/err.hlinux/i2c.hlinux/init.hlinux/kernel.hlinux/module.hlinux/pmbus.hpmbus.h
Detected Declarations
struct hac300s_datafunction hac300s_read_byte_datafunction hac300s_read_word_datafunction hac300s_probe
Annotated Snippet
struct hac300s_data {
struct pmbus_driver_info info;
s8 exponent;
};
static int hac300s_read_byte_data(struct i2c_client *client, int page, int reg)
{
const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
struct hac300s_data *data = to_hac300s_data(info);
if (reg == PMBUS_VOUT_MODE)
return data->exponent;
return -ENODATA;
}
static int hac300s_read_word_data(struct i2c_client *client, int page,
int phase, int reg)
{
int rv;
switch (reg) {
case PMBUS_VOUT_OV_WARN_LIMIT:
case PMBUS_VOUT_UV_WARN_LIMIT:
case PMBUS_VOUT_OV_FAULT_LIMIT:
case PMBUS_VOUT_UV_FAULT_LIMIT:
case PMBUS_MFR_VOUT_MAX:
case PMBUS_MFR_VOUT_MIN:
case PMBUS_READ_VOUT:
rv = pmbus_read_word_data(client, page, phase, reg);
if (rv < 0)
return rv;
return FIELD_GET(LINEAR11_MANTISSA_MASK, rv);
default:
return -ENODATA;
}
}
static struct pmbus_driver_info hac300s_info = {
.pages = 1,
.func[0] = PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 | \
PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | \
PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | \
PMBUS_HAVE_POUT | PMBUS_HAVE_STATUS_TEMP,
.read_byte_data = hac300s_read_byte_data,
.read_word_data = hac300s_read_word_data,
.format[PSC_VOLTAGE_OUT] = linear,
};
static struct pmbus_platform_data hac300s_pdata = {
.flags = PMBUS_NO_CAPABILITY,
};
static int hac300s_probe(struct i2c_client *client)
{
struct hac300s_data *data;
int rv;
data = devm_kzalloc(&client->dev, sizeof(struct hac300s_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_READ_BYTE_DATA |
I2C_FUNC_SMBUS_READ_WORD_DATA))
return -ENODEV;
rv = i2c_smbus_read_word_data(client, PMBUS_READ_VOUT);
if (rv < 0)
return dev_err_probe(&client->dev, rv, "Failed to read vout_mode\n");
data->exponent = FIELD_GET(LINEAR11_EXPONENT_MASK, rv);
data->info = hac300s_info;
client->dev.platform_data = &hac300s_pdata;
return pmbus_do_probe(client, &data->info);
}
static const struct of_device_id hac300s_of_match[] = {
{ .compatible = "hitron,hac300s" },
{}
};
MODULE_DEVICE_TABLE(of, hac300s_of_match);
static const struct i2c_device_id hac300s_id[] = {
{ .name = "hac300s" },
{ }
};
MODULE_DEVICE_TABLE(i2c, hac300s_id);
static struct i2c_driver hac300s_driver = {
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/err.h`, `linux/i2c.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/pmbus.h`.
- Detected declarations: `struct hac300s_data`, `function hac300s_read_byte_data`, `function hac300s_read_word_data`, `function hac300s_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.