From ec1712a862dcaaa18e4ecf0e532a05354f0970f1 Mon Sep 17 00:00:00 2001
From: Shelley Yang <shelley.yang@infineon.com>
Date: Tue, 6 Feb 2024 21:37:03 -0600
Subject: [PATCH 238/296] brcmfmac: fix warning error when enable
 PCIE_BARWIN_SZ

-rpi patch needs to enable this feature by kernel config

Signed-off-by: Shelley Yang <shelley.yang@infineon.com>
---
 .../broadcom/brcm80211/brcmfmac/pcie.c        | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
index 11a1f166b433..3fbc91c689cb 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
@@ -539,8 +539,6 @@ brcmf_pcie_write_reg32(struct brcmf_pciedev_info *devinfo, u32 reg_offset,
 static u8
 brcmf_pcie_read_tcm8(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 {
-	struct pci_dev *pdev = devinfo->pdev;
-	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	void __iomem *address = devinfo->tcm + mem_offset;
 #ifdef CONFIG_BRCMFMAC_PCIE_BARWIN_SZ
 	unsigned long flags;
@@ -558,6 +556,8 @@ brcmf_pcie_read_tcm8(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 
 	return value;
 #else
+	struct pci_dev *pdev = devinfo->pdev;
+	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	if ((address - devinfo->tcm) >= devinfo->bar1_size) {
 		brcmf_err(bus,
 			  "mem_offset:%d exceeds device size=%ld\n",
@@ -573,8 +573,6 @@ brcmf_pcie_read_tcm8(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 static u16
 brcmf_pcie_read_tcm16(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 {
-	struct pci_dev *pdev = devinfo->pdev;
-	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	void __iomem *address = devinfo->tcm + mem_offset;
 #ifdef CONFIG_BRCMFMAC_PCIE_BARWIN_SZ
 	u16 value;
@@ -592,6 +590,8 @@ brcmf_pcie_read_tcm16(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 
 	return value;
 #else
+	struct pci_dev *pdev = devinfo->pdev;
+	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	if ((address - devinfo->tcm) >= devinfo->bar1_size) {
 		brcmf_err(bus, "mem_offset:%d exceeds device size=%ld\n",
 				mem_offset, devinfo->bar1_size);
@@ -607,8 +607,6 @@ static void
 brcmf_pcie_write_tcm16(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 		       u16 value)
 {
-	struct pci_dev *pdev = devinfo->pdev;
-	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	void __iomem *address = devinfo->tcm + mem_offset;
 #ifdef CONFIG_BRCMFMAC_PCIE_BARWIN_SZ
 	unsigned long flags;
@@ -624,6 +622,8 @@ brcmf_pcie_write_tcm16(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 	pci_write_config_dword(devinfo->pdev, BCMA_PCI_BAR1_WIN, 0x0);
 	raw_spin_unlock_irqrestore(&pcie_lock, flags);
 #else
+	struct pci_dev *pdev = devinfo->pdev;
+	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	if ((address - devinfo->tcm) >= devinfo->bar1_size) {
 		brcmf_err(bus, "mem_offset:%d exceeds device size=%ld\n",
 				mem_offset, devinfo->bar1_size);
@@ -657,8 +657,6 @@ brcmf_pcie_write_idx(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 static u32
 brcmf_pcie_read_tcm32(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 {
-	struct pci_dev *pdev = devinfo->pdev;
-	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	void __iomem *address = devinfo->tcm + mem_offset;
 #ifdef CONFIG_BRCMFMAC_PCIE_BARWIN_SZ
 	u32 value;
@@ -676,6 +674,8 @@ brcmf_pcie_read_tcm32(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 
 	return value;
 #else
+	struct pci_dev *pdev = devinfo->pdev;
+	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	if ((address - devinfo->tcm) >= devinfo->bar1_size) {
 		brcmf_err(bus, "mem_offset:%d exceeds device size=%ld\n",
 			  mem_offset, devinfo->bar1_size);
@@ -691,8 +691,6 @@ static void
 brcmf_pcie_write_tcm32(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 		       u32 value)
 {
-	struct pci_dev *pdev = devinfo->pdev;
-	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	void __iomem *address = devinfo->tcm + mem_offset;
 #ifdef CONFIG_BRCMFMAC_PCIE_BARWIN_SZ
 	unsigned long flags;
@@ -707,6 +705,8 @@ brcmf_pcie_write_tcm32(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 	pci_write_config_dword(devinfo->pdev, BCMA_PCI_BAR1_WIN, 0x0);
 	raw_spin_unlock_irqrestore(&pcie_lock, flags);
 #else
+	struct pci_dev *pdev = devinfo->pdev;
+	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	if ((address - devinfo->tcm) >= devinfo->bar1_size) {
 		brcmf_err(bus, "mem_offset:%d exceeds device size=%ld\n",
 			  mem_offset, devinfo->bar1_size);
@@ -721,8 +721,6 @@ brcmf_pcie_write_tcm32(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 static u32
 brcmf_pcie_read_ram32(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 {
-	struct pci_dev *pdev = devinfo->pdev;
-	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	void __iomem *address = devinfo->tcm + devinfo->ci->rambase
 		+ mem_offset;
 #ifdef CONFIG_BRCMFMAC_PCIE_BARWIN_SZ
@@ -741,6 +739,8 @@ brcmf_pcie_read_ram32(struct brcmf_pciedev_info *devinfo, u32 mem_offset)
 
 	return value;
 #else
+	struct pci_dev *pdev = devinfo->pdev;
+	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	if ((address - devinfo->tcm) >= devinfo->bar1_size) {
 		brcmf_err(bus, "mem_offset:%d exceeds device size=%ld\n",
 			  mem_offset, devinfo->bar1_size);
@@ -756,8 +756,6 @@ static void
 brcmf_pcie_write_ram32(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 		       u32 value)
 {
-	struct pci_dev *pdev = devinfo->pdev;
-	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	void __iomem *address = devinfo->tcm + devinfo->ci->rambase
 		+ mem_offset;
 #ifdef CONFIG_BRCMFMAC_PCIE_BARWIN_SZ
@@ -773,6 +771,8 @@ brcmf_pcie_write_ram32(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
 	pci_write_config_dword(devinfo->pdev, BCMA_PCI_BAR1_WIN, 0x0);
 	raw_spin_unlock_irqrestore(&pcie_lock, flags);
 #else
+	struct pci_dev *pdev = devinfo->pdev;
+	struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
 	if ((address - devinfo->tcm) >= devinfo->bar1_size) {
 		brcmf_err(bus, "mem_offset:%d exceeds device size=%ld\n",
 			  mem_offset, devinfo->bar1_size);
-- 
2.25.1

