drivers/net/ethernet/netronome/nfp/nfp_hwmon.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/netronome/nfp/nfp_hwmon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/netronome/nfp/nfp_hwmon.c- Extension
.c- Size
- 3139 bytes
- Lines
- 133
- Domain
- Driver Families
- Bucket
- drivers/net
- 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/kernel.hlinux/bitops.hlinux/hwmon.hnfpcore/nfp_cpp.hnfpcore/nfp_nsp.hnfp_main.h
Detected Declarations
function nfp_hwmon_sensor_idfunction nfp_hwmon_readfunction nfp_hwmon_is_visiblefunction nfp_hwmon_registerfunction nfp_hwmon_unregister
Annotated Snippet
if (const_vals[i].type == type && const_vals[i].attr == attr) {
*val = const_vals[i].val;
return 0;
}
err = nfp_hwmon_sensor_id(type, channel);
if (err < 0)
return err;
id = err;
if (!(pf->nspi->sensor_mask & BIT(id)))
return -EOPNOTSUPP;
if (type == hwmon_temp && attr == hwmon_temp_input)
return nfp_hwmon_read_sensor(pf->cpp, id, val);
if (type == hwmon_power && attr == hwmon_power_input)
return nfp_hwmon_read_sensor(pf->cpp, id, val);
return -EINVAL;
}
static umode_t
nfp_hwmon_is_visible(const void *data, enum hwmon_sensor_types type, u32 attr,
int channel)
{
if (type == hwmon_temp) {
switch (attr) {
case hwmon_temp_input:
case hwmon_temp_crit:
case hwmon_temp_max:
return 0444;
}
} else if (type == hwmon_power) {
switch (attr) {
case hwmon_power_input:
case hwmon_power_max:
return 0444;
}
}
return 0;
}
static const struct hwmon_channel_info * const nfp_hwmon_info[] = {
HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ),
HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_CRIT),
HWMON_CHANNEL_INFO(power, HWMON_P_INPUT | HWMON_P_MAX,
HWMON_P_INPUT,
HWMON_P_INPUT),
NULL
};
static const struct hwmon_ops nfp_hwmon_ops = {
.is_visible = nfp_hwmon_is_visible,
.read = nfp_hwmon_read,
};
static const struct hwmon_chip_info nfp_chip_info = {
.ops = &nfp_hwmon_ops,
.info = nfp_hwmon_info,
};
int nfp_hwmon_register(struct nfp_pf *pf)
{
if (!IS_REACHABLE(CONFIG_HWMON))
return 0;
if (!pf->nspi) {
nfp_warn(pf->cpp, "not registering HWMON (no NSP info)\n");
return 0;
}
if (!pf->nspi->sensor_mask) {
nfp_info(pf->cpp,
"not registering HWMON (NSP doesn't report sensors)\n");
return 0;
}
pf->hwmon_dev = hwmon_device_register_with_info(&pf->pdev->dev, "nfp",
pf, &nfp_chip_info,
NULL);
return PTR_ERR_OR_ZERO(pf->hwmon_dev);
}
void nfp_hwmon_unregister(struct nfp_pf *pf)
{
if (!IS_REACHABLE(CONFIG_HWMON) || !pf->hwmon_dev)
return;
hwmon_device_unregister(pf->hwmon_dev);
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/bitops.h`, `linux/hwmon.h`, `nfpcore/nfp_cpp.h`, `nfpcore/nfp_nsp.h`, `nfp_main.h`.
- Detected declarations: `function nfp_hwmon_sensor_id`, `function nfp_hwmon_read`, `function nfp_hwmon_is_visible`, `function nfp_hwmon_register`, `function nfp_hwmon_unregister`.
- Atlas domain: Driver Families / drivers/net.
- 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.