Skip to content

Commit

Permalink
bnxt_en: Enhance hwmon temperature reporting
Browse files Browse the repository at this point in the history
Driver currently does hwmon device register and unregister
in open and close() respectively. As a result, user will not
be able to query hwmon temperature when interface is in
ifdown state.

Enhance it by moving the hwmon register/unregister to the
probe/remove functions.

Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kalesh AP authored and David S. Miller committed Oct 4, 2023
1 parent 754fbf6 commit 6ad7198
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -10280,15 +10280,15 @@ static struct attribute *bnxt_attrs[] = {
};
ATTRIBUTE_GROUPS(bnxt);

static void bnxt_hwmon_close(struct bnxt *bp)
static void bnxt_hwmon_uninit(struct bnxt *bp)
{
if (bp->hwmon_dev) {
hwmon_device_unregister(bp->hwmon_dev);
bp->hwmon_dev = NULL;
}
}

static void bnxt_hwmon_open(struct bnxt *bp)
static void bnxt_hwmon_init(struct bnxt *bp)
{
struct hwrm_temp_monitor_query_input *req;
struct pci_dev *pdev = bp->pdev;
Expand All @@ -10298,7 +10298,7 @@ static void bnxt_hwmon_open(struct bnxt *bp)
if (!rc)
rc = hwrm_req_send_silent(bp, req);
if (rc == -EACCES || rc == -EOPNOTSUPP) {
bnxt_hwmon_close(bp);
bnxt_hwmon_uninit(bp);
return;
}

Expand All @@ -10314,11 +10314,11 @@ static void bnxt_hwmon_open(struct bnxt *bp)
}
}
#else
static void bnxt_hwmon_close(struct bnxt *bp)
static void bnxt_hwmon_uninit(struct bnxt *bp)
{
}

static void bnxt_hwmon_open(struct bnxt *bp)
static void bnxt_hwmon_init(struct bnxt *bp)
{
}
#endif
Expand Down Expand Up @@ -10651,7 +10651,6 @@ static int bnxt_open(struct net_device *dev)
bnxt_reenable_sriov(bp);
}
}
bnxt_hwmon_open(bp);
}

return rc;
Expand Down Expand Up @@ -10736,7 +10735,6 @@ static int bnxt_close(struct net_device *dev)
{
struct bnxt *bp = netdev_priv(dev);

bnxt_hwmon_close(bp);
bnxt_close_nic(bp, true, true);
bnxt_hwrm_shutdown_link(bp);
bnxt_hwrm_if_change(bp, false);
Expand Down Expand Up @@ -12300,6 +12298,7 @@ static int bnxt_fw_init_one_p2(struct bnxt *bp)
if (bp->fw_cap & BNXT_FW_CAP_PTP)
__bnxt_hwrm_ptp_qcfg(bp);
bnxt_dcb_init(bp);
bnxt_hwmon_init(bp);
return 0;
}

Expand Down Expand Up @@ -13205,6 +13204,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
bnxt_clear_int_mode(bp);
bnxt_hwrm_func_drv_unrgtr(bp);
bnxt_free_hwrm_resources(bp);
bnxt_hwmon_uninit(bp);
bnxt_ethtool_free(bp);
bnxt_dcb_free(bp);
kfree(bp->ptp_cfg);
Expand Down Expand Up @@ -13801,6 +13801,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
init_err_pci_clean:
bnxt_hwrm_func_drv_unrgtr(bp);
bnxt_free_hwrm_resources(bp);
bnxt_hwmon_uninit(bp);
bnxt_ethtool_free(bp);
bnxt_ptp_clear(bp);
kfree(bp->ptp_cfg);
Expand Down

0 comments on commit 6ad7198

Please sign in to comment.