From 7efdab657b56c4d34749ca7e5f617c64f65e0a03 Mon Sep 17 00:00:00 2001 From: Mohammed Siddiq Date: Wed, 29 Dec 2021 17:43:01 +0530 Subject: [PATCH] cnss2: Add api to return the pci slot in use Add api to return the pci slot in use. With the new targets, QCA6490/kiwi devices are getting attached on pci slot 1 as well, so host driver call this exported api to get the pci slot of device attached. Change-Id: Ief51204258090df16b48267f3aeb851ded365525 --- cnss2/pci.c | 21 +++++++++++++++++++++ inc/cnss2.h | 1 + 2 files changed, 22 insertions(+) diff --git a/cnss2/pci.c b/cnss2/pci.c index 488368d7ea..ab8086e33d 100644 --- a/cnss2/pci.c +++ b/cnss2/pci.c @@ -1655,6 +1655,27 @@ void cnss_pci_unlock_reg_window(struct device *dev, unsigned long *flags) } EXPORT_SYMBOL(cnss_pci_unlock_reg_window); +int cnss_get_pci_slot(struct device *dev) +{ + struct pci_dev *pci_dev = to_pci_dev(dev); + struct cnss_pci_data *pci_priv = cnss_get_pci_priv(pci_dev); + struct cnss_plat_data *plat_priv = NULL; + + if (!pci_priv) { + cnss_pr_err("pci_priv is NULL\n"); + return -EINVAL; + } + + plat_priv = pci_priv->plat_priv; + if (!plat_priv) { + cnss_pr_err("plat_priv is NULL\n"); + return -ENODEV; + } + + return plat_priv->rc_num; +} +EXPORT_SYMBOL(cnss_get_pci_slot); + /** * cnss_pci_dump_bl_sram_mem - Dump WLAN device bootloader debug log * @pci_priv: driver PCI bus context pointer diff --git a/inc/cnss2.h b/inc/cnss2.h index 1376995b67..c836e4a586 100644 --- a/inc/cnss2.h +++ b/inc/cnss2.h @@ -275,4 +275,5 @@ extern int cnss_get_mem_seg_count(enum cnss_remote_mem_type type, u32 *seg); extern int cnss_get_mem_segment_info(enum cnss_remote_mem_type type, struct cnss_mem_segment segment[], u32 segment_count); +extern int cnss_get_pci_slot(struct device *dev); #endif /* _NET_CNSS2_H */