From ee4241b76814f06438dbf14b19681af191f079f1 Mon Sep 17 00:00:00 2001 From: Yue Ma Date: Mon, 10 Sep 2018 17:20:54 -0700 Subject: [PATCH] cnss2: Add API to check if WLAN PCIe device is down API provision for WLAN host driver to check if WLAN PCIe device is down. Change-Id: I91efcd781af67c72b787c89e6b619c4cc49da34b Signed-off-by: Yue Ma --- drivers/net/wireless/cnss2/pci.c | 21 +++++++++++++++++++++ include/net/cnss2.h | 1 + 2 files changed, 22 insertions(+) diff --git a/drivers/net/wireless/cnss2/pci.c b/drivers/net/wireless/cnss2/pci.c index 4869b33c8526..8f9bc213cac3 100644 --- a/drivers/net/wireless/cnss2/pci.c +++ b/drivers/net/wireless/cnss2/pci.c @@ -236,6 +236,27 @@ static int cnss_set_pci_link(struct cnss_pci_data *pci_priv, bool link_up) } #endif /* CONFIG_PCI_MSM */ +int cnss_pci_is_device_down(struct device *dev) +{ + struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev); + struct cnss_pci_data *pci_priv; + + if (!plat_priv) { + cnss_pr_err("plat_priv is NULL\n"); + return -ENODEV; + } + + pci_priv = plat_priv->bus_priv; + if (!pci_priv) { + cnss_pr_err("pci_priv is NULL\n"); + return -ENODEV; + } + + return test_bit(CNSS_DEV_ERR_NOTIFY, &plat_priv->driver_state) | + pci_priv->pci_link_down_ind; +} +EXPORT_SYMBOL(cnss_pci_is_device_down); + int cnss_pci_recovery_update_status(struct cnss_pci_data *pci_priv) { struct cnss_plat_data *plat_priv; diff --git a/include/net/cnss2.h b/include/net/cnss2.h index 3a8b503c1938..e06f0b670d90 100644 --- a/include/net/cnss2.h +++ b/include/net/cnss2.h @@ -167,6 +167,7 @@ static inline int cnss_wlan_pm_control(struct device *dev, bool vote) return 0; } #endif /* CONFIG_PCI_MSM */ +extern int cnss_pci_is_device_down(struct device *dev); extern void cnss_schedule_recovery(struct device *dev, enum cnss_recovery_reason reason); extern int cnss_self_recovery(struct device *dev, -- 2.11.0