libertas: convert CMD_802_11_EEPROM_ACCESS to a direct command
authorHolger Schurig <hs4233@mail.mn-solutions.de>
Wed, 26 Mar 2008 09:03:48 +0000 (10:03 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 1 Apr 2008 21:13:16 +0000 (17:13 -0400)
Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Acked-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/libertas/cmd.c
drivers/net/wireless/libertas/cmdresp.c
drivers/net/wireless/libertas/dev.h
drivers/net/wireless/libertas/ethtool.c
drivers/net/wireless/libertas/hostcmd.h
drivers/net/wireless/libertas/wext.h

index d396a5f066669364948da40a28506aee56ae1d09..6e7bfb36b49133ce3f8d79cc6e9557952d1a13d5 100644 (file)
@@ -953,27 +953,6 @@ static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
        return 0;
 }
 
-static int lbs_cmd_802_11_eeprom_access(struct cmd_ds_command *cmd,
-                                       void *pdata_buf)
-{
-       struct lbs_ioctl_regrdwr *ea = pdata_buf;
-
-       lbs_deb_enter(LBS_DEB_CMD);
-
-       cmd->command = cpu_to_le16(CMD_802_11_EEPROM_ACCESS);
-       cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) +
-                               S_DS_GEN);
-       cmd->result = 0;
-
-       cmd->params.rdeeprom.action = cpu_to_le16(ea->action);
-       cmd->params.rdeeprom.offset = cpu_to_le16(ea->offset);
-       cmd->params.rdeeprom.bytecount = cpu_to_le16(ea->NOB);
-       cmd->params.rdeeprom.value = 0;
-
-       lbs_deb_leave(LBS_DEB_CMD);
-       return 0;
-}
-
 static int lbs_cmd_bt_access(struct cmd_ds_command *cmd,
                               u16 cmd_action, void *pdata_buf)
 {
@@ -1412,10 +1391,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
                ret = lbs_cmd_80211_ad_hoc_stop(cmdptr);
                break;
 
-       case CMD_802_11_EEPROM_ACCESS:
-               ret = lbs_cmd_802_11_eeprom_access(cmdptr, pdata_buf);
-               break;
-
        case CMD_802_11_SET_AFC:
        case CMD_802_11_GET_AFC:
 
index c3b80c139d4fb841a71afa29b011aab6da52c28f..8b5d1a55a0e9b29214332a87fc52ff5de1401b1b 100644 (file)
@@ -249,31 +249,6 @@ static int lbs_ret_802_11_rssi(struct lbs_private *priv,
        return 0;
 }
 
-static int lbs_ret_802_11_eeprom_access(struct lbs_private *priv,
-                                 struct cmd_ds_command *resp)
-{
-       struct lbs_ioctl_regrdwr *pbuf;
-       pbuf = (struct lbs_ioctl_regrdwr *) priv->prdeeprom;
-
-       lbs_deb_enter_args(LBS_DEB_CMD, "len %d",
-              le16_to_cpu(resp->params.rdeeprom.bytecount));
-       if (pbuf->NOB < le16_to_cpu(resp->params.rdeeprom.bytecount)) {
-               pbuf->NOB = 0;
-               lbs_deb_cmd("EEPROM read length too big\n");
-               return -1;
-       }
-       pbuf->NOB = le16_to_cpu(resp->params.rdeeprom.bytecount);
-       if (pbuf->NOB > 0) {
-
-               memcpy(&pbuf->value, (u8 *) & resp->params.rdeeprom.value,
-                      le16_to_cpu(resp->params.rdeeprom.bytecount));
-               lbs_deb_hex(LBS_DEB_CMD, "EEPROM", (char *)&pbuf->value,
-                       le16_to_cpu(resp->params.rdeeprom.bytecount));
-       }
-       lbs_deb_leave(LBS_DEB_CMD);
-       return 0;
-}
-
 static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
                                        struct cmd_ds_command *resp)
 {
@@ -359,10 +334,6 @@ static inline int handle_cmd_response(struct lbs_private *priv,
                ret = lbs_ret_80211_ad_hoc_stop(priv);
                break;
 
-       case CMD_RET(CMD_802_11_EEPROM_ACCESS):
-               ret = lbs_ret_802_11_eeprom_access(priv, resp);
-               break;
-
        case CMD_RET(CMD_802_11D_DOMAIN_INFO):
                ret = lbs_ret_802_11d_domain_info(resp);
                break;
index 17e02bed6bfa8caf6d3e0cd2f5ea0f1b5b062f7e..8e770dd6ef6b015767894f3057923691592bb779 100644 (file)
@@ -320,7 +320,6 @@ struct lbs_private {
        u32 enable11d;
 
        /**     MISCELLANEOUS */
-       u8 *prdeeprom;
        struct lbs_offset_value offsetvalue;
 
        u32 monitormode;
index 21e6f988ea81cf9e1753df30e98811e6c9e9da5b..7c8ce7d0f23a71c1728628a5486e451d7d1296d5 100644 (file)
@@ -48,61 +48,28 @@ static int lbs_ethtool_get_eeprom(struct net_device *dev,
                                   struct ethtool_eeprom *eeprom, u8 * bytes)
 {
        struct lbs_private *priv = (struct lbs_private *) dev->priv;
-       struct lbs_ioctl_regrdwr regctrl;
-       char *ptr;
+       struct cmd_ds_802_11_eeprom_access cmd;
        int ret;
 
-       regctrl.action = 0;
-       regctrl.offset = eeprom->offset;
-       regctrl.NOB = eeprom->len;
-
-       if (eeprom->offset + eeprom->len > LBS_EEPROM_LEN)
-               return -EINVAL;
-
-//      mutex_lock(&priv->mutex);
-
-       priv->prdeeprom = kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL);
-       if (!priv->prdeeprom)
-               return -ENOMEM;
-       memcpy(priv->prdeeprom, &regctrl, sizeof(regctrl));
-
-       /* +14 is for action, offset, and NOB in
-        * response */
-       lbs_deb_ethtool("action:%d offset: %x NOB: %02x\n",
-              regctrl.action, regctrl.offset, regctrl.NOB);
+       lbs_deb_enter(LBS_DEB_ETHTOOL);
 
-       ret = lbs_prepare_and_send_command(priv,
-                                   CMD_802_11_EEPROM_ACCESS,
-                                   regctrl.action,
-                                   CMD_OPTION_WAITFORRSP, 0,
-                                   &regctrl);
-
-       if (ret) {
-               if (priv->prdeeprom)
-                       kfree(priv->prdeeprom);
-               goto done;
+       if (eeprom->offset + eeprom->len > LBS_EEPROM_LEN ||
+           eeprom->len > LBS_EEPROM_READ_LEN) {
+               ret = -EINVAL;
+               goto out;
        }
 
-       mdelay(10);
-
-       ptr = (char *)priv->prdeeprom;
-
-       /* skip the command header, but include the "value" u32 variable */
-       ptr = ptr + sizeof(struct lbs_ioctl_regrdwr) - 4;
-
-       /*
-        * Return the result back to the user
-        */
-       memcpy(bytes, ptr, eeprom->len);
-
-       if (priv->prdeeprom)
-               kfree(priv->prdeeprom);
-//     mutex_unlock(&priv->mutex);
-
-       ret = 0;
-
-done:
-       lbs_deb_enter_args(LBS_DEB_ETHTOOL, "ret %d", ret);
+       cmd.hdr.size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) -
+               LBS_EEPROM_READ_LEN + eeprom->len);
+       cmd.action = cpu_to_le16(CMD_ACT_GET);
+       cmd.offset = cpu_to_le16(eeprom->offset);
+       cmd.len    = cpu_to_le16(eeprom->len);
+       ret = lbs_cmd_with_response(priv, CMD_802_11_EEPROM_ACCESS, &cmd);
+       if (!ret)
+               memcpy(bytes, cmd.value, eeprom->len);
+
+out:
+       lbs_deb_leave_args(LBS_DEB_ETHTOOL, "ret %d", ret);
         return ret;
 }
 
index e56d0049f5fdced33182582cbce55d82b8cdced3..9256daba48fc2187194fd774ad51ea171aa87ec3 100644 (file)
@@ -588,12 +588,13 @@ struct cmd_ds_802_11_key_material {
 } __attribute__ ((packed));
 
 struct cmd_ds_802_11_eeprom_access {
+       struct cmd_header hdr;
        __le16 action;
-
-       /* multiple 4 */
        __le16 offset;
-       __le16 bytecount;
-       u8 value;
+       __le16 len;
+       /* firmware says it returns a maximum of 20 bytes */
+#define LBS_EEPROM_READ_LEN 20
+       u8 value[LBS_EEPROM_READ_LEN];
 } __attribute__ ((packed));
 
 struct cmd_ds_802_11_tpc_cfg {
@@ -713,7 +714,6 @@ struct cmd_ds_command {
                struct cmd_ds_mac_reg_access macreg;
                struct cmd_ds_bbp_reg_access bbpreg;
                struct cmd_ds_rf_reg_access rfreg;
-               struct cmd_ds_802_11_eeprom_access rdeeprom;
 
                struct cmd_ds_802_11d_domain_info domaininfo;
                struct cmd_ds_802_11d_domain_info domaininforesp;
index f0f439a6ab49d561b489474b9eb33170df34966c..4c08db497606707a97ea409a877c8b05a60e4dc4 100644 (file)
@@ -4,17 +4,6 @@
 #ifndef        _LBS_WEXT_H_
 #define        _LBS_WEXT_H_
 
-/** lbs_ioctl_regrdwr */
-struct lbs_ioctl_regrdwr {
-       /** Which register to access */
-       u16 whichreg;
-       /** Read or Write */
-       u16 action;
-       u32 offset;
-       u16 NOB;
-       u32 value;
-};
-
 extern struct iw_handler_def lbs_handler_def;
 extern struct iw_handler_def mesh_handler_def;