From patchwork Mon Sep 18 07:42:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ganapathi Bhat X-Patchwork-Id: 9955631 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 8C1DB60208 for ; Mon, 18 Sep 2017 07:46:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C66F28BB9 for ; Mon, 18 Sep 2017 07:46:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 710A628BBB; Mon, 18 Sep 2017 07:46:01 +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 E86FB28BB9 for ; Mon, 18 Sep 2017 07:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752136AbdIRHp6 (ORCPT ); Mon, 18 Sep 2017 03:45:58 -0400 Received: from mx0b-0016f401.pphosted.com ([67.231.156.173]:42047 "EHLO mx0b-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750772AbdIRHp6 (ORCPT ); Mon, 18 Sep 2017 03:45:58 -0400 Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8I7j96H031929; Mon, 18 Sep 2017 00:45:57 -0700 Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 2d13feegav-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 18 Sep 2017 00:45:56 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 18 Sep 2017 00:45:54 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Mon, 18 Sep 2017 00:45:54 -0700 Received: from localhost (gbhat-thinkpad-t430.marvell.com [10.31.130.81]) by maili.marvell.com (Postfix) with ESMTP id F2D9C3F7040; Mon, 18 Sep 2017 00:45:54 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by localhost (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id v8I7hJo1013400; Mon, 18 Sep 2017 13:13:19 +0530 Received: (from root@localhost) by localhost (8.14.4/8.14.4/Submit) id v8I7hIY9013397; Mon, 18 Sep 2017 13:13:18 +0530 From: Ganapathi Bhat To: CC: Brian Norris , Cathy Luo , Xinming Hu , Zhiyuan Yang , James Cao , Mangesh Malusare , Ganapathi Bhat Subject: [PATCH 2/2] mwifiex: use get_random_mask_addr() helper Date: Mon, 18 Sep 2017 13:12:17 +0530 Message-ID: <1505720537-13362-1-git-send-email-gbhat@marvell.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-18_01:, , signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1709180110 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 Avoid calculating random MAC address in driver. Instead make use of 'get_random_mask_addr()' function. Signed-off-by: Ganapathi Bhat Reviewed-by: Brian Norris --- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index 84c1518..2b293b1 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c @@ -2503,6 +2503,7 @@ static int mwifiex_set_ibss_params(struct mwifiex_private *priv, struct ieee80211_channel *chan; struct ieee_types_header *ie; struct mwifiex_user_scan_cfg *user_scan_cfg; + u8 mac_addr[ETH_ALEN]; mwifiex_dbg(priv->adapter, CMD, "info: received scan request on %s\n", dev->name); @@ -2529,12 +2530,10 @@ static int mwifiex_set_ibss_params(struct mwifiex_private *priv, priv->scan_request = request; if (request->flags & NL80211_SCAN_FLAG_RANDOM_ADDR) { - for (i = 0; i < ETH_ALEN; i++) { - request->mac_addr[i] &= request->mac_addr_mask[i]; - request->mac_addr[i] |= - get_random_int() & ~(request->mac_addr_mask[i]); - } - ether_addr_copy(user_scan_cfg->random_mac, request->mac_addr); + get_random_mask_addr(mac_addr, request->mac_addr, + request->mac_addr_mask); + ether_addr_copy(request->mac_addr, mac_addr); + ether_addr_copy(user_scan_cfg->random_mac, mac_addr); } user_scan_cfg->num_ssids = request->n_ssids;