From patchwork Tue Dec 17 16:15:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 11298109 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7ABE517F0 for ; Tue, 17 Dec 2019 16:16:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4E88621835 for ; Tue, 17 Dec 2019 16:16:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="gtWPbKiZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729182AbfLQQQJ (ORCPT ); Tue, 17 Dec 2019 11:16:09 -0500 Received: from mail-dm6nam12on2072.outbound.protection.outlook.com ([40.107.243.72]:33729 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728755AbfLQQQH (ORCPT ); Tue, 17 Dec 2019 11:16:07 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iE2K/Doea4h75gGb+iAwpe9qRLMUQIsiFXTLQLGODM6ayqiLLw+8jXnF1oFiKAB//P58XoYsmxh0bfxLKON85U7siONU6X6zjSbY/B5sTqag3v/BVr/zbynewpi1BdRD20ywmRx6KeR1hu1B1J6SuGm2RQF7dPbI2jMzlkI+H2PwU0KmfuRejsoPgh02jmrMcu2+1bsvHrByJGNhPtxepsLlQ4Ol4B2hzho3XjGkSX8XOAWn6wIvqpz0qq5g27CQxkzAGGTFrSBtpLj5rp75OPCf31xhDCSaI4Db1UbPQgl4FdVC05SaIpj3bEOG4lTSfdJZUZJCnlh8A1u4DlgrEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ee/z6m/vvrRSmvj8M3TfLohn1Xv4JRcuME8cta91xHM=; b=X2Axt3+Aub1+11QtO1uOuE1v1rMBSd+54GVYfgKvTBDVEOCP9nlhG+VA8XZAP+gz1fbmwzj6sxcPPZQgYZ02LyKfJYO5To7mHASmY7hXUsExJYVUhOV07gcx8T0Ezps+I7pd6Hnc5Cz+ijmtC3EeoRDM7abj38apLVsu7OhxwROppGD1PseXlFi6dWW49we6Yjp01L1pXCfs052tZdPWkJMQ/Wd9XcLEvPYAOZ0ciyvzB275phr0b8SAat0qW/mNxiJKXBxZK5/+rKy16rv8HpI3LnGR+2Fd1Yc5ryFFCrFtf1VZK5KmI39SVTeS6whE3qCgTbHLcXOn2aMbxvJMgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ee/z6m/vvrRSmvj8M3TfLohn1Xv4JRcuME8cta91xHM=; b=gtWPbKiZs9Pq6YAOOQXcUD6J5fmgVJrsECw4dRr0yqK09vDi8hcXHHd1HdKz4mqrSFixzs56rVMEuLUuEWLeIoQamzwL/+BPteK2cj9mRMBj4HAr3vc51WHJqdfKzJK8Tj2TCoAmBi/nlWBKvjQagdr+68DUhsKTlxgTJ1ee3fQ= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4477.namprd11.prod.outlook.com (52.135.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.17; Tue, 17 Dec 2019 16:15:59 +0000 Received: from MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf]) by MN2PR11MB4063.namprd11.prod.outlook.com ([fe80::f46c:e5b4:2a85:f0bf%4]) with mapi id 15.20.2538.019; Tue, 17 Dec 2019 16:15:59 +0000 From: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= To: "devel@driverdev.osuosl.org" , "linux-wireless@vger.kernel.org" CC: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH v2 49/55] staging: wfx: simplify hif_set_template_frame() usage Thread-Topic: [PATCH v2 49/55] staging: wfx: simplify hif_set_template_frame() usage Thread-Index: AQHVtPU27t+6bG2zg0qyvxNTFnYGUg== Date: Tue, 17 Dec 2019 16:15:34 +0000 Message-ID: <20191217161318.31402-50-Jerome.Pouiller@silabs.com> References: <20191217161318.31402-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20191217161318.31402-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PR0P264CA0174.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1c::18) To MN2PR11MB4063.namprd11.prod.outlook.com (2603:10b6:208:13f::22) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.24.0 x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2f2b8e61-5884-43b3-3a35-08d7830c589c x-ms-traffictypediagnostic: MN2PR11MB4477: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(376002)(346002)(396003)(136003)(366004)(39860400002)(199004)(189003)(1076003)(66574012)(186003)(107886003)(8676002)(6506007)(86362001)(478600001)(85182001)(5660300002)(81156014)(26005)(4326008)(6486002)(8936002)(316002)(110136005)(54906003)(64756008)(66446008)(66946007)(2616005)(66556008)(66476007)(85202003)(36756003)(6512007)(2906002)(52116002)(6666004)(71200400001)(81166006);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB4477;H:MN2PR11MB4063.namprd11.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: silabs.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ImqAzruPbCt+dfDZNxioIW2C8Hj8Lz4pI+xJiX9ZzDhGoDl8CCTHBUBrtoOtfYpB2W33aNyl/9yWVkoaJH+RA8SUYmNOr5TuDXRHUuhuP0cnUlpEJmhF6afVgFxyn1i6sj0R+CKpW7jqs4EhysAVlOC9JfDSYjy3Q5Ur7d2myuYnuhm9nRUbMjGii38ODxr0nSWJym2B1EuCQkd3+aWsRor1DR4aVKu4V/eJf6mkisTtBicwW9vSerdwfQJs7Fs3SscwlX7S4AvNerA0ttbSa0JwUXToRDYe5haQ1OzO6eUjZfzxh804iDEM5szUmf7ZDYO+r0461itj1yR+hBw2nl9HAjYyfCiC3Yfg5ksKodsBIO2Yi0L/AG6xOtYZrmVp2zcGjhgredq7DeBw9mVbfkYujKb3fPYntUEBnTjd68nMu7ro+STeQHR/wVi9JySj Content-ID: <4C80F7D799C1AA4DAB6C0C60FBE369CA@namprd11.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f2b8e61-5884-43b3-3a35-08d7830c589c X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Dec 2019 16:15:34.7273 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jx5tLeJMajjxLebmima1Vd8ZAvq+7fsUHnajcEWy31vCf3vccPGRuqxj5Z+0V4cNFxJyAkA9QN9BSnqLKVxFZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4477 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Jérôme Pouiller The structure hif_mib_template_frame come from hardware API. It is not intended to be manipulated in upper layers of the driver. In add, the current code for hif_set_template_frame() is dumb. All the difficult task is left to the caller. So, there is code to factorize here. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_tx_mib.h | 11 ++++++++++- drivers/staging/wfx/scan.c | 7 +------ drivers/staging/wfx/sta.c | 29 +++++++---------------------- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h index d77765f75f10..b1eeda2a3ab3 100644 --- a/drivers/staging/wfx/hif_tx_mib.h +++ b/drivers/staging/wfx/hif_tx_mib.h @@ -130,8 +130,17 @@ static inline int hif_set_operational_mode(struct wfx_dev *wdev, } static inline int hif_set_template_frame(struct wfx_vif *wvif, - struct hif_mib_template_frame *arg) + struct sk_buff *skb, + u8 frame_type, int init_rate) { + struct hif_mib_template_frame *arg; + + skb_push(skb, 4); + arg = (struct hif_mib_template_frame *)skb->data; + skb_pull(skb, 4); + arg->init_rate = init_rate; + arg->frame_type = frame_type; + arg->frame_length = cpu_to_le16(skb->len); return hif_write_mib(wvif->wdev, wvif->id, HIF_MIB_ID_TEMPLATE_FRAME, arg, sizeof(*arg)); } diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c index 8b184efad0cf..c82c04ff5d06 100644 --- a/drivers/staging/wfx/scan.c +++ b/drivers/staging/wfx/scan.c @@ -52,7 +52,6 @@ static int wfx_scan_start(struct wfx_vif *wvif, static int update_probe_tmpl(struct wfx_vif *wvif, struct cfg80211_scan_request *req) { - struct hif_mib_template_frame *tmpl; struct sk_buff *skb; skb = ieee80211_probereq_get(wvif->wdev->hw, wvif->vif->addr, @@ -61,11 +60,7 @@ static int update_probe_tmpl(struct wfx_vif *wvif, return -ENOMEM; skb_put_data(skb, req->ie, req->ie_len); - skb_push(skb, 4); - tmpl = (struct hif_mib_template_frame *)skb->data; - tmpl->frame_type = HIF_TMPLT_PRBREQ; - tmpl->frame_length = cpu_to_le16(skb->len - 4); - hif_set_template_frame(wvif, tmpl); + hif_set_template_frame(wvif, skb, HIF_TMPLT_PRBREQ, 0); dev_kfree_skb(skb); return 0; } diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 19ca13543a25..ba3e81fd477b 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -831,32 +831,20 @@ static int wfx_update_beaconing(struct wfx_vif *wvif) static int wfx_upload_beacon(struct wfx_vif *wvif) { - int ret = 0; - struct sk_buff *skb = NULL; + struct sk_buff *skb; struct ieee80211_mgmt *mgmt; - struct hif_mib_template_frame *p; if (wvif->vif->type == NL80211_IFTYPE_STATION || wvif->vif->type == NL80211_IFTYPE_MONITOR || wvif->vif->type == NL80211_IFTYPE_UNSPECIFIED) - goto done; + return 0; skb = ieee80211_beacon_get(wvif->wdev->hw, wvif->vif); - if (!skb) return -ENOMEM; + hif_set_template_frame(wvif, skb, HIF_TMPLT_BCN, + API_RATE_INDEX_B_1MBPS); - p = (struct hif_mib_template_frame *) skb_push(skb, 4); - p->frame_type = HIF_TMPLT_BCN; - p->init_rate = API_RATE_INDEX_B_1MBPS; /* 1Mbps DSSS */ - p->frame_length = cpu_to_le16(skb->len - 4); - - ret = hif_set_template_frame(wvif, p); - - skb_pull(skb, 4); - - if (ret) - goto done; /* TODO: Distill probe resp; remove TIM and any other beacon-specific * IEs */ @@ -864,14 +852,11 @@ static int wfx_upload_beacon(struct wfx_vif *wvif) mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); - p->frame_type = HIF_TMPLT_PRBRES; - - ret = hif_set_template_frame(wvif, p); + hif_set_template_frame(wvif, skb, HIF_TMPLT_PRBRES, + API_RATE_INDEX_B_1MBPS); wfx_fwd_probe_req(wvif, false); - -done: dev_kfree_skb(skb); - return ret; + return 0; } static int wfx_is_ht(const struct wfx_ht_info *ht_info)