Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7460f5a6 authored by Holger Schurig's avatar Holger Schurig Committed by John W. Linville
Browse files

libertas: convert CMD_802_11_EEPROM_ACCESS to a direct command

parent 2af9f039
Loading
Loading
Loading
Loading
+0 −25
Original line number Original line Diff line number Diff line
@@ -953,27 +953,6 @@ static int lbs_cmd_reg_access(struct cmd_ds_command *cmdptr,
	return 0;
	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,
static int lbs_cmd_bt_access(struct cmd_ds_command *cmd,
			       u16 cmd_action, void *pdata_buf)
			       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);
		ret = lbs_cmd_80211_ad_hoc_stop(cmdptr);
		break;
		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_SET_AFC:
	case CMD_802_11_GET_AFC:
	case CMD_802_11_GET_AFC:


+0 −29
Original line number Original line Diff line number Diff line
@@ -249,31 +249,6 @@ static int lbs_ret_802_11_rssi(struct lbs_private *priv,
	return 0;
	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,
static int lbs_ret_802_11_bcn_ctrl(struct lbs_private * priv,
					struct cmd_ds_command *resp)
					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);
		ret = lbs_ret_80211_ad_hoc_stop(priv);
		break;
		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):
	case CMD_RET(CMD_802_11D_DOMAIN_INFO):
		ret = lbs_ret_802_11d_domain_info(resp);
		ret = lbs_ret_802_11d_domain_info(resp);
		break;
		break;
+0 −1
Original line number Original line Diff line number Diff line
@@ -320,7 +320,6 @@ struct lbs_private {
	u32 enable11d;
	u32 enable11d;


	/**	MISCELLANEOUS */
	/**	MISCELLANEOUS */
	u8 *prdeeprom;
	struct lbs_offset_value offsetvalue;
	struct lbs_offset_value offsetvalue;


	u32 monitormode;
	u32 monitormode;
+17 −50
Original line number Original line Diff line number Diff line
@@ -48,61 +48,28 @@ static int lbs_ethtool_get_eeprom(struct net_device *dev,
                                  struct ethtool_eeprom *eeprom, u8 * bytes)
                                  struct ethtool_eeprom *eeprom, u8 * bytes)
{
{
	struct lbs_private *priv = (struct lbs_private *) dev->priv;
	struct lbs_private *priv = (struct lbs_private *) dev->priv;
	struct lbs_ioctl_regrdwr regctrl;
	struct cmd_ds_802_11_eeprom_access cmd;
	char *ptr;
	int ret;
	int ret;


	regctrl.action = 0;
	lbs_deb_enter(LBS_DEB_ETHTOOL);
	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);


	ret = lbs_prepare_and_send_command(priv,
	if (eeprom->offset + eeprom->len > LBS_EEPROM_LEN ||
				    CMD_802_11_EEPROM_ACCESS,
	    eeprom->len > LBS_EEPROM_READ_LEN) {
				    regctrl.action,
		ret = -EINVAL;
				    CMD_OPTION_WAITFORRSP, 0,
		goto out;
				    &regctrl);

	if (ret) {
		if (priv->prdeeprom)
			kfree(priv->prdeeprom);
		goto done;
	}
	}


	mdelay(10);
	cmd.hdr.size = cpu_to_le16(sizeof(struct cmd_ds_802_11_eeprom_access) -

		LBS_EEPROM_READ_LEN + eeprom->len);
	ptr = (char *)priv->prdeeprom;
	cmd.action = cpu_to_le16(CMD_ACT_GET);

	cmd.offset = cpu_to_le16(eeprom->offset);
	/* skip the command header, but include the "value" u32 variable */
	cmd.len    = cpu_to_le16(eeprom->len);
	ptr = ptr + sizeof(struct lbs_ioctl_regrdwr) - 4;
	ret = lbs_cmd_with_response(priv, CMD_802_11_EEPROM_ACCESS, &cmd);

	if (!ret)
	/*
		memcpy(bytes, cmd.value, eeprom->len);
	 * Return the result back to the user

	 */
out:
	memcpy(bytes, ptr, eeprom->len);
	lbs_deb_leave_args(LBS_DEB_ETHTOOL, "ret %d", ret);

	if (priv->prdeeprom)
		kfree(priv->prdeeprom);
//	mutex_unlock(&priv->mutex);

	ret = 0;

done:
	lbs_deb_enter_args(LBS_DEB_ETHTOOL, "ret %d", ret);
        return ret;
        return ret;
}
}


+5 −5
Original line number Original line Diff line number Diff line
@@ -588,12 +588,13 @@ struct cmd_ds_802_11_key_material {
} __attribute__ ((packed));
} __attribute__ ((packed));


struct cmd_ds_802_11_eeprom_access {
struct cmd_ds_802_11_eeprom_access {
	struct cmd_header hdr;
	__le16 action;
	__le16 action;

	/* multiple 4 */
	__le16 offset;
	__le16 offset;
	__le16 bytecount;
	__le16 len;
	u8 value;
	/* firmware says it returns a maximum of 20 bytes */
#define LBS_EEPROM_READ_LEN 20
	u8 value[LBS_EEPROM_READ_LEN];
} __attribute__ ((packed));
} __attribute__ ((packed));


struct cmd_ds_802_11_tpc_cfg {
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_mac_reg_access macreg;
		struct cmd_ds_bbp_reg_access bbpreg;
		struct cmd_ds_bbp_reg_access bbpreg;
		struct cmd_ds_rf_reg_access rfreg;
		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 domaininfo;
		struct cmd_ds_802_11d_domain_info domaininforesp;
		struct cmd_ds_802_11d_domain_info domaininforesp;
Loading