drivers/hwmon/ntc_thermistor.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/ntc_thermistor.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/ntc_thermistor.c- Extension
.c- Size
- 21773 bytes
- Lines
- 752
- 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/slab.hlinux/module.hlinux/math64.hlinux/mod_devicetable.hlinux/platform_device.hlinux/property.hlinux/err.hlinux/fixp-arith.hlinux/iio/consumer.hlinux/hwmon.h
Detected Declarations
struct ntc_compensationstruct ntc_typestruct ntc_dataenum ntc_thermistor_typefunction ntc_adc_iio_readfunction div64_u64_safefunction get_ohm_of_thermistorfunction lookup_compfunction get_temp_mcfunction ntc_thermistor_get_ohmfunction ntc_readfunction ntc_is_visiblefunction ntc_thermistor_parse_propsfunction ntc_thermistor_probe
Annotated Snippet
struct ntc_compensation {
int temp_c;
unsigned int ohm;
};
/*
* Used as index in a zero-terminated array, holes not allowed so
* that NTC_LAST is the first empty array entry.
*/
enum {
NTC_B57330V2103,
NTC_B57891S0103,
NTC_NCP03WB473,
NTC_NCP03WF104,
NTC_NCP15WB473,
NTC_NCP15WL333,
NTC_NCP15XH103,
NTC_NCP18WB473,
NTC_NCP21WB473,
NTC_SSG1404001221,
NTC_NCP18WM474,
NTC_LAST,
};
static const struct platform_device_id ntc_thermistor_id[] = {
[NTC_B57330V2103] = { .name = "b57330v2103", .driver_data = TYPE_B57330V2103 },
[NTC_B57891S0103] = { .name = "b57891s0103", .driver_data = TYPE_B57891S0103 },
[NTC_NCP03WB473] = { .name = "ncp03wb473", .driver_data = TYPE_NCPXXWB473 },
[NTC_NCP03WF104] = { .name = "ncp03wf104", .driver_data = TYPE_NCPXXWF104 },
[NTC_NCP15WB473] = { .name = "ncp15wb473", .driver_data = TYPE_NCPXXWB473 },
[NTC_NCP15WL333] = { .name = "ncp15wl333", .driver_data = TYPE_NCPXXWL333 },
[NTC_NCP15XH103] = { .name = "ncp15xh103", .driver_data = TYPE_NCPXXXH103 },
[NTC_NCP18WB473] = { .name = "ncp18wb473", .driver_data = TYPE_NCPXXWB473 },
[NTC_NCP21WB473] = { .name = "ncp21wb473", .driver_data = TYPE_NCPXXWB473 },
[NTC_SSG1404001221] = { .name = "ssg1404_001221", .driver_data = TYPE_NCPXXWB473 },
[NTC_NCP18WM474] = { .name = "ncp18wm474", .driver_data = TYPE_NCPXXWM474 },
[NTC_LAST] = { }
};
MODULE_DEVICE_TABLE(platform, ntc_thermistor_id);
/*
* A compensation table should be sorted by the values of .ohm
* in descending order.
* The following compensation tables are from the specification of Murata NTC
* Thermistors Datasheet
*/
static const struct ntc_compensation ncpXXwb473[] = {
{ .temp_c = -40, .ohm = 1747920 },
{ .temp_c = -35, .ohm = 1245428 },
{ .temp_c = -30, .ohm = 898485 },
{ .temp_c = -25, .ohm = 655802 },
{ .temp_c = -20, .ohm = 483954 },
{ .temp_c = -15, .ohm = 360850 },
{ .temp_c = -10, .ohm = 271697 },
{ .temp_c = -5, .ohm = 206463 },
{ .temp_c = 0, .ohm = 158214 },
{ .temp_c = 5, .ohm = 122259 },
{ .temp_c = 10, .ohm = 95227 },
{ .temp_c = 15, .ohm = 74730 },
{ .temp_c = 20, .ohm = 59065 },
{ .temp_c = 25, .ohm = 47000 },
{ .temp_c = 30, .ohm = 37643 },
{ .temp_c = 35, .ohm = 30334 },
{ .temp_c = 40, .ohm = 24591 },
{ .temp_c = 45, .ohm = 20048 },
{ .temp_c = 50, .ohm = 16433 },
{ .temp_c = 55, .ohm = 13539 },
{ .temp_c = 60, .ohm = 11209 },
{ .temp_c = 65, .ohm = 9328 },
{ .temp_c = 70, .ohm = 7798 },
{ .temp_c = 75, .ohm = 6544 },
{ .temp_c = 80, .ohm = 5518 },
{ .temp_c = 85, .ohm = 4674 },
{ .temp_c = 90, .ohm = 3972 },
{ .temp_c = 95, .ohm = 3388 },
{ .temp_c = 100, .ohm = 2902 },
{ .temp_c = 105, .ohm = 2494 },
{ .temp_c = 110, .ohm = 2150 },
{ .temp_c = 115, .ohm = 1860 },
{ .temp_c = 120, .ohm = 1615 },
{ .temp_c = 125, .ohm = 1406 },
};
static const struct ntc_compensation ncpXXwl333[] = {
{ .temp_c = -40, .ohm = 1610154 },
{ .temp_c = -35, .ohm = 1130850 },
{ .temp_c = -30, .ohm = 802609 },
{ .temp_c = -25, .ohm = 575385 },
{ .temp_c = -20, .ohm = 416464 },
{ .temp_c = -15, .ohm = 304219 },
{ .temp_c = -10, .ohm = 224193 },
Annotation
- Immediate include surface: `linux/slab.h`, `linux/module.h`, `linux/math64.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/property.h`, `linux/err.h`, `linux/fixp-arith.h`.
- Detected declarations: `struct ntc_compensation`, `struct ntc_type`, `struct ntc_data`, `enum ntc_thermistor_type`, `function ntc_adc_iio_read`, `function div64_u64_safe`, `function get_ohm_of_thermistor`, `function lookup_comp`, `function get_temp_mc`, `function ntc_thermistor_get_ohm`.
- 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.