Commit 6024089f authored by Quytelda Kahja's avatar Quytelda Kahja Committed by Greg Kroah-Hartman

staging: ks7010: Factor out common members in request structs.

Most of the request structures defined in ks_hostif.h have common
members:
* __le16 phy_type;
* __le16 cts_mode;
* __le16 scan_type;
* __le16 capability;
* struct rate_set16_t rate_set;

Factor out these members into a common substructure of type
'hostif_request_t'.  This allows a large portion of the request
initialization code in ks_hostif.c to be factored out into the
'init_request' function.
Signed-off-by: default avatarQuytelda Kahja <quytelda@tamalin.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 20e9cb0a
...@@ -1316,6 +1316,17 @@ static __le16 ks_wlan_cap(struct ks_wlan_private *priv) ...@@ -1316,6 +1316,17 @@ static __le16 ks_wlan_cap(struct ks_wlan_private *priv)
return cpu_to_le16((uint16_t)capability); return cpu_to_le16((uint16_t)capability);
} }
static void init_request(struct ks_wlan_private *priv, struct hostif_request_t *req)
{
req->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
req->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
req->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
req->rate_set.size = priv->reg.rate_set.size;
req->capability = ks_wlan_cap(priv);
memcpy(&req->rate_set.body[0], &priv->reg.rate_set.body[0],
priv->reg.rate_set.size);
}
static static
void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
{ {
...@@ -1325,14 +1336,8 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) ...@@ -1325,14 +1336,8 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv)
if (!pp) if (!pp)
return; return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); init_request(priv, &pp->request);
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
pp->rate_set.size = priv->reg.rate_set.size;
pp->capability = ks_wlan_cap(priv);
memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
priv->reg.rate_set.size);
/* send to device request */ /* send to device request */
ps_confirm_wait_inc(priv); ps_confirm_wait_inc(priv);
...@@ -1348,16 +1353,9 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv) ...@@ -1348,16 +1353,9 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv)
if (!pp) if (!pp)
return; return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); init_request(priv, &pp->request);
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
pp->rate_set.size = priv->reg.rate_set.size;
memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
priv->reg.rate_set.size);
pp->ssid.size = priv->reg.ssid.size; pp->ssid.size = priv->reg.ssid.size;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
pp->capability = ks_wlan_cap(priv);
pp->beacon_lost_count = pp->beacon_lost_count =
cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type));
...@@ -1395,16 +1393,9 @@ static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) ...@@ -1395,16 +1393,9 @@ static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv)
if (!pp) if (!pp)
return; return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); init_request(priv, &pp->request);
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
pp->rate_set.size = priv->reg.rate_set.size;
memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
priv->reg.rate_set.size);
pp->ssid.size = priv->reg.ssid.size; pp->ssid.size = priv->reg.ssid.size;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
pp->capability = ks_wlan_cap(priv);
pp->beacon_lost_count = pp->beacon_lost_count =
cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type));
...@@ -1445,16 +1436,10 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv) ...@@ -1445,16 +1436,10 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv)
if (!pp) if (!pp)
return; return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); init_request(priv, &pp->request);
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel));
pp->rate_set.size = priv->reg.rate_set.size;
memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
priv->reg.rate_set.size);
pp->ssid.size = priv->reg.ssid.size; pp->ssid.size = priv->reg.ssid.size;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
pp->capability = ks_wlan_cap(priv);
/* send to device request */ /* send to device request */
ps_confirm_wait_inc(priv); ps_confirm_wait_inc(priv);
...@@ -1470,15 +1455,9 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv) ...@@ -1470,15 +1455,9 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
if (!pp) if (!pp)
return; return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); init_request(priv, &pp->request);
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
pp->rate_set.size = priv->reg.rate_set.size;
memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0],
priv->reg.rate_set.size);
pp->ssid.size = priv->reg.ssid.size; pp->ssid.size = priv->reg.ssid.size;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
pp->capability = ks_wlan_cap(priv);
pp->channel_list.body[0] = priv->reg.channel; pp->channel_list.body[0] = priv->reg.channel;
pp->channel_list.size = 1; pp->channel_list.size = 1;
......
...@@ -335,6 +335,22 @@ struct hostif_stop_confirm_t { ...@@ -335,6 +335,22 @@ struct hostif_stop_confirm_t {
__le16 result_code; __le16 result_code;
} __packed; } __packed;
#define D_11B_ONLY_MODE 0
#define D_11G_ONLY_MODE 1
#define D_11BG_COMPATIBLE_MODE 2
#define D_11A_ONLY_MODE 3
#define CTS_MODE_FALSE 0
#define CTS_MODE_TRUE 1
struct hostif_request_t {
__le16 phy_type;
__le16 cts_mode;
__le16 scan_type;
__le16 capability;
struct rate_set16_t rate_set;
} __packed;
/** /**
* struct hostif_ps_adhoc_set_request_t - pseudo adhoc mode * struct hostif_ps_adhoc_set_request_t - pseudo adhoc mode
* @capability: bit5 : preamble * @capability: bit5 : preamble
...@@ -344,18 +360,8 @@ struct hostif_stop_confirm_t { ...@@ -344,18 +360,8 @@ struct hostif_stop_confirm_t {
*/ */
struct hostif_ps_adhoc_set_request_t { struct hostif_ps_adhoc_set_request_t {
struct hostif_hdr header; struct hostif_hdr header;
__le16 phy_type; struct hostif_request_t request;
#define D_11B_ONLY_MODE 0
#define D_11G_ONLY_MODE 1
#define D_11BG_COMPATIBLE_MODE 2
#define D_11A_ONLY_MODE 3
__le16 cts_mode;
#define CTS_MODE_FALSE 0
#define CTS_MODE_TRUE 1
__le16 channel; __le16 channel;
struct rate_set16_t rate_set;
__le16 capability;
__le16 scan_type;
} __packed; } __packed;
struct hostif_ps_adhoc_set_confirm_t { struct hostif_ps_adhoc_set_confirm_t {
...@@ -372,17 +378,13 @@ struct hostif_ps_adhoc_set_confirm_t { ...@@ -372,17 +378,13 @@ struct hostif_ps_adhoc_set_confirm_t {
*/ */
struct hostif_infrastructure_set_request_t { struct hostif_infrastructure_set_request_t {
struct hostif_hdr header; struct hostif_hdr header;
__le16 phy_type; struct hostif_request_t request;
__le16 cts_mode;
struct rate_set16_t rate_set;
struct ssid_t ssid; struct ssid_t ssid;
__le16 capability;
__le16 beacon_lost_count; __le16 beacon_lost_count;
__le16 auth_type; __le16 auth_type;
#define AUTH_TYPE_OPEN_SYSTEM 0 #define AUTH_TYPE_OPEN_SYSTEM 0
#define AUTH_TYPE_SHARED_KEY 1 #define AUTH_TYPE_SHARED_KEY 1
struct channel_list_t channel_list; struct channel_list_t channel_list;
__le16 scan_type;
} __packed; } __packed;
/** /**
...@@ -394,17 +396,13 @@ struct hostif_infrastructure_set_request_t { ...@@ -394,17 +396,13 @@ struct hostif_infrastructure_set_request_t {
*/ */
struct hostif_infrastructure_set2_request_t { struct hostif_infrastructure_set2_request_t {
struct hostif_hdr header; struct hostif_hdr header;
__le16 phy_type; struct hostif_request_t request;
__le16 cts_mode;
struct rate_set16_t rate_set;
struct ssid_t ssid; struct ssid_t ssid;
__le16 capability;
__le16 beacon_lost_count; __le16 beacon_lost_count;
__le16 auth_type; __le16 auth_type;
#define AUTH_TYPE_OPEN_SYSTEM 0 #define AUTH_TYPE_OPEN_SYSTEM 0
#define AUTH_TYPE_SHARED_KEY 1 #define AUTH_TYPE_SHARED_KEY 1
struct channel_list_t channel_list; struct channel_list_t channel_list;
__le16 scan_type;
u8 bssid[ETH_ALEN]; u8 bssid[ETH_ALEN];
} __packed; } __packed;
...@@ -422,13 +420,9 @@ struct hostif_infrastructure_set_confirm_t { ...@@ -422,13 +420,9 @@ struct hostif_infrastructure_set_confirm_t {
*/ */
struct hostif_adhoc_set_request_t { struct hostif_adhoc_set_request_t {
struct hostif_hdr header; struct hostif_hdr header;
__le16 phy_type; struct hostif_request_t request;
__le16 cts_mode;
__le16 channel;
struct rate_set16_t rate_set;
struct ssid_t ssid; struct ssid_t ssid;
__le16 capability; __le16 channel;
__le16 scan_type;
} __packed; } __packed;
/** /**
...@@ -440,13 +434,9 @@ struct hostif_adhoc_set_request_t { ...@@ -440,13 +434,9 @@ struct hostif_adhoc_set_request_t {
*/ */
struct hostif_adhoc_set2_request_t { struct hostif_adhoc_set2_request_t {
struct hostif_hdr header; struct hostif_hdr header;
__le16 phy_type; struct hostif_request_t request;
__le16 cts_mode;
__le16 reserved; __le16 reserved;
struct rate_set16_t rate_set;
struct ssid_t ssid; struct ssid_t ssid;
__le16 capability;
__le16 scan_type;
struct channel_list_t channel_list; struct channel_list_t channel_list;
u8 bssid[ETH_ALEN]; u8 bssid[ETH_ALEN];
} __packed; } __packed;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment