From 5312af9ecad609dd283974620e34445a085df227 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Fri, 30 Mar 2018 23:07:41 -0700 Subject: staging: ks7010: Use the ARRAY_SIZE() macro to calculate array sizes. This macro, provided in 'linux/kernel.h', will calculate the size more succinctly than a division operation. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 9078e13b0d4a..533feef604a9 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2702,10 +2702,9 @@ static const iw_handler ks_wlan_private_handler[] = { }; static const struct iw_handler_def ks_wlan_handler_def = { - .num_standard = sizeof(ks_wlan_handler) / sizeof(iw_handler), - .num_private = sizeof(ks_wlan_private_handler) / sizeof(iw_handler), - .num_private_args = - sizeof(ks_wlan_private_args) / sizeof(struct iw_priv_args), + .num_standard = ARRAY_SIZE(ks_wlan_handler), + .num_private = ARRAY_SIZE(ks_wlan_private_handler), + .num_private_args = ARRAY_SIZE(ks_wlan_private_args), .standard = (iw_handler *)ks_wlan_handler, .private = (iw_handler *)ks_wlan_private_handler, .private_args = (struct iw_priv_args *)ks_wlan_private_args, -- cgit v1.2.3-59-g8ed1b From 01d391d45701790be830e6af0a18fece388cc1f4 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Fri, 30 Mar 2018 23:08:34 -0700 Subject: staging: ks7010: Remove trailing _t from 'struct local_ap_t'. The "_t" suffix is not needed for structure names in this driver, and is a reflection of an older typedef system that is no longer in place. Replace all occurences of 'struct local_ap_t' with 'struct local_ap'. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 10 +++++----- drivers/staging/ks7010/ks_wlan.h | 6 +++--- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 92865d1363c4..442f5e2b44e5 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -109,14 +109,14 @@ int ks_wlan_do_power_save(struct ks_wlan_private *priv) static int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info) { - struct local_ap_t *ap; + struct local_ap *ap; union iwreq_data wrqu; struct net_device *netdev = priv->net_dev; ap = &priv->current_ap; if (is_disconnect_status(priv->connect_status)) { - memset(ap, 0, sizeof(struct local_ap_t)); + memset(ap, 0, sizeof(struct local_ap)); return -EPERM; } @@ -224,12 +224,12 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body) static int get_ap_information(struct ks_wlan_private *priv, struct ap_info *ap_info, - struct local_ap_t *ap) + struct local_ap *ap) { unsigned char *bp; int bsize, offset; - memset(ap, 0, sizeof(struct local_ap_t)); + memset(ap, 0, sizeof(struct local_ap)); /* bssid */ memcpy(ap->bssid, ap_info->bssid, ETH_ALEN); @@ -2359,7 +2359,7 @@ void hostif_sme_enqueue(struct ks_wlan_private *priv, unsigned short event) static inline void hostif_aplist_init(struct ks_wlan_private *priv) { - size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap_t); + size_t size = LOCAL_APLIST_MAX * sizeof(struct local_ap); priv->aplist.size = 0; memset(&priv->aplist.ap[0], 0, size); } diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 30d81f9456b7..3104ff92c453 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -218,7 +218,7 @@ struct wps_ie { } __packed; #endif /* WPS */ -struct local_ap_t { +struct local_ap { u8 bssid[6]; u8 rssi; u8 sq; @@ -246,7 +246,7 @@ struct local_ap_t { #define LOCAL_CURRENT_AP LOCAL_APLIST_MAX struct local_aplist_t { int size; - struct local_ap_t ap[LOCAL_APLIST_MAX + 1]; + struct local_ap ap[LOCAL_APLIST_MAX + 1]; }; struct local_gain_t { @@ -424,7 +424,7 @@ struct ks_wlan_private { unsigned char eth_addr[ETH_ALEN]; struct local_aplist_t aplist; - struct local_ap_t current_ap; + struct local_ap current_ap; struct power_save_status_t psstatus; struct sleep_status_t sleepstatus; struct wpa_status_t wpa; diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 533feef604a9..a4f10bec865f 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1301,7 +1301,7 @@ static int ks_wlan_set_scan(struct net_device *dev, static inline char *ks_wlan_translate_scan(struct net_device *dev, struct iw_request_info *info, char *current_ev, char *end_buf, - struct local_ap_t *ap) + struct local_ap *ap) { /* struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; */ struct iw_event iwe; /* Temporary buffer */ -- cgit v1.2.3-59-g8ed1b From 8b76eb091b5b8aec094b0fde9cf58856a8e699cb Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Fri, 30 Mar 2018 23:08:41 -0700 Subject: staging: ks7010: Remove trailing _t from 'struct wpa_key_t'. The "_t" suffix is not needed for structure names in this driver, and is a reflection of an older typedef system that is no longer in place. Replace all occurences of 'struct wpa_key_t' with 'struct wpa_key'. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 2 +- drivers/staging/ks7010/ks_wlan.h | 4 ++-- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 442f5e2b44e5..d5be57e974ac 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -318,7 +318,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv, struct michael_mic_t michael_mic; union iwreq_data wrqu; unsigned int key_index = auth_type - 1; - struct wpa_key_t *key = &priv->wpa.key[key_index]; + struct wpa_key *key = &priv->wpa.key[key_index]; eth_hdr = (struct ether_hdr *)(priv->rxp); eth_proto = ntohs(eth_hdr->h_proto); diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index ece9950ba893..2458dbba66a0 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -339,7 +339,7 @@ enum { #define MIC_KEY_SIZE 8 -struct wpa_key_t { +struct wpa_key { u32 ext_flags; /* IW_ENCODE_EXT_xxx */ u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ @@ -373,7 +373,7 @@ struct wpa_status_t { int key_mgmt_suite; /* authentication key management suite */ int auth_alg; int txkey; - struct wpa_key_t key[WPA_KEY_INDEX_MAX]; + struct wpa_key key[WPA_KEY_INDEX_MAX]; struct scan_ext scan_ext; struct mic_failure_t mic_failure; }; diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index a4f10bec865f..1b8234720d78 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1706,7 +1706,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_encode_ext *enc; int index = dwrq->flags & IW_ENCODE_INDEX; unsigned int commit = 0; - struct wpa_key_t *key; + struct wpa_key *key; enc = (struct iw_encode_ext *)extra; if (!enc) -- cgit v1.2.3-59-g8ed1b From b74024743e2530d0fe10b2e4cc6754c8c5af2be5 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Fri, 30 Mar 2018 23:08:45 -0700 Subject: staging: ks7010: Remove trailing _t from 'struct pmk_t'. The "_t" suffix is not needed for structure names in this driver, and is a reflection of an older typedef system that is no longer in place. Replace all occurences of 'struct pmk_t' with 'struct pmk'. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 2 +- drivers/staging/ks7010/ks_wlan.h | 2 +- drivers/staging/ks7010/ks_wlan_net.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 85b9e2678fd3..42f1cd823672 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -2130,7 +2130,7 @@ void hostif_sme_set_pmksa(struct ks_wlan_private *priv) u8 pmkid[IW_PMKID_LEN]; } __packed list[PMK_LIST_MAX]; } __packed pmkcache; - struct pmk_t *pmk; + struct pmk *pmk; int i; i = 0; diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 69eac00e75b1..20b584524a77 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -383,7 +383,7 @@ struct wpa_status { struct pmk_list { u16 size; struct list_head head; - struct pmk_t { + struct pmk { struct list_head list; u8 bssid[ETH_ALEN]; u8 pmkid[IW_PMKID_LEN]; diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 1b8234720d78..72a52c6f9fd2 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1818,7 +1818,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev, struct ks_wlan_private *priv = netdev_priv(dev); struct iw_pmksa *pmksa; int i; - struct pmk_t *pmk; + struct pmk *pmk; struct list_head *ptr; if (priv->sleep_mode == SLP_SLEEP) @@ -1847,7 +1847,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev, } /* search cache data */ list_for_each(ptr, &priv->pmklist.head) { - pmk = list_entry(ptr, struct pmk_t, list); + pmk = list_entry(ptr, struct pmk, list); if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) { memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); list_move(&pmk->list, &priv->pmklist.head); @@ -1869,7 +1869,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev, list_add(&pmk->list, &priv->pmklist.head); priv->pmklist.size++; } else { /* overwrite old cache data */ - pmk = list_entry(priv->pmklist.head.prev, struct pmk_t, + pmk = list_entry(priv->pmklist.head.prev, struct pmk, list); memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); @@ -1882,7 +1882,7 @@ static int ks_wlan_set_pmksa(struct net_device *dev, } /* search cache data */ list_for_each(ptr, &priv->pmklist.head) { - pmk = list_entry(ptr, struct pmk_t, list); + pmk = list_entry(ptr, struct pmk, list); if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) { eth_zero_addr(pmk->bssid); memset(pmk->pmkid, 0, IW_PMKID_LEN); -- cgit v1.2.3-59-g8ed1b From 582475a29c85bf7f15b3a6fd82371970dc7856bd Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Fri, 30 Mar 2018 23:08:50 -0700 Subject: staging: ks7010: Rename ks_wlan_set_multicast_list() All of the net_device_ops callbacks are named after their counterparts in the kernel's 'struct net_device_ops', except ks_wlan_set_multicast_list(). Rename it to ks_wlan_set_rx_mode() for greater consistency. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 72a52c6f9fd2..c4d94211b01b 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -73,7 +73,7 @@ static int ks_wlan_open(struct net_device *dev); static void ks_wlan_tx_timeout(struct net_device *dev); static int ks_wlan_start_xmit(struct sk_buff *skb, struct net_device *dev); static int ks_wlan_close(struct net_device *dev); -static void ks_wlan_set_multicast_list(struct net_device *dev); +static void ks_wlan_set_rx_mode(struct net_device *dev); static struct net_device_stats *ks_wlan_get_stats(struct net_device *dev); static int ks_wlan_set_mac_address(struct net_device *dev, void *addr); static int ks_wlan_netdev_ioctl(struct net_device *dev, struct ifreq *rq, @@ -2817,7 +2817,7 @@ void send_packet_complete(struct ks_wlan_private *priv, struct sk_buff *skb) * This routine is not state sensitive and need not be SMP locked. */ static -void ks_wlan_set_multicast_list(struct net_device *dev) +void ks_wlan_set_rx_mode(struct net_device *dev) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -2865,7 +2865,7 @@ static const struct net_device_ops ks_wlan_netdev_ops = { .ndo_set_mac_address = ks_wlan_set_mac_address, .ndo_get_stats = ks_wlan_get_stats, .ndo_tx_timeout = ks_wlan_tx_timeout, - .ndo_set_rx_mode = ks_wlan_set_multicast_list, + .ndo_set_rx_mode = ks_wlan_set_rx_mode, }; int ks_wlan_net_start(struct net_device *dev) -- cgit v1.2.3-59-g8ed1b From 8102f61d453edada4395bfc664538c3e11c6464d Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Fri, 30 Mar 2018 23:08:52 -0700 Subject: staging: ks7010: Change 'device_open_status' to a bool. The 'device_open_status' member of 'struct ks_wlan_private' is only ever set to zero or one, so it makes more sense for it to be a bool instead of an int. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan.h | 2 +- drivers/staging/ks7010/ks_wlan_net.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index eb0c14e78bd2..efda12258d44 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -443,7 +443,7 @@ struct ks_wlan_private { unsigned int need_commit; /* for ioctl */ /* DeviceIoControl */ - int device_open_status; + bool device_open_status; atomic_t event_count; atomic_t rec_count; int dev_count; diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index c4d94211b01b..9f9a51e96ab5 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2875,10 +2875,9 @@ int ks_wlan_net_start(struct net_device *dev) priv = netdev_priv(dev); priv->mac_address_valid = false; + priv->device_open_status = true; priv->need_commit = 0; - priv->device_open_status = 1; - /* phy information update timer */ atomic_set(&update_phyinfo, 0); timer_setup(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0); @@ -2908,7 +2907,7 @@ int ks_wlan_net_stop(struct net_device *dev) { struct ks_wlan_private *priv = netdev_priv(dev); - priv->device_open_status = 0; + priv->device_open_status = false; del_timer_sync(&update_phyinfo_timer); if (netif_running(dev)) -- cgit v1.2.3-59-g8ed1b From e9f830334ff97844ea98bc7fcac5a7baf10a9d91 Mon Sep 17 00:00:00 2001 From: Quytelda Kahja Date: Fri, 30 Mar 2018 23:08:53 -0700 Subject: staging: ks7010: Remove unnecessary casts in 'struct ks_wlan_handler_def'. The casts used when initializing members of this data structure mirror the types the variables already have. Remove the casts. Signed-off-by: Quytelda Kahja Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 9f9a51e96ab5..138d19a48a4c 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2705,9 +2705,9 @@ static const struct iw_handler_def ks_wlan_handler_def = { .num_standard = ARRAY_SIZE(ks_wlan_handler), .num_private = ARRAY_SIZE(ks_wlan_private_handler), .num_private_args = ARRAY_SIZE(ks_wlan_private_args), - .standard = (iw_handler *)ks_wlan_handler, - .private = (iw_handler *)ks_wlan_private_handler, - .private_args = (struct iw_priv_args *)ks_wlan_private_args, + .standard = ks_wlan_handler, + .private = ks_wlan_private_handler, + .private_args = ks_wlan_private_args, .get_wireless_stats = ks_get_wireless_stats, }; -- cgit v1.2.3-59-g8ed1b From 9b5124319d89321edfbb7c92de19b1afacd13042 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 6 Apr 2018 14:37:45 +0200 Subject: staging: ks7010: remove nosense #if 1 directive This commit removes #if 1 directive from code to improve readability. It is always true, so it makes no sense to have it there. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 138d19a48a4c..eaee49d76dff 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -966,7 +966,6 @@ static int ks_wlan_get_encode(struct net_device *dev, dwrq->length = priv->reg.wep_key[index].size; if (dwrq->length > 16) dwrq->length = 0; -#if 1 /* IW_ENCODE_NOKEY; */ if (dwrq->length) { if ((index >= 0) && (index < 4)) memcpy(extra, priv->reg.wep_key[index].val, @@ -974,7 +973,7 @@ static int ks_wlan_get_encode(struct net_device *dev, } else { memcpy(extra, zeros, dwrq->length); } -#endif + return 0; } -- cgit v1.2.3-59-g8ed1b From fffe8becb7cf67c78f954721689e6906cc936c68 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 19 Apr 2018 07:07:57 +0200 Subject: staging: ks7010: remove auxiliar zeros buffer in ks_wlan_get_encode This commit removes the local buffer zeros in ks_wlan_get_encode function. It also refactors related conditions in order to fill 'extra' output parameter of the function. Originally this zeros is just memset to zeros and only being used if drw->length is truncated to zero because of priv->reg.wep_key[index].size is greater than 16 chars. In those cases the final if statement is just using zeros but it is using memcpy with a length of zero bytes which has no sense. Instead of that just handle the good case copying from the same source the number of bytes of priv->reg.wep_key[index].size. If it is zero the final 'extra' parameter won't be copied at all because the number of bytes to copy will be zero. With this change the code gets simplified. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index eaee49d76dff..d0350a2c527e 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -932,7 +932,6 @@ static int ks_wlan_get_encode(struct net_device *dev, struct iw_point *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); - char zeros[16]; int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; if (priv->sleep_mode == SLP_SLEEP) @@ -951,8 +950,6 @@ static int ks_wlan_get_encode(struct net_device *dev, break; } - memset(zeros, 0, sizeof(zeros)); - /* Which key do we want ? -1 -> tx index */ if ((index < 0) || (index >= 4)) index = priv->reg.wep_index; @@ -962,16 +959,10 @@ static int ks_wlan_get_encode(struct net_device *dev, } dwrq->flags |= index + 1; /* Copy the key to the user buffer */ - if ((index >= 0) && (index < 4)) - dwrq->length = priv->reg.wep_key[index].size; - if (dwrq->length > 16) - dwrq->length = 0; - if (dwrq->length) { - if ((index >= 0) && (index < 4)) - memcpy(extra, priv->reg.wep_key[index].val, - dwrq->length); - } else { - memcpy(extra, zeros, dwrq->length); + if (index >= 0 && index < 4) { + dwrq->length = (priv->reg.wep_key[index].size <= 16) ? + priv->reg.wep_key[index].size : 0; + memcpy(extra, priv->reg.wep_key[index].val, dwrq->length); } return 0; -- cgit v1.2.3-59-g8ed1b From 6cf070d231d82d31248dfd204260ba8817f72d43 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 19 Apr 2018 07:07:58 +0200 Subject: staging: ks7010: refactor ks_wlan_set_encode function This commit refactors ks_wlan_set_encode function to improve readability. It just removes level indentation in some paths as well as removes not needed conditions paths which was checked before. Changes are as follows: - (dwrq->length > MAX_KEY_SIZE) check has been moved to the top. - extra check about (dwrq->length > 0) inside an if block where that was the condition to enter inside it has been removed. - (dwrq->flags & IW_ENCODE_NOKEY) check has been turned to avoid one level indentation. - extra check (index >= 0) && (index < 4) has been removed. In the top of the file invalid index values are being checked so it has no sense to check that again. - remove commented line. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 84 +++++++++++++----------------------- 1 file changed, 31 insertions(+), 53 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index d0350a2c527e..1f2e9f3e2f85 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -819,64 +819,48 @@ static int ks_wlan_set_encode(struct net_device *dev, struct iw_point *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); - struct wep_key key; int index = (dwrq->flags & IW_ENCODE_INDEX); - int current_index = priv->reg.wep_index; - int i; if (priv->sleep_mode == SLP_SLEEP) return -EPERM; + if (dwrq->length > MAX_KEY_SIZE) + return -EINVAL; + /* for SLEEP MODE */ - /* index check */ if ((index < 0) || (index > 4)) return -EINVAL; - else if (index == 0) - index = current_index; - else - index--; + + index = (index == 0) ? priv->reg.wep_index : (index - 1); /* Is WEP supported ? */ /* Basic checking: do we have a key to set ? */ if (dwrq->length > 0) { - if (dwrq->length > MAX_KEY_SIZE) { /* Check the size of the key */ - return -EINVAL; - } - if (dwrq->length > MIN_KEY_SIZE) { /* Set the length */ - key.len = MAX_KEY_SIZE; - priv->reg.privacy_invoked = 0x01; - priv->need_commit |= SME_WEP_FLAG; - wep_on_off = WEP_ON_128BIT; - } else { - if (dwrq->length > 0) { - key.len = MIN_KEY_SIZE; - priv->reg.privacy_invoked = 0x01; - priv->need_commit |= SME_WEP_FLAG; - wep_on_off = WEP_ON_64BIT; - } else { /* Disable the key */ - key.len = 0; - } - } + key.len = (dwrq->length > MIN_KEY_SIZE) ? + MAX_KEY_SIZE : MIN_KEY_SIZE; + priv->reg.privacy_invoked = 0x01; + priv->need_commit |= SME_WEP_FLAG; + wep_on_off = (dwrq->length > MIN_KEY_SIZE) ? + WEP_ON_128BIT : WEP_ON_64BIT; /* Check if the key is not marked as invalid */ - if (!(dwrq->flags & IW_ENCODE_NOKEY)) { - /* Cleanup */ - memset(key.key, 0, MAX_KEY_SIZE); - /* Copy the key in the driver */ - if (copy_from_user - (key.key, dwrq->pointer, dwrq->length)) { - key.len = 0; - return -EFAULT; - } - /* Send the key to the card */ - priv->reg.wep_key[index].size = key.len; - for (i = 0; i < (priv->reg.wep_key[index].size); i++) - priv->reg.wep_key[index].val[i] = key.key[i]; + if (dwrq->flags & IW_ENCODE_NOKEY) + return 0; - priv->need_commit |= (SME_WEP_VAL1 << index); - priv->reg.wep_index = index; - priv->need_commit |= SME_WEP_INDEX; + /* Cleanup */ + memset(key.key, 0, MAX_KEY_SIZE); + /* Copy the key in the driver */ + if (copy_from_user(key.key, dwrq->pointer, dwrq->length)) { + key.len = 0; + return -EFAULT; } + /* Send the key to the card */ + priv->reg.wep_key[index].size = key.len; + memcpy(&priv->reg.wep_key[index].val[0], &key.key[0], + priv->reg.wep_key[index].size); + priv->need_commit |= (SME_WEP_VAL1 << index); + priv->reg.wep_index = index; + priv->need_commit |= SME_WEP_INDEX; } else { if (dwrq->flags & IW_ENCODE_DISABLED) { priv->reg.wep_key[0].size = 0; @@ -891,16 +875,11 @@ static int ks_wlan_set_encode(struct net_device *dev, wep_on_off = WEP_OFF; priv->need_commit |= SME_WEP_FLAG; } else { - /* Do we want to just set the transmit key index ? */ - if ((index >= 0) && (index < 4)) { - /* set_wep_key(priv, index, 0, 0, 1); xxx */ - if (priv->reg.wep_key[index].size != 0) { - priv->reg.wep_index = index; - priv->need_commit |= SME_WEP_INDEX; - } else { - return -EINVAL; - } - } + /* set_wep_key(priv, index, 0, 0, 1); xxx */ + if (priv->reg.wep_key[index].size == 0) + return -EINVAL; + priv->reg.wep_index = index; + priv->need_commit |= SME_WEP_INDEX; } } @@ -919,7 +898,6 @@ static int ks_wlan_set_encode(struct net_device *dev, priv->reg.authenticate_type = AUTH_TYPE_SHARED_KEY; } -// return -EINPROGRESS; /* Call commit handler */ if (priv->need_commit) { ks_wlan_setup_parameter(priv, priv->need_commit); priv->need_commit = 0; -- cgit v1.2.3-59-g8ed1b From 9dbeb16aab70af79ab853e5237d23c7a24b8d820 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 19 Apr 2018 07:07:59 +0200 Subject: staging: ks7010: change if-else condition assignment to use ternary operator This commit changes an if-else block used to just assign a variable to use a ternary operator to do the same improving readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 1f2e9f3e2f85..6a0ec9c66603 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -673,10 +673,7 @@ static int ks_wlan_get_rate(struct net_device *dev, ks_wlan_update_phy_information(priv); vwrq->value = ((priv->current_rate) & RATE_MASK) * 500000; - if (priv->reg.tx_rate == TX_RATE_FIXED) - vwrq->fixed = 1; - else - vwrq->fixed = 0; + vwrq->fixed = (priv->reg.tx_rate == TX_RATE_FIXED) ? 1 : 0; return 0; } -- cgit v1.2.3-59-g8ed1b From 6cb3e6062bcae0d841188d59091c6720ff8981c3 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 19 Apr 2018 07:08:00 +0200 Subject: staging: ks7010: refactor ks_wlan_set_rx_gain function This commit refactors ks_wlan_set_rx_gain function to improve readability: - error condition is handling the error to avoid an 'else' - ternary operator is used to clean if-else block assignment. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 6a0ec9c66603..2fbacc56abdd 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2327,16 +2327,11 @@ static int ks_wlan_set_rx_gain(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ - priv->gain.rx_gain = (uint8_t)*uwrq; - else + if (*uwrq < 0 || *uwrq > 0xFF) return -EINVAL; - if (priv->gain.rx_gain < 0xFF) - priv->gain.rx_mode = 1; - else - priv->gain.rx_mode = 0; - + priv->gain.rx_gain = (uint8_t)*uwrq; + priv->gain.rx_mode = (priv->gain.rx_gain < 0xFF) ? 1 : 0; hostif_sme_enqueue(priv, SME_SET_GAIN); return 0; } -- cgit v1.2.3-59-g8ed1b From 86357f794b9692e8754718183801ce5d6f163392 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 19 Apr 2018 07:08:01 +0200 Subject: staging: ks7010: refactor ks_wlan_set_tx_gain function This commit refactors ks_wlan_set_rx_gain function to improve readability: - error condition is handling the error to avoid an 'else' - ternary operator is used to clean if-else block assignment. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 2fbacc56abdd..81889a5b2251 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2290,16 +2290,11 @@ static int ks_wlan_set_tx_gain(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq >= 0 && *uwrq <= 0xFF) /* 0-255 */ - priv->gain.tx_gain = (uint8_t)*uwrq; - else + if (*uwrq < 0 || *uwrq > 0xFF) return -EINVAL; - if (priv->gain.tx_gain < 0xFF) - priv->gain.tx_mode = 1; - else - priv->gain.tx_mode = 0; - + priv->gain.tx_gain = (uint8_t)*uwrq; + priv->gain.tx_mode = (priv->gain.tx_gain < 0xFF) ? 1 : 0; hostif_sme_enqueue(priv, SME_SET_GAIN); return 0; } -- cgit v1.2.3-59-g8ed1b From 6519967b959b2b412b6d6012f251a9d80e1f920c Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 19 Apr 2018 07:08:02 +0200 Subject: staging: ks7010: refactor ks_wlan_set_wps_enable function This commit refactors ks_wlan_set_wps_enable function to improve readability handling the error first to avoid an 'else'. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 81889a5b2251..74946e964a25 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2224,11 +2224,10 @@ static int ks_wlan_set_wps_enable(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq == 0 || *uwrq == 1) - priv->wps.wps_enabled = *uwrq; - else + if (*uwrq != 0 && *uwrq != 1) return -EINVAL; + priv->wps.wps_enabled = *uwrq; hostif_sme_enqueue(priv, SME_WPS_ENABLE_REQUEST); return 0; -- cgit v1.2.3-59-g8ed1b From 8a4e6ab3f544f409b1ec6e3d7ebb47a598afb929 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 19 Apr 2018 07:08:03 +0200 Subject: staging: ks7010: review includes of ks_wlan_net.c file This commit reviews really needed includes in ks_wlan_net.c source file. It removes those which are not needed at all. It also reorder the remaining ones in alphabetical order. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 74946e964a25..c53a61458bf2 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -9,23 +9,11 @@ * published by the Free Software Foundation. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include -#include -#include -#include +#include +#include #include -#include -#include #include static int wep_on_off; -- cgit v1.2.3-59-g8ed1b From 5e8779dcdcc51fda2437f39deef26b6b6af5058a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 19 Apr 2018 07:08:13 +0200 Subject: staging: ks7010: align comments in ks_wlan_private_handler This commit align comment inside ks_wlan_private_handler WEXT private driver operations. This improves readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 39 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index c53a61458bf2..05f8216e502b 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2602,31 +2602,30 @@ static const iw_handler ks_wlan_handler[] = { /* private_handler */ static const iw_handler ks_wlan_private_handler[] = { - (iw_handler)NULL, /* 0 */ - (iw_handler)NULL, /* 1, used to be: KS_WLAN_GET_DRIVER_VERSION */ - (iw_handler)NULL, /* 2 */ - (iw_handler)ks_wlan_get_firmware_version, /* 3 KS_WLAN_GET_FIRM_VERSION */ + (iw_handler)NULL, /* 0 */ + (iw_handler)NULL, /* 1, KS_WLAN_GET_DRIVER_VERSION */ + (iw_handler)NULL, /* 2 */ + (iw_handler)ks_wlan_get_firmware_version,/* 3 KS_WLAN_GET_FIRM_VERSION */ #ifdef WPS - (iw_handler)ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ - (iw_handler)ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ - (iw_handler)ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ + (iw_handler)ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ + (iw_handler)ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ + (iw_handler)ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ #else - (iw_handler)NULL, /* 4 */ - (iw_handler)NULL, /* 5 */ - (iw_handler)NULL, /* 6 */ + (iw_handler)NULL, /* 4 */ + (iw_handler)NULL, /* 5 */ + (iw_handler)NULL, /* 6 */ #endif /* WPS */ - - (iw_handler)ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ - (iw_handler)ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ - (iw_handler)ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ + (iw_handler)ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ + (iw_handler)ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ + (iw_handler)ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ (iw_handler)ks_wlan_set_power_mgmt, /* 10 KS_WLAN_SET_POWER_SAVE */ (iw_handler)ks_wlan_get_power_mgmt, /* 11 KS_WLAN_GET_POWER_SAVE */ (iw_handler)ks_wlan_set_scan_type, /* 12 KS_WLAN_SET_SCAN_TYPE */ (iw_handler)ks_wlan_get_scan_type, /* 13 KS_WLAN_GET_SCAN_TYPE */ (iw_handler)ks_wlan_set_rx_gain, /* 14 KS_WLAN_SET_RX_GAIN */ (iw_handler)ks_wlan_get_rx_gain, /* 15 KS_WLAN_GET_RX_GAIN */ - (iw_handler)ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */ - (iw_handler)NULL, /* 17 */ + (iw_handler)ks_wlan_hostt, /* 16 KS_WLAN_HOSTT */ + (iw_handler)NULL, /* 17 */ (iw_handler)ks_wlan_set_beacon_lost, /* 18 KS_WLAN_SET_BECAN_LOST */ (iw_handler)ks_wlan_get_beacon_lost, /* 19 KS_WLAN_GET_BECAN_LOST */ (iw_handler)ks_wlan_set_tx_gain, /* 20 KS_WLAN_SET_TX_GAIN */ @@ -2635,12 +2634,12 @@ static const iw_handler ks_wlan_private_handler[] = { (iw_handler)ks_wlan_get_phy_type, /* 23 KS_WLAN_GET_PHY_TYPE */ (iw_handler)ks_wlan_set_cts_mode, /* 24 KS_WLAN_SET_CTS_MODE */ (iw_handler)ks_wlan_get_cts_mode, /* 25 KS_WLAN_GET_CTS_MODE */ - (iw_handler)NULL, /* 26 */ - (iw_handler)NULL, /* 27 */ + (iw_handler)NULL, /* 26 */ + (iw_handler)NULL, /* 27 */ (iw_handler)ks_wlan_set_sleep_mode, /* 28 KS_WLAN_SET_SLEEP_MODE */ (iw_handler)ks_wlan_get_sleep_mode, /* 29 KS_WLAN_GET_SLEEP_MODE */ - (iw_handler)NULL, /* 30 */ - (iw_handler)NULL, /* 31 */ + (iw_handler)NULL, /* 30 */ + (iw_handler)NULL, /* 31 */ }; static const struct iw_handler_def ks_wlan_handler_def = { -- cgit v1.2.3-59-g8ed1b From d892cc1cfe0c1ce4e4eb58a1877835802953adac Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Apr 2018 15:44:48 +0200 Subject: staging: ks7010: change name and type for device_open_status field This commit changes type for device_open_status field of ks_wlan_private structure from int to bool. This variable is only be set to 1 on ks_wlan_net_start and set to 0 on ks_wlan_net_stop. For this purpose it is not necessary at all to use an integer because a bool is enough. This also renames field name from device_open_status to is_device_open. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 2 +- drivers/staging/ks7010/ks_wlan.h | 2 +- drivers/staging/ks7010/ks_wlan_net.c | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index d11b0a2259e2..3b10f9ac0fa0 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -1562,7 +1562,7 @@ void hostif_mic_failure_request(struct ks_wlan_private *priv, static void devio_rec_ind(struct ks_wlan_private *priv, unsigned char *p, unsigned int size) { - if (priv->device_open_status) { + if (priv->is_device_open) { spin_lock(&priv->dev_read_lock); /* request spin lock */ priv->dev_data[atomic_read(&priv->rec_count)] = p; priv->dev_size[atomic_read(&priv->rec_count)] = size; diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 615c42e2cffb..52de44866d53 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -424,7 +424,7 @@ struct ks_wlan_private { unsigned int need_commit; /* for ioctl */ /* DeviceIoControl */ - bool device_open_status; + bool is_device_open; atomic_t event_count; atomic_t rec_count; int dev_count; diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 05f8216e502b..76ed4ed9d167 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2816,9 +2816,8 @@ int ks_wlan_net_start(struct net_device *dev) priv = netdev_priv(dev); priv->mac_address_valid = false; - priv->device_open_status = true; + priv->is_device_open = true; priv->need_commit = 0; - /* phy information update timer */ atomic_set(&update_phyinfo, 0); timer_setup(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0); @@ -2848,7 +2847,7 @@ int ks_wlan_net_stop(struct net_device *dev) { struct ks_wlan_private *priv = netdev_priv(dev); - priv->device_open_status = false; + priv->is_device_open = false; del_timer_sync(&update_phyinfo_timer); if (netif_running(dev)) -- cgit v1.2.3-59-g8ed1b From 18e76e23740a4fd86808ef97cb023cf76f7cc942 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Apr 2018 15:44:56 +0200 Subject: staging: ks7010: use IW_HANDLER macro in ks_wlan_handler This commit make use of IW_HANDLER to set wext operations of the device. Using this, comments are not neccessary anymore and also NULL entries so readability is clearly increased. In order to avoid casting because of the use of a different prototype in all related functions, those which are affected have been updated also to make use of the union iwreq_data as third parameter updating code accordly. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 446 +++++++++++++++++------------------ 1 file changed, 213 insertions(+), 233 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 76ed4ed9d167..05cdeb1edb1e 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -160,7 +160,8 @@ int ks_wlan_setup_parameter(struct ks_wlan_private *priv, */ static int ks_wlan_get_name(struct net_device *dev, - struct iw_request_info *info, char *cwrq, + struct iw_request_info *info, + union iwreq_data *cwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -170,20 +171,20 @@ static int ks_wlan_get_name(struct net_device *dev, /* for SLEEP MODE */ if (priv->dev_state < DEVICE_STATE_READY) - strcpy(cwrq, "NOT READY!"); + strcpy(cwrq->name, "NOT READY!"); else if (priv->reg.phy_type == D_11B_ONLY_MODE) - strcpy(cwrq, "IEEE 802.11b"); + strcpy(cwrq->name, "IEEE 802.11b"); else if (priv->reg.phy_type == D_11G_ONLY_MODE) - strcpy(cwrq, "IEEE 802.11g"); + strcpy(cwrq->name, "IEEE 802.11g"); else - strcpy(cwrq, "IEEE 802.11b/g"); + strcpy(cwrq->name, "IEEE 802.11b/g"); return 0; } static int ks_wlan_set_freq(struct net_device *dev, - struct iw_request_info *info, struct iw_freq *fwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *fwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); int channel; @@ -193,28 +194,28 @@ static int ks_wlan_set_freq(struct net_device *dev, /* for SLEEP MODE */ /* If setting by frequency, convert to a channel */ - if ((fwrq->e == 1) && - (fwrq->m >= (int)2.412e8) && (fwrq->m <= (int)2.487e8)) { - int f = fwrq->m / 100000; + if ((fwrq->freq.e == 1) && + (fwrq->freq.m >= (int)2.412e8) && (fwrq->freq.m <= (int)2.487e8)) { + int f = fwrq->freq.m / 100000; int c = 0; while ((c < 14) && (f != frequency_list[c])) c++; /* Hack to fall through... */ - fwrq->e = 0; - fwrq->m = c + 1; + fwrq->freq.e = 0; + fwrq->freq.m = c + 1; } /* Setting by channel number */ - if ((fwrq->m > 1000) || (fwrq->e > 0)) + if ((fwrq->freq.m > 1000) || (fwrq->freq.e > 0)) return -EOPNOTSUPP; - channel = fwrq->m; + channel = fwrq->freq.m; /* We should do a better check than that, * based on the card capability !!! */ if ((channel < 1) || (channel > 14)) { netdev_dbg(dev, "%s: New channel value of %d is invalid!\n", - dev->name, fwrq->m); + dev->name, fwrq->freq.m); return -EINVAL; } @@ -226,8 +227,8 @@ static int ks_wlan_set_freq(struct net_device *dev, } static int ks_wlan_get_freq(struct net_device *dev, - struct iw_request_info *info, struct iw_freq *fwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *fwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); int f; @@ -241,15 +242,15 @@ static int ks_wlan_get_freq(struct net_device *dev, else f = (int)priv->reg.channel; - fwrq->m = frequency_list[f - 1] * 100000; - fwrq->e = 1; + fwrq->freq.m = frequency_list[f - 1] * 100000; + fwrq->freq.e = 1; return 0; } static int ks_wlan_set_essid(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); size_t len; @@ -259,12 +260,12 @@ static int ks_wlan_set_essid(struct net_device *dev, /* for SLEEP MODE */ /* Check if we asked for `any' */ - if (!dwrq->flags) { + if (!dwrq->essid.flags) { /* Just send an empty SSID list */ memset(priv->reg.ssid.body, 0, sizeof(priv->reg.ssid.body)); priv->reg.ssid.size = 0; } else { - len = dwrq->length; + len = dwrq->essid.length; /* iwconfig uses nul termination in SSID.. */ if (len > 0 && extra[len - 1] == '\0') len--; @@ -288,7 +289,7 @@ static int ks_wlan_set_essid(struct net_device *dev, static int ks_wlan_get_essid(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -306,18 +307,18 @@ static int ks_wlan_get_essid(struct net_device *dev, /* If none, we may want to get the one that was set */ /* Push it out ! */ - dwrq->length = priv->reg.ssid.size; - dwrq->flags = 1; /* active */ + dwrq->essid.length = priv->reg.ssid.size; + dwrq->essid.flags = 1; /* active */ } else { - dwrq->length = 0; - dwrq->flags = 0; /* ANY */ + dwrq->essid.length = 0; + dwrq->essid.flags = 0; /* ANY */ } return 0; } static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, - struct sockaddr *ap_addr, char *extra) + union iwreq_data *awrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -327,7 +328,7 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, /* for SLEEP MODE */ if (priv->reg.operation_mode == MODE_ADHOC || priv->reg.operation_mode == MODE_INFRASTRUCTURE) { - memcpy(priv->reg.bssid, &ap_addr->sa_data, ETH_ALEN); + memcpy(priv->reg.bssid, &awrq->ap_addr.sa_data, ETH_ALEN); if (is_valid_ether_addr((u8 *)priv->reg.bssid)) priv->need_commit |= SME_MODE_SET; @@ -348,7 +349,7 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, } static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, - struct sockaddr *awrq, char *extra) + union iwreq_data *awrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -357,18 +358,18 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, /* for SLEEP MODE */ if (is_connect_status(priv->connect_status)) - memcpy(awrq->sa_data, priv->current_ap.bssid, ETH_ALEN); + memcpy(awrq->ap_addr.sa_data, priv->current_ap.bssid, ETH_ALEN); else - eth_zero_addr(awrq->sa_data); + eth_zero_addr(awrq->ap_addr.sa_data); - awrq->sa_family = ARPHRD_ETHER; + awrq->ap_addr.sa_family = ARPHRD_ETHER; return 0; } static int ks_wlan_set_nick(struct net_device *dev, - struct iw_request_info *info, struct iw_point *dwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -377,18 +378,18 @@ static int ks_wlan_set_nick(struct net_device *dev, /* for SLEEP MODE */ /* Check the size of the string */ - if (dwrq->length > 16 + 1) + if (dwrq->data.length > 16 + 1) return -E2BIG; memset(priv->nick, 0, sizeof(priv->nick)); - memcpy(priv->nick, extra, dwrq->length); + memcpy(priv->nick, extra, dwrq->data.length); return -EINPROGRESS; /* Call commit handler */ } static int ks_wlan_get_nick(struct net_device *dev, - struct iw_request_info *info, struct iw_point *dwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -398,14 +399,14 @@ static int ks_wlan_get_nick(struct net_device *dev, /* for SLEEP MODE */ strncpy(extra, priv->nick, 16); extra[16] = '\0'; - dwrq->length = strlen(extra) + 1; + dwrq->data.length = strlen(extra) + 1; return 0; } static int ks_wlan_set_rate(struct net_device *dev, - struct iw_request_info *info, struct iw_param *vwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); int i = 0; @@ -415,17 +416,17 @@ static int ks_wlan_set_rate(struct net_device *dev, /* for SLEEP MODE */ if (priv->reg.phy_type == D_11B_ONLY_MODE) { - if (vwrq->fixed == 1) { - switch (vwrq->value) { + if (vwrq->bitrate.fixed == 1) { + switch (vwrq->bitrate.value) { case 11000000: case 5500000: priv->reg.rate_set.body[0] = - (uint8_t)(vwrq->value / 500000); + (uint8_t)(vwrq->bitrate.value / 500000); break; case 2000000: case 1000000: priv->reg.rate_set.body[0] = - ((uint8_t)(vwrq->value / 500000)) | + ((uint8_t)(vwrq->bitrate.value / 500000)) | BASIC_RATE; break; default: @@ -434,8 +435,8 @@ static int ks_wlan_set_rate(struct net_device *dev, priv->reg.tx_rate = TX_RATE_FIXED; priv->reg.rate_set.size = 1; } else { /* vwrq->fixed == 0 */ - if (vwrq->value > 0) { - switch (vwrq->value) { + if (vwrq->bitrate.value > 0) { + switch (vwrq->bitrate.value) { case 11000000: priv->reg.rate_set.body[3] = TX_RATE_11M; @@ -472,15 +473,15 @@ static int ks_wlan_set_rate(struct net_device *dev, } } } else { /* D_11B_ONLY_MODE or D_11BG_COMPATIBLE_MODE */ - if (vwrq->fixed == 1) { - switch (vwrq->value) { + if (vwrq->bitrate.fixed == 1) { + switch (vwrq->bitrate.value) { case 54000000: case 48000000: case 36000000: case 18000000: case 9000000: priv->reg.rate_set.body[0] = - (uint8_t)(vwrq->value / 500000); + (uint8_t)(vwrq->bitrate.value / 500000); break; case 24000000: case 12000000: @@ -490,7 +491,7 @@ static int ks_wlan_set_rate(struct net_device *dev, case 2000000: case 1000000: priv->reg.rate_set.body[0] = - ((uint8_t)(vwrq->value / 500000)) | + ((uint8_t)(vwrq->bitrate.value / 500000)) | BASIC_RATE; break; default: @@ -499,8 +500,8 @@ static int ks_wlan_set_rate(struct net_device *dev, priv->reg.tx_rate = TX_RATE_FIXED; priv->reg.rate_set.size = 1; } else { /* vwrq->fixed == 0 */ - if (vwrq->value > 0) { - switch (vwrq->value) { + if (vwrq->bitrate.value > 0) { + switch (vwrq->bitrate.value) { case 54000000: priv->reg.rate_set.body[11] = TX_RATE_54M; @@ -522,7 +523,7 @@ static int ks_wlan_set_rate(struct net_device *dev, case 11000000: case 9000000: case 6000000: - if (vwrq->value == 24000000) { + if (vwrq->bitrate.value == 24000000) { priv->reg.rate_set.body[8] = TX_RATE_18M; i++; @@ -541,7 +542,7 @@ static int ks_wlan_set_rate(struct net_device *dev, priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; i++; - } else if (vwrq->value == 18000000) { + } else if (vwrq->bitrate.value == 18000000) { priv->reg.rate_set.body[7] = TX_RATE_18M; i++; @@ -557,7 +558,7 @@ static int ks_wlan_set_rate(struct net_device *dev, priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; i++; - } else if (vwrq->value == 12000000) { + } else if (vwrq->bitrate.value == 12000000) { priv->reg.rate_set.body[6] = TX_RATE_9M; i++; @@ -570,7 +571,7 @@ static int ks_wlan_set_rate(struct net_device *dev, priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; i++; - } else if (vwrq->value == 11000000) { + } else if (vwrq->bitrate.value == 11000000) { priv->reg.rate_set.body[5] = TX_RATE_9M; i++; @@ -580,7 +581,7 @@ static int ks_wlan_set_rate(struct net_device *dev, priv->reg.rate_set.body[3] = TX_RATE_11M | BASIC_RATE; i++; - } else if (vwrq->value == 9000000) { + } else if (vwrq->bitrate.value == 9000000) { priv->reg.rate_set.body[4] = TX_RATE_9M; i++; @@ -645,8 +646,8 @@ static int ks_wlan_set_rate(struct net_device *dev, } static int ks_wlan_get_rate(struct net_device *dev, - struct iw_request_info *info, struct iw_param *vwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -660,23 +661,23 @@ static int ks_wlan_get_rate(struct net_device *dev, if (!atomic_read(&update_phyinfo)) ks_wlan_update_phy_information(priv); - vwrq->value = ((priv->current_rate) & RATE_MASK) * 500000; - vwrq->fixed = (priv->reg.tx_rate == TX_RATE_FIXED) ? 1 : 0; + vwrq->bitrate.value = ((priv->current_rate) & RATE_MASK) * 500000; + vwrq->bitrate.fixed = (priv->reg.tx_rate == TX_RATE_FIXED) ? 1 : 0; return 0; } static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); - int rthr = vwrq->value; + int rthr = vwrq->rts.value; if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (vwrq->disabled) + if (vwrq->rts.disabled) rthr = 2347; if ((rthr < 0) || (rthr > 2347)) return -EINVAL; @@ -688,7 +689,7 @@ static int ks_wlan_set_rts(struct net_device *dev, struct iw_request_info *info, } static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -696,25 +697,25 @@ static int ks_wlan_get_rts(struct net_device *dev, struct iw_request_info *info, return -EPERM; /* for SLEEP MODE */ - vwrq->value = priv->reg.rts; - vwrq->disabled = (vwrq->value >= 2347); - vwrq->fixed = 1; + vwrq->rts.value = priv->reg.rts; + vwrq->rts.disabled = (vwrq->rts.value >= 2347); + vwrq->rts.fixed = 1; return 0; } static int ks_wlan_set_frag(struct net_device *dev, - struct iw_request_info *info, struct iw_param *vwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); - int fthr = vwrq->value; + int fthr = vwrq->frag.value; if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (vwrq->disabled) + if (vwrq->frag.disabled) fthr = 2346; if ((fthr < 256) || (fthr > 2346)) return -EINVAL; @@ -727,8 +728,8 @@ static int ks_wlan_set_frag(struct net_device *dev, } static int ks_wlan_get_frag(struct net_device *dev, - struct iw_request_info *info, struct iw_param *vwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -736,16 +737,16 @@ static int ks_wlan_get_frag(struct net_device *dev, return -EPERM; /* for SLEEP MODE */ - vwrq->value = priv->reg.fragment; - vwrq->disabled = (vwrq->value >= 2346); - vwrq->fixed = 1; + vwrq->frag.value = priv->reg.fragment; + vwrq->frag.disabled = (vwrq->frag.value >= 2346); + vwrq->frag.fixed = 1; return 0; } static int ks_wlan_set_mode(struct net_device *dev, - struct iw_request_info *info, __u32 *uwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *uwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -753,7 +754,7 @@ static int ks_wlan_set_mode(struct net_device *dev, return -EPERM; /* for SLEEP MODE */ - switch (*uwrq) { + switch (uwrq->mode) { case IW_MODE_ADHOC: priv->reg.operation_mode = MODE_ADHOC; priv->need_commit |= SME_MODE_SET; @@ -775,8 +776,8 @@ static int ks_wlan_set_mode(struct net_device *dev, } static int ks_wlan_get_mode(struct net_device *dev, - struct iw_request_info *info, __u32 *uwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *uwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -787,13 +788,13 @@ static int ks_wlan_get_mode(struct net_device *dev, /* If not managed, assume it's ad-hoc */ switch (priv->reg.operation_mode) { case MODE_INFRASTRUCTURE: - *uwrq = IW_MODE_INFRA; + uwrq->mode = IW_MODE_INFRA; break; case MODE_ADHOC: - *uwrq = IW_MODE_ADHOC; + uwrq->mode = IW_MODE_ADHOC; break; default: - *uwrq = IW_MODE_ADHOC; + uwrq->mode = IW_MODE_ADHOC; } return 0; @@ -801,16 +802,17 @@ static int ks_wlan_get_mode(struct net_device *dev, static int ks_wlan_set_encode(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); + struct iw_point *enc = &dwrq->encoding; struct wep_key key; - int index = (dwrq->flags & IW_ENCODE_INDEX); + int index = (enc->flags & IW_ENCODE_INDEX); if (priv->sleep_mode == SLP_SLEEP) return -EPERM; - if (dwrq->length > MAX_KEY_SIZE) + if (enc->length > MAX_KEY_SIZE) return -EINVAL; /* for SLEEP MODE */ @@ -821,21 +823,21 @@ static int ks_wlan_set_encode(struct net_device *dev, /* Is WEP supported ? */ /* Basic checking: do we have a key to set ? */ - if (dwrq->length > 0) { - key.len = (dwrq->length > MIN_KEY_SIZE) ? + if (enc->length > 0) { + key.len = (enc->length > MIN_KEY_SIZE) ? MAX_KEY_SIZE : MIN_KEY_SIZE; priv->reg.privacy_invoked = 0x01; priv->need_commit |= SME_WEP_FLAG; - wep_on_off = (dwrq->length > MIN_KEY_SIZE) ? + wep_on_off = (enc->length > MIN_KEY_SIZE) ? WEP_ON_128BIT : WEP_ON_64BIT; /* Check if the key is not marked as invalid */ - if (dwrq->flags & IW_ENCODE_NOKEY) + if (enc->flags & IW_ENCODE_NOKEY) return 0; /* Cleanup */ memset(key.key, 0, MAX_KEY_SIZE); /* Copy the key in the driver */ - if (copy_from_user(key.key, dwrq->pointer, dwrq->length)) { + if (copy_from_user(key.key, enc->pointer, enc->length)) { key.len = 0; return -EFAULT; } @@ -847,7 +849,7 @@ static int ks_wlan_set_encode(struct net_device *dev, priv->reg.wep_index = index; priv->need_commit |= SME_WEP_INDEX; } else { - if (dwrq->flags & IW_ENCODE_DISABLED) { + if (enc->flags & IW_ENCODE_DISABLED) { priv->reg.wep_key[0].size = 0; priv->reg.wep_key[1].size = 0; priv->reg.wep_key[2].size = 0; @@ -869,15 +871,15 @@ static int ks_wlan_set_encode(struct net_device *dev, } /* Commit the changes if needed */ - if (dwrq->flags & IW_ENCODE_MODE) + if (enc->flags & IW_ENCODE_MODE) priv->need_commit |= SME_WEP_FLAG; - if (dwrq->flags & IW_ENCODE_OPEN) { + if (enc->flags & IW_ENCODE_OPEN) { if (priv->reg.authenticate_type == AUTH_TYPE_SHARED_KEY) priv->need_commit |= SME_MODE_SET; priv->reg.authenticate_type = AUTH_TYPE_OPEN_SYSTEM; - } else if (dwrq->flags & IW_ENCODE_RESTRICTED) { + } else if (enc->flags & IW_ENCODE_RESTRICTED) { if (priv->reg.authenticate_type == AUTH_TYPE_OPEN_SYSTEM) priv->need_commit |= SME_MODE_SET; @@ -892,24 +894,25 @@ static int ks_wlan_set_encode(struct net_device *dev, static int ks_wlan_get_encode(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); - int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; + struct iw_point *enc = &dwrq->encoding; + int index = (enc->flags & IW_ENCODE_INDEX) - 1; if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - dwrq->flags = IW_ENCODE_DISABLED; + enc->flags = IW_ENCODE_DISABLED; /* Check encryption mode */ switch (priv->reg.authenticate_type) { case AUTH_TYPE_OPEN_SYSTEM: - dwrq->flags = IW_ENCODE_OPEN; + enc->flags = IW_ENCODE_OPEN; break; case AUTH_TYPE_SHARED_KEY: - dwrq->flags = IW_ENCODE_RESTRICTED; + enc->flags = IW_ENCODE_RESTRICTED; break; } @@ -917,15 +920,15 @@ static int ks_wlan_get_encode(struct net_device *dev, if ((index < 0) || (index >= 4)) index = priv->reg.wep_index; if (priv->reg.privacy_invoked) { - dwrq->flags &= ~IW_ENCODE_DISABLED; + enc->flags &= ~IW_ENCODE_DISABLED; /* dwrq->flags |= IW_ENCODE_NOKEY; */ } - dwrq->flags |= index + 1; + enc->flags |= index + 1; /* Copy the key to the user buffer */ if (index >= 0 && index < 4) { - dwrq->length = (priv->reg.wep_key[index].size <= 16) ? + enc->length = (priv->reg.wep_key[index].size <= 16) ? priv->reg.wep_key[index].size : 0; - memcpy(extra, priv->reg.wep_key[index].val, dwrq->length); + memcpy(extra, priv->reg.wep_key[index].val, enc->length); } return 0; @@ -934,52 +937,52 @@ static int ks_wlan_get_encode(struct net_device *dev, #ifndef KSC_OPNOTSUPP static int ks_wlan_set_txpow(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { return -EOPNOTSUPP; /* Not Support */ } static int ks_wlan_get_txpow(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ /* Not Support */ - vwrq->value = 0; - vwrq->disabled = (vwrq->value == 0); - vwrq->fixed = 1; + vwrq->txpower.value = 0; + vwrq->txpower.disabled = (vwrq->txpower.value == 0); + vwrq->txpower.fixed = 1; return 0; } static int ks_wlan_set_retry(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { return -EOPNOTSUPP; /* Not Support */ } static int ks_wlan_get_retry(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ /* Not Support */ - vwrq->value = 0; - vwrq->disabled = (vwrq->value == 0); - vwrq->fixed = 1; + vwrq->retry.value = 0; + vwrq->retry.disabled = (vwrq->retry.value == 0); + vwrq->retry.fixed = 1; return 0; } #endif /* KSC_OPNOTSUPP */ static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); struct iw_range *range = (struct iw_range *)extra; @@ -989,7 +992,7 @@ static int ks_wlan_get_range(struct net_device *dev, return -EPERM; /* for SLEEP MODE */ - dwrq->length = sizeof(struct iw_range); + dwrq->data.length = sizeof(struct iw_range); memset(range, 0, sizeof(*range)); range->min_nwid = 0x0000; range->max_nwid = 0x0000; @@ -1109,14 +1112,14 @@ static int ks_wlan_get_range(struct net_device *dev, static int ks_wlan_set_power(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP) return -EPERM; - if (vwrq->disabled) { + if (vwrq->power.disabled) { priv->reg.power_mgmt = POWER_MGMT_ACTIVE; } else { if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) @@ -1132,7 +1135,7 @@ static int ks_wlan_set_power(struct net_device *dev, static int ks_wlan_get_power(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -1140,26 +1143,26 @@ static int ks_wlan_get_power(struct net_device *dev, return -EPERM; /* for SLEEP MODE */ if (priv->reg.power_mgmt > 0) - vwrq->disabled = 0; + vwrq->power.disabled = 0; else - vwrq->disabled = 1; + vwrq->power.disabled = 1; return 0; } static int ks_wlan_get_iwstats(struct net_device *dev, struct iw_request_info *info, - struct iw_quality *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - vwrq->qual = 0; /* not supported */ - vwrq->level = priv->wstats.qual.level; - vwrq->noise = 0; /* not supported */ - vwrq->updated = 0; + vwrq->qual.qual = 0; /* not supported */ + vwrq->qual.level = priv->wstats.qual.level; + vwrq->qual.noise = 0; /* not supported */ + vwrq->qual.updated = 0; return 0; } @@ -1167,20 +1170,20 @@ static int ks_wlan_get_iwstats(struct net_device *dev, #ifndef KSC_OPNOTSUPP static int ks_wlan_set_sens(struct net_device *dev, - struct iw_request_info *info, struct iw_param *vwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *vwrq, char *extra) { return -EOPNOTSUPP; /* Not Support */ } static int ks_wlan_get_sens(struct net_device *dev, - struct iw_request_info *info, struct iw_param *vwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *vwrq, char *extra) { /* Not Support */ - vwrq->value = 0; - vwrq->disabled = (vwrq->value == 0); - vwrq->fixed = 1; + vwrq->sens.value = 0; + vwrq->sens.disabled = (vwrq->sens.value == 0); + vwrq->sens.fixed = 1; return 0; } #endif /* KSC_OPNOTSUPP */ @@ -1188,7 +1191,7 @@ static int ks_wlan_get_sens(struct net_device *dev, /* Note : this is deprecated in favor of IWSCAN */ static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); struct sockaddr *address = (struct sockaddr *)extra; @@ -1209,11 +1212,11 @@ static int ks_wlan_get_aplist(struct net_device *dev, qual[i].updated = 7; } if (i) { - dwrq->flags = 1; /* Should be define'd */ + dwrq->data.flags = 1; /* Should be define'd */ memcpy(extra + sizeof(struct sockaddr) * i, &qual, sizeof(struct iw_quality) * i); } - dwrq->length = i; + dwrq->data.length = i; return 0; } @@ -1410,8 +1413,8 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, } static int ks_wlan_get_scan(struct net_device *dev, - struct iw_request_info *info, struct iw_point *dwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); int i; @@ -1432,25 +1435,26 @@ static int ks_wlan_get_scan(struct net_device *dev, /* Read and parse all entries */ for (i = 0; i < priv->aplist.size; i++) { - if ((extra + dwrq->length) - current_ev <= IW_EV_ADDR_LEN) { - dwrq->length = 0; + if ((extra + dwrq->data.length) - current_ev <= IW_EV_ADDR_LEN) { + dwrq->data.length = 0; return -E2BIG; } /* Translate to WE format this entry */ current_ev = ks_wlan_translate_scan(dev, info, current_ev, - extra + dwrq->length, + extra + dwrq->data.length, &priv->aplist.ap[i]); } /* Length of data */ - dwrq->length = (current_ev - extra); - dwrq->flags = 0; + dwrq->data.length = (current_ev - extra); + dwrq->data.flags = 0; return 0; } /* called after a bunch of SET operations */ static int ks_wlan_config_commit(struct net_device *dev, - struct iw_request_info *info, void *zwrq, + struct iw_request_info *info, + union iwreq_data *zwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -1466,7 +1470,7 @@ static int ks_wlan_config_commit(struct net_device *dev, /* set association ie params */ static int ks_wlan_set_genie(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -1479,11 +1483,12 @@ static int ks_wlan_set_genie(struct net_device *dev, static int ks_wlan_set_auth_mode(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); - int index = (vwrq->flags & IW_AUTH_INDEX); - int value = vwrq->value; + struct iw_param *param = &vwrq->param; + int index = (param->flags & IW_AUTH_INDEX); + int value = param->value; if (priv->sleep_mode == SLP_SLEEP) return -EPERM; @@ -1611,10 +1616,11 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, static int ks_wlan_get_auth_mode(struct net_device *dev, struct iw_request_info *info, - struct iw_param *vwrq, char *extra) + union iwreq_data *vwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); - int index = (vwrq->flags & IW_AUTH_INDEX); + struct iw_param *param = &vwrq->param; + int index = (param->flags & IW_AUTH_INDEX); if (priv->sleep_mode == SLP_SLEEP) return -EPERM; @@ -1623,22 +1629,22 @@ static int ks_wlan_get_auth_mode(struct net_device *dev, /* WPA (not used ?? wpa_supplicant) */ switch (index) { case IW_AUTH_WPA_VERSION: - vwrq->value = priv->wpa.version; + param->value = priv->wpa.version; break; case IW_AUTH_CIPHER_PAIRWISE: - vwrq->value = priv->wpa.pairwise_suite; + param->value = priv->wpa.pairwise_suite; break; case IW_AUTH_CIPHER_GROUP: - vwrq->value = priv->wpa.group_suite; + param->value = priv->wpa.group_suite; break; case IW_AUTH_KEY_MGMT: - vwrq->value = priv->wpa.key_mgmt_suite; + param->value = priv->wpa.key_mgmt_suite; break; case IW_AUTH_80211_AUTH_ALG: - vwrq->value = priv->wpa.auth_alg; + param->value = priv->wpa.auth_alg; break; case IW_AUTH_WPA_ENABLED: - vwrq->value = priv->wpa.rsn_enabled; + param->value = priv->wpa.rsn_enabled; break; case IW_AUTH_RX_UNENCRYPTED_EAPOL: /* OK??? */ case IW_AUTH_TKIP_COUNTERMEASURES: @@ -1653,11 +1659,11 @@ static int ks_wlan_get_auth_mode(struct net_device *dev, /* set encoding token & mode (WPA)*/ static int ks_wlan_set_encode_ext(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); struct iw_encode_ext *enc; - int index = dwrq->flags & IW_ENCODE_INDEX; + int index = dwrq->encoding.flags & IW_ENCODE_INDEX; unsigned int commit = 0; struct wpa_key *key; @@ -1674,7 +1680,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, index--; key = &priv->wpa.key[index]; - if (dwrq->flags & IW_ENCODE_DISABLED) + if (dwrq->encoding.flags & IW_ENCODE_DISABLED) key->key_len = 0; key->ext_flags = enc->ext_flags; @@ -1746,7 +1752,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, /* get encoding token & mode (WPA)*/ static int ks_wlan_get_encode_ext(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); @@ -1766,7 +1772,7 @@ static int ks_wlan_get_encode_ext(struct net_device *dev, static int ks_wlan_set_pmksa(struct net_device *dev, struct iw_request_info *info, - struct iw_point *dwrq, char *extra) + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); struct iw_pmksa *pmksa; @@ -1906,8 +1912,8 @@ static int ks_wlan_set_stop_request(struct net_device *dev, #include static int ks_wlan_set_mlme(struct net_device *dev, - struct iw_request_info *info, struct iw_point *dwrq, - char *extra) + struct iw_request_info *info, + union iwreq_data *dwrq, char *extra) { struct ks_wlan_private *priv = netdev_priv(dev); struct iw_mlme *mlme = (struct iw_mlme *)extra; @@ -2528,76 +2534,50 @@ static const struct iw_priv_args ks_wlan_private_args[] = { }; static const iw_handler ks_wlan_handler[] = { - (iw_handler)ks_wlan_config_commit, /* SIOCSIWCOMMIT */ - (iw_handler)ks_wlan_get_name, /* SIOCGIWNAME */ - (iw_handler)NULL, /* SIOCSIWNWID */ - (iw_handler)NULL, /* SIOCGIWNWID */ - (iw_handler)ks_wlan_set_freq, /* SIOCSIWFREQ */ - (iw_handler)ks_wlan_get_freq, /* SIOCGIWFREQ */ - (iw_handler)ks_wlan_set_mode, /* SIOCSIWMODE */ - (iw_handler)ks_wlan_get_mode, /* SIOCGIWMODE */ + IW_HANDLER(SIOCSIWCOMMIT, ks_wlan_config_commit), + IW_HANDLER(SIOCGIWNAME, ks_wlan_get_name), + IW_HANDLER(SIOCSIWFREQ, ks_wlan_set_freq), + IW_HANDLER(SIOCGIWFREQ, ks_wlan_get_freq), + IW_HANDLER(SIOCSIWMODE, ks_wlan_set_mode), + IW_HANDLER(SIOCGIWMODE, ks_wlan_get_mode), #ifndef KSC_OPNOTSUPP - (iw_handler)ks_wlan_set_sens, /* SIOCSIWSENS */ - (iw_handler)ks_wlan_get_sens, /* SIOCGIWSENS */ -#else /* KSC_OPNOTSUPP */ - (iw_handler)NULL, /* SIOCSIWSENS */ - (iw_handler)NULL, /* SIOCGIWSENS */ + IW_HANDLER(SIOCSIWSENS, ks_wlan_set_sens), + IW_HANDLER(SIOCGIWSENS, ks_wlan_get_sens), #endif /* KSC_OPNOTSUPP */ - (iw_handler)NULL, /* SIOCSIWRANGE */ - (iw_handler)ks_wlan_get_range, /* SIOCGIWRANGE */ - (iw_handler)NULL, /* SIOCSIWPRIV */ - (iw_handler)NULL, /* SIOCGIWPRIV */ - (iw_handler)NULL, /* SIOCSIWSTATS */ - (iw_handler)ks_wlan_get_iwstats, /* SIOCGIWSTATS */ - (iw_handler)NULL, /* SIOCSIWSPY */ - (iw_handler)NULL, /* SIOCGIWSPY */ - (iw_handler)NULL, /* SIOCSIWTHRSPY */ - (iw_handler)NULL, /* SIOCGIWTHRSPY */ - (iw_handler)ks_wlan_set_wap, /* SIOCSIWAP */ - (iw_handler)ks_wlan_get_wap, /* SIOCGIWAP */ -// (iw_handler)NULL, /* SIOCSIWMLME */ - (iw_handler)ks_wlan_set_mlme, /* SIOCSIWMLME */ - (iw_handler)ks_wlan_get_aplist, /* SIOCGIWAPLIST */ - (iw_handler)ks_wlan_set_scan, /* SIOCSIWSCAN */ - (iw_handler)ks_wlan_get_scan, /* SIOCGIWSCAN */ - (iw_handler)ks_wlan_set_essid, /* SIOCSIWESSID */ - (iw_handler)ks_wlan_get_essid, /* SIOCGIWESSID */ - (iw_handler)ks_wlan_set_nick, /* SIOCSIWNICKN */ - (iw_handler)ks_wlan_get_nick, /* SIOCGIWNICKN */ - (iw_handler)NULL, /* -- hole -- */ - (iw_handler)NULL, /* -- hole -- */ - (iw_handler)ks_wlan_set_rate, /* SIOCSIWRATE */ - (iw_handler)ks_wlan_get_rate, /* SIOCGIWRATE */ - (iw_handler)ks_wlan_set_rts, /* SIOCSIWRTS */ - (iw_handler)ks_wlan_get_rts, /* SIOCGIWRTS */ - (iw_handler)ks_wlan_set_frag, /* SIOCSIWFRAG */ - (iw_handler)ks_wlan_get_frag, /* SIOCGIWFRAG */ + IW_HANDLER(SIOCGIWRANGE, ks_wlan_get_range), + IW_HANDLER(SIOCGIWSTATS, ks_wlan_get_iwstats), + IW_HANDLER(SIOCSIWAP, ks_wlan_set_wap), + IW_HANDLER(SIOCGIWAP, ks_wlan_get_wap), + IW_HANDLER(SIOCSIWMLME, ks_wlan_set_mlme), + IW_HANDLER(SIOCGIWAPLIST, ks_wlan_get_aplist), + IW_HANDLER(SIOCSIWSCAN, ks_wlan_set_scan), + IW_HANDLER(SIOCGIWSCAN, ks_wlan_get_scan), + IW_HANDLER(SIOCSIWESSID, ks_wlan_set_essid), + IW_HANDLER(SIOCGIWESSID, ks_wlan_get_essid), + IW_HANDLER(SIOCSIWNICKN, ks_wlan_set_nick), + IW_HANDLER(SIOCGIWNICKN, ks_wlan_get_nick), + IW_HANDLER(SIOCSIWRATE, ks_wlan_set_rate), + IW_HANDLER(SIOCGIWRATE, ks_wlan_get_rate), + IW_HANDLER(SIOCSIWRTS, ks_wlan_set_rts), + IW_HANDLER(SIOCGIWRTS, ks_wlan_get_rts), + IW_HANDLER(SIOCSIWFRAG, ks_wlan_set_frag), + IW_HANDLER(SIOCGIWFRAG, ks_wlan_get_frag), #ifndef KSC_OPNOTSUPP - (iw_handler)ks_wlan_set_txpow, /* SIOCSIWTXPOW */ - (iw_handler)ks_wlan_get_txpow, /* SIOCGIWTXPOW */ - (iw_handler)ks_wlan_set_retry, /* SIOCSIWRETRY */ - (iw_handler)ks_wlan_get_retry, /* SIOCGIWRETRY */ -#else /* KSC_OPNOTSUPP */ - (iw_handler)NULL, /* SIOCSIWTXPOW */ - (iw_handler)NULL, /* SIOCGIWTXPOW */ - (iw_handler)NULL, /* SIOCSIWRETRY */ - (iw_handler)NULL, /* SIOCGIWRETRY */ + IW_HANDLER(SIOCSIWTXPOW, ks_wlan_set_txpow), + IW_HANDLER(SIOCGIWTXPOW, ks_wlan_get_txpow), + IW_HANDLER(SIOCSIWRETRY, ks_wlan_set_retry), + IW_HANDLER(SIOCGIWRETRY, ks_wlan_get_retry), #endif /* KSC_OPNOTSUPP */ - (iw_handler)ks_wlan_set_encode, /* SIOCSIWENCODE */ - (iw_handler)ks_wlan_get_encode, /* SIOCGIWENCODE */ - (iw_handler)ks_wlan_set_power, /* SIOCSIWPOWER */ - (iw_handler)ks_wlan_get_power, /* SIOCGIWPOWER */ - (iw_handler)NULL, /* -- hole -- */ - (iw_handler)NULL, /* -- hole -- */ -// (iw_handler)NULL, /* SIOCSIWGENIE */ - (iw_handler)ks_wlan_set_genie, /* SIOCSIWGENIE */ - (iw_handler)NULL, /* SIOCGIWGENIE */ - (iw_handler)ks_wlan_set_auth_mode, /* SIOCSIWAUTH */ - (iw_handler)ks_wlan_get_auth_mode, /* SIOCGIWAUTH */ - (iw_handler)ks_wlan_set_encode_ext, /* SIOCSIWENCODEEXT */ - (iw_handler)ks_wlan_get_encode_ext, /* SIOCGIWENCODEEXT */ - (iw_handler)ks_wlan_set_pmksa, /* SIOCSIWPMKSA */ - (iw_handler)NULL, /* -- hole -- */ + IW_HANDLER(SIOCSIWENCODE, ks_wlan_set_encode), + IW_HANDLER(SIOCGIWENCODE, ks_wlan_get_encode), + IW_HANDLER(SIOCSIWPOWER, ks_wlan_set_power), + IW_HANDLER(SIOCGIWPOWER, ks_wlan_get_power), + IW_HANDLER(SIOCSIWGENIE, ks_wlan_set_genie), + IW_HANDLER(SIOCSIWAUTH, ks_wlan_set_auth_mode), + IW_HANDLER(SIOCGIWAUTH, ks_wlan_get_auth_mode), + IW_HANDLER(SIOCSIWENCODEEXT, ks_wlan_set_encode_ext), + IW_HANDLER(SIOCGIWENCODEEXT, ks_wlan_get_encode_ext), + IW_HANDLER(SIOCSIWPMKSA, ks_wlan_set_pmksa), }; /* private_handler */ -- cgit v1.2.3-59-g8ed1b From 5dfd0cfeeee5440b242b2c8578fc41a09aa26430 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Apr 2018 15:44:57 +0200 Subject: staging: ks7010: remove KSC_OPNOTSUPP related code This commit reviews KSC_OPNOTSUPP related code. The preprocessor KSC_OPNOTSUPP is defined by default so related wext functions are not being used. Just clean code removing all of this stuff. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 79 ------------------------------------ 1 file changed, 79 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 05cdeb1edb1e..2f79e6a797ca 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -52,8 +52,6 @@ struct wep_key { /* List of Wireless Handlers (new API) */ static const struct iw_handler_def ks_wlan_handler_def; -#define KSC_OPNOTSUPP /* Operation Not Support */ - /* * function prototypes */ @@ -934,52 +932,6 @@ static int ks_wlan_get_encode(struct net_device *dev, return 0; } -#ifndef KSC_OPNOTSUPP -static int ks_wlan_set_txpow(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *vwrq, char *extra) -{ - return -EOPNOTSUPP; /* Not Support */ -} - -static int ks_wlan_get_txpow(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *vwrq, char *extra) -{ - if (priv->sleep_mode == SLP_SLEEP) - return -EPERM; - - /* for SLEEP MODE */ - /* Not Support */ - vwrq->txpower.value = 0; - vwrq->txpower.disabled = (vwrq->txpower.value == 0); - vwrq->txpower.fixed = 1; - return 0; -} - -static int ks_wlan_set_retry(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *vwrq, char *extra) -{ - return -EOPNOTSUPP; /* Not Support */ -} - -static int ks_wlan_get_retry(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *vwrq, char *extra) -{ - if (priv->sleep_mode == SLP_SLEEP) - return -EPERM; - - /* for SLEEP MODE */ - /* Not Support */ - vwrq->retry.value = 0; - vwrq->retry.disabled = (vwrq->retry.value == 0); - vwrq->retry.fixed = 1; - return 0; -} -#endif /* KSC_OPNOTSUPP */ - static int ks_wlan_get_range(struct net_device *dev, struct iw_request_info *info, union iwreq_data *dwrq, char *extra) @@ -1167,27 +1119,6 @@ static int ks_wlan_get_iwstats(struct net_device *dev, return 0; } -#ifndef KSC_OPNOTSUPP - -static int ks_wlan_set_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *vwrq, char *extra) -{ - return -EOPNOTSUPP; /* Not Support */ -} - -static int ks_wlan_get_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *vwrq, char *extra) -{ - /* Not Support */ - vwrq->sens.value = 0; - vwrq->sens.disabled = (vwrq->sens.value == 0); - vwrq->sens.fixed = 1; - return 0; -} -#endif /* KSC_OPNOTSUPP */ - /* Note : this is deprecated in favor of IWSCAN */ static int ks_wlan_get_aplist(struct net_device *dev, struct iw_request_info *info, @@ -2540,10 +2471,6 @@ static const iw_handler ks_wlan_handler[] = { IW_HANDLER(SIOCGIWFREQ, ks_wlan_get_freq), IW_HANDLER(SIOCSIWMODE, ks_wlan_set_mode), IW_HANDLER(SIOCGIWMODE, ks_wlan_get_mode), -#ifndef KSC_OPNOTSUPP - IW_HANDLER(SIOCSIWSENS, ks_wlan_set_sens), - IW_HANDLER(SIOCGIWSENS, ks_wlan_get_sens), -#endif /* KSC_OPNOTSUPP */ IW_HANDLER(SIOCGIWRANGE, ks_wlan_get_range), IW_HANDLER(SIOCGIWSTATS, ks_wlan_get_iwstats), IW_HANDLER(SIOCSIWAP, ks_wlan_set_wap), @@ -2562,12 +2489,6 @@ static const iw_handler ks_wlan_handler[] = { IW_HANDLER(SIOCGIWRTS, ks_wlan_get_rts), IW_HANDLER(SIOCSIWFRAG, ks_wlan_set_frag), IW_HANDLER(SIOCGIWFRAG, ks_wlan_get_frag), -#ifndef KSC_OPNOTSUPP - IW_HANDLER(SIOCSIWTXPOW, ks_wlan_set_txpow), - IW_HANDLER(SIOCGIWTXPOW, ks_wlan_get_txpow), - IW_HANDLER(SIOCSIWRETRY, ks_wlan_set_retry), - IW_HANDLER(SIOCGIWRETRY, ks_wlan_get_retry), -#endif /* KSC_OPNOTSUPP */ IW_HANDLER(SIOCSIWENCODE, ks_wlan_set_encode), IW_HANDLER(SIOCGIWENCODE, ks_wlan_get_encode), IW_HANDLER(SIOCSIWPOWER, ks_wlan_set_power), -- cgit v1.2.3-59-g8ed1b From b58e1ddaa25fc07ea995f3a0ccb5fcc0820f61f3 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 24 Apr 2018 15:49:56 +0200 Subject: staging: ks7010: remove some duplicated definitions in ks_wlan_net.c This definitions are in linux/wireless.h header so it is not necessary at all to have this compatibility stuff duplicated here. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 2f79e6a797ca..58226789812f 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -43,12 +43,6 @@ struct wep_key { u8 key[16]; /* 40-bit and 104-bit keys */ }; -/* Backward compatibility */ -#ifndef IW_ENCODE_NOKEY -#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */ -#define IW_ENCODE_MODE (IW_ENCODE_DISABLED | IW_ENCODE_RESTRICTED | IW_ENCODE_OPEN) -#endif /* IW_ENCODE_NOKEY */ - /* List of Wireless Handlers (new API) */ static const struct iw_handler_def ks_wlan_handler_def; -- cgit v1.2.3-59-g8ed1b From 1e4c7fb3a54ec2b1be17c7d2d1b53c593f959a1d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 24 Apr 2018 15:49:57 +0200 Subject: staging: ks7010: refactor ks_wlan_set_mode function Most cases which are being handled in the switch-case of ks_wlan_set_mode function are just returning EINVAL. Avoid the use of switch-case stament and just use a simple if to handle those. This decrease LOC as well as improves readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 58226789812f..cb3d0a898b5f 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -745,24 +745,13 @@ static int ks_wlan_set_mode(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; - /* for SLEEP MODE */ - switch (uwrq->mode) { - case IW_MODE_ADHOC: - priv->reg.operation_mode = MODE_ADHOC; - priv->need_commit |= SME_MODE_SET; - break; - case IW_MODE_INFRA: - priv->reg.operation_mode = MODE_INFRASTRUCTURE; - priv->need_commit |= SME_MODE_SET; - break; - case IW_MODE_AUTO: - case IW_MODE_MASTER: - case IW_MODE_REPEAT: - case IW_MODE_SECOND: - case IW_MODE_MONITOR: - default: + if (uwrq->mode != IW_MODE_ADHOC && + uwrq->mode != IW_MODE_INFRA) return -EINVAL; - } + + priv->reg.operation_mode = (uwrq->mode == IW_MODE_ADHOC) ? + MODE_ADHOC : MODE_INFRASTRUCTURE; + priv->need_commit |= SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ } -- cgit v1.2.3-59-g8ed1b From ca94697252370f8d8dc1346d0007508b98f95ca7 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 24 Apr 2018 15:49:58 +0200 Subject: staging: ks7010: refactor ks_wlan_get_mode function Avoid the use of switch-case block which is not necessary at all and just use a ternary operator to achieve this. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index cb3d0a898b5f..ccec25ed155a 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -765,18 +765,9 @@ static int ks_wlan_get_mode(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; - /* for SLEEP MODE */ /* If not managed, assume it's ad-hoc */ - switch (priv->reg.operation_mode) { - case MODE_INFRASTRUCTURE: - uwrq->mode = IW_MODE_INFRA; - break; - case MODE_ADHOC: - uwrq->mode = IW_MODE_ADHOC; - break; - default: - uwrq->mode = IW_MODE_ADHOC; - } + uwrq->mode = (priv->reg.operation_mode == MODE_INFRASTRUCTURE) ? + IW_MODE_INFRA : IW_MODE_ADHOC; return 0; } -- cgit v1.2.3-59-g8ed1b From e83cfca1abbeee6ad77e2c8543183483eba10eab Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 24 Apr 2018 15:49:59 +0200 Subject: staging: ks7010: fix line exceding 80 characters in ks_wlan_get_range Avoid very long if condition just changing its style. This makes checkpatch script not complains about this line. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index ccec25ed155a..3f631d9a45ba 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -933,7 +933,8 @@ static int ks_wlan_get_range(struct net_device *dev, range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ } range->num_frequency = k; - if (priv->reg.phy_type == D_11B_ONLY_MODE || priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) { /* channel 14 */ + if (priv->reg.phy_type == D_11B_ONLY_MODE || + priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) { /* channel 14 */ range->freq[13].i = 14; /* List index */ range->freq[13].m = frequency_list[13] * 100000; range->freq[13].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ -- cgit v1.2.3-59-g8ed1b From 92c1552caef3661f049c4e967550e933599e2663 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 24 Apr 2018 15:50:00 +0200 Subject: staging: ks7010: remove WPS definition conditional code WPS definition was defined by default in ks_wlan.h header file. So it makes no sense to have conditional preprocessor stuff along the code about this. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan.h | 12 ------------ drivers/staging/ks7010/ks_wlan_ioctl.h | 2 -- drivers/staging/ks7010/ks_wlan_net.c | 11 ----------- 3 files changed, 25 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 365001bebabc..2894b0c3816c 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -12,8 +12,6 @@ #ifndef _KS_WLAN_H #define _KS_WLAN_H -#define WPS - #include /* struct atomic_t */ #include /* struct completion */ #include /* struct net_device_stats, struct sk_buff */ @@ -122,10 +120,8 @@ enum { SME_RSN_AUTH_REQUEST, SME_RSN_ENABLED_REQUEST, SME_RSN_MODE_REQUEST, -#ifdef WPS SME_WPS_ENABLE_REQUEST, SME_WPS_PROBE_REQUEST, -#endif SME_SET_GAIN, SME_GET_GAIN, SME_SLEEP_REQUEST, @@ -198,14 +194,12 @@ struct rsn_ie { u8 body[RSN_IE_BODY_MAX]; } __packed; -#ifdef WPS #define WPS_IE_BODY_MAX 255 struct wps_ie { u8 id; /* 221 'dd 00 50 F2 04' */ u8 size; /* max ? 255 ? */ u8 body[WPS_IE_BODY_MAX]; } __packed; -#endif /* WPS */ struct local_ap { u8 bssid[6]; @@ -226,9 +220,7 @@ struct local_ap { u8 noise; struct rsn_ie wpa_ie; struct rsn_ie rsn_ie; -#ifdef WPS struct wps_ie wps_ie; -#endif /* WPS */ }; #define LOCAL_APLIST_MAX 31 @@ -371,13 +363,11 @@ struct pmk_list { } pmk[PMK_LIST_MAX]; }; -#ifdef WPS struct wps_status { int wps_enabled; int ielen; u8 ie[255]; }; -#endif /* WPS */ struct ks_wlan_private { /* hardware information */ @@ -450,9 +440,7 @@ struct ks_wlan_private { u8 scan_ssid_len; u8 scan_ssid[IW_ESSID_MAX_SIZE + 1]; struct local_gain gain; -#ifdef WPS struct wps_status wps; -#endif /* WPS */ u8 sleep_mode; u8 region; diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h b/drivers/staging/ks7010/ks_wlan_ioctl.h index 121e7cb808a2..e45a33291b46 100644 --- a/drivers/staging/ks7010/ks_wlan_ioctl.h +++ b/drivers/staging/ks7010/ks_wlan_ioctl.h @@ -19,11 +19,9 @@ /* former KS_WLAN_GET_DRIVER_VERSION (SIOCIWFIRSTPRIV + 1) */ /* (SIOCIWFIRSTPRIV + 2) */ #define KS_WLAN_GET_FIRM_VERSION (SIOCIWFIRSTPRIV + 3) -#ifdef WPS #define KS_WLAN_SET_WPS_ENABLE (SIOCIWFIRSTPRIV + 4) #define KS_WLAN_GET_WPS_ENABLE (SIOCIWFIRSTPRIV + 5) #define KS_WLAN_SET_WPS_PROBE_REQ (SIOCIWFIRSTPRIV + 6) -#endif #define KS_WLAN_GET_EEPROM_CKSUM (SIOCIWFIRSTPRIV + 7) #define KS_WLAN_SET_PREAMBLE (SIOCIWFIRSTPRIV + 8) #define KS_WLAN_GET_PREAMBLE (SIOCIWFIRSTPRIV + 9) diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 3f631d9a45ba..a9fdf25b45c0 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2113,8 +2113,6 @@ static int ks_wlan_get_sleep_mode(struct net_device *dev, return 0; } -#ifdef WPS - static int ks_wlan_set_wps_enable(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, char *extra) @@ -2178,7 +2176,6 @@ static int ks_wlan_set_wps_probe_req(struct net_device *dev, return 0; } -#endif /* WPS */ static int ks_wlan_set_tx_gain(struct net_device *dev, struct iw_request_info *info, __u32 *uwrq, @@ -2389,14 +2386,12 @@ static const struct iw_priv_args ks_wlan_private_args[] = { /*{ cmd, set_args, get_args, name[16] } */ {KS_WLAN_GET_FIRM_VERSION, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_CHAR | (128 + 1), "GetFirmwareVer"}, -#ifdef WPS {KS_WLAN_SET_WPS_ENABLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetWPSEnable"}, {KS_WLAN_GET_WPS_ENABLE, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "GetW"}, {KS_WLAN_SET_WPS_PROBE_REQ, IW_PRIV_TYPE_BYTE | 2047, IW_PRIV_TYPE_NONE, "SetWPSProbeReq"}, -#endif /* WPS */ {KS_WLAN_SET_PREAMBLE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, IW_PRIV_TYPE_NONE, "SetPreamble"}, {KS_WLAN_GET_PREAMBLE, IW_PRIV_TYPE_NONE, @@ -2482,15 +2477,9 @@ static const iw_handler ks_wlan_private_handler[] = { (iw_handler)NULL, /* 1, KS_WLAN_GET_DRIVER_VERSION */ (iw_handler)NULL, /* 2 */ (iw_handler)ks_wlan_get_firmware_version,/* 3 KS_WLAN_GET_FIRM_VERSION */ -#ifdef WPS (iw_handler)ks_wlan_set_wps_enable, /* 4 KS_WLAN_SET_WPS_ENABLE */ (iw_handler)ks_wlan_get_wps_enable, /* 5 KS_WLAN_GET_WPS_ENABLE */ (iw_handler)ks_wlan_set_wps_probe_req, /* 6 KS_WLAN_SET_WPS_PROBE_REQ */ -#else - (iw_handler)NULL, /* 4 */ - (iw_handler)NULL, /* 5 */ - (iw_handler)NULL, /* 6 */ -#endif /* WPS */ (iw_handler)ks_wlan_get_eeprom_cksum, /* 7 KS_WLAN_GET_CONNECT */ (iw_handler)ks_wlan_set_preamble, /* 8 KS_WLAN_SET_PREAMBLE */ (iw_handler)ks_wlan_get_preamble, /* 9 KS_WLAN_GET_PREAMBLE */ -- cgit v1.2.3-59-g8ed1b From f445594240fb18a43aebed7f0ce917c09e9dd87a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 24 Apr 2018 15:50:01 +0200 Subject: staging: ks7010: remove duplicated ks_wlan_handler_def declaration This declaration is declared twice so just remove this one because the other one is the one which contains static struct initializers. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index a9fdf25b45c0..81d66ac898c6 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -43,9 +43,6 @@ struct wep_key { u8 key[16]; /* 40-bit and 104-bit keys */ }; -/* List of Wireless Handlers (new API) */ -static const struct iw_handler_def ks_wlan_handler_def; - /* * function prototypes */ -- cgit v1.2.3-59-g8ed1b From 07335253e121a6b3c4e63c46f34fe57ddb8a521a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 24 Apr 2018 15:50:02 +0200 Subject: staging: ks7010: use ether_addr_copy() instead of custom copy In order to achieve ethernet address copies, ether_addr_copy() function exists. So just use it and avoid the byte by byte copy. This increase readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 81d66ac898c6..aaa57c263002 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2686,14 +2686,7 @@ int ks_wlan_net_start(struct net_device *dev) /* dummy address set */ memcpy(priv->eth_addr, dummy_addr, ETH_ALEN); - dev->dev_addr[0] = priv->eth_addr[0]; - dev->dev_addr[1] = priv->eth_addr[1]; - dev->dev_addr[2] = priv->eth_addr[2]; - dev->dev_addr[3] = priv->eth_addr[3]; - dev->dev_addr[4] = priv->eth_addr[4]; - dev->dev_addr[5] = priv->eth_addr[5]; - dev->dev_addr[6] = 0x00; - dev->dev_addr[7] = 0x00; + ether_addr_copy(dev->dev_addr, priv->eth_addr); /* The ks_wlan-specific entries in the device structure. */ dev->netdev_ops = &ks_wlan_netdev_ops; -- cgit v1.2.3-59-g8ed1b From 25ee63eb2da2a908685c8318b891054accfc6d0d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:41 +0200 Subject: staging: ks7010: refactor ks_wlan_set_beacon_lost function Change if condition to handle invalid value first and avoid nonsense else's path improving readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index aaa57c263002..e2e72cd7e457 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1973,17 +1973,17 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq >= BEACON_LOST_COUNT_MIN && *uwrq <= BEACON_LOST_COUNT_MAX) - priv->reg.beacon_lost_count = *uwrq; - else + if (*uwrq < BEACON_LOST_COUNT_MIN || *uwrq > BEACON_LOST_COUNT_MAX) return -EINVAL; + priv->reg.beacon_lost_count = *uwrq; + if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) { priv->need_commit |= SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ - } else { - return 0; } + + return 0; } static int ks_wlan_get_beacon_lost(struct net_device *dev, -- cgit v1.2.3-59-g8ed1b From 7a2cc8db50b801d9a384959a5b6c663559c139dd Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:42 +0200 Subject: staging: ks7010: refactor ks_wlan_set_scan_type function This commit changes logic to handle invalid values first and just assign valid ones afterwards. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index e2e72cd7e457..e943d372c393 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1940,14 +1940,11 @@ static int ks_wlan_set_scan_type(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq == ACTIVE_SCAN) { /* 0 */ - priv->reg.scan_type = ACTIVE_SCAN; - } else if (*uwrq == PASSIVE_SCAN) { /* 1 */ - priv->reg.scan_type = PASSIVE_SCAN; - } else { + + if (*uwrq != ACTIVE_SCAN && *uwrq != PASSIVE_SCAN) return -EINVAL; - } + priv->reg.scan_type = *uwrq; return 0; } -- cgit v1.2.3-59-g8ed1b From c87125805216ba3c66d3cb8ed3ff5c36d2ddff01 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:43 +0200 Subject: staging: ks7010: refactor ks_wlan_set_power_mgmt function This commit change logic to simplify conditional paths in ks_wlan_set_power_mgmt function. It handles invalid's first and just finally assign a valid value. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index e943d372c393..3c9fbb9bcd52 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1895,23 +1895,16 @@ static int ks_wlan_set_power_mgmt(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; - /* for SLEEP MODE */ - if (*uwrq == POWER_MGMT_ACTIVE) { /* 0 */ - priv->reg.power_mgmt = POWER_MGMT_ACTIVE; - } else if (*uwrq == POWER_MGMT_SAVE1) { /* 1 */ - if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) - priv->reg.power_mgmt = POWER_MGMT_SAVE1; - else - return -EINVAL; - } else if (*uwrq == POWER_MGMT_SAVE2) { /* 2 */ - if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) - priv->reg.power_mgmt = POWER_MGMT_SAVE2; - else - return -EINVAL; - } else { + if (*uwrq != POWER_MGMT_ACTIVE && + *uwrq != POWER_MGMT_SAVE1 && + *uwrq != POWER_MGMT_SAVE2) + return -EINVAL; + + if ((*uwrq == POWER_MGMT_SAVE1 || *uwrq == POWER_MGMT_SAVE2) && + (priv->reg.operation_mode != MODE_INFRASTRUCTURE)) return -EINVAL; - } + priv->reg.power_mgmt = *uwrq; hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); return 0; -- cgit v1.2.3-59-g8ed1b From 8521b4e65e2330e5b952d4341976fe3b98c4efa0 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:44 +0200 Subject: staging: ks7010: refactor ks_wlan_set_preamble function Change if logic to handle invalid values first and just assign at the end the valid one if it is the case. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 3c9fbb9bcd52..87c051958bf3 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1860,14 +1860,10 @@ static int ks_wlan_set_preamble(struct net_device *dev, return -EPERM; /* for SLEEP MODE */ - if (*uwrq == LONG_PREAMBLE) { /* 0 */ - priv->reg.preamble = LONG_PREAMBLE; - } else if (*uwrq == SHORT_PREAMBLE) { /* 1 */ - priv->reg.preamble = SHORT_PREAMBLE; - } else { + if (*uwrq != LONG_PREAMBLE && *uwrq != SHORT_PREAMBLE) return -EINVAL; - } + priv->reg.preamble = *uwrq; priv->need_commit |= SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ } -- cgit v1.2.3-59-g8ed1b From bf338a9054a48bdc48e05ef1dc960889097a32f2 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:45 +0200 Subject: staging: ks7010: refactor ks_wlan_set_cts_mode function This commit refactors ks_wlan_set_cts_mode function to handle invalid values first and then assign the good one changing a bit logic to use a ternary operator. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 87c051958bf3..a398b6a2b3e3 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2030,18 +2030,13 @@ static int ks_wlan_set_cts_mode(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq == CTS_MODE_FALSE) { /* 0 */ - priv->reg.cts_mode = CTS_MODE_FALSE; - } else if (*uwrq == CTS_MODE_TRUE) { /* 1 */ - if (priv->reg.phy_type == D_11G_ONLY_MODE || - priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) { - priv->reg.cts_mode = CTS_MODE_TRUE; - } else { - priv->reg.cts_mode = CTS_MODE_FALSE; - } - } else { + if (*uwrq != CTS_MODE_FALSE && *uwrq != CTS_MODE_TRUE) return -EINVAL; - } + + priv->reg.cts_mode = (*uwrq == CTS_MODE_FALSE) ? *uwrq : + (priv->reg.phy_type == D_11G_ONLY_MODE || + priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) ? + *uwrq : !*uwrq; priv->need_commit |= SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ -- cgit v1.2.3-59-g8ed1b From 092f239e9f03b35705129082a4962e25f6c0965d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:46 +0200 Subject: staging: ks7010: refactor ks_wlan_set_pmksa function This commit cleans a bit ks_wlan_set_pmksa function removing nonsense comments as well as make use of ether_addr_* family functions written to not do manually things that were being here. Minor single if brackets has been removed also. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 45 +++++++++++++++++------------------- 1 file changed, 21 insertions(+), 24 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index a398b6a2b3e3..f3e83f9aa283 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1694,68 +1694,65 @@ static int ks_wlan_set_pmksa(struct net_device *dev, switch (pmksa->cmd) { case IW_PMKSA_ADD: - if (list_empty(&priv->pmklist.head)) { /* new list */ + if (list_empty(&priv->pmklist.head)) { for (i = 0; i < PMK_LIST_MAX; i++) { pmk = &priv->pmklist.pmk[i]; - if (memcmp("\x00\x00\x00\x00\x00\x00", - pmk->bssid, ETH_ALEN) == 0) - break; /* loop */ + if (is_zero_ether_addr(pmk->bssid)) + break; } - memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data); memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); list_add(&pmk->list, &priv->pmklist.head); priv->pmklist.size++; - break; /* case */ + break; } /* search cache data */ list_for_each(ptr, &priv->pmklist.head) { pmk = list_entry(ptr, struct pmk, list); - if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) { + if (ether_addr_equal(pmksa->bssid.sa_data, pmk->bssid)) { memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); list_move(&pmk->list, &priv->pmklist.head); - break; /* list_for_each */ + break; } } - if (ptr != &priv->pmklist.head) /* not find address. */ - break; /* case */ - - if (priv->pmklist.size < PMK_LIST_MAX) { /* new cache data */ + /* not find address. */ + if (ptr != &priv->pmklist.head) + break; + /* new cache data */ + if (priv->pmklist.size < PMK_LIST_MAX) { for (i = 0; i < PMK_LIST_MAX; i++) { pmk = &priv->pmklist.pmk[i]; - if (memcmp("\x00\x00\x00\x00\x00\x00", - pmk->bssid, ETH_ALEN) == 0) - break; /* loop */ + if (is_zero_ether_addr(pmk->bssid)) + break; } - memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data); memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); list_add(&pmk->list, &priv->pmklist.head); priv->pmklist.size++; - } else { /* overwrite old cache data */ + } else { /* overwrite old cache data */ pmk = list_entry(priv->pmklist.head.prev, struct pmk, list); - memcpy(pmk->bssid, pmksa->bssid.sa_data, ETH_ALEN); + ether_addr_copy(pmk->bssid, pmksa->bssid.sa_data); memcpy(pmk->pmkid, pmksa->pmkid, IW_PMKID_LEN); list_move(&pmk->list, &priv->pmklist.head); } break; case IW_PMKSA_REMOVE: - if (list_empty(&priv->pmklist.head)) { /* list empty */ + if (list_empty(&priv->pmklist.head)) return -EINVAL; - } /* search cache data */ list_for_each(ptr, &priv->pmklist.head) { pmk = list_entry(ptr, struct pmk, list); - if (memcmp(pmksa->bssid.sa_data, pmk->bssid, ETH_ALEN) == 0) { + if (ether_addr_equal(pmksa->bssid.sa_data, pmk->bssid)) { eth_zero_addr(pmk->bssid); memset(pmk->pmkid, 0, IW_PMKID_LEN); list_del_init(&pmk->list); break; } } - if (ptr == &priv->pmklist.head) { /* not find address. */ + /* not find address. */ + if (ptr == &priv->pmklist.head) return 0; - } - break; case IW_PMKSA_FLUSH: memset(&priv->pmklist, 0, sizeof(priv->pmklist)); -- cgit v1.2.3-59-g8ed1b From b8cbbc1261bed209e4ecbf5ba5fa0f4f684c7ad0 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:47 +0200 Subject: staging: ks7010: use ether_addr_copy in ks_wlan_set_encode_ext Instead of manually memcpy ethernet addresses use ether_addr_copy function for this purpose. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index f3e83f9aa283..8f4da53d3c43 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1594,7 +1594,7 @@ static int ks_wlan_set_encode_ext(struct net_device *dev, memcpy(&key->rx_seq[0], &enc->rx_seq[0], IW_ENCODE_SEQ_MAX_SIZE); } - memcpy(&key->addr.sa_data[0], &enc->addr.sa_data[0], ETH_ALEN); + ether_addr_copy(&key->addr.sa_data[0], &enc->addr.sa_data[0]); switch (enc->alg) { case IW_ENCODE_ALG_NONE: -- cgit v1.2.3-59-g8ed1b From 60d4125d79c3bc41c123fd0a333d2eb159c8b141 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:48 +0200 Subject: staging: ks7010: align values in frequency_list array To avoid a long line align values in static array frequency_list array. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 8f4da53d3c43..b4b38d86f4f8 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -31,7 +31,8 @@ static int wep_on_off; #include /* New driver API */ /* Frequency list (map channels to frequencies) */ -static const long frequency_list[] = { 2412, 2417, 2422, 2427, 2432, 2437, 2442, +static const long frequency_list[] = { + 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462, 2467, 2472, 2484 }; -- cgit v1.2.3-59-g8ed1b From 90db591233907386010c05a4bd060bb8dd3c515b Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:49 +0200 Subject: staging: ks7010: refactor ks_wlan_set_wap function Make use of ether_addr_copy instead of memcpy for copying ethernet address data in ks_wlan_set_wap function and avoid an 'else' just changing if logic to check invalid values first. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index b4b38d86f4f8..f23838e2330e 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -316,18 +316,16 @@ static int ks_wlan_set_wap(struct net_device *dev, struct iw_request_info *info, return -EPERM; /* for SLEEP MODE */ - if (priv->reg.operation_mode == MODE_ADHOC || - priv->reg.operation_mode == MODE_INFRASTRUCTURE) { - memcpy(priv->reg.bssid, &awrq->ap_addr.sa_data, ETH_ALEN); - - if (is_valid_ether_addr((u8 *)priv->reg.bssid)) - priv->need_commit |= SME_MODE_SET; - - } else { + if (priv->reg.operation_mode != MODE_ADHOC && + priv->reg.operation_mode != MODE_INFRASTRUCTURE) { eth_zero_addr(priv->reg.bssid); return -EOPNOTSUPP; } + ether_addr_copy(priv->reg.bssid, awrq->ap_addr.sa_data); + if (is_valid_ether_addr((u8 *)priv->reg.bssid)) + priv->need_commit |= SME_MODE_SET; + netdev_dbg(dev, "bssid = %pM\n", priv->reg.bssid); /* Write it to the card */ -- cgit v1.2.3-59-g8ed1b From afa10db0e10c269f8d3824f645c9f6caacf504b3 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:50 +0200 Subject: staging: ks7010: use ether_addr_copy in ks_wlan_get_wap Use ether_addr_copy to copy ethernet addresses instead of a custom memcpy. This improves readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index f23838e2330e..45f850a20ed6 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -346,7 +346,7 @@ static int ks_wlan_get_wap(struct net_device *dev, struct iw_request_info *info, /* for SLEEP MODE */ if (is_connect_status(priv->connect_status)) - memcpy(awrq->ap_addr.sa_data, priv->current_ap.bssid, ETH_ALEN); + ether_addr_copy(awrq->ap_addr.sa_data, priv->current_ap.bssid); else eth_zero_addr(awrq->ap_addr.sa_data); -- cgit v1.2.3-59-g8ed1b From f3b0bd23956524c8c98ce0a25f7b7bf897d4af85 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:51 +0200 Subject: staging: ks7010: avoid an 'else' in ks_wlan_set_power Change if logic to handle invalid case for operation_mode at first avoiding an 'else' path. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 45f850a20ed6..9d79af9eefc8 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1045,10 +1045,9 @@ static int ks_wlan_set_power(struct net_device *dev, if (vwrq->power.disabled) { priv->reg.power_mgmt = POWER_MGMT_ACTIVE; } else { - if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) - priv->reg.power_mgmt = POWER_MGMT_SAVE1; - else + if (priv->reg.operation_mode != MODE_INFRASTRUCTURE) return -EINVAL; + priv->reg.power_mgmt = POWER_MGMT_SAVE1; } hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST); -- cgit v1.2.3-59-g8ed1b From 1df964acca5a5e85de8aae30133ed8e7ef610f84 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:52 +0200 Subject: staging: ks7010: avoid if-else condition in ks_wlan_get_power The if-else code in ks_wlan_get_power function is not needed at all and can be achieved with a simple boolean assignation. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 9d79af9eefc8..3d09e3605f46 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1064,10 +1064,7 @@ static int ks_wlan_get_power(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (priv->reg.power_mgmt > 0) - vwrq->power.disabled = 0; - else - vwrq->power.disabled = 1; + vwrq->power.disabled = (priv->reg.power_mgmt <= 0); return 0; } -- cgit v1.2.3-59-g8ed1b From 77b948df47a9b81fde0ee34c313b5c8c009daff6 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:53 +0200 Subject: staging: ks7010: use ether_addr_copy in ks_wlan_get_aplist Use ether_addr_copy to copy ethernet addresses instead of using custom memcpy for that. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 3d09e3605f46..d2a213b5817a 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1101,8 +1101,7 @@ static int ks_wlan_get_aplist(struct net_device *dev, return -EPERM; /* for SLEEP MODE */ for (i = 0; i < priv->aplist.size; i++) { - memcpy(address[i].sa_data, &(priv->aplist.ap[i].bssid[0]), - ETH_ALEN); + ether_addr_copy(address[i].sa_data, priv->aplist.ap[i].bssid); address[i].sa_family = ARPHRD_ETHER; qual[i].level = 256 - priv->aplist.ap[i].rssi; qual[i].qual = priv->aplist.ap[i].sq; -- cgit v1.2.3-59-g8ed1b From 55b56be2c40ca2eb59888d87a629c77329836747 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:54 +0200 Subject: staging: ks7010: avoid blank line between declarations in ks_wlan_get_aplist This commit removes a blank line which is included between declarations and it has not sense at all. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index d2a213b5817a..f208b940e841 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1094,7 +1094,6 @@ static int ks_wlan_get_aplist(struct net_device *dev, struct ks_wlan_private *priv = netdev_priv(dev); struct sockaddr *address = (struct sockaddr *)extra; struct iw_quality qual[LOCAL_APLIST_MAX]; - int i; if (priv->sleep_mode == SLP_SLEEP) -- cgit v1.2.3-59-g8ed1b From bcb53e8a466f2a95b2f3089006931b0b5984103b Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 25 Apr 2018 16:01:55 +0200 Subject: staging: ks7010: refactor ks_wlan_translate_scan function This commit refactors ks_wlan_translate_scan function with the following changes: - reorder local variables - use ether_addr_copy to copy ethernet addresses - change style in 'current_ev' variable assignments - make use of some ternaries avoiding if-else code - use preferred style for comments - extract common code into a new ks_wlan_add_leader_event function After this changes readability has been improved. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 150 +++++++++++++++-------------------- 1 file changed, 66 insertions(+), 84 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index f208b940e841..694decc05c88 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1146,6 +1146,33 @@ static int ks_wlan_set_scan(struct net_device *dev, return 0; } +static char *ks_wlan_add_leader_event(const char *rsn_leader, char *end_buf, + char *current_ev, struct rsn_ie *rsn, + struct iw_event *iwe, + struct iw_request_info *info) +{ + char buffer[RSN_IE_BODY_MAX * 2 + 30]; + char *pbuf; + int i; + + pbuf = &buffer[0]; + memset(iwe, 0, sizeof(*iwe)); + iwe->cmd = IWEVCUSTOM; + memcpy(buffer, rsn_leader, sizeof(rsn_leader) - 1); + iwe->u.data.length += sizeof(rsn_leader) - 1; + pbuf += sizeof(rsn_leader) - 1; + pbuf += sprintf(pbuf, "%02x", rsn->id); + pbuf += sprintf(pbuf, "%02x", rsn->size); + iwe->u.data.length += 4; + + for (i = 0; i < rsn->size; i++) + pbuf += sprintf(pbuf, "%02x", rsn->body[i]); + + iwe->u.data.length += rsn->size * 2; + + return iwe_stream_add_point(info, current_ev, end_buf, iwe, &buffer[0]); +} + /* * Translate scan data returned from the card to a card independent * format that the Wireless Tools will understand - Jean II @@ -1156,22 +1183,19 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, struct local_ap *ap) { /* struct ks_wlan_private *priv = (struct ks_wlan_private *)dev->priv; */ + static const char rsn_leader[] = "rsn_ie="; + static const char wpa_leader[] = "wpa_ie="; struct iw_event iwe; /* Temporary buffer */ u16 capabilities; char *current_val; /* For rates */ int i; - static const char rsn_leader[] = "rsn_ie="; - static const char wpa_leader[] = "wpa_ie="; - char buf0[RSN_IE_BODY_MAX * 2 + 30]; - char buf1[RSN_IE_BODY_MAX * 2 + 30]; - char *pbuf; + /* First entry *MUST* be the AP MAC address */ iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - memcpy(iwe.u.ap_addr.sa_data, ap->bssid, ETH_ALEN); - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_ADDR_LEN); + ether_addr_copy(iwe.u.ap_addr.sa_data, ap->bssid); + current_ev = iwe_stream_add_event(info, current_ev, + end_buf, &iwe, IW_EV_ADDR_LEN); /* Other entries will be displayed in the order we give them */ @@ -1181,21 +1205,17 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, iwe.u.data.length = 32; iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - current_ev = - iwe_stream_add_point(info, current_ev, end_buf, &iwe, - ap->ssid.body); + current_ev = iwe_stream_add_point(info, current_ev, + end_buf, &iwe, ap->ssid.body); /* Add mode */ iwe.cmd = SIOCGIWMODE; capabilities = ap->capability; if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { - if (capabilities & WLAN_CAPABILITY_ESS) - iwe.u.mode = IW_MODE_INFRA; - else - iwe.u.mode = IW_MODE_ADHOC; - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_UINT_LEN); + iwe.u.mode = (capabilities & WLAN_CAPABILITY_ESS) ? + IW_MODE_INFRA : IW_MODE_ADHOC; + current_ev = iwe_stream_add_event(info, current_ev, + end_buf, &iwe, IW_EV_UINT_LEN); } /* Add frequency */ @@ -1203,32 +1223,29 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, iwe.u.freq.m = ap->channel; iwe.u.freq.m = frequency_list[iwe.u.freq.m - 1] * 100000; iwe.u.freq.e = 1; - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_FREQ_LEN); + current_ev = iwe_stream_add_event(info, current_ev, + end_buf, &iwe, IW_EV_FREQ_LEN); /* Add quality statistics */ iwe.cmd = IWEVQUAL; iwe.u.qual.level = 256 - ap->rssi; iwe.u.qual.qual = ap->sq; iwe.u.qual.noise = 0; /* invalid noise value */ - current_ev = - iwe_stream_add_event(info, current_ev, end_buf, &iwe, - IW_EV_QUAL_LEN); + current_ev = iwe_stream_add_event(info, current_ev, end_buf, + &iwe, IW_EV_QUAL_LEN); /* Add encryption capability */ iwe.cmd = SIOCGIWENCODE; - if (capabilities & WLAN_CAPABILITY_PRIVACY) - iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - else - iwe.u.data.flags = IW_ENCODE_DISABLED; + iwe.u.data.flags = (capabilities & WLAN_CAPABILITY_PRIVACY) ? + (IW_ENCODE_ENABLED | IW_ENCODE_NOKEY) : + IW_ENCODE_DISABLED; iwe.u.data.length = 0; - current_ev = - iwe_stream_add_point(info, current_ev, end_buf, &iwe, - ap->ssid.body); + current_ev = iwe_stream_add_point(info, current_ev, end_buf, + &iwe, ap->ssid.body); - /* Rate : stuffing multiple values in a single event require a bit - * more of magic - Jean II + /* + * Rate : stuffing multiple values in a single event + * require a bit more of magic - Jean II */ current_val = current_ev + IW_EV_LCP_LEN; @@ -1246,9 +1263,9 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, /* Bit rate given in 500 kb/s units (+ 0x80) */ iwe.u.bitrate.value = ((ap->rate_set.body[i] & 0x7f) * 500000); /* Add new value to event */ - current_val = - iwe_stream_add_value(info, current_ev, current_val, end_buf, - &iwe, IW_EV_PARAM_LEN); + current_val = iwe_stream_add_value(info, current_ev, + current_val, end_buf, &iwe, + IW_EV_PARAM_LEN); } /* Check if we added any event */ if ((current_val - current_ev) > IW_EV_LCP_LEN) @@ -1256,53 +1273,18 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, #define GENERIC_INFO_ELEM_ID 0xdd #define RSN_INFO_ELEM_ID 0x30 - if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) { - pbuf = &buf0[0]; - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - memcpy(buf0, rsn_leader, sizeof(rsn_leader) - 1); - iwe.u.data.length += sizeof(rsn_leader) - 1; - pbuf += sizeof(rsn_leader) - 1; - - pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.id); - pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.size); - iwe.u.data.length += 4; - - for (i = 0; i < ap->rsn_ie.size; i++) - pbuf += sprintf(pbuf, "%02x", ap->rsn_ie.body[i]); - iwe.u.data.length += (ap->rsn_ie.size) * 2; - - netdev_dbg(dev, "ap->rsn.size=%d\n", ap->rsn_ie.size); - - current_ev = - iwe_stream_add_point(info, current_ev, end_buf, &iwe, - &buf0[0]); - } - if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) { - pbuf = &buf1[0]; - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - memcpy(buf1, wpa_leader, sizeof(wpa_leader) - 1); - iwe.u.data.length += sizeof(wpa_leader) - 1; - pbuf += sizeof(wpa_leader) - 1; - - pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.id); - pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.size); - iwe.u.data.length += 4; - - for (i = 0; i < ap->wpa_ie.size; i++) - pbuf += sprintf(pbuf, "%02x", ap->wpa_ie.body[i]); - iwe.u.data.length += (ap->wpa_ie.size) * 2; - - netdev_dbg(dev, "ap->rsn.size=%d\n", ap->wpa_ie.size); - netdev_dbg(dev, "iwe.u.data.length=%d\n", iwe.u.data.length); - - current_ev = - iwe_stream_add_point(info, current_ev, end_buf, &iwe, - &buf1[0]); - } - - /* The other data in the scan result are not really + if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) + current_ev = ks_wlan_add_leader_event(rsn_leader, end_buf, + current_ev, &ap->rsn_ie, + &iwe, info); + + if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) + current_ev = ks_wlan_add_leader_event(wpa_leader, end_buf, + current_ev, &ap->wpa_ie, + &iwe, info); + + /* + * The other data in the scan result are not really * interesting, so for now drop it - Jean II */ return current_ev; -- cgit v1.2.3-59-g8ed1b From a0a954b151d037e8cbf8822eb56a1a79c4caed30 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:05 +0200 Subject: staging: ks7010: add SPDX identifiers to all files It's good to have SPDX identifiers in all files to make it easier to audit the kernel tree for correct licenses. Fix up the all of the staging ks7010 files to have a proper SPDX identifier, based on the license text in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. Extra GPL text wording can be removed as it is no longer needed at all. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 5 +---- drivers/staging/ks7010/ks7010_sdio.h | 5 +---- drivers/staging/ks7010/ks_hostif.c | 5 +---- drivers/staging/ks7010/ks_hostif.h | 5 +---- drivers/staging/ks7010/ks_wlan.h | 5 +---- drivers/staging/ks7010/ks_wlan_ioctl.h | 5 +---- drivers/staging/ks7010/ks_wlan_net.c | 5 +---- drivers/staging/ks7010/michael_mic.c | 5 +---- drivers/staging/ks7010/michael_mic.h | 5 +---- 9 files changed, 9 insertions(+), 36 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index b29f48c421cc..6a5565d479ac 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -1,13 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Driver for KeyStream, KS7010 based SDIO cards. * * Copyright (C) 2006-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. * Copyright (C) 2016 Sang Engineering, Wolfram Sang - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include diff --git a/drivers/staging/ks7010/ks7010_sdio.h b/drivers/staging/ks7010/ks7010_sdio.h index 95ac86b94a7c..831b2f105f58 100644 --- a/drivers/staging/ks7010/ks7010_sdio.h +++ b/drivers/staging/ks7010/ks7010_sdio.h @@ -1,12 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Driver for KeyStream, KS7010 based SDIO cards. * * Copyright (C) 2006-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #ifndef _KS7010_SDIO_H #define _KS7010_SDIO_H diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 9a05374d950e..c0a9a67dc0b4 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -1,12 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Driver for KeyStream wireless LAN cards. * * Copyright (C) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include diff --git a/drivers/staging/ks7010/ks_hostif.h b/drivers/staging/ks7010/ks_hostif.h index 05ff5ca5da19..172d38f17595 100644 --- a/drivers/staging/ks7010/ks_hostif.h +++ b/drivers/staging/ks7010/ks_hostif.h @@ -1,12 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Driver for KeyStream wireless LAN * * Copyright (c) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #ifndef _KS_HOSTIF_H_ diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index 2894b0c3816c..5070af86115f 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -1,12 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Driver for KeyStream IEEE802.11 b/g wireless LAN cards. * * Copyright (C) 2006-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #ifndef _KS_WLAN_H diff --git a/drivers/staging/ks7010/ks_wlan_ioctl.h b/drivers/staging/ks7010/ks_wlan_ioctl.h index e45a33291b46..97c7d95de411 100644 --- a/drivers/staging/ks7010/ks_wlan_ioctl.h +++ b/drivers/staging/ks7010/ks_wlan_ioctl.h @@ -1,12 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Driver for KeyStream 11b/g wireless LAN * * Copyright (c) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #ifndef _KS_WLAN_IOCTL_H diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 694decc05c88..e96477937f65 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1,12 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Driver for KeyStream 11b/g wireless LAN * * Copyright (C) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c index 2128c8441405..e6bd70846e98 100644 --- a/drivers/staging/ks7010/michael_mic.c +++ b/drivers/staging/ks7010/michael_mic.c @@ -1,12 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Driver for KeyStream wireless LAN * * Copyright (C) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include diff --git a/drivers/staging/ks7010/michael_mic.h b/drivers/staging/ks7010/michael_mic.h index eb22fdd660d9..f0ac164b999b 100644 --- a/drivers/staging/ks7010/michael_mic.h +++ b/drivers/staging/ks7010/michael_mic.h @@ -1,12 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Driver for KeyStream wireless LAN * * Copyright (C) 2005-2008 KeyStream Corp. * Copyright (C) 2009 Renesas Technology Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ /* MichaelMIC routine define */ -- cgit v1.2.3-59-g8ed1b From 1c800aabfd68b22795f01358d6b36c4cc5b12571 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:26 +0200 Subject: staging: ks7010: move two preprocessor definitions to ks_wlan.h In ks_wlan_translate_scan function there are two preprocessor definitions: - RSN_INFO_ELEM_ID - GENERIC_INFO_ELEM_ID These can be moved to common ks_wlan.h because they can be used in get_current_ap function instead of use hardcoded values. GENERIC_INFO_ELEM_ID has been renamed to WPA_INFO_ELEM_ID which is more clear. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 4 ++-- drivers/staging/ks7010/ks_wlan.h | 3 +++ drivers/staging/ks7010/ks_wlan_net.c | 4 +--- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index f8bca54ffdb8..0054c481cf12 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -132,12 +132,12 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info *ap_info) ap_info->rsn.size : RSN_IE_BODY_MAX; if ((ap_info->rsn_mode & RSN_MODE_WPA2) && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA2)) { - ap->rsn_ie.id = 0x30; + ap->rsn_ie.id = RSN_INFO_ELEM_ID; ap->rsn_ie.size = size; memcpy(ap->rsn_ie.body, ap_info->rsn.body, size); } else if ((ap_info->rsn_mode & RSN_MODE_WPA) && (priv->wpa.version == IW_AUTH_WPA_VERSION_WPA)) { - ap->wpa_ie.id = 0xdd; + ap->wpa_ie.id = WPA_INFO_ELEM_ID; ap->wpa_ie.size = size; memcpy(ap->wpa_ie.body, ap_info->rsn.body, size); } else { diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index fb080feb7202..dd42692de451 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -190,6 +190,9 @@ struct rsn_ie { u8 body[RSN_IE_BODY_MAX]; } __packed; +#define WPA_INFO_ELEM_ID 0xdd +#define RSN_INFO_ELEM_ID 0x30 + #define WPS_IE_BODY_MAX 255 struct wps_ie { u8 id; /* 221 'dd 00 50 F2 04' */ diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index e96477937f65..838db49898d4 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1268,14 +1268,12 @@ static inline char *ks_wlan_translate_scan(struct net_device *dev, if ((current_val - current_ev) > IW_EV_LCP_LEN) current_ev = current_val; -#define GENERIC_INFO_ELEM_ID 0xdd -#define RSN_INFO_ELEM_ID 0x30 if (ap->rsn_ie.id == RSN_INFO_ELEM_ID && ap->rsn_ie.size != 0) current_ev = ks_wlan_add_leader_event(rsn_leader, end_buf, current_ev, &ap->rsn_ie, &iwe, info); - if (ap->wpa_ie.id == GENERIC_INFO_ELEM_ID && ap->wpa_ie.size != 0) + if (ap->wpa_ie.id == WPA_INFO_ELEM_ID && ap->wpa_ie.size != 0) current_ev = ks_wlan_add_leader_event(wpa_leader, end_buf, current_ev, &ap->wpa_ie, &iwe, info); -- cgit v1.2.3-59-g8ed1b From d96f3a7cecdc399af19da3268f69d2d05b07093d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:29 +0200 Subject: staging: ks7010: change type for rsn_enabled in wpa_status struct Field rsn_enabled included in wpa_status struct is declared as unsigned int but it is only be set using 0 and 1 values and in conditional if code is just being used as a boolean. Change its type to be a boolean. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 2 +- drivers/staging/ks7010/ks_wlan.h | 2 +- drivers/staging/ks7010/ks_wlan_net.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 0ab2e1b08329..8cd3dac4fcd3 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -2296,7 +2296,7 @@ static inline void hostif_sme_init(struct ks_wlan_private *priv) static inline void hostif_wpa_init(struct ks_wlan_private *priv) { memset(&priv->wpa, 0, sizeof(priv->wpa)); - priv->wpa.rsn_enabled = 0; + priv->wpa.rsn_enabled = false; priv->wpa.mic_failure.failure = 0; priv->wpa.mic_failure.last_failure_time = 0; priv->wpa.mic_failure.stop = 0; diff --git a/drivers/staging/ks7010/ks_wlan.h b/drivers/staging/ks7010/ks_wlan.h index dd42692de451..655f1e3a2157 100644 --- a/drivers/staging/ks7010/ks_wlan.h +++ b/drivers/staging/ks7010/ks_wlan.h @@ -338,7 +338,7 @@ struct mic_failure { struct wpa_status { int wpa_enabled; - unsigned int rsn_enabled; + bool rsn_enabled; int version; int pairwise_suite; /* unicast cipher */ int group_suite; /* multicast cipher */ diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 838db49898d4..8b4a1ed636bd 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1372,14 +1372,14 @@ static int ks_wlan_set_auth_mode(struct net_device *dev, case IW_AUTH_WPA_VERSION_DISABLED: priv->wpa.version = value; if (priv->wpa.rsn_enabled) - priv->wpa.rsn_enabled = 0; + priv->wpa.rsn_enabled = false; priv->need_commit |= SME_RSN; break; case IW_AUTH_WPA_VERSION_WPA: case IW_AUTH_WPA_VERSION_WPA2: priv->wpa.version = value; if (!(priv->wpa.rsn_enabled)) - priv->wpa.rsn_enabled = 1; + priv->wpa.rsn_enabled = true; priv->need_commit |= SME_RSN; break; default: -- cgit v1.2.3-59-g8ed1b From 3ec51bb250b3f56bbd3da5bdfc61924cf355d690 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:39 +0200 Subject: staging: ks7010: use ether_addr_copy in ks_wlan_set_mac_address Use ether_addr_copy to copy ethernet address instad of using memcpy in ks_wlan_set_mac_address function. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 8b4a1ed636bd..bb8ec048afe5 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2500,7 +2500,7 @@ int ks_wlan_set_mac_address(struct net_device *dev, void *addr) if (netif_running(dev)) return -EBUSY; memcpy(dev->dev_addr, mac_addr->sa_data, dev->addr_len); - memcpy(priv->eth_addr, mac_addr->sa_data, ETH_ALEN); + ether_addr_copy(priv->eth_addr, mac_addr->sa_data); priv->mac_address_valid = false; hostif_sme_enqueue(priv, SME_MACADDRESS_SET_REQUEST); -- cgit v1.2.3-59-g8ed1b From 97d173c64301427174e144eeda4cb7af756589b6 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:40 +0200 Subject: staging: ks7010: use ether_addr_copy in ks_wlan_net_start Instead of use memcpy for copying ethernet addresses, use ether_addr_copy that do the same. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index bb8ec048afe5..a5401db1d565 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2633,7 +2633,7 @@ int ks_wlan_net_start(struct net_device *dev) timer_setup(&update_phyinfo_timer, ks_wlan_update_phyinfo_timeout, 0); /* dummy address set */ - memcpy(priv->eth_addr, dummy_addr, ETH_ALEN); + ether_addr_copy(priv->eth_addr, dummy_addr); ether_addr_copy(dev->dev_addr, priv->eth_addr); /* The ks_wlan-specific entries in the device structure. */ -- cgit v1.2.3-59-g8ed1b From 7f3c8bb5bcf3a133d1eeb171cf90888bc5253a69 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:41 +0200 Subject: staging: ks7010: refactor ks_wlan_set_sleep_mode function This commit refactors ks_wlan_set_sleep_mode function avoiding to use switch-case statement ans using simple if logic to handle invalid values first. This simplifies data paths as well as improves readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index a5401db1d565..53288c80df51 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2028,22 +2028,20 @@ static int ks_wlan_set_sleep_mode(struct net_device *dev, { struct ks_wlan_private *priv = netdev_priv(dev); - if (*uwrq == SLP_SLEEP) { - priv->sleep_mode = *uwrq; - netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode); - - hostif_sme_enqueue(priv, SME_STOP_REQUEST); - hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); - - } else if (*uwrq == SLP_ACTIVE) { - priv->sleep_mode = *uwrq; - netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode); - hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); - } else { + if (*uwrq != SLP_SLEEP && + *uwrq != SLP_ACTIVE) { netdev_err(dev, "SET_SLEEP_MODE %d error\n", *uwrq); return -EINVAL; } + priv->sleep_mode = *uwrq; + netdev_info(dev, "SET_SLEEP_MODE %d\n", priv->sleep_mode); + + if (*uwrq == SLP_SLEEP) + hostif_sme_enqueue(priv, SME_STOP_REQUEST); + + hostif_sme_enqueue(priv, SME_SLEEP_REQUEST); + return 0; } -- cgit v1.2.3-59-g8ed1b From 81255d867c7fa3e3e5c3b0000a7938466c492265 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:42 +0200 Subject: staging: ks7010: refactor ks_wlan_set_phy_type function Handle invalid values first and assign good ones at the end if it is the case. This makes code simplier. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 53288c80df51..62a9d55e854a 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1960,17 +1960,14 @@ static int ks_wlan_set_phy_type(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; - /* for SLEEP MODE */ - if (*uwrq == D_11B_ONLY_MODE) { /* 0 */ - priv->reg.phy_type = D_11B_ONLY_MODE; - } else if (*uwrq == D_11G_ONLY_MODE) { /* 1 */ - priv->reg.phy_type = D_11G_ONLY_MODE; - } else if (*uwrq == D_11BG_COMPATIBLE_MODE) { /* 2 */ - priv->reg.phy_type = D_11BG_COMPATIBLE_MODE; - } else { + + if (*uwrq != D_11B_ONLY_MODE && + *uwrq != D_11G_ONLY_MODE && + *uwrq != D_11BG_COMPATIBLE_MODE) return -EINVAL; - } + /* for SLEEP MODE */ + priv->reg.phy_type = *uwrq; priv->need_commit |= SME_MODE_SET; return -EINPROGRESS; /* Call commit handler */ } -- cgit v1.2.3-59-g8ed1b From 2d1de1e3186d13725ea152c643804ed59b1621aa Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:43 +0200 Subject: staging: ks7010: refactor ks_wlan_set_mlme function This commit refactors ks_wlan_set_mlme function changing switch-case block for more simple if paths improving readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 62a9d55e854a..30f8cee8f88c 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1787,23 +1787,20 @@ static int ks_wlan_set_mlme(struct net_device *dev, { struct ks_wlan_private *priv = netdev_priv(dev); struct iw_mlme *mlme = (struct iw_mlme *)extra; - __u32 mode; + __u32 mode = 1; if (priv->sleep_mode == SLP_SLEEP) return -EPERM; - /* for SLEEP MODE */ - switch (mlme->cmd) { - case IW_MLME_DEAUTH: - if (mlme->reason_code == WLAN_REASON_MIC_FAILURE) - return 0; - /* fall through */ - case IW_MLME_DISASSOC: - mode = 1; - return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); - default: - return -EOPNOTSUPP; /* Not Support */ - } + if (mlme->cmd != IW_MLME_DEAUTH && + mlme->cmd != IW_MLME_DISASSOC) + return -EOPNOTSUPP; + + if (mlme->cmd == IW_MLME_DEAUTH && + mlme->reason_code == WLAN_REASON_MIC_FAILURE) + return 0; + + return ks_wlan_set_stop_request(dev, NULL, &mode, NULL); } static int ks_wlan_get_firmware_version(struct net_device *dev, -- cgit v1.2.3-59-g8ed1b From 203ad5a1c8c1b7b31b845d103cd26f7ce449c73d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 4 May 2018 06:16:44 +0200 Subject: staging: ks7010: refactor ks_get_wireless_stats function This commit refactor a bit ks_get_wireless_stats using ternary operator for return code. It also change a comment to use preferred style. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 30f8cee8f88c..ee164ab571a9 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1743,14 +1743,11 @@ static struct iw_statistics *ks_get_wireless_stats(struct net_device *dev) struct ks_wlan_private *priv = netdev_priv(dev); struct iw_statistics *wstats = &priv->wstats; - if (!atomic_read(&update_phyinfo)) { - if (priv->dev_state < DEVICE_STATE_READY) - return NULL; /* not finished initialize */ - else - return wstats; - } + if (!atomic_read(&update_phyinfo)) + return (priv->dev_state < DEVICE_STATE_READY) ? NULL : wstats; - /* Packets discarded in the wireless adapter due to wireless + /* + * Packets discarded in the wireless adapter due to wireless * specific problems */ wstats->discard.nwid = 0; /* Rx invalid nwid */ -- cgit v1.2.3-59-g8ed1b From 6d6612deaf559c42ab4df207e3842aa92a5af71d Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Sun, 6 May 2018 15:03:00 -0700 Subject: staging: ks7010: Remove unnecessary limit checks uwrq is an unsigned 32-bit integer, it cannot be less than zero. Signed-off-by: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index ee164ab571a9..6d5ac6258d99 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -1920,7 +1920,7 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq < BEACON_LOST_COUNT_MIN || *uwrq > BEACON_LOST_COUNT_MAX) + if (*uwrq > BEACON_LOST_COUNT_MAX) return -EINVAL; priv->reg.beacon_lost_count = *uwrq; @@ -2120,7 +2120,7 @@ static int ks_wlan_set_tx_gain(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq < 0 || *uwrq > 0xFF) + if (*uwrq > 0xFF) return -EINVAL; priv->gain.tx_gain = (uint8_t)*uwrq; @@ -2152,7 +2152,7 @@ static int ks_wlan_set_rx_gain(struct net_device *dev, if (priv->sleep_mode == SLP_SLEEP) return -EPERM; /* for SLEEP MODE */ - if (*uwrq < 0 || *uwrq > 0xFF) + if (*uwrq > 0xFF) return -EINVAL; priv->gain.rx_gain = (uint8_t)*uwrq; -- cgit v1.2.3-59-g8ed1b From 255d4e1ddc9f1d46a7e25298af24429d61378d9c Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 13 May 2018 20:35:41 +0200 Subject: staging: ks7010: change uint8_t casts to u8 in ks_wlan_set_rate There are some casts to uint8_t in ks_wlan_set_rate function to assign values of the bitrate. Just change it to u8 which is the one defined for the field 'body' of the struct which is in use. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 6d5ac6258d99..1cd690a0b7ab 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -406,12 +406,12 @@ static int ks_wlan_set_rate(struct net_device *dev, case 11000000: case 5500000: priv->reg.rate_set.body[0] = - (uint8_t)(vwrq->bitrate.value / 500000); + (u8)(vwrq->bitrate.value / 500000); break; case 2000000: case 1000000: priv->reg.rate_set.body[0] = - ((uint8_t)(vwrq->bitrate.value / 500000)) | + ((u8)(vwrq->bitrate.value / 500000)) | BASIC_RATE; break; default: @@ -466,7 +466,7 @@ static int ks_wlan_set_rate(struct net_device *dev, case 18000000: case 9000000: priv->reg.rate_set.body[0] = - (uint8_t)(vwrq->bitrate.value / 500000); + (u8)(vwrq->bitrate.value / 500000); break; case 24000000: case 12000000: @@ -476,7 +476,7 @@ static int ks_wlan_set_rate(struct net_device *dev, case 2000000: case 1000000: priv->reg.rate_set.body[0] = - ((uint8_t)(vwrq->bitrate.value / 500000)) | + ((u8)(vwrq->bitrate.value / 500000)) | BASIC_RATE; break; default: -- cgit v1.2.3-59-g8ed1b From ace98ed095631588bd5a7ca8524b07076c690824 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 13 May 2018 20:35:42 +0200 Subject: staging: ks7010: replace uint8_t with u8 in ks_wlan_set_tx_gain In function ks_wlan_set_tx_gain a cast to uint8_t is being used to assign transmission gain. 'tx_gain' field is defined as u8 so replace the cast to the correct type. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 1cd690a0b7ab..c85ea83d23e1 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2123,7 +2123,7 @@ static int ks_wlan_set_tx_gain(struct net_device *dev, if (*uwrq > 0xFF) return -EINVAL; - priv->gain.tx_gain = (uint8_t)*uwrq; + priv->gain.tx_gain = (u8)*uwrq; priv->gain.tx_mode = (priv->gain.tx_gain < 0xFF) ? 1 : 0; hostif_sme_enqueue(priv, SME_SET_GAIN); return 0; -- cgit v1.2.3-59-g8ed1b From f647b8e1ffcd0ded55feb5445afbb9d421c3155c Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 13 May 2018 20:35:43 +0200 Subject: staging: ks7010: replace uint8_t with u8 in ks_wlan_set_rx_gain In function ks_wlan_set_rx_gain a cast to uint8_t is being used to assign reception gain. 'rx_gain' field is defined as u8 so replace the cast to the correct type Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging/ks7010/ks_wlan_net.c') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index c85ea83d23e1..dc5459ae0b51 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -2155,7 +2155,7 @@ static int ks_wlan_set_rx_gain(struct net_device *dev, if (*uwrq > 0xFF) return -EINVAL; - priv->gain.rx_gain = (uint8_t)*uwrq; + priv->gain.rx_gain = (u8)*uwrq; priv->gain.rx_mode = (priv->gain.rx_gain < 0xFF) ? 1 : 0; hostif_sme_enqueue(priv, SME_SET_GAIN); return 0; -- cgit v1.2.3-59-g8ed1b