drivers/hwmon/ltc2947-core.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/ltc2947-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/ltc2947-core.c- Extension
.c- Size
- 29419 bytes
- Lines
- 1142
- Domain
- Driver Families
- Bucket
- drivers/hwmon
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/bits.hlinux/clk.hlinux/device.hlinux/hwmon.hlinux/module.hlinux/math64.hlinux/mod_devicetable.hlinux/property.hlinux/regmap.hltc2947.h
Detected Declarations
struct ltc2947_datafunction __ltc2947_val_read16function __ltc2947_val_read24function __ltc2947_val_read64function ltc2947_val_readfunction __ltc2947_val_write64function __ltc2947_val_write16function ltc2947_val_writefunction ltc2947_reset_historyfunction ltc2947_alarm_readfunction ltc2947_read_tempfunction ltc2947_read_powerfunction ltc2947_read_currfunction ltc2947_read_infunction ltc2947_read_energyfunction ltc2947_readfunction ltc2947_write_tempfunction ltc2947_write_powerfunction ltc2947_write_currfunction ltc2947_write_infunction ltc2947_writefunction ltc2947_read_labelsfunction ltc2947_in_is_visiblefunction ltc2947_curr_is_visiblefunction ltc2947_power_is_visiblefunction ltc2947_temp_is_visiblefunction ltc2947_is_visiblefunction ltc2947_setupfunction ltc2947_core_probefunction ltc2947_resumefunction ltc2947_suspendexport ltc2947_core_probeexport ltc2947_of_match
Annotated Snippet
struct ltc2947_data {
struct regmap *map;
struct device *dev;
u32 lsb_energy;
bool gpio_out;
};
static int __ltc2947_val_read16(const struct ltc2947_data *st, const u8 reg,
u64 *val)
{
__be16 __val = 0;
int ret;
ret = regmap_bulk_read(st->map, reg, &__val, 2);
if (ret)
return ret;
*val = be16_to_cpu(__val);
return 0;
}
static int __ltc2947_val_read24(const struct ltc2947_data *st, const u8 reg,
u64 *val)
{
__be32 __val = 0;
int ret;
ret = regmap_bulk_read(st->map, reg, &__val, 3);
if (ret)
return ret;
*val = be32_to_cpu(__val) >> 8;
return 0;
}
static int __ltc2947_val_read64(const struct ltc2947_data *st, const u8 reg,
u64 *val)
{
__be64 __val = 0;
int ret;
ret = regmap_bulk_read(st->map, reg, &__val, 6);
if (ret)
return ret;
*val = be64_to_cpu(__val) >> 16;
return 0;
}
static int ltc2947_val_read(struct ltc2947_data *st, const u8 reg,
const u8 page, const size_t size, s64 *val)
{
int ret;
u64 __val = 0;
ret = regmap_write(st->map, LTC2947_REG_PAGE_CTRL, page);
if (ret)
return ret;
dev_dbg(st->dev, "Read val, reg:%02X, p:%d sz:%zu\n", reg, page,
size);
switch (size) {
case 2:
ret = __ltc2947_val_read16(st, reg, &__val);
break;
case 3:
ret = __ltc2947_val_read24(st, reg, &__val);
break;
case 6:
ret = __ltc2947_val_read64(st, reg, &__val);
break;
default:
ret = -EINVAL;
break;
}
if (ret)
return ret;
*val = sign_extend64(__val, (8 * size) - 1);
dev_dbg(st->dev, "Got s:%lld, u:%016llX\n", *val, __val);
return 0;
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bits.h`, `linux/clk.h`, `linux/device.h`, `linux/hwmon.h`, `linux/module.h`, `linux/math64.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct ltc2947_data`, `function __ltc2947_val_read16`, `function __ltc2947_val_read24`, `function __ltc2947_val_read64`, `function ltc2947_val_read`, `function __ltc2947_val_write64`, `function __ltc2947_val_write16`, `function ltc2947_val_write`, `function ltc2947_reset_history`, `function ltc2947_alarm_read`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: integration 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.