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: Quytelda Kahja <quytelda@tamalin.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Quytelda Kahja 2018-03-22 22:07:41 -07:00 committed by Greg Kroah-Hartman
parent 20e9cb0a64
commit 6024089f0b
2 changed files with 38 additions and 69 deletions

View File

@ -1316,6 +1316,17 @@ static __le16 ks_wlan_cap(struct ks_wlan_private *priv)
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
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)
return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
init_request(priv, &pp->request);
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 */
ps_confirm_wait_inc(priv);
@ -1348,16 +1353,9 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv)
if (!pp)
return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
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);
init_request(priv, &pp->request);
pp->ssid.size = 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 =
cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
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)
if (!pp)
return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
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);
init_request(priv, &pp->request);
pp->ssid.size = 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 =
cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count));
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)
if (!pp)
return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode));
pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type));
init_request(priv, &pp->request);
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;
memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size);
pp->capability = ks_wlan_cap(priv);
/* send to device request */
ps_confirm_wait_inc(priv);
@ -1470,15 +1455,9 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv)
if (!pp)
return;
pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type));
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);
init_request(priv, &pp->request);
pp->ssid.size = 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.size = 1;

View File

@ -335,6 +335,22 @@ struct hostif_stop_confirm_t {
__le16 result_code;
} __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
* @capability: bit5 : preamble
@ -344,18 +360,8 @@ struct hostif_stop_confirm_t {
*/
struct hostif_ps_adhoc_set_request_t {
struct hostif_hdr header;
__le16 phy_type;
#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
struct hostif_request_t request;
__le16 channel;
struct rate_set16_t rate_set;
__le16 capability;
__le16 scan_type;
} __packed;
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_hdr header;
__le16 phy_type;
__le16 cts_mode;
struct rate_set16_t rate_set;
struct hostif_request_t request;
struct ssid_t ssid;
__le16 capability;
__le16 beacon_lost_count;
__le16 auth_type;
#define AUTH_TYPE_OPEN_SYSTEM 0
#define AUTH_TYPE_SHARED_KEY 1
struct channel_list_t channel_list;
__le16 scan_type;
} __packed;
/**
@ -394,17 +396,13 @@ struct hostif_infrastructure_set_request_t {
*/
struct hostif_infrastructure_set2_request_t {
struct hostif_hdr header;
__le16 phy_type;
__le16 cts_mode;
struct rate_set16_t rate_set;
struct hostif_request_t request;
struct ssid_t ssid;
__le16 capability;
__le16 beacon_lost_count;
__le16 auth_type;
#define AUTH_TYPE_OPEN_SYSTEM 0
#define AUTH_TYPE_SHARED_KEY 1
struct channel_list_t channel_list;
__le16 scan_type;
u8 bssid[ETH_ALEN];
} __packed;
@ -422,13 +420,9 @@ struct hostif_infrastructure_set_confirm_t {
*/
struct hostif_adhoc_set_request_t {
struct hostif_hdr header;
__le16 phy_type;
__le16 cts_mode;
__le16 channel;
struct rate_set16_t rate_set;
struct hostif_request_t request;
struct ssid_t ssid;
__le16 capability;
__le16 scan_type;
__le16 channel;
} __packed;
/**
@ -440,13 +434,9 @@ struct hostif_adhoc_set_request_t {
*/
struct hostif_adhoc_set2_request_t {
struct hostif_hdr header;
__le16 phy_type;
__le16 cts_mode;
struct hostif_request_t request;
__le16 reserved;
struct rate_set16_t rate_set;
struct ssid_t ssid;
__le16 capability;
__le16 scan_type;
struct channel_list_t channel_list;
u8 bssid[ETH_ALEN];
} __packed;