drivers/rtc/rtc-isl12022.c
Source file repositories/reference/linux-study-clean/drivers/rtc/rtc-isl12022.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rtc/rtc-isl12022.c- Extension
.c- Size
- 16667 bytes
- Lines
- 626
- Domain
- Driver Families
- Bucket
- drivers/rtc
- 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 user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/bcd.hlinux/bitfield.hlinux/clk-provider.hlinux/err.hlinux/hwmon.hlinux/i2c.hlinux/module.hlinux/regmap.hlinux/rtc.hlinux/slab.hasm/byteorder.h
Detected Declarations
struct isl12022function isl12022_hwmon_is_visiblefunction isl12022_hwmon_read_tempfunction isl12022_hwmon_readfunction isl12022_hwmon_registerfunction isl12022_rtc_read_timefunction isl12022_rtc_set_timefunction isl12022_rtc_read_alarmfunction isl12022_rtc_set_alarmfunction isl12022_rtc_interruptfunction isl12022_rtc_alarm_irq_enablefunction isl12022_setup_irqfunction isl12022_rtc_ioctlfunction isl12022_register_clockfunction isl12022_set_trip_levelsfunction isl12022_probe
Annotated Snippet
struct isl12022 {
struct rtc_device *rtc;
struct regmap *regmap;
int irq;
bool irq_enabled;
};
static umode_t isl12022_hwmon_is_visible(const void *data,
enum hwmon_sensor_types type,
u32 attr, int channel)
{
if (type == hwmon_temp && attr == hwmon_temp_input)
return 0444;
return 0;
}
/*
* A user-initiated temperature conversion is not started by this function,
* so the temperature is updated once every ~60 seconds.
*/
static int isl12022_hwmon_read_temp(struct device *dev, long *mC)
{
struct regmap *regmap = dev_get_drvdata(dev);
int temp, ret;
__le16 buf;
ret = regmap_bulk_read(regmap, ISL12022_REG_TEMP_L, &buf, sizeof(buf));
if (ret)
return ret;
/*
* Temperature is represented as a 10-bit number, unit half-Kelvins.
*/
temp = le16_to_cpu(buf);
temp *= 500;
temp -= 273000;
*mC = temp;
return 0;
}
static int isl12022_hwmon_read(struct device *dev,
enum hwmon_sensor_types type,
u32 attr, int channel, long *val)
{
if (type == hwmon_temp && attr == hwmon_temp_input)
return isl12022_hwmon_read_temp(dev, val);
return -EOPNOTSUPP;
}
static const struct hwmon_channel_info * const isl12022_hwmon_info[] = {
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT),
NULL
};
static const struct hwmon_ops isl12022_hwmon_ops = {
.is_visible = isl12022_hwmon_is_visible,
.read = isl12022_hwmon_read,
};
static const struct hwmon_chip_info isl12022_hwmon_chip_info = {
.ops = &isl12022_hwmon_ops,
.info = isl12022_hwmon_info,
};
static void isl12022_hwmon_register(struct device *dev)
{
struct isl12022 *isl12022 = dev_get_drvdata(dev);
struct regmap *regmap = isl12022->regmap;
struct device *hwmon;
int ret;
if (!IS_REACHABLE(CONFIG_HWMON))
return;
ret = regmap_update_bits(regmap, ISL12022_REG_BETA,
ISL12022_BETA_TSE, ISL12022_BETA_TSE);
if (ret) {
dev_warn(dev, "unable to enable temperature sensor\n");
return;
}
hwmon = devm_hwmon_device_register_with_info(dev, "isl12022", regmap,
&isl12022_hwmon_chip_info,
NULL);
if (IS_ERR(hwmon))
dev_warn(dev, "unable to register hwmon device: %pe\n", hwmon);
}
Annotation
- Immediate include surface: `linux/bcd.h`, `linux/bitfield.h`, `linux/clk-provider.h`, `linux/err.h`, `linux/hwmon.h`, `linux/i2c.h`, `linux/module.h`, `linux/regmap.h`.
- Detected declarations: `struct isl12022`, `function isl12022_hwmon_is_visible`, `function isl12022_hwmon_read_temp`, `function isl12022_hwmon_read`, `function isl12022_hwmon_register`, `function isl12022_rtc_read_time`, `function isl12022_rtc_set_time`, `function isl12022_rtc_read_alarm`, `function isl12022_rtc_set_alarm`, `function isl12022_rtc_interrupt`.
- Atlas domain: Driver Families / drivers/rtc.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.