From patchwork Tue Mar 20 16:55:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Singh X-Patchwork-Id: 10297485 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 315C960385 for ; Tue, 20 Mar 2018 16:56:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2092A28B38 for ; Tue, 20 Mar 2018 16:56:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14FFE295F8; Tue, 20 Mar 2018 16:56:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55EBF2925F for ; Tue, 20 Mar 2018 16:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751669AbeCTQ4I (ORCPT ); Tue, 20 Mar 2018 12:56:08 -0400 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:64085 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751628AbeCTQ4H (ORCPT ); Tue, 20 Mar 2018 12:56:07 -0400 X-IronPort-AV: E=Sophos;i="5.48,336,1517900400"; d="scan'208";a="12470567" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES128-SHA; 20 Mar 2018 09:56:06 -0700 Received: from ajaysk-VirtualBox.mchp-main.com (10.10.76.4) by CHN-SV-EXCH01.mchp-main.com (10.10.76.37) with Microsoft SMTP Server id 14.3.352.0; Tue, 20 Mar 2018 09:56:05 -0700 From: Ajay Singh To: CC: , , , , , , , Ajay Singh Subject: [PATCH 04/11] staging: wilc1000: refactor WILC_WFI_p2p_rx() to avoid line over 80 char Date: Tue, 20 Mar 2018 22:25:37 +0530 Message-ID: <1521564944-3565-5-git-send-email-ajay.kathat@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1521564944-3565-1-git-send-email-ajay.kathat@microchip.com> References: <1521564944-3565-1-git-send-email-ajay.kathat@microchip.com> MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fix 'line over 80 characters' issue found by checkpatch.pl script. Refactor and split the function to avoid the checkpatch reported issues. Signed-off-by: Ajay Singh --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 145 ++++++++++++---------- 1 file changed, 82 insertions(+), 63 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 9d35a08..090d59d 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1365,12 +1365,49 @@ static void wilc_wfi_cfg_parse_tx_action(u8 *buf, u32 len, bool oper_ch, op_channel_attr_index); } +static void wilc_wfi_cfg_parse_rx_vendor_spec(struct wilc_priv *priv, u8 *buff, + u32 size) +{ + int i; + u8 subtype; + struct wilc_vif *vif = netdev_priv(priv->dev); + + subtype = buff[P2P_PUB_ACTION_SUBTYPE]; + if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && !wilc_ie) { + for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { + if (!memcmp(p2p_vendor_spec, &buff[i], 6)) { + p2p_recv_random = buff[i + 6]; + wilc_ie = true; + break; + } + } + } + + if (p2p_local_random <= p2p_recv_random) { + netdev_dbg(vif->ndev, + "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", + p2p_local_random, p2p_recv_random); + return; + } + + if (subtype == GO_NEG_REQ || subtype == GO_NEG_RSP || + subtype == P2P_INV_REQ || subtype == P2P_INV_RSP) { + for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { + if (buff[i] == P2PELEM_ATTR_ID && + !(memcmp(p2p_oui, &buff[i + 2], 4))) { + wilc_wfi_cfg_parse_rx_action(&buff[i + 6], + size - (i + 6)); + break; + } + } + } +} + void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size) { struct wilc_priv *priv; u32 header, pkt_offset; struct host_if_drv *wfi_drv; - u32 i = 0; s32 s32Freq; priv = wiphy_priv(dev->ieee80211_ptr->wiphy); @@ -1381,75 +1418,57 @@ void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size) pkt_offset = GET_PKT_OFFSET(header); if (pkt_offset & IS_MANAGMEMENT_CALLBACK) { - if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) { - cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size, true, GFP_KERNEL); - return; - } else { - if (pkt_offset & IS_MGMT_STATUS_SUCCES) - cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size, true, GFP_KERNEL); - else - cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size, false, GFP_KERNEL); - return; - } - } else { - s32Freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ); + bool ack = false; - if (ieee80211_is_action(buff[FRAME_TYPE_ID])) { - if (priv->cfg_scanning && time_after_eq(jiffies, (unsigned long)wfi_drv->p2p_timeout)) { - netdev_dbg(dev, "Receiving action wrong ch\n"); - return; - } - if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { - switch (buff[ACTION_SUBTYPE_ID]) { - case GAS_INITIAL_REQ: - break; + if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP || + pkt_offset & IS_MGMT_STATUS_SUCCES) + ack = true; - case GAS_INITIAL_RSP: - break; + cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size, + ack, GFP_KERNEL); + return; + } - case PUBLIC_ACT_VENDORSPEC: - if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) { - if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) { - if (!wilc_ie) { - for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) { - if (!memcmp(p2p_vendor_spec, &buff[i], 6)) { - p2p_recv_random = buff[i + 6]; - wilc_ie = true; - break; - } - } - } - } - if (p2p_local_random > p2p_recv_random) { - if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP || - buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) { - for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) { - if (buff[i] == P2PELEM_ATTR_ID && !(memcmp(p2p_oui, &buff[i + 2], 4))) { - wilc_wfi_cfg_parse_rx_action(&buff[i + 6], size - (i + 6)); - break; - } - } - } - } else { - netdev_dbg(dev, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", p2p_local_random, p2p_recv_random); - } - } + s32Freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ); - if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (wilc_ie)) { - cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0); - return; - } - break; + if (!ieee80211_is_action(buff[FRAME_TYPE_ID])) { + cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size, 0); + return; + } - default: - netdev_dbg(dev, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]); - break; - } - } - } + if (priv->cfg_scanning && + time_after_eq(jiffies, (unsigned long)wfi_drv->p2p_timeout)) { + netdev_dbg(dev, "Receiving action wrong ch\n"); + return; + } + if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { + u8 subtype = buff[P2P_PUB_ACTION_SUBTYPE]; - cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size, 0); + switch (buff[ACTION_SUBTYPE_ID]) { + case GAS_INITIAL_REQ: + case GAS_INITIAL_RSP: + break; + + case PUBLIC_ACT_VENDORSPEC: + if (!memcmp(p2p_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) + wilc_wfi_cfg_parse_rx_vendor_spec(priv, buff, + size); + + if ((subtype == GO_NEG_REQ || subtype == GO_NEG_RSP) && + wilc_ie) + size -= 7; + + break; + + default: + netdev_dbg(dev, + "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", + buff[ACTION_SUBTYPE_ID]); + break; + } } + + cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size, 0); } static void wilc_wfi_mgmt_tx_complete(void *priv, int status)