drivers/hwmon/nct6775-core.c
Source file repositories/reference/linux-study-clean/drivers/hwmon/nct6775-core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/hwmon/nct6775-core.c- Extension
.c- Size
- 129305 bytes
- Lines
- 4403
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/module.hlinux/init.hlinux/slab.hlinux/jiffies.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/err.hlinux/mutex.hlinux/bitops.hlinux/nospec.hlinux/regmap.hlm75.hnct6775.h
Detected Declarations
struct sensor_device_templatestruct sensor_device_attr_ustruct sensor_template_groupfunction reg_to_pwm_enablefunction pwm_enable_to_regfunction step_time_from_regfunction step_time_to_regfunction fan_from_reg8function fan_from_reg13function fan_from_reg16function fan_from_reg_rpmfunction fan_to_regfunction div_from_regfunction in_from_regfunction in_to_regfunction tsi_temp_from_regfunction nct6775_add_template_attr_groupfunction nct6775_reg_is_word_sizedfunction nct6775_read_tempfunction nct6775_write_fan_divfunction nct6775_write_fan_div_commonfunction nct6775_update_fan_divfunction nct6775_update_fan_div_commonfunction nct6775_init_fan_divfunction nct6775_init_fan_commonfunction nct6775_select_fan_divfunction nct6775_update_pwmfunction nct6775_update_pwm_limitsfunction show_in_regfunction store_in_regfunction nct6775_show_alarmfunction find_temp_sourcefunction show_temp_alarmfunction nct6775_show_beepfunction nct6775_store_beepfunction show_temp_beepfunction store_temp_beepfunction nct6775_in_is_visiblefunction show_fanfunction show_fan_minfunction show_fan_divfunction store_fan_minfunction dividerfunction show_fan_pulsesfunction store_fan_pulsesfunction nct6775_fan_is_visiblefunction show_temp_labelfunction show_temp
Annotated Snippet
struct sensor_device_template {
struct device_attribute dev_attr;
union {
struct {
u8 nr;
u8 index;
} s;
int index;
} u;
bool s2; /* true if both index and nr are used */
};
struct sensor_device_attr_u {
union {
struct sensor_device_attribute a1;
struct sensor_device_attribute_2 a2;
} u;
char name[32];
};
#define __TEMPLATE_ATTR(_template, _mode, _show, _store) { \
.attr = {.name = _template, .mode = _mode }, \
.show = _show, \
.store = _store, \
}
#define SENSOR_DEVICE_TEMPLATE(_template, _mode, _show, _store, _index) \
{ .dev_attr = __TEMPLATE_ATTR(_template, _mode, _show, _store), \
.u.index = _index, \
.s2 = false }
#define SENSOR_DEVICE_TEMPLATE_2(_template, _mode, _show, _store, \
_nr, _index) \
{ .dev_attr = __TEMPLATE_ATTR(_template, _mode, _show, _store), \
.u.s.index = _index, \
.u.s.nr = _nr, \
.s2 = true }
#define SENSOR_TEMPLATE(_name, _template, _mode, _show, _store, _index) \
static struct sensor_device_template sensor_dev_template_##_name \
= SENSOR_DEVICE_TEMPLATE(_template, _mode, _show, _store, \
_index)
#define SENSOR_TEMPLATE_2(_name, _template, _mode, _show, _store, \
_nr, _index) \
static struct sensor_device_template sensor_dev_template_##_name \
= SENSOR_DEVICE_TEMPLATE_2(_template, _mode, _show, _store, \
_nr, _index)
struct sensor_template_group {
struct sensor_device_template **templates;
umode_t (*is_visible)(struct kobject *, struct attribute *, int);
int base;
};
static int nct6775_add_template_attr_group(struct device *dev, struct nct6775_data *data,
const struct sensor_template_group *tg, int repeat)
{
struct attribute_group *group;
struct sensor_device_attr_u *su;
struct sensor_device_attribute *a;
struct sensor_device_attribute_2 *a2;
struct attribute **attrs;
struct sensor_device_template **t;
int i, count;
if (repeat <= 0)
return -EINVAL;
t = tg->templates;
for (count = 0; *t; t++, count++)
;
if (count == 0)
return -EINVAL;
group = devm_kzalloc(dev, sizeof(*group), GFP_KERNEL);
if (group == NULL)
return -ENOMEM;
attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
GFP_KERNEL);
if (attrs == NULL)
return -ENOMEM;
su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
GFP_KERNEL);
if (su == NULL)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/slab.h`, `linux/jiffies.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`, `linux/err.h`, `linux/mutex.h`.
- Detected declarations: `struct sensor_device_template`, `struct sensor_device_attr_u`, `struct sensor_template_group`, `function reg_to_pwm_enable`, `function pwm_enable_to_reg`, `function step_time_from_reg`, `function step_time_to_reg`, `function fan_from_reg8`, `function fan_from_reg13`, `function fan_from_reg16`.
- Atlas domain: Driver Families / drivers/hwmon.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.