Commit 41f1efcb authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Greg Kroah-Hartman
Browse files

staging: vt6656: vnt_set_keymode simplify key modes.



Unused macros and onfly_latch are removed and others contain
to actual key_type value is or-ed with key_mode.

Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Link: https://lore.kernel.org/r/0eb6f5bb-f756-ab1d-5b63-db9b0dc422da@gmail.com


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ae220204
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ int vnt_key_init_table(struct vnt_private *priv)

static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr,
			   struct ieee80211_key_conf *key, u32 key_type,
			   u32 mode, bool onfly_latch)
			   u32 mode)
{
	struct vnt_private *priv = hw->priv;
	u8 broadcast[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
@@ -68,17 +68,11 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr,
		entry = MAX_KEY_TABLE - 1;
		key->hw_key_idx = entry;
		/* fall through */
	case VNT_KEY_ALLGROUP:
		key_mode |= VNT_KEY_ALLGROUP;
		if (onfly_latch)
			key_mode |= VNT_KEY_ONFLY_ALL;
		/* fall through */
	case VNT_KEY_GROUP_ADDRESS:
		key_mode |= mode;
		/* fall through */
		key_mode = mode | (mode << 4);
		break;
	case VNT_KEY_GROUP:
		key_mode |= (mode << 4);
		key_mode |= VNT_KEY_GROUP;
		key_mode = mode << 4;
		break;
	case  VNT_KEY_PAIRWISE:
		key_mode |= mode;
@@ -88,8 +82,7 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 *mac_addr,
		return -EINVAL;
	}

	if (onfly_latch)
		key_mode |= VNT_KEY_ONFLY;
	key_mode |= key_type;

	if (mode == KEY_CTL_WEP) {
		if (key->keylen == WLAN_KEY_LEN_WEP40)
@@ -126,7 +119,7 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
			vnt_mac_disable_keyentry(priv, u);

		vnt_set_keymode(hw, mac_addr, key, VNT_KEY_DEFAULTKEY,
				KEY_CTL_WEP, true);
				KEY_CTL_WEP);

		key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV;

@@ -152,10 +145,10 @@ int vnt_set_keys(struct ieee80211_hw *hw, struct ieee80211_sta *sta,

	if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)
		vnt_set_keymode(hw, mac_addr, key, VNT_KEY_PAIRWISE,
				key_dec_mode, true);
				key_dec_mode);
	else
		vnt_set_keymode(hw, mac_addr, key, VNT_KEY_GROUP_ADDRESS,
				key_dec_mode, true);
		vnt_set_keymode(hw, mac_addr, key,
				VNT_KEY_GROUP_ADDRESS, key_dec_mode);

	return 0;
}
+7 −6
Original line number Diff line number Diff line
@@ -25,13 +25,14 @@
#define KEY_CTL_TKIP        0x02
#define KEY_CTL_CCMP        0x03

#define VNT_KEY_DEFAULTKEY	0x1
#define VNT_KEY_GROUP_ADDRESS	0x2
#define VNT_KEY_ALLGROUP	0x4
#define VNT_KEY_GROUP		0x40
#define VNT_KEY_PAIRWISE	0x00
#define VNT_KEY_ONFLY		0x8000
#define VNT_KEY_ONFLY_ALL	0x4000
#define VNT_KEY_ONFLY		0x8000
#define VNT_KEY_ALLGROUP	0x04
#define VNT_KEY_GROUP		0x40
#define VNT_KEY_PAIRWISE	VNT_KEY_ONFLY
#define VNT_KEY_GROUP_ADDRESS	(VNT_KEY_ALLGROUP | VNT_KEY_GROUP)
#define VNT_KEY_DEFAULTKEY	(VNT_KEY_GROUP_ADDRESS | VNT_KEY_ONFLY |\
				VNT_KEY_ONFLY_ALL)

int vnt_key_init_table(struct vnt_private *priv);