From patchwork Mon Mar 25 22:27:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adham Abozaeid X-Patchwork-Id: 10870265 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7463D1575 for ; Mon, 25 Mar 2019 22:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AE4728F94 for ; Mon, 25 Mar 2019 22:27:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AE3529041; Mon, 25 Mar 2019 22:27:31 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 716C228F94 for ; Mon, 25 Mar 2019 22:27:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729840AbfCYW13 (ORCPT ); Mon, 25 Mar 2019 18:27:29 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:19949 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728912AbfCYW13 (ORCPT ); Mon, 25 Mar 2019 18:27:29 -0400 X-IronPort-AV: E=Sophos;i="5.60,270,1549954800"; d="scan'208";a="26959229" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Mar 2019 15:27:29 -0700 Received: from NAM01-SN1-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.108) with Microsoft SMTP Server (TLS) id 14.3.352.0; Mon, 25 Mar 2019 15:27:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=geEJ2SkKz58lpxCJStWwcwuunLxRBj/4HGiz+WzRE3w=; b=BsW4b2N37YwcwwkJeSXJa+PlUAfsv5KFWw/ZmEotXKXfJcFr5HsAV2VlCSMbQuY+OBjAEQQe9jDF14Z8LTFRl3GBCnH1p/8WE1DiaYVIS6a9hxxwuM4wDZFwP9jRTUZz8bQErf4oOFYkTnlzHtYLSvZ/0zpOE33dTxAALLSuZIQ= Received: from MWHPR11MB1373.namprd11.prod.outlook.com (10.169.234.7) by MWHPR11MB1712.namprd11.prod.outlook.com (10.169.236.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.15; Mon, 25 Mar 2019 22:27:26 +0000 Received: from MWHPR11MB1373.namprd11.prod.outlook.com ([fe80::583a:f4d8:147c:549]) by MWHPR11MB1373.namprd11.prod.outlook.com ([fe80::583a:f4d8:147c:549%4]) with mapi id 15.20.1730.019; Mon, 25 Mar 2019 22:27:26 +0000 From: To: CC: , , , , Subject: [PATCH] staging: wilc1000: use cfg80211 ssid list instead of repacking it Thread-Topic: [PATCH] staging: wilc1000: use cfg80211 ssid list instead of repacking it Thread-Index: AQHU41ns+IN3tSci0EOoJhL3zpyFlA== Date: Mon, 25 Mar 2019 22:27:26 +0000 Message-ID: <20190325222636.29708-1-adham.abozaeid@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [198.175.253.81] x-clientproxiedby: BYAPR05CA0041.namprd05.prod.outlook.com (2603:10b6:a03:74::18) To MWHPR11MB1373.namprd11.prod.outlook.com (2603:10b6:300:24::7) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Adham.Abozaeid@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8fd69d62-bcf1-4a74-f4e3-08d6b1710f1e x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020);SRVR:MWHPR11MB1712; x-ms-traffictypediagnostic: MWHPR11MB1712: x-microsoft-antispam-prvs: x-forefront-prvs: 0987ACA2E2 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(136003)(376002)(346002)(39860400002)(396003)(366004)(199004)(189003)(478600001)(107886003)(72206003)(6506007)(3846002)(66066001)(6116002)(5660300002)(25786009)(36756003)(386003)(52116002)(14454004)(4326008)(102836004)(99286004)(2501003)(26005)(8936002)(6486002)(5640700003)(105586002)(106356001)(256004)(14444005)(86362001)(50226002)(6436002)(316002)(6512007)(6916009)(81156014)(68736007)(81166006)(486006)(8676002)(7736002)(1076003)(305945005)(53936002)(2906002)(186003)(71190400001)(71200400001)(476003)(54906003)(2616005)(97736004)(2351001);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR11MB1712;H:MWHPR11MB1373.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: vcnW/0IkWIITpBe8H29M1Bm5WBVhVEsIr01cB+AaTd7yUWxHCumkBncAZM+O8QWwUjijGuAzoRFzAIh5UMHYvgNfzs+iutj+7UT09xYdtxGAeII1ONKlT4GkS/1N23tnC2EfWgp6VRckip3jrp9a3A8iTGRGaOnFHu/CeB/2M501LeU2wHU+INiUDsluIsf0NqYT+MPyHGW8l8zL1t6wxQkQozwMfzwdedkRzpISy+r8t7XEbu2/KfePVcXkM7/QFtLUUInT4rCcMkozjQUc13Of1hkOGto3ZWNS1iEUrpD3eaE6u/+0pYMFP/tPz/c/p3YjyuxPQBucVeK1afiMH5VFPQJjhqLD+KrzuXBsrDiGdHQXGtvtj3lQBAc8VW5Cc2fn+vnvQvju1LLxbAtLl5S7K1bFZ6gyS1VlmZD/dRk= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 8fd69d62-bcf1-4a74-f4e3-08d6b1710f1e X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Mar 2019 22:27:26.6384 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1712 X-OriginatorOrg: microchip.com 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 From: Adham Abozaeid Avoid repacking ssid values into struct wilc_probe_ssid, and use the cfg80211 provided struct to pass the ssid list to wilc_scan. With this change, struct wilc_probe_ssid, struct wilc_probe_ssid_info and function wilc_wfi_cfg_alloc_fill_ssid will not be needed anymore. Signed-off-by: Adham Abozaeid --- drivers/staging/wilc1000/host_interface.c | 32 ++++----- drivers/staging/wilc1000/host_interface.h | 14 +--- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 69 +------------------ 3 files changed, 20 insertions(+), 95 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 44556b22613e..91ea16a6ae2e 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -229,10 +229,10 @@ static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) } int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, - u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, size_t ies_len, + u8 *ch_freq_list, u8 ch_list_len, void (*scan_result_fn)(enum scan_event, struct wilc_rcvd_net_info *, void *), - void *user_arg, struct wilc_probe_ssid *search) + void *user_arg, struct cfg80211_scan_request *request) { int result = 0; struct wid wid_list[5]; @@ -258,9 +258,9 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, hif_drv->usr_scan_req.ch_cnt = 0; - if (search) { - for (i = 0; i < search->n_ssids; i++) - valuesize += ((search->ssid_info[i].ssid_len) + 1); + if (request->n_ssids) { + for (i = 0; i < request->n_ssids; i++) + valuesize += ((request->ssids[i].ssid_len) + 1); search_ssid_vals = kmalloc(valuesize + 1, GFP_KERNEL); if (search_ssid_vals) { wid_list[index].id = WID_SSID_PROBE_REQ; @@ -268,13 +268,13 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, wid_list[index].val = search_ssid_vals; buffer = wid_list[index].val; - *buffer++ = search->n_ssids; + *buffer++ = request->n_ssids; - for (i = 0; i < search->n_ssids; i++) { - *buffer++ = search->ssid_info[i].ssid_len; - memcpy(buffer, search->ssid_info[i].ssid, - search->ssid_info[i].ssid_len); - buffer += search->ssid_info[i].ssid_len; + for (i = 0; i < request->n_ssids; i++) { + *buffer++ = request->ssids[i].ssid_len; + memcpy(buffer, request->ssids[i].ssid, + request->ssids[i].ssid_len); + buffer += request->ssids[i].ssid_len; } wid_list[index].size = (s32)(valuesize + 1); index++; @@ -283,8 +283,8 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, wid_list[index].id = WID_INFO_ELEMENT_PROBE; wid_list[index].type = WID_BIN_DATA; - wid_list[index].val = (s8 *)ies; - wid_list[index].size = ies_len; + wid_list[index].val = (s8 *)request->ie; + wid_list[index].size = request->ie_len; index++; wid_list[index].id = WID_SCAN_TYPE; @@ -328,10 +328,8 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, jiffies + msecs_to_jiffies(WILC_HIF_SCAN_TIMEOUT_MS)); error: - if (search) { - kfree(search->ssid_info); - kfree(search_ssid_vals); - } + + kfree(search_ssid_vals); return result; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 678e62312215..a907c6d33012 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -115,16 +115,6 @@ struct wilc_rcvd_net_info { struct ieee80211_mgmt *mgmt; }; -struct wilc_probe_ssid_info { - u8 ssid_len; - u8 *ssid; -}; - -struct wilc_probe_ssid { - struct wilc_probe_ssid_info *ssid_info; - u8 n_ssids; - u32 size; -}; struct wilc_user_scan_req { void (*scan_result)(enum scan_event evt, @@ -205,10 +195,10 @@ int wilc_disconnect(struct wilc_vif *vif); int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel); int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level); int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, - u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, size_t ies_len, + u8 *ch_freq_list, u8 ch_list_len, void (*scan_result_fn)(enum scan_event, struct wilc_rcvd_net_info *, void *), - void *user_arg, struct wilc_probe_ssid *search); + void *user_arg, struct cfg80211_scan_request *request); int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *cfg_param); int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 75ec752b5059..f6825727bf77 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -214,50 +214,6 @@ static int set_channel(struct wiphy *wiphy, return result; } -static inline int -wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request *request, - struct wilc_probe_ssid *search) -{ - int i; - int slot_id = 0; - - search->ssid_info = kcalloc(request->n_ssids, - sizeof(*search->ssid_info), GFP_KERNEL); - if (!search->ssid_info) - goto out; - - search->n_ssids = request->n_ssids; - - for (i = 0; i < request->n_ssids; i++) { - if (request->ssids[i].ssid_len > 0) { - struct wilc_probe_ssid_info *info; - - info = &search->ssid_info[slot_id]; - info->ssid = kmemdup(request->ssids[i].ssid, - request->ssids[i].ssid_len, - GFP_KERNEL); - if (!info->ssid) - goto out_free; - - info->ssid_len = request->ssids[i].ssid_len; - slot_id++; - } else { - search->n_ssids -= 1; - } - } - return 0; - -out_free: - - for (i = 0; i < slot_id; i++) - kfree(search->ssid_info[i].ssid); - - kfree(search->ssid_info); -out: - - return -ENOMEM; -} - static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) { struct wilc_priv *priv = wiphy_priv(wiphy); @@ -265,7 +221,6 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) u32 i; int ret = 0; u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH]; - struct wilc_probe_ssid probe_ssid; if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) { netdev_err(priv->dev, "Requested scanned channels over\n"); @@ -280,28 +235,10 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) scan_ch_list[i] = ieee80211_frequency_to_channel(freq); } - if (request->n_ssids >= 1) { - if (wilc_wfi_cfg_alloc_fill_ssid(request, &probe_ssid)) { - ret = -ENOMEM; - goto out; - } - - ret = wilc_scan(vif, WILC_FW_USER_SCAN, - WILC_FW_ACTIVE_SCAN, scan_ch_list, - request->n_channels, - (const u8 *)request->ie, - request->ie_len, cfg_scan_result, - (void *)priv, &probe_ssid); - } else { - ret = wilc_scan(vif, WILC_FW_USER_SCAN, - WILC_FW_ACTIVE_SCAN, scan_ch_list, - request->n_channels, - (const u8 *)request->ie, - request->ie_len, cfg_scan_result, - (void *)priv, NULL); - } + ret = wilc_scan(vif, WILC_FW_USER_SCAN, WILC_FW_ACTIVE_SCAN, + scan_ch_list, request->n_channels, cfg_scan_result, + (void *)priv, request); -out: if (ret) { priv->scan_req = NULL; priv->cfg_scanning = false;