aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitkumar Karwar <akarwar@marvell.com>2012-02-02 23:48:57 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-06 14:55:53 -0500
commitf3c8d2591fa7278abe58ee0278a41d5b130d1718 (patch)
treed035f14b32068527b389d6d5e274a046068e0fee
parent3d86b93064c7f18378a2008bab9608ca7d11bdbb (diff)
mwifiex: cleanup in snmp_mib command preparation code
1) Remove unnecessary switch case usage. 2) Replace "X=cpu_to_le16(le16_to_cpu(X) + Y)" by "le16_add_cpu(X, Y)" 3) Declare "ul_temp" variable as u16 instead of u32 to avoid unnecessary typecasting Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/mwifiex/sta_cmd.c60
1 files changed, 8 insertions, 52 deletions
diff --git a/drivers/net/wireless/mwifiex/sta_cmd.c b/drivers/net/wireless/mwifiex/sta_cmd.c
index 6e443ffa0465..324c651527cb 100644
--- a/drivers/net/wireless/mwifiex/sta_cmd.c
+++ b/drivers/net/wireless/mwifiex/sta_cmd.c
@@ -103,7 +103,7 @@ static int mwifiex_cmd_mac_control(struct mwifiex_private *priv,
103static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv, 103static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv,
104 struct host_cmd_ds_command *cmd, 104 struct host_cmd_ds_command *cmd,
105 u16 cmd_action, u32 cmd_oid, 105 u16 cmd_action, u32 cmd_oid,
106 u32 *ul_temp) 106 u16 *ul_temp)
107{ 107{
108 struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib; 108 struct host_cmd_ds_802_11_snmp_mib *snmp_mib = &cmd->params.smib;
109 109
@@ -112,62 +112,18 @@ static int mwifiex_cmd_802_11_snmp_mib(struct mwifiex_private *priv,
112 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib) 112 cmd->size = cpu_to_le16(sizeof(struct host_cmd_ds_802_11_snmp_mib)
113 - 1 + S_DS_GEN); 113 - 1 + S_DS_GEN);
114 114
115 snmp_mib->oid = cpu_to_le16((u16)cmd_oid);
115 if (cmd_action == HostCmd_ACT_GEN_GET) { 116 if (cmd_action == HostCmd_ACT_GEN_GET) {
116 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET); 117 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_GET);
117 snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE); 118 snmp_mib->buf_size = cpu_to_le16(MAX_SNMP_BUF_SIZE);
118 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size) 119 le16_add_cpu(&cmd->size, MAX_SNMP_BUF_SIZE);
119 + MAX_SNMP_BUF_SIZE); 120 } else if (cmd_action == HostCmd_ACT_GEN_SET) {
121 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET);
122 snmp_mib->buf_size = cpu_to_le16(sizeof(u16));
123 *((__le16 *) (snmp_mib->value)) = cpu_to_le16(*ul_temp);
124 le16_add_cpu(&cmd->size, sizeof(u16));
120 } 125 }
121 126
122 switch (cmd_oid) {
123 case FRAG_THRESH_I:
124 snmp_mib->oid = cpu_to_le16((u16) FRAG_THRESH_I);
125 if (cmd_action == HostCmd_ACT_GEN_SET) {
126 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET);
127 snmp_mib->buf_size = cpu_to_le16(sizeof(u16));
128 *((__le16 *) (snmp_mib->value)) =
129 cpu_to_le16((u16) *ul_temp);
130 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size)
131 + sizeof(u16));
132 }
133 break;
134 case RTS_THRESH_I:
135 snmp_mib->oid = cpu_to_le16((u16) RTS_THRESH_I);
136 if (cmd_action == HostCmd_ACT_GEN_SET) {
137 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET);
138 snmp_mib->buf_size = cpu_to_le16(sizeof(u16));
139 *(__le16 *) (snmp_mib->value) =
140 cpu_to_le16((u16) *ul_temp);
141 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size)
142 + sizeof(u16));
143 }
144 break;
145
146 case SHORT_RETRY_LIM_I:
147 snmp_mib->oid = cpu_to_le16((u16) SHORT_RETRY_LIM_I);
148 if (cmd_action == HostCmd_ACT_GEN_SET) {
149 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET);
150 snmp_mib->buf_size = cpu_to_le16(sizeof(u16));
151 *((__le16 *) (snmp_mib->value)) =
152 cpu_to_le16((u16) *ul_temp);
153 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size)
154 + sizeof(u16));
155 }
156 break;
157 case DOT11D_I:
158 snmp_mib->oid = cpu_to_le16((u16) DOT11D_I);
159 if (cmd_action == HostCmd_ACT_GEN_SET) {
160 snmp_mib->query_type = cpu_to_le16(HostCmd_ACT_GEN_SET);
161 snmp_mib->buf_size = cpu_to_le16(sizeof(u16));
162 *((__le16 *) (snmp_mib->value)) =
163 cpu_to_le16((u16) *ul_temp);
164 cmd->size = cpu_to_le16(le16_to_cpu(cmd->size)
165 + sizeof(u16));
166 }
167 break;
168 default:
169 break;
170 }
171 dev_dbg(priv->adapter->dev, 127 dev_dbg(priv->adapter->dev,
172 "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x," 128 "cmd: SNMP_CMD: Action=0x%x, OID=0x%x, OIDSize=0x%x,"
173 " Value=0x%x\n", 129 " Value=0x%x\n",