From patchwork Mon Dec 16 17:03:58 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: 11294751 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 6F642930 for ; Mon, 16 Dec 2019 17:07:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 39DEA2082E for ; Mon, 16 Dec 2019 17:07:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="EBp2YzKa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727974AbfLPRHE (ORCPT ); Mon, 16 Dec 2019 12:07:04 -0500 Received: from mail-eopbgr690050.outbound.protection.outlook.com ([40.107.69.50]:60371 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727950AbfLPRHD (ORCPT ); Mon, 16 Dec 2019 12:07:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hSYjrWWQ9MIBVAgP6w40QmPXeGXA7RRvQy42vDV9Qhn0Qa0yomshIKWHYPEbnezrLdhpKL07OF1YDvvaBDrX2e8koTFVlrLOaP3XCqnl64ZU6hzIIAUUpsW8lR+J0SxlFbWLfYgXep6Hy602igMX0LxfNgR2PyvzlPRuw3zSY0RYK79vKRfNPZHavMvPJZ2DJTBzAPht2vKneT2J6F7z6MyWjJX80ZN6F76mwRSN1kNeFGjDCyZjsbuNdzkHBz6yDXbRgL2lcvJComaBQXhlaA+x+Hfx9rER1aT4hT6ComHMyjwfTwsy7hfpjboz0M7ODAHfANa+UgAKOMmXEBAX6Q== 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=so5SnU6Iyxo02ShpQyiAgAyv7tQEZbXh6voMT2xWEeo=; b=OF7i72qWzhbg2mWg8aWuZBgDFSBIEGjtWlx37RuMZYASQrKmjtoylvYeR1iogopNlj0dOhsBV/Dl7drQcT4jT2RYY9MAqkT5nEdBgjU85ZyvIro8z3W513nthPSLUDpTqyXLg4zec9pKi4l09xz+lcMXOwL0hKqOXunqDwTlX3DZaPapLoFEZMdjhElH0fVRB0W8JDh/TlF6zais/4MzD8uONIjthrPXM773eCPYW/CrIZSJsVMlaCAnxd1lpU8hRmSYnLs5NWkrBWXyvMOB4Jg0ifQCYZG12udeaRNUlc0syZ0qAzNswJPsf+tdGw0wU+zR6TsEARp0XzTWrJmFUw== 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=so5SnU6Iyxo02ShpQyiAgAyv7tQEZbXh6voMT2xWEeo=; b=EBp2YzKa72X5FiLXxXL4zEVymQMGz1WPBhyWJoq2R7l9xSCjwCpL+bem5BJGb7YjNCLXIlm9Zd1nmtPUdXkqN3WwEJmv2VetyfW+evlFhM7osSMUbn34hrdianJSGlZxnqIvdMkqfd0fUG8Y322HHTLdEd3tHChIjCpLeXOt/Uw= Received: from MN2PR11MB4063.namprd11.prod.outlook.com (10.255.180.22) by MN2PR11MB4142.namprd11.prod.outlook.com (20.179.149.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2538.15; Mon, 16 Dec 2019 17:06:48 +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; Mon, 16 Dec 2019 17:06:48 +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 49/55] staging: wfx: simplify hif_set_template_frame() usage Thread-Topic: [PATCH 49/55] staging: wfx: simplify hif_set_template_frame() usage Thread-Index: AQHVtDLOYb/UslY1dEe3AM5ifbzjdQ== Date: Mon, 16 Dec 2019 17:03:58 +0000 Message-ID: <20191216170302.29543-50-Jerome.Pouiller@silabs.com> References: <20191216170302.29543-1-Jerome.Pouiller@silabs.com> In-Reply-To: <20191216170302.29543-1-Jerome.Pouiller@silabs.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Jerome.Pouiller@silabs.com; x-originating-ip: [37.71.187.125] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1e75c2c6-24f3-47e2-a462-08d7824a5636 x-ms-traffictypediagnostic: MN2PR11MB4142: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-forefront-prvs: 02530BD3AA x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(396003)(346002)(136003)(376002)(39850400004)(199004)(189003)(6512007)(71200400001)(91956017)(6486002)(8676002)(2906002)(54906003)(81166006)(81156014)(186003)(76116006)(478600001)(36756003)(85182001)(85202003)(6666004)(66556008)(66476007)(66446008)(64756008)(1076003)(66574012)(316002)(2616005)(4326008)(6506007)(26005)(8936002)(110136005)(5660300002)(107886003)(66946007)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:MN2PR11MB4142;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: MqE3iOKEuS8GbvrkVjoPA3LETINozMwzReqeuQIH0KhDPWrpv0SahCShRxcJiSLNNNJdn3wVomIio8/kq29W+f+Fhnymw5CaTutik31OhFPPhqBcrVx/RAILJIoX+5tLR7tcSwEsaD4XnN9mxuh6QXtkGjiX4M4EnPhypqf8RhDuc0Rb1J4UvHDXa5WDffqRUjPf+/GIr86gWamvJ0/oxzSw6YeSjn445aCxemZeYxT9yTHZBroNcvZGPABd4NGbW7Mco7MWsB8gx15HKruxdDRttxfH54apEcR2adC2935NG9xEeFFQTgZC4QaBrt2BORTL3pqjN1DigfKxaO283sPitMi4zrkIk6eD+P87v7NPGwAbDqZ/VQK4CyyUfRcn9oP6D8JkWEa5AloUU79x6Mg8H7VHjiVcFONkZ2fB7f41yoVXkrK+VkN8Yed43pzY Content-ID: MIME-Version: 1.0 X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e75c2c6-24f3-47e2-a462-08d7824a5636 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Dec 2019 17:03:58.5098 (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: 2sR10ecwL4SlZvbeyufXLdjIMlhcLvkhxol6WRCXGA25EjPOnOeD/SIswH0lRjVp8I5H8+VglFIc+TSHZb1FhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4142 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)