drivers/hwmon/mc34vr500.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/mc34vr500.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/mc34vr500.c- Extension
.c- Size
- 6116 bytes
- Lines
- 264
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/bits.hlinux/dev_printk.hlinux/device.hlinux/err.hlinux/errno.hlinux/hwmon.hlinux/i2c.hlinux/interrupt.hlinux/irqreturn.hlinux/module.hlinux/of.hlinux/regmap.h
Detected Declarations
struct mc34vr500_datafunction mc34vr500_process_interruptfunction mc34vr500_is_visiblefunction mc34vr500_alarm_readfunction mc34vr500_readfunction mc34vr500_probe
Annotated Snippet
struct mc34vr500_data {
struct device *hwmon_dev;
struct regmap *regmap;
};
static irqreturn_t mc34vr500_process_interrupt(int irq, void *userdata)
{
struct mc34vr500_data *data = (struct mc34vr500_data *)userdata;
unsigned int reg;
int ret;
ret = regmap_read(data->regmap, MC34VR500_INTSTAT0, ®);
if (ret < 0)
return IRQ_HANDLED;
if (reg) {
if (reg & LOWVINS_BIT)
hwmon_notify_event(data->hwmon_dev, hwmon_in,
hwmon_in_min_alarm, 0);
if (reg & THERM110S_BIT)
hwmon_notify_event(data->hwmon_dev, hwmon_temp,
hwmon_temp_max_alarm, 0);
if (reg & THERM120S_BIT)
hwmon_notify_event(data->hwmon_dev, hwmon_temp,
hwmon_temp_crit_alarm, 0);
if (reg & THERM130S_BIT)
hwmon_notify_event(data->hwmon_dev, hwmon_temp,
hwmon_temp_emergency_alarm, 0);
/* write 1 to clear */
regmap_write(data->regmap, MC34VR500_INTSTAT0, LOWVINS_BIT |
THERM110S_BIT | THERM120S_BIT | THERM130S_BIT);
}
return IRQ_HANDLED;
}
static umode_t mc34vr500_is_visible(const void *data,
enum hwmon_sensor_types type,
u32 attr, int channel)
{
switch (attr) {
case hwmon_in_min_alarm:
case hwmon_temp_max_alarm:
case hwmon_temp_crit_alarm:
case hwmon_temp_emergency_alarm:
return 0444;
default:
break;
}
return 0;
}
static int mc34vr500_alarm_read(struct mc34vr500_data *data, int index,
long *val)
{
unsigned int reg;
int ret;
ret = regmap_read(data->regmap, MC34VR500_INTSENSE0, ®);
if (ret < 0)
return ret;
*val = !!(reg & index);
return 0;
}
static int mc34vr500_read(struct device *dev, enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
struct mc34vr500_data *data = dev_get_drvdata(dev);
switch (type) {
case hwmon_in:
switch (attr) {
case hwmon_in_min_alarm:
return mc34vr500_alarm_read(data, LOWVINS_BIT, val);
default:
return -EOPNOTSUPP;
}
case hwmon_temp:
switch (attr) {
case hwmon_temp_max_alarm:
return mc34vr500_alarm_read(data, THERM110S_BIT, val);
case hwmon_temp_crit_alarm:
Annotation
- Immediate include surface: `linux/bits.h`, `linux/dev_printk.h`, `linux/device.h`, `linux/err.h`, `linux/errno.h`, `linux/hwmon.h`, `linux/i2c.h`, `linux/interrupt.h`.
- Detected declarations: `struct mc34vr500_data`, `function mc34vr500_process_interrupt`, `function mc34vr500_is_visible`, `function mc34vr500_alarm_read`, `function mc34vr500_read`, `function mc34vr500_probe`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.