[PATCH] libertas: remove a hundred CMD_RET_xxx definitions

types.h contains the same amount of CMD_RET_xxx and CMD_xxx definitions.
They contains the same info: the firmware command opcode and, when the
firmware sends back a result, the command opcode ORed with 0x8000.

Having the same data twice in the source code is redundant and can lead to
errors (e.g. if you update or delete only one instance). This patch removed
all CMD_RET_xxx definitions and introduces a simple CMD_RET() macro.

Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Holger Schurig 2007-08-02 11:53:36 -04:00 коммит произвёл David S. Miller
Родитель ece5619193
Коммит 6b63cd0f42
4 изменённых файлов: 76 добавлений и 140 удалений

Просмотреть файл

@ -124,7 +124,7 @@ static int wlan_ret_reg_access(wlan_private * priv,
lbs_deb_enter(LBS_DEB_CMD);
switch (type) {
case CMD_RET_MAC_REG_ACCESS:
case CMD_RET(CMD_MAC_REG_ACCESS):
{
struct cmd_ds_mac_reg_access *reg = &resp->params.macreg;
@ -133,7 +133,7 @@ static int wlan_ret_reg_access(wlan_private * priv,
break;
}
case CMD_RET_BBP_REG_ACCESS:
case CMD_RET(CMD_BBP_REG_ACCESS):
{
struct cmd_ds_bbp_reg_access *reg = &resp->params.bbpreg;
@ -142,7 +142,7 @@ static int wlan_ret_reg_access(wlan_private * priv,
break;
}
case CMD_RET_RF_REG_ACCESS:
case CMD_RET(CMD_RF_REG_ACCESS):
{
struct cmd_ds_rf_reg_access *reg = &resp->params.rfreg;
@ -560,134 +560,135 @@ static inline int handle_cmd_response(u16 respcmd,
wlan_adapter *adapter = priv->adapter;
switch (respcmd) {
case CMD_RET_MAC_REG_ACCESS:
case CMD_RET_BBP_REG_ACCESS:
case CMD_RET_RF_REG_ACCESS:
case CMD_RET(CMD_MAC_REG_ACCESS):
case CMD_RET(CMD_BBP_REG_ACCESS):
case CMD_RET(CMD_RF_REG_ACCESS):
ret = wlan_ret_reg_access(priv, respcmd, resp);
break;
case CMD_RET_HW_SPEC_INFO:
case CMD_RET(CMD_GET_HW_SPEC):
ret = wlan_ret_get_hw_spec(priv, resp);
break;
case CMD_RET_802_11_SCAN:
case CMD_RET(CMD_802_11_SCAN):
ret = libertas_ret_80211_scan(priv, resp);
break;
case CMD_RET_802_11_GET_LOG:
case CMD_RET(CMD_802_11_GET_LOG):
ret = wlan_ret_get_log(priv, resp);
break;
case CMD_RET_802_11_ASSOCIATE:
case CMD_RET_802_11_REASSOCIATE:
case CMD_RET(CMD_802_11_ASSOCIATE):
case CMD_RET(CMD_802_11_REASSOCIATE):
ret = libertas_ret_80211_associate(priv, resp);
break;
case CMD_RET_802_11_DISASSOCIATE:
case CMD_RET_802_11_DEAUTHENTICATE:
case CMD_RET(CMD_802_11_DISASSOCIATE):
case CMD_RET(CMD_802_11_DEAUTHENTICATE):
ret = libertas_ret_80211_disassociate(priv, resp);
break;
case CMD_RET_802_11_AD_HOC_START:
case CMD_RET_802_11_AD_HOC_JOIN:
case CMD_RET(CMD_802_11_AD_HOC_START):
case CMD_RET(CMD_802_11_AD_HOC_JOIN):
ret = libertas_ret_80211_ad_hoc_start(priv, resp);
break;
case CMD_RET_802_11_STAT:
case CMD_RET(CMD_802_11_GET_STAT):
ret = wlan_ret_802_11_stat(priv, resp);
break;
case CMD_RET_802_11_SNMP_MIB:
case CMD_RET(CMD_802_11_SNMP_MIB):
ret = wlan_ret_802_11_snmp_mib(priv, resp);
break;
case CMD_RET_802_11_RF_TX_POWER:
case CMD_RET(CMD_802_11_RF_TX_POWER):
ret = wlan_ret_802_11_rf_tx_power(priv, resp);
break;
case CMD_RET_802_11_SET_AFC:
case CMD_RET_802_11_GET_AFC:
case CMD_RET(CMD_802_11_SET_AFC):
case CMD_RET(CMD_802_11_GET_AFC):
spin_lock_irqsave(&adapter->driver_lock, flags);
memmove(adapter->cur_cmd->pdata_buf, &resp->params.afc,
sizeof(struct cmd_ds_802_11_afc));
spin_unlock_irqrestore(&adapter->driver_lock, flags);
break;
case CMD_RET_802_11_RF_ANTENNA:
case CMD_RET(CMD_802_11_RF_ANTENNA):
ret = wlan_ret_802_11_rf_antenna(priv, resp);
break;
case CMD_RET_MAC_MULTICAST_ADR:
case CMD_RET_MAC_CONTROL:
case CMD_RET_802_11_SET_WEP:
case CMD_RET_802_11_RESET:
case CMD_RET_802_11_AUTHENTICATE:
case CMD_RET_802_11_RADIO_CONTROL:
case CMD_RET_802_11_BEACON_STOP:
case CMD_RET(CMD_MAC_MULTICAST_ADR):
case CMD_RET(CMD_MAC_CONTROL):
case CMD_RET(CMD_802_11_SET_WEP):
case CMD_RET(CMD_802_11_RESET):
case CMD_RET(CMD_802_11_AUTHENTICATE):
case CMD_RET(CMD_802_11_RADIO_CONTROL):
case CMD_RET(CMD_802_11_BEACON_STOP):
break;
case CMD_RET_802_11_ENABLE_RSN:
case CMD_RET(CMD_802_11_ENABLE_RSN):
ret = libertas_ret_802_11_enable_rsn(priv, resp);
break;
case CMD_RET_802_11_DATA_RATE:
case CMD_RET(CMD_802_11_DATA_RATE):
ret = wlan_ret_802_11_data_rate(priv, resp);
break;
case CMD_RET_802_11_RATE_ADAPT_RATESET:
case CMD_RET(CMD_802_11_RATE_ADAPT_RATESET):
ret = wlan_ret_802_11_rate_adapt_rateset(priv, resp);
break;
case CMD_RET_802_11_RF_CHANNEL:
case CMD_RET(CMD_802_11_RF_CHANNEL):
ret = wlan_ret_802_11_rf_channel(priv, resp);
break;
case CMD_RET_802_11_RSSI:
case CMD_RET(CMD_802_11_RSSI):
ret = wlan_ret_802_11_rssi(priv, resp);
break;
case CMD_RET_802_11_MAC_ADDRESS:
case CMD_RET(CMD_802_11_MAC_ADDRESS):
ret = wlan_ret_802_11_mac_address(priv, resp);
break;
case CMD_RET_802_11_AD_HOC_STOP:
case CMD_RET(CMD_802_11_AD_HOC_STOP):
ret = libertas_ret_80211_ad_hoc_stop(priv, resp);
break;
case CMD_RET_802_11_KEY_MATERIAL:
case CMD_RET(CMD_802_11_KEY_MATERIAL):
lbs_deb_cmd("CMD_RESP: KEY_MATERIAL command response\n");
ret = wlan_ret_802_11_key_material(priv, resp);
break;
case CMD_RET_802_11_EEPROM_ACCESS:
case CMD_RET(CMD_802_11_EEPROM_ACCESS):
ret = wlan_ret_802_11_eeprom_access(priv, resp);
break;
case CMD_RET_802_11D_DOMAIN_INFO:
case CMD_RET(CMD_802_11D_DOMAIN_INFO):
ret = libertas_ret_802_11d_domain_info(priv, resp);
break;
case CMD_RET_802_11_SLEEP_PARAMS:
case CMD_RET(CMD_802_11_SLEEP_PARAMS):
ret = wlan_ret_802_11_sleep_params(priv, resp);
break;
case CMD_RET_802_11_INACTIVITY_TIMEOUT:
case CMD_RET(CMD_802_11_INACTIVITY_TIMEOUT):
spin_lock_irqsave(&adapter->driver_lock, flags);
*((u16 *) adapter->cur_cmd->pdata_buf) =
le16_to_cpu(resp->params.inactivity_timeout.timeout);
spin_unlock_irqrestore(&adapter->driver_lock, flags);
break;
case CMD_RET_802_11_TPC_CFG:
case CMD_RET(CMD_802_11_TPC_CFG):
spin_lock_irqsave(&adapter->driver_lock, flags);
memmove(adapter->cur_cmd->pdata_buf, &resp->params.tpccfg,
sizeof(struct cmd_ds_802_11_tpc_cfg));
spin_unlock_irqrestore(&adapter->driver_lock, flags);
break;
case CMD_RET_802_11_LED_GPIO_CTRL:
case CMD_RET(CMD_802_11_LED_GPIO_CTRL):
spin_lock_irqsave(&adapter->driver_lock, flags);
memmove(adapter->cur_cmd->pdata_buf, &resp->params.ledgpio,
sizeof(struct cmd_ds_802_11_led_ctrl));
spin_unlock_irqrestore(&adapter->driver_lock, flags);
break;
case CMD_RET_802_11_PWR_CFG:
case CMD_RET(CMD_802_11_PWR_CFG):
spin_lock_irqsave(&adapter->driver_lock, flags);
memmove(adapter->cur_cmd->pdata_buf, &resp->params.pwrcfg,
sizeof(struct cmd_ds_802_11_pwr_cfg));
@ -695,32 +696,32 @@ static inline int handle_cmd_response(u16 respcmd,
break;
case CMD_RET_GET_TSF:
case CMD_RET(CMD_GET_TSF):
spin_lock_irqsave(&adapter->driver_lock, flags);
memcpy(priv->adapter->cur_cmd->pdata_buf,
&resp->params.gettsf.tsfvalue, sizeof(u64));
spin_unlock_irqrestore(&adapter->driver_lock, flags);
break;
case CMD_RET_BT_ACCESS:
case CMD_RET(CMD_BT_ACCESS):
spin_lock_irqsave(&adapter->driver_lock, flags);
if (adapter->cur_cmd->pdata_buf)
memcpy(adapter->cur_cmd->pdata_buf,
&resp->params.bt.addr1, 2 * ETH_ALEN);
spin_unlock_irqrestore(&adapter->driver_lock, flags);
break;
case CMD_RET_FWT_ACCESS:
case CMD_RET(CMD_FWT_ACCESS):
spin_lock_irqsave(&adapter->driver_lock, flags);
if (adapter->cur_cmd->pdata_buf)
memcpy(adapter->cur_cmd->pdata_buf, &resp->params.fwt,
sizeof(resp->params.fwt));
spin_unlock_irqrestore(&adapter->driver_lock, flags);
break;
case CMD_RET_MESH_ACCESS:
case CMD_RET(CMD_MESH_ACCESS):
if (adapter->cur_cmd->pdata_buf)
memcpy(adapter->cur_cmd->pdata_buf, &resp->params.mesh,
sizeof(resp->params.mesh));
break;
case CMD_RTE_802_11_TX_RATE_QUERY:
case CMD_RET(CMD_802_11_TX_RATE_QUERY):
priv->adapter->txrate = resp->params.txrate.txrate;
break;
default:
@ -782,7 +783,7 @@ int libertas_process_rx_command(wlan_private * priv)
/* Store the response code to cur_cmd_retcode. */
adapter->cur_cmd_retcode = result;;
if (respcmd == CMD_RET_802_11_PS_MODE) {
if (respcmd == CMD_RET(CMD_802_11_PS_MODE)) {
struct cmd_ds_802_11_ps_mode *psmode = &resp->params.psmode;
u16 action = le16_to_cpu(psmode->action);
@ -852,8 +853,8 @@ int libertas_process_rx_command(wlan_private * priv)
* Handling errors here
*/
switch (respcmd) {
case CMD_RET_HW_SPEC_INFO:
case CMD_RET_802_11_RESET:
case CMD_RET(CMD_GET_HW_SPEC):
case CMD_RET(CMD_802_11_RESET):
lbs_deb_cmd("CMD_RESP: Reset command failed\n");
break;

Просмотреть файл

@ -447,7 +447,7 @@ static ssize_t libertas_lowrssi_read(struct file *file, char __user *userbuf,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);
@ -511,7 +511,7 @@ static u16 libertas_get_events_bitmap(wlan_private *priv)
return 0;
}
if (pcmdptr->command != CMD_RET_802_11_SUBSCRIBE_EVENT) {
if (pcmdptr->command != CMD_RET(CMD_802_11_SUBSCRIBE_EVENT)) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
return 0;
@ -591,7 +591,7 @@ static ssize_t libertas_lowrssi_write(struct file *file,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);
@ -644,7 +644,7 @@ static ssize_t libertas_lowsnr_read(struct file *file, char __user *userbuf,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);
@ -743,7 +743,7 @@ static ssize_t libertas_lowsnr_write(struct file *file,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);
@ -797,7 +797,7 @@ static ssize_t libertas_failcount_read(struct file *file, char __user *userbuf,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);
@ -895,7 +895,7 @@ static ssize_t libertas_failcount_write(struct file *file,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);
@ -948,7 +948,7 @@ static ssize_t libertas_bcnmiss_read(struct file *file, char __user *userbuf,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
free_page(addr);
kfree(response_buf);
@ -1045,7 +1045,7 @@ static ssize_t libertas_bcnmiss_write(struct file *file,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
free_page(addr);
kfree(response_buf);
@ -1098,7 +1098,7 @@ static ssize_t libertas_highrssi_read(struct file *file, char __user *userbuf,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);
@ -1196,7 +1196,7 @@ static ssize_t libertas_highrssi_write(struct file *file,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
return 0;
@ -1248,7 +1248,7 @@ static ssize_t libertas_highsnr_read(struct file *file, char __user *userbuf,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);
@ -1347,7 +1347,7 @@ static ssize_t libertas_highsnr_write(struct file *file,
return 0;
}
if (pcmdptr->command != cpu_to_le16(CMD_RET_802_11_SUBSCRIBE_EVENT)) {
if (pcmdptr->command != cpu_to_le16(CMD_RET(CMD_802_11_SUBSCRIBE_EVENT))) {
lbs_pr_err("command response incorrect!\n");
kfree(response_buf);
free_page(addr);

Просмотреть файл

@ -22,7 +22,17 @@
#define CMD_OPTION_WAITFORRSP 0x0002
/** Host command ID */
/** Host command IDs */
/* Return command are almost always the same as the host command, but with
* bit 15 set high. There are a few exceptions, though...
*/
#define CMD_RET(cmd) (0x8000 | cmd)
/* Return command convention exceptions: */
#define CMD_RET_802_11_ASSOCIATE 0x8012
/* Command codes */
#define CMD_CODE_DNLD 0x0002
#define CMD_GET_HW_SPEC 0x0003
#define CMD_EEPROM_UPDATE 0x0004
@ -97,13 +107,10 @@
#define CMD_GET_TSF 0x0080
#define CMD_BT_ACCESS 0x0087
#define CMD_RET_BT_ACCESS 0x8087
#define CMD_FWT_ACCESS 0x0095
#define CMD_RET_FWT_ACCESS 0x8095
#define CMD_MESH_ACCESS 0x009b
#define CMD_RET_MESH_ACCESS 0x809b
/* For the IEEE Power Save */
#define CMD_SUBCMD_ENTER_PS 0x0030
@ -112,46 +119,6 @@
#define CMD_SUBCMD_FULL_POWERDOWN 0x0035
#define CMD_SUBCMD_FULL_POWERUP 0x0036
/* command RET code, MSB is set to 1 */
#define CMD_RET_HW_SPEC_INFO 0x8003
#define CMD_RET_EEPROM_UPDATE 0x8004
#define CMD_RET_802_11_RESET 0x8005
#define CMD_RET_802_11_SCAN 0x8006
#define CMD_RET_802_11_GET_LOG 0x800b
#define CMD_RET_MAC_CONTROL 0x8028
#define CMD_RET_MAC_MULTICAST_ADR 0x8010
#define CMD_RET_802_11_AUTHENTICATE 0x8011
#define CMD_RET_802_11_DEAUTHENTICATE 0x8024
#define CMD_RET_802_11_ASSOCIATE 0x8012
#define CMD_RET_802_11_REASSOCIATE 0x8025
#define CMD_RET_802_11_DISASSOCIATE 0x8026
#define CMD_RET_802_11_SET_WEP 0x8013
#define CMD_RET_802_11_STAT 0x8014
#define CMD_RET_802_3_STAT 0x8015
#define CMD_RET_802_11_SNMP_MIB 0x8016
#define CMD_RET_MAC_REG_MAP 0x8017
#define CMD_RET_BBP_REG_MAP 0x8018
#define CMD_RET_RF_REG_MAP 0x8023
#define CMD_RET_MAC_REG_ACCESS 0x8019
#define CMD_RET_BBP_REG_ACCESS 0x801a
#define CMD_RET_RF_REG_ACCESS 0x801b
#define CMD_RET_802_11_RADIO_CONTROL 0x801c
#define CMD_RET_802_11_RF_CHANNEL 0x801d
#define CMD_RET_802_11_RSSI 0x801f
#define CMD_RET_802_11_RF_TX_POWER 0x801e
#define CMD_RET_802_11_RF_ANTENNA 0x8020
#define CMD_RET_802_11_PS_MODE 0x8021
#define CMD_RET_802_11_DATA_RATE 0x8022
#define CMD_RET_802_11_AD_HOC_START 0x802B
#define CMD_RET_802_11_AD_HOC_JOIN 0x802C
#define CMD_RET_802_11_QUERY_TKIP_REPLY_CNTRS 0x802e
#define CMD_RET_802_11_ENABLE_RSN 0x802f
#define CMD_RET_802_11_PAIRWISE_TSC 0x8036
#define CMD_RET_802_11_GROUP_TSC 0x8037
#define CMD_RET_802_11_KEY_MATERIAL 0x805e
#define CMD_ENABLE_RSN 0x0001
#define CMD_DISABLE_RSN 0x0000
@ -162,38 +129,6 @@
#define CMD_ACT_SET_AES (CMD_ACT_SET + 2)
#define CMD_ACT_REMOVE_AES (CMD_ACT_SET + 3)
#define CMD_RET_802_11_SET_AFC 0x803c
#define CMD_RET_802_11_GET_AFC 0x803d
#define CMD_RET_802_11_AD_HOC_STOP 0x8040
#define CMD_RET_802_11_BEACON_STOP 0x8049
#define CMD_RET_802_11_MAC_ADDRESS 0x804D
#define CMD_RET_802_11_EEPROM_ACCESS 0x8059
#define CMD_RET_802_11_BAND_CONFIG 0x8058
#define CMD_RET_802_11_SLEEP_PARAMS 0x8066
#define CMD_RET_802_11_INACTIVITY_TIMEOUT 0x8067
#define CMD_RET_802_11D_DOMAIN_INFO (0x8000 | \
CMD_802_11D_DOMAIN_INFO)
#define CMD_RET_802_11_TPC_CFG (CMD_802_11_TPC_CFG | 0x8000)
#define CMD_RET_802_11_PWR_CFG (CMD_802_11_PWR_CFG | 0x8000)
#define CMD_RET_802_11_LED_GPIO_CTRL 0x804e
#define CMD_RET_802_11_SUBSCRIBE_EVENT (CMD_802_11_SUBSCRIBE_EVENT | 0x8000)
#define CMD_RET_802_11_RATE_ADAPT_RATESET (CMD_802_11_RATE_ADAPT_RATESET | 0x8000)
#define CMD_RTE_802_11_TX_RATE_QUERY (CMD_802_11_TX_RATE_QUERY | 0x8000)
#define CMD_RET_GET_TSF 0x8080
/* Define action or option for CMD_802_11_SET_WEP */
#define CMD_ACT_ADD 0x0002
#define CMD_ACT_REMOVE 0x0004

Просмотреть файл

@ -814,7 +814,7 @@ int libertas_ret_80211_ad_hoc_start(wlan_private * priv,
/* Send a Media Connected event, according to the Spec */
adapter->connect_status = LIBERTAS_CONNECTED;
if (command == CMD_RET_802_11_AD_HOC_START) {
if (command == CMD_RET(CMD_802_11_AD_HOC_START)) {
/* Update the created network descriptor with the new BSSID */
memcpy(bss->bssid, padhocresult->bssid, ETH_ALEN);
}