drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c- Extension
.c- Size
- 5942 bytes
- Lines
- 242
- 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/dev_printk.hlinux/errno.hlinux/hwmon.hlinux/hwmon-sysfs.hlinux/pci.hlinux/bnxt/hsi.hbnxt.hbnxt_hwrm.hbnxt_hwmon.h
Detected Declarations
function bnxt_hwmon_notify_eventfunction bnxt_hwrm_temp_queryfunction bnxt_hwmon_is_visiblefunction bnxt_hwmon_readfunction temp1_shutdown_showfunction temp1_shutdown_alarm_showfunction bnxt_temp_extra_attrs_visiblefunction bnxt_hwmon_uninitfunction bnxt_hwmon_init
Annotated Snippet
#include <linux/dev_printk.h>
#include <linux/errno.h>
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/pci.h>
#include <linux/bnxt/hsi.h>
#include "bnxt.h"
#include "bnxt_hwrm.h"
#include "bnxt_hwmon.h"
void bnxt_hwmon_notify_event(struct bnxt *bp)
{
u32 attr;
if (!bp->hwmon_dev)
return;
switch (bp->thermal_threshold_type) {
case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN:
attr = hwmon_temp_max_alarm;
break;
case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_CRITICAL:
attr = hwmon_temp_crit_alarm;
break;
case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_FATAL:
case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_SHUTDOWN:
attr = hwmon_temp_emergency_alarm;
break;
default:
return;
}
hwmon_notify_event(&bp->pdev->dev, hwmon_temp, attr, 0);
}
static int bnxt_hwrm_temp_query(struct bnxt *bp, u8 *temp)
{
struct hwrm_temp_monitor_query_output *resp;
struct hwrm_temp_monitor_query_input *req;
int rc;
rc = hwrm_req_init(bp, req, HWRM_TEMP_MONITOR_QUERY);
if (rc)
return rc;
resp = hwrm_req_hold(bp, req);
rc = hwrm_req_send_silent(bp, req);
if (rc)
goto drop_req;
if (temp) {
*temp = resp->temp;
} else if (resp->flags &
TEMP_MONITOR_QUERY_RESP_FLAGS_THRESHOLD_VALUES_AVAILABLE) {
bp->fw_cap |= BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED;
bp->warn_thresh_temp = resp->warn_threshold;
bp->crit_thresh_temp = resp->critical_threshold;
bp->fatal_thresh_temp = resp->fatal_threshold;
bp->shutdown_thresh_temp = resp->shutdown_threshold;
}
drop_req:
hwrm_req_drop(bp, req);
return rc;
}
static umode_t bnxt_hwmon_is_visible(const void *_data, enum hwmon_sensor_types type,
u32 attr, int channel)
{
const struct bnxt *bp = _data;
if (type != hwmon_temp)
return 0;
switch (attr) {
case hwmon_temp_input:
return 0444;
case hwmon_temp_max:
case hwmon_temp_crit:
case hwmon_temp_emergency:
case hwmon_temp_max_alarm:
case hwmon_temp_crit_alarm:
case hwmon_temp_emergency_alarm:
if (!(bp->fw_cap & BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED))
return 0;
return 0444;
default:
return 0;
}
}
Annotation
- Immediate include surface: `linux/dev_printk.h`, `linux/errno.h`, `linux/hwmon.h`, `linux/hwmon-sysfs.h`, `linux/pci.h`, `linux/bnxt/hsi.h`, `bnxt.h`, `bnxt_hwrm.h`.
- Detected declarations: `function bnxt_hwmon_notify_event`, `function bnxt_hwrm_temp_query`, `function bnxt_hwmon_is_visible`, `function bnxt_hwmon_read`, `function temp1_shutdown_show`, `function temp1_shutdown_alarm_show`, `function bnxt_temp_extra_attrs_visible`, `function bnxt_hwmon_uninit`, `function bnxt_hwmon_init`.
- 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.