drivers/hwmon/max77705-hwmon.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/max77705-hwmon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/max77705-hwmon.c- Extension
.c- Size
- 4663 bytes
- Lines
- 222
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/hwmon-sysfs.hlinux/hwmon.hlinux/kernel.hlinux/mfd/max77705-private.hlinux/platform_device.hlinux/regmap.h
Detected Declarations
struct channel_descfunction max77705_read_and_convertfunction max77705_is_visiblefunction max77705_read_stringfunction max77705_readfunction max77705_hwmon_probe
Annotated Snippet
struct channel_desc {
u8 reg;
u8 avg_reg;
const char *const label;
// register resolution. nano Volts for voltage, nano Amperes for current
u32 resolution;
};
static const struct channel_desc current_channel_desc[] = {
{
.reg = IIN_REG,
.label = "IIN_REG",
.resolution = 125000
},
{
.reg = ISYS_REG,
.avg_reg = AVGISYS_REG,
.label = "ISYS_REG",
.resolution = 312500
}
};
static const struct channel_desc voltage_channel_desc[] = {
{
.reg = VBYP_REG,
.label = "VBYP_REG",
.resolution = 427246
},
{
.reg = VSYS_REG,
.label = "VSYS_REG",
.resolution = 156250
}
};
static int max77705_read_and_convert(struct regmap *regmap, u8 reg, u32 res,
bool is_signed, long *val)
{
int ret;
u32 regval;
ret = regmap_read(regmap, reg, ®val);
if (ret < 0)
return ret;
if (is_signed)
*val = mult_frac((long)sign_extend32(regval, 15), res, 1000000);
else
*val = mult_frac((long)regval, res, 1000000);
return 0;
}
static umode_t max77705_is_visible(const void *data,
enum hwmon_sensor_types type,
u32 attr, int channel)
{
switch (type) {
case hwmon_in:
switch (attr) {
case hwmon_in_input:
case hwmon_in_label:
return 0444;
default:
break;
}
break;
case hwmon_curr:
switch (attr) {
case hwmon_curr_input:
case hwmon_in_label:
return 0444;
case hwmon_curr_average:
if (current_channel_desc[channel].avg_reg)
return 0444;
break;
default:
break;
}
break;
default:
break;
}
return 0;
}
static int max77705_read_string(struct device *dev, enum hwmon_sensor_types type, u32 attr,
int channel, const char **buf)
{
switch (type) {
Annotation
- Immediate include surface: `linux/err.h`, `linux/hwmon-sysfs.h`, `linux/hwmon.h`, `linux/kernel.h`, `linux/mfd/max77705-private.h`, `linux/platform_device.h`, `linux/regmap.h`.
- Detected declarations: `struct channel_desc`, `function max77705_read_and_convert`, `function max77705_is_visible`, `function max77705_read_string`, `function max77705_read`, `function max77705_hwmon_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.