drivers/hwmon/adt7410.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/adt7410.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/adt7410.c- Extension
.c- Size
- 2730 bytes
- Lines
- 121
- 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/module.hlinux/mod_devicetable.hlinux/init.hlinux/i2c.hlinux/regmap.hadt7x10.h
Detected Declarations
function adt7410_regmap_is_volatilefunction adt7410_reg_readfunction adt7410_reg_writefunction adt7410_i2c_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* ADT7410/ADT7420 digital temperature sensor driver
*
* Copyright 2012-2013 Analog Devices Inc.
* Author: Lars-Peter Clausen <lars@metafoo.de>
*/
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include "adt7x10.h"
static bool adt7410_regmap_is_volatile(struct device *dev, unsigned int reg)
{
switch (reg) {
case ADT7X10_TEMPERATURE:
case ADT7X10_STATUS:
return true;
default:
return false;
}
}
static int adt7410_reg_read(void *context, unsigned int reg, unsigned int *val)
{
struct i2c_client *client = context;
int regval;
switch (reg) {
case ADT7X10_TEMPERATURE:
case ADT7X10_T_ALARM_HIGH:
case ADT7X10_T_ALARM_LOW:
case ADT7X10_T_CRIT:
regval = i2c_smbus_read_word_swapped(client, reg);
break;
default:
regval = i2c_smbus_read_byte_data(client, reg);
break;
}
if (regval < 0)
return regval;
*val = regval;
return 0;
}
static int adt7410_reg_write(void *context, unsigned int reg, unsigned int val)
{
struct i2c_client *client = context;
int ret;
switch (reg) {
case ADT7X10_TEMPERATURE:
case ADT7X10_T_ALARM_HIGH:
case ADT7X10_T_ALARM_LOW:
case ADT7X10_T_CRIT:
ret = i2c_smbus_write_word_swapped(client, reg, val);
break;
default:
ret = i2c_smbus_write_byte_data(client, reg, val);
break;
}
return ret;
}
static const struct regmap_config adt7410_regmap_config = {
.reg_bits = 8,
.val_bits = 16,
.max_register = ADT7X10_ID,
.cache_type = REGCACHE_MAPLE,
.volatile_reg = adt7410_regmap_is_volatile,
.reg_read = adt7410_reg_read,
.reg_write = adt7410_reg_write,
};
static int adt7410_i2c_probe(struct i2c_client *client)
{
struct regmap *regmap;
regmap = devm_regmap_init(&client->dev, NULL, client,
&adt7410_regmap_config);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
return adt7x10_probe(&client->dev, client->name, client->irq, regmap);
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/mod_devicetable.h`, `linux/init.h`, `linux/i2c.h`, `linux/regmap.h`, `adt7x10.h`.
- Detected declarations: `function adt7410_regmap_is_volatile`, `function adt7410_reg_read`, `function adt7410_reg_write`, `function adt7410_i2c_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.