[PATCH] wireless/atmel: fix setting TX key only in ENCODEEXT

The previous patch that added ENCODEEXT and AUTH support to the atmel
driver contained a slight error which would cause just setting the TX
key index to also set the encryption key again. This patch allows any
combination of setting the TX key index and setting an encryption key.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by Dan Williams and committed by John W. Linville 0d467502 ab479995

+33 -30
+33 -30
drivers/net/wireless/atmel.c
··· 1872 struct atmel_private *priv = netdev_priv(dev); 1873 struct iw_point *encoding = &wrqu->encoding; 1874 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1875 - int idx, key_len; 1876 1877 /* Determine and validate the key index */ 1878 idx = encoding->flags & IW_ENCODE_INDEX; ··· 1883 } else 1884 idx = priv->default_key; 1885 1886 - if ((encoding->flags & IW_ENCODE_DISABLED) || 1887 - ext->alg == IW_ENCODE_ALG_NONE) { 1888 - priv->wep_is_on = 0; 1889 - priv->encryption_level = 0; 1890 - priv->pairwise_cipher_suite = CIPHER_SUITE_NONE; 1891 } 1892 1893 - if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) 1894 - priv->default_key = idx; 1895 - 1896 - /* Set the requested key */ 1897 - switch (ext->alg) { 1898 - case IW_ENCODE_ALG_NONE: 1899 - break; 1900 - case IW_ENCODE_ALG_WEP: 1901 - if (ext->key_len > 5) { 1902 - priv->wep_key_len[idx] = 13; 1903 - priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_128; 1904 - priv->encryption_level = 2; 1905 - } else if (ext->key_len > 0) { 1906 - priv->wep_key_len[idx] = 5; 1907 - priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_64; 1908 - priv->encryption_level = 1; 1909 - } else { 1910 return -EINVAL; 1911 } 1912 - priv->wep_is_on = 1; 1913 - memset(priv->wep_keys[idx], 0, 13); 1914 - key_len = min ((int)ext->key_len, priv->wep_key_len[idx]); 1915 - memcpy(priv->wep_keys[idx], ext->key, key_len); 1916 - break; 1917 - default: 1918 - return -EINVAL; 1919 } 1920 1921 return -EINPROGRESS;
··· 1872 struct atmel_private *priv = netdev_priv(dev); 1873 struct iw_point *encoding = &wrqu->encoding; 1874 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1875 + int idx, key_len, alg = ext->alg, set_key = 1; 1876 1877 /* Determine and validate the key index */ 1878 idx = encoding->flags & IW_ENCODE_INDEX; ··· 1883 } else 1884 idx = priv->default_key; 1885 1886 + if (encoding->flags & IW_ENCODE_DISABLED) 1887 + alg = IW_ENCODE_ALG_NONE; 1888 + 1889 + if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { 1890 + priv->default_key = idx; 1891 + set_key = ext->key_len > 0 ? 1 : 0; 1892 } 1893 1894 + if (set_key) { 1895 + /* Set the requested key first */ 1896 + switch (alg) { 1897 + case IW_ENCODE_ALG_NONE: 1898 + priv->wep_is_on = 0; 1899 + priv->encryption_level = 0; 1900 + priv->pairwise_cipher_suite = CIPHER_SUITE_NONE; 1901 + break; 1902 + case IW_ENCODE_ALG_WEP: 1903 + if (ext->key_len > 5) { 1904 + priv->wep_key_len[idx] = 13; 1905 + priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_128; 1906 + priv->encryption_level = 2; 1907 + } else if (ext->key_len > 0) { 1908 + priv->wep_key_len[idx] = 5; 1909 + priv->pairwise_cipher_suite = CIPHER_SUITE_WEP_64; 1910 + priv->encryption_level = 1; 1911 + } else { 1912 + return -EINVAL; 1913 + } 1914 + priv->wep_is_on = 1; 1915 + memset(priv->wep_keys[idx], 0, 13); 1916 + key_len = min ((int)ext->key_len, priv->wep_key_len[idx]); 1917 + memcpy(priv->wep_keys[idx], ext->key, key_len); 1918 + break; 1919 + default: 1920 return -EINVAL; 1921 } 1922 } 1923 1924 return -EINPROGRESS;