staging: rtl8192e: Remove constant index from channel_array[]
authorPhilipp Hortmann <philipp.g.hortmann@gmail.com>
Sat, 18 Nov 2023 08:52:08 +0000 (09:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Nov 2023 12:46:19 +0000 (12:46 +0000)
Used index of channel_array[] is always COUNTRY_CODE_WORLD_WIDE_13. Remove
index and store only used entry in channel_array. This shortens the code
and increases readability.

Signed-off-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>
Link: https://lore.kernel.org/r/379293f2b48d176aaafb023d36aac9bb057f67c7.1700296319.git.philipp.g.hortmann@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192e/dot11d.c
drivers/staging/rtl8192e/dot11d.h
drivers/staging/rtl8192e/rtl8192e/rtl_core.c

index 37106fd54f0009a9f3453008f15696fe25b19491..fdc39e6e7abbe28e004638ff611a40e5fc166a17 100644 (file)
@@ -12,28 +12,7 @@ struct channel_list {
        u8      len;
 };
 
-static struct channel_list channel_array[] = {
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64,
-         149, 153, 157, 161, 165}, 24},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56,
-         60, 64}, 21},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
-         56, 60, 64}, 22},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
-         56, 60, 64}, 22},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
-         56, 60, 64}, 22},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52,
-        56, 60, 64}, 22},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13},
-       {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52,
-         56, 60, 64}, 21}
-};
+static struct channel_list channel_array = {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13};
 
 void dot11d_init(struct rtllib_device *ieee)
 {
@@ -49,7 +28,7 @@ void dot11d_init(struct rtllib_device *ieee)
 }
 EXPORT_SYMBOL(dot11d_init);
 
-void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee)
+void dot11d_channel_map(struct rtllib_device *ieee)
 {
        int i;
 
@@ -57,10 +36,8 @@ void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee)
 
        memset(GET_DOT11D_INFO(ieee)->channel_map, 0,
               sizeof(GET_DOT11D_INFO(ieee)->channel_map));
-       for (i = 0; i < channel_array[channel_plan].len; i++) {
-               GET_DOT11D_INFO(ieee)->channel_map[channel_array
-                               [channel_plan].channel[i]] = 1;
-       }
+       for (i = 0; i < channel_array.len; i++)
+               GET_DOT11D_INFO(ieee)->channel_map[channel_array.channel[i]] = 1;
 
        for (i = 12; i <= 13; i++)
                GET_DOT11D_INFO(ieee)->channel_map[i] = 2;
index 6d2b93acfa4315bc4d5012f3541789f61b7562b2..78d1ca1e7743c41ab596117b7ff3cff837d3bdb3 100644 (file)
@@ -75,7 +75,7 @@ static inline void RESET_CIE_WATCHDOG(struct rtllib_device *__ieee_dev)
 #define UPDATE_CIE_WATCHDOG(__ieee_dev) (++GET_CIE_WATCHDOG(__ieee_dev))
 
 void dot11d_init(struct rtllib_device *dev);
-void dot11d_channel_map(u8 channel_plan, struct rtllib_device *ieee);
+void dot11d_channel_map(struct rtllib_device *ieee);
 void dot11d_reset(struct rtllib_device *dev);
 void dot11d_update_country(struct rtllib_device *dev, u8 *address,
                           u16 country_len, u8 *country);
index 68bd035002675c67e45c4a2d8c78a117acf411c6..4b842a1789c25bd28ce30f2b1499d8d88bc3d53b 100644 (file)
@@ -796,7 +796,7 @@ static short _rtl92e_get_channel_map(struct net_device *dev)
        struct r8192_priv *priv = rtllib_priv(dev);
 
        dot11d_init(priv->rtllib);
-       dot11d_channel_map(COUNTRY_CODE_WORLD_WIDE_13, priv->rtllib);
+       dot11d_channel_map(priv->rtllib);
        for (i = 1; i <= 11; i++)
                (priv->rtllib->active_channel_map)[i] = 1;
        (priv->rtllib->active_channel_map)[12] = 2;