diff mbox series

[v2] wifi: wilc1000: change firmware path from 'atmel' to 'microchip/wilc'

Message ID 20230707194025.47085-1-ajay.kathat@microchip.com
State New
Headers show
Series [v2] wifi: wilc1000: change firmware path from 'atmel' to 'microchip/wilc' | expand

Commit Message

Ajay Singh July 7, 2023, 7:41 p.m. UTC
From: Ajay Singh <ajay.kathat@microchip.com>

To inline 'linux-firmware' path with driver, the firmware path is changed
from 'atmel' to 'microchip/wilc'. The path change will be submitted to
'linux-firmware' repo.
For backward compatibility, when the updated kernel and older
linux-firmware that has firmware at 'atmel/' path are used, add a fallback
method to read firmware from 'atmel' path.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 changes since v1:
  - load firmware from older path when firmware is missing at new path for
  backward compatibility.

---
 .../net/wireless/microchip/wilc1000/netdev.c  | 33 ++++++++++++++-----
 1 file changed, 25 insertions(+), 8 deletions(-)

--
2.34.1

Comments

Kalle Valo July 25, 2023, 3:02 p.m. UTC | #1
<Ajay.Kathat@microchip.com> wrote:

> From: Ajay Singh <ajay.kathat@microchip.com>
> 
> To inline 'linux-firmware' path with driver, the firmware path is changed
> from 'atmel' to 'microchip/wilc'. The path change will be submitted to
> 'linux-firmware' repo.
> For backward compatibility, when the updated kernel and older
> linux-firmware that has firmware at 'atmel/' path are used, add a fallback
> method to read firmware from 'atmel' path.
> 
> Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>

Like discussed in the other thread, I'm dropping this.

Patch set to Changes Requested.
diff mbox series

Patch

diff --git a/drivers/net/wireless/microchip/wilc1000/netdev.c b/drivers/net/wireless/microchip/wilc1000/netdev.c
index e9f59de31b0b..c0dd7072decc 100644
--- a/drivers/net/wireless/microchip/wilc1000/netdev.c
+++ b/drivers/net/wireless/microchip/wilc1000/netdev.c
@@ -19,10 +19,13 @@ 
 /* latest API version supported */
 #define WILC1000_API_VER		1

-#define WILC1000_FW_PREFIX		"atmel/wilc1000_wifi_firmware-"
+#define WILC1000_FW_PREFIX		"wilc1000_wifi_firmware-"
 #define __WILC1000_FW(api)		WILC1000_FW_PREFIX #api ".bin"
 #define WILC1000_FW(api)		__WILC1000_FW(api)

+#define WILC1000_ATMEL_FW(api)          "atmel/" WILC1000_FW(api)
+#define WILC1000_MICROCHIP_FW(api)      "microchip/wilc/" WILC1000_FW(api)
+
 static irqreturn_t isr_uh_routine(int irq, void *user_data)
 {
 	struct wilc *wilc = user_data;
@@ -187,14 +190,27 @@  static int wilc_wlan_get_firmware(struct net_device *dev)
 	chip_id = wilc_get_chipid(wilc, false);

 	netdev_info(dev, "ChipID [%x] loading firmware [%s]\n", chip_id,
-		    WILC1000_FW(WILC1000_API_VER));
+		    WILC1000_MICROCHIP_FW(WILC1000_API_VER));

-	ret = request_firmware(&wilc_fw, WILC1000_FW(WILC1000_API_VER),
+	ret = request_firmware(&wilc_fw,
+			       WILC1000_MICROCHIP_FW(WILC1000_API_VER),
 			       wilc->dev);
-	if (ret != 0) {
-		netdev_err(dev, "%s - firmware not available\n",
-			   WILC1000_FW(WILC1000_API_VER));
-		return -EINVAL;
+	if (ret == -ENOENT) {
+		netdev_info(dev, "firmware not found at[%s], try [%s]\n",
+			    WILC1000_MICROCHIP_FW(WILC1000_API_VER),
+			    WILC1000_ATMEL_FW(WILC1000_API_VER));
+		ret = request_firmware(&wilc_fw,
+				       WILC1000_ATMEL_FW(WILC1000_API_VER),
+				       wilc->dev);
+		if (ret) {
+			netdev_err(dev, "[%s] - request firmware failed %d\n",
+				   WILC1000_ATMEL_FW(WILC1000_API_VER), ret);
+			return ret;
+		}
+	} else if (ret) {
+		netdev_err(dev, "[%s] - request firmware failed %d\n",
+			   WILC1000_MICROCHIP_FW(WILC1000_API_VER), ret);
+		return ret;
 	}
 	wilc->firmware = wilc_fw;

@@ -1007,4 +1023,5 @@  struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
 }

 MODULE_LICENSE("GPL");
-MODULE_FIRMWARE(WILC1000_FW(WILC1000_API_VER));
+MODULE_FIRMWARE(WILC1000_ATMEL_FW(WILC1000_API_VER));
+MODULE_FIRMWARE(WILC1000_MICROCHIP_FW(WILC1000_API_VER));