]> git.baikalelectronics.ru Git - kernel.git/commitdiff
staging: vt6656: Move firmware functions into main_usb.
authorMalcolm Priestley <tvboxspy@gmail.com>
Sun, 19 Apr 2020 10:26:06 +0000 (11:26 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Apr 2020 11:31:59 +0000 (13:31 +0200)
The firmware function are not that complicated so
move them into main_usb as static functions in callers
visibility

Firmware definitions moved to device.h and MODULE_FIRMWARE
move to below module_usb_driver.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/7b384871-826b-9365-e3ed-5717ecefd31c@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6656/Makefile
drivers/staging/vt6656/device.h
drivers/staging/vt6656/firmware.c [deleted file]
drivers/staging/vt6656/firmware.h [deleted file]
drivers/staging/vt6656/main_usb.c

index 375f54e9f58b5b9b974132df02114d9c983e242e..a0f3862dea7523d58a7b42a0c76a3ce605e73db0 100644 (file)
@@ -13,7 +13,6 @@ vt6656_stage-y +=     main_usb.o \
                        key.o \
                        rf.o \
                        usbpipe.o \
-                       channel.o \
-                       firmware.o
+                       channel.o
 
 obj-$(CONFIG_VT6656) +=        vt6656_stage.o
index 41226cd599c6666a3a6254045d1a54884f871100..7834d69e7ac03314dcd73958b047aa7178448473 100644 (file)
 
 #define DEVICE_VERSION                 "mac80211"
 
+#define FIRMWARE_VERSION               0x133           /* version 1.51 */
+#define FIRMWARE_NAME                  "vntwusb.fw"
+#define FIRMWARE_CHUNK_SIZE            0x400
+
 #define CONFIG_PATH                    "/etc/vntconfiguration.dat"
 
 #define MAX_UINTS                      8
diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c
deleted file mode 100644 (file)
index 70358d4..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * File: baseband.c
- *
- * Purpose: Implement functions to access baseband
- *
- * Author: Yiching Chen
- *
- * Date: May 20, 2004
- *
- * Functions:
- *
- * Revision History:
- *
- */
-
-#include <linux/compiler.h>
-#include "firmware.h"
-#include "usbpipe.h"
-
-#define FIRMWARE_VERSION       0x133           /* version 1.51 */
-#define FIRMWARE_NAME          "vntwusb.fw"
-
-#define FIRMWARE_CHUNK_SIZE    0x400
-
-int vnt_download_firmware(struct vnt_private *priv)
-{
-       struct device *dev = &priv->usb->dev;
-       const struct firmware *fw;
-       u16 length;
-       int ii;
-       int ret = 0;
-
-       dev_dbg(dev, "---->Download firmware\n");
-
-       ret = request_firmware(&fw, FIRMWARE_NAME, dev);
-       if (ret) {
-               dev_err(dev, "firmware file %s request failed (%d)\n",
-                       FIRMWARE_NAME, ret);
-               goto end;
-       }
-
-       for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) {
-               length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
-
-               ret = vnt_control_out(priv, 0, 0x1200 + ii, 0x0000, length,
-                                     fw->data + ii);
-               if (ret)
-                       goto free_fw;
-
-               dev_dbg(dev, "Download firmware...%d %zu\n", ii, fw->size);
-       }
-
-free_fw:
-       release_firmware(fw);
-end:
-       return ret;
-}
-MODULE_FIRMWARE(FIRMWARE_NAME);
-
-int vnt_firmware_branch_to_sram(struct vnt_private *priv)
-{
-       dev_dbg(&priv->usb->dev, "---->Branch to Sram\n");
-
-       return vnt_control_out(priv, 1, 0x1200, 0x0000, 0, NULL);
-}
-
-int vnt_check_firmware_version(struct vnt_private *priv)
-{
-       int ret = 0;
-
-       ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0,
-                            MESSAGE_REQUEST_VERSION, 2,
-                            (u8 *)&priv->firmware_version);
-       if (ret) {
-               dev_dbg(&priv->usb->dev,
-                       "Could not get firmware version: %d.\n", ret);
-               goto end;
-       }
-
-       dev_dbg(&priv->usb->dev, "Firmware Version [%04x]\n",
-               priv->firmware_version);
-
-       if (priv->firmware_version == 0xFFFF) {
-               dev_dbg(&priv->usb->dev, "In Loader.\n");
-               ret = -EINVAL;
-               goto end;
-       }
-
-       if (priv->firmware_version < FIRMWARE_VERSION) {
-               /* branch to loader for download new firmware */
-               ret = vnt_firmware_branch_to_sram(priv);
-               if (ret) {
-                       dev_dbg(&priv->usb->dev,
-                               "Could not branch to SRAM: %d.\n", ret);
-               } else {
-                       ret = -EINVAL;
-               }
-       }
-
-end:
-       return ret;
-}
diff --git a/drivers/staging/vt6656/firmware.h b/drivers/staging/vt6656/firmware.h
deleted file mode 100644 (file)
index 161126f..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * All rights reserved.
- *
- * File: firmware.h
- *
- * Purpose: Version and Release Information
- *
- * Author: Yiching Chen
- *
- * Date: May 20, 2004
- *
- */
-
-#ifndef __FIRMWARE_H__
-#define __FIRMWARE_H__
-
-#include "device.h"
-
-int vnt_download_firmware(struct vnt_private *priv);
-int vnt_firmware_branch_to_sram(struct vnt_private *priv);
-int vnt_check_firmware_version(struct vnt_private *priv);
-
-#endif /* __FIRMWARE_H__ */
index 3c76d3cb5bbe266453e03b4cdfd0c3ea25c2ec06..9b6229e6b46ccdae40d12602a3367b9f7034d67a 100644 (file)
@@ -33,7 +33,6 @@
 #include "wcmd.h"
 #include "rxtx.h"
 #include "rf.h"
-#include "firmware.h"
 #include "usbpipe.h"
 #include "channel.h"
 
@@ -103,6 +102,84 @@ static void vnt_set_options(struct vnt_private *priv)
        priv->exist_sw_net_addr = false;
 }
 
+static int vnt_download_firmware(struct vnt_private *priv)
+{
+       struct device *dev = &priv->usb->dev;
+       const struct firmware *fw;
+       u16 length;
+       int ii;
+       int ret = 0;
+
+       dev_dbg(dev, "---->Download firmware\n");
+
+       ret = request_firmware(&fw, FIRMWARE_NAME, dev);
+       if (ret) {
+               dev_err(dev, "firmware file %s request failed (%d)\n",
+                       FIRMWARE_NAME, ret);
+               goto end;
+       }
+
+       for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) {
+               length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE);
+
+               ret = vnt_control_out(priv, 0, 0x1200 + ii, 0x0000, length,
+                                     fw->data + ii);
+               if (ret)
+                       goto free_fw;
+
+               dev_dbg(dev, "Download firmware...%d %zu\n", ii, fw->size);
+       }
+
+free_fw:
+       release_firmware(fw);
+end:
+       return ret;
+}
+
+static int vnt_firmware_branch_to_sram(struct vnt_private *priv)
+{
+       dev_dbg(&priv->usb->dev, "---->Branch to Sram\n");
+
+       return vnt_control_out(priv, 1, 0x1200, 0x0000, 0, NULL);
+}
+
+static int vnt_check_firmware_version(struct vnt_private *priv)
+{
+       int ret = 0;
+
+       ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0,
+                            MESSAGE_REQUEST_VERSION, 2,
+                            (u8 *)&priv->firmware_version);
+       if (ret) {
+               dev_dbg(&priv->usb->dev,
+                       "Could not get firmware version: %d.\n", ret);
+               goto end;
+       }
+
+       dev_dbg(&priv->usb->dev, "Firmware Version [%04x]\n",
+               priv->firmware_version);
+
+       if (priv->firmware_version == 0xFFFF) {
+               dev_dbg(&priv->usb->dev, "In Loader.\n");
+               ret = -EINVAL;
+               goto end;
+       }
+
+       if (priv->firmware_version < FIRMWARE_VERSION) {
+               /* branch to loader for download new firmware */
+               ret = vnt_firmware_branch_to_sram(priv);
+               if (ret) {
+                       dev_dbg(&priv->usb->dev,
+                               "Could not branch to SRAM: %d.\n", ret);
+               } else {
+                       ret = -EINVAL;
+               }
+       }
+
+end:
+       return ret;
+}
+
 /*
  * initialization of MAC & BBP registers
  */
@@ -1067,3 +1144,5 @@ static struct usb_driver vt6656_driver = {
 };
 
 module_usb_driver(vt6656_driver);
+
+MODULE_FIRMWARE(FIRMWARE_NAME);