diff options
author | Pavel Roskin <proski@gnu.org> | 2007-06-16 03:38:36 -0400 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2007-06-16 13:42:57 +0200 |
commit | 4176d78759eedfab4dc08e7bde8991fb7942bf5c (patch) | |
tree | 2e533c9ca1c97fd644d6e5333fad589b2c3864da | |
parent | 50f4afa032dca9bab401284d5b87c149cae6a5c5 (diff) |
[PATCH] Eliminate macros containing offsetof for MIB structures
They make it harder to check correctness of MIB requests. For instance,
STATION_ID_OFFSET doesn't show that it's an offset in struct
mib_mac_mgmt, so it's not obvious if priv->mib_buf.type is set to
MIB_MAC_MGMT correctly.
Signed-off-by: Pavel Roskin <proski@gnu.org>
-rw-r--r-- | at76_usb.c | 21 | ||||
-rw-r--r-- | at76_usb.h | 18 |
2 files changed, 11 insertions, 28 deletions
@@ -916,7 +916,7 @@ static int at76_set_pm_mode(struct at76_priv *priv) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_MAC_MGMT; priv->mib_buf.size = 1; - priv->mib_buf.index = POWER_MGMT_MODE_OFFSET; + priv->mib_buf.index = offsetof(struct mib_mac_mgmt, power_mgmt_mode); priv->mib_buf.data[0] = priv->pm_mode; @@ -936,7 +936,7 @@ static int at76_set_associd(struct at76_priv *priv, u16 id) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_MAC_MGMT; priv->mib_buf.size = 2; - priv->mib_buf.index = STATION_ID_OFFSET; + priv->mib_buf.index = offsetof(struct mib_mac_mgmt, station_id); priv->mib_buf.data[0] = id & 0xff; priv->mib_buf.data[1] = id >> 8; @@ -958,7 +958,7 @@ static int at76_set_listen_interval(struct at76_priv *priv, u16 interval) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_MAC; priv->mib_buf.size = 2; - priv->mib_buf.index = STATION_ID_OFFSET; + priv->mib_buf.index = offsetof(struct mib_mac_mgmt, station_id); priv->mib_buf.data[0] = interval & 0xff; priv->mib_buf.data[1] = interval >> 8; @@ -978,7 +978,7 @@ static int at76_set_preamble(struct at76_priv *priv, u8 type) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_LOCAL; priv->mib_buf.size = 1; - priv->mib_buf.index = PREAMBLE_TYPE_OFFSET; + priv->mib_buf.index = offsetof(struct mib_local, preamble_type); priv->mib_buf.data[0] = type; ret = at76_set_mib(priv, &priv->mib_buf); if (ret < 0) { @@ -995,7 +995,7 @@ static int at76_set_frag(struct at76_priv *priv, u16 size) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_MAC; priv->mib_buf.size = 2; - priv->mib_buf.index = FRAGMENTATION_OFFSET; + priv->mib_buf.index = offsetof(struct mib_mac, frag_threshold); *(__le16 *)priv->mib_buf.data = cpu_to_le16(size); ret = at76_set_mib(priv, &priv->mib_buf); if (ret < 0) { @@ -1012,7 +1012,7 @@ static int at76_set_rts(struct at76_priv *priv, u16 size) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_MAC; priv->mib_buf.size = 2; - priv->mib_buf.index = RTS_OFFSET; + priv->mib_buf.index = offsetof(struct mib_mac, rts_threshold); *(__le16 *)priv->mib_buf.data = cpu_to_le16(size); ret = at76_set_mib(priv, &priv->mib_buf); if (ret < 0) { @@ -1028,7 +1028,7 @@ static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_LOCAL; priv->mib_buf.size = 1; - priv->mib_buf.index = TX_AUTORATE_FALLBACK_OFFSET; + priv->mib_buf.index = offsetof(struct mib_local, txautorate_fallback); priv->mib_buf.data[0] = onoff; ret = at76_set_mib(priv, &priv->mib_buf); if (ret < 0) { @@ -1549,7 +1549,7 @@ static int at76_start_ibss(struct at76_priv *priv) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_MAC_MGMT; priv->mib_buf.size = 1; - priv->mib_buf.index = IBSS_CHANGE_OK_OFFSET; + priv->mib_buf.index = offsetof(struct mib_mac_mgmt, ibss_change); ret = at76_set_mib(priv, &priv->mib_buf); if (ret < 0) { err("%s: set_mib (ibss change ok) failed: %d", @@ -3505,7 +3505,8 @@ static int at76_set_iroaming(struct at76_priv *priv, int onoff) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_MAC_MGMT; priv->mib_buf.size = 1; - priv->mib_buf.index = IROAMING_OFFSET; + priv->mib_buf.index = + offsetof(struct mib_mac_mgmt, multi_domain_capability_enabled); priv->mib_buf.data[0] = (priv->international_roaming ? 1 : 0); ret = at76_set_mib(priv, &priv->mib_buf); if (ret < 0) { @@ -4563,7 +4564,7 @@ static void at76_work_new_bss(struct work_struct *work) memset(&priv->mib_buf, 0, sizeof(struct set_mib_buffer)); priv->mib_buf.type = MIB_MAC_MGMT; priv->mib_buf.size = 1; - priv->mib_buf.index = IBSS_CHANGE_OK_OFFSET; + priv->mib_buf.index = offsetof(struct mib_mac_mgmt, ibss_change); ret = at76_set_mib(priv, &priv->mib_buf); if (ret < 0) err("%s: set_mib (ibss change ok) failed: %d", netdev->name, @@ -113,24 +113,6 @@ #define IR_OFF 0 #define IR_ON 1 -/* offsets into the MIBs we use to configure the device */ -#define TX_AUTORATE_FALLBACK_OFFSET offsetof(struct mib_local,txautorate_fallback) -#define FRAGMENTATION_OFFSET offsetof(struct mib_mac,frag_threshold) -#define PREAMBLE_TYPE_OFFSET offsetof(struct mib_local,preamble_type) -#define RTS_OFFSET offsetof(struct mib_mac, rts_threshold) - -/* valid only for rfmd and 505 !*/ -#define IBSS_CHANGE_OK_OFFSET offsetof(struct mib_mac_mgmt, ibss_change) -#define IROAMING_IMPL_OFFSET offsetof(struct mib_mac_mgmt, multi_domain_capability_implemented) -#define IROAMING_OFFSET \ - offsetof(struct mib_mac_mgmt, multi_domain_capability_enabled) -/* the AssocID */ -#define STATION_ID_OFFSET offsetof(struct mib_mac_mgmt, station_id) -#define POWER_MGMT_MODE_OFFSET offsetof(struct mib_mac_mgmt, power_mgmt_mode) -#define LISTEN_INTERVAL_OFFSET offsetof(struct mib_mac, listen_interval) - -#define PRIVACY_OPT_IMPL offsetof(struct mib_mac_mgmt, privacy_option_implemented) - struct hwcfg_r505 { u8 cr39_values[14]; u8 reserved1[14]; |