drivers/hwmon/mc33xs2410_hwmon.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/mc33xs2410_hwmon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/mc33xs2410_hwmon.c- Extension
.c- Size
- 4539 bytes
- Lines
- 179
- 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/auxiliary_bus.hlinux/bitfield.hlinux/bitops.hlinux/hwmon.hlinux/mc33xs2410.hlinux/module.h
Detected Declarations
function mc33xs2410_hwmon_is_visiblefunction mc33xs2410_hwmon_readfunction mc33xs2410_hwmon_writefunction mc33xs2410_read_stringfunction mc33xs2410_hwmon_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2025 Liebherr-Electronics and Drives GmbH
*/
#include <linux/auxiliary_bus.h>
#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/hwmon.h>
#include <linux/mc33xs2410.h>
#include <linux/module.h>
/* ctrl registers */
#define MC33XS2410_TEMP_WT 0x29
#define MC33XS2410_TEMP_WT_MASK GENMASK(7, 0)
/* diag registers */
/* chan in { 1 ... 4 } */
#define MC33XS2410_OUT_STA(chan) (0x02 + (chan) - 1)
#define MC33XS2410_OUT_STA_OTW BIT(8)
#define MC33XS2410_TS_TEMP_DIE 0x26
#define MC33XS2410_TS_TEMP_MASK GENMASK(9, 0)
/* chan in { 1 ... 4 } */
#define MC33XS2410_TS_TEMP(chan) (0x2f + (chan) - 1)
static const struct hwmon_channel_info * const mc33xs2410_hwmon_info[] = {
HWMON_CHANNEL_INFO(temp,
HWMON_T_LABEL | HWMON_T_INPUT,
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX |
HWMON_T_ALARM,
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX |
HWMON_T_ALARM,
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX |
HWMON_T_ALARM,
HWMON_T_LABEL | HWMON_T_INPUT | HWMON_T_MAX |
HWMON_T_ALARM),
NULL,
};
static umode_t mc33xs2410_hwmon_is_visible(const void *data,
enum hwmon_sensor_types type,
u32 attr, int channel)
{
switch (attr) {
case hwmon_temp_input:
case hwmon_temp_alarm:
case hwmon_temp_label:
return 0444;
case hwmon_temp_max:
return 0644;
default:
return 0;
}
}
static int mc33xs2410_hwmon_read(struct device *dev,
enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
struct spi_device *spi = dev_get_drvdata(dev);
u16 reg_val;
int ret;
u8 reg;
switch (attr) {
case hwmon_temp_input:
reg = (channel == 0) ? MC33XS2410_TS_TEMP_DIE :
MC33XS2410_TS_TEMP(channel);
ret = mc33xs2410_read_reg_diag(spi, reg, ®_val);
if (ret < 0)
return ret;
/* LSB is 0.25 degree celsius */
*val = FIELD_GET(MC33XS2410_TS_TEMP_MASK, reg_val) * 250 - 40000;
return 0;
case hwmon_temp_alarm:
ret = mc33xs2410_read_reg_diag(spi, MC33XS2410_OUT_STA(channel),
®_val);
if (ret < 0)
return ret;
*val = FIELD_GET(MC33XS2410_OUT_STA_OTW, reg_val);
return 0;
case hwmon_temp_max:
ret = mc33xs2410_read_reg_ctrl(spi, MC33XS2410_TEMP_WT, ®_val);
if (ret < 0)
Annotation
- Immediate include surface: `linux/auxiliary_bus.h`, `linux/bitfield.h`, `linux/bitops.h`, `linux/hwmon.h`, `linux/mc33xs2410.h`, `linux/module.h`.
- Detected declarations: `function mc33xs2410_hwmon_is_visible`, `function mc33xs2410_hwmon_read`, `function mc33xs2410_hwmon_write`, `function mc33xs2410_read_string`, `function mc33xs2410_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.