From patchwork Fri Oct 6 15:04:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 9989655 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 8119C6020F for ; Fri, 6 Oct 2017 15:05:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CECA28DC4 for ; Fri, 6 Oct 2017 15:05:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7062C28DC8; Fri, 6 Oct 2017 15:05:23 +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=-0.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS, RCVD_IN_SORBS_SPAM, RCVD_IN_SORBS_WEB autolearn=no 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 2416728DC4 for ; Fri, 6 Oct 2017 15:05:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbdJFPFE (ORCPT ); Fri, 6 Oct 2017 11:05:04 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:37541 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751515AbdJFPFD (ORCPT ); Fri, 6 Oct 2017 11:05:03 -0400 Received: by mail-pg0-f65.google.com with SMTP id o1so17314919pga.4; Fri, 06 Oct 2017 08:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ImEY1jV7u2M75Wk3Nbp+gJ2GDHd7klSQE7BnKeNzlMk=; b=K1n8z5/W2Orh0jj3HHfNtkuba9Pqxw+/e+CzDiXbSbiNsDG0zt7arVjJBe4hYDdxBK GKymr2+4Yjph9dKMiiu66qIyodyrvPeEcTW2WTmxpra3tMTTkV9/1VGVjKclJJGDB1CD r6Q4OwAawG9IWVUECgK/JS1Ouar3ilFIh2axFYsQUUhxmhDbtf1gGsJV9NcUAhrh48bs DYwiWSaH3MS/JE2PpRR5kugnM4SUM7ByAgp38v7K0JAerAPb9c3qYK2P1aiaKyaG1K3T vMlYJQG98QpqAeIGDqb4oYtH8Pt0rPq9smRnoR0tZwsq1TIE6gQvocfCC+pNzS8rhtt3 KYuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ImEY1jV7u2M75Wk3Nbp+gJ2GDHd7klSQE7BnKeNzlMk=; b=HkR6AGoHgbRsquAl3dP7sU8MKO41U3nX307cOpzfbVFsxNTmJF46qvNAMNO6YM/hq5 A7zDHrFabLofSyuzn1ZrTk1xNXJrzeG1A4OCZ3YBkl7lBpXC7T7LinwWZQff8iJjGd3m bjsV6CT6IZcZOu+Ym33TJHrEAzWHWRz3HZFCJNhdZ6L6T1yUwH+sqXmkrhv936dw3tTj 3vPr5/5H9buMWHKr19tliIZYkfzxAgkwj9im6oxz7gThq24QrhWpUqJp/R7QcD5ewdP/ 5L+Qzw8/ikIhkfkV9t3UYZfLvNVjo7laLJXVNgkR12YpW11dl9d7OHCqJaXT5N8KW845 4NZQ== X-Gm-Message-State: AMCzsaXQ+RQsdwydKeL1wbAXWlPmxqci13NhrE3vujkV45Whl5ugw0eU iYQCsPN5ONnVXnav+h+7/d0= X-Google-Smtp-Source: AOwi7QDQ8Ls5J+QY1zxuM84znTzoRNZR1HNfs3CZCYKP1W3OWuIVIZ94WepHyj8KyoYB8r8npbC2gA== X-Received: by 10.98.205.68 with SMTP id o65mr2502794pfg.117.1507302302547; Fri, 06 Oct 2017 08:05:02 -0700 (PDT) Received: from localhost.localdomain ([103.254.204.108]) by smtp.gmail.com with ESMTPSA id q8sm44904pfk.100.2017.10.06.08.04.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 06 Oct 2017 08:05:01 -0700 (PDT) From: Himanshu Jha To: amitkarwar@gmail.com Cc: nishants@marvell.com, gbhat@marvell.com, huxm@marvell.com, kvalo@codeaurora.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Himanshu Jha Subject: [PATCH v2] mwifiex: Use put_unaligned_le32 Date: Fri, 6 Oct 2017 20:34:39 +0530 Message-Id: <1507302279-3875-1-git-send-email-himanshujha199640@gmail.com> X-Mailer: git-send-email 2.7.4 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 Use put_unaligned_le32 rather than using byte ordering function and memcpy which makes code clear. Also, add the header file where it is declared. Done using Coccinelle and semantic patch used is : @ rule1 @ identifier tmp; expression ptr,x; type T; @@ - tmp = cpu_to_le32(x); <+... when != tmp - memcpy(ptr, (T)&tmp, ...); + put_unaligned_le32(x,ptr); ...+> @ depends on rule1 @ type j; identifier tmp; @@ - j tmp; ...when != tmp Signed-off-by: Himanshu Jha --- v2: * added correct header file. drivers/net/wireless/marvell/mwifiex/cmdevt.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c index 0edc5d6..e28e119 100644 --- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c +++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c @@ -17,6 +17,7 @@ * this warranty disclaimer. */ +#include #include "decl.h" #include "ioctl.h" #include "util.h" @@ -183,7 +184,6 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, uint16_t cmd_code; uint16_t cmd_size; unsigned long flags; - __le32 tmp; if (!adapter || !cmd_node) return -1; @@ -249,9 +249,9 @@ static int mwifiex_dnld_cmd_to_fw(struct mwifiex_private *priv, mwifiex_dbg_dump(adapter, CMD_D, "cmd buffer:", host_cmd, cmd_size); if (adapter->iface_type == MWIFIEX_USB) { - tmp = cpu_to_le32(MWIFIEX_USB_TYPE_CMD); skb_push(cmd_node->cmd_skb, MWIFIEX_TYPE_LEN); - memcpy(cmd_node->cmd_skb->data, &tmp, MWIFIEX_TYPE_LEN); + put_unaligned_le32(MWIFIEX_USB_TYPE_CMD, + cmd_node->cmd_skb->data); adapter->cmd_sent = true; ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_USB_EP_CMD_EVENT, @@ -317,7 +317,6 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) (struct mwifiex_opt_sleep_confirm *) adapter->sleep_cfm->data; struct sk_buff *sleep_cfm_tmp; - __le32 tmp; priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); @@ -342,8 +341,7 @@ static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter) + MWIFIEX_TYPE_LEN); skb_put(sleep_cfm_tmp, sizeof(struct mwifiex_opt_sleep_confirm) + MWIFIEX_TYPE_LEN); - tmp = cpu_to_le32(MWIFIEX_USB_TYPE_CMD); - memcpy(sleep_cfm_tmp->data, &tmp, MWIFIEX_TYPE_LEN); + put_unaligned_le32(MWIFIEX_USB_TYPE_CMD, sleep_cfm_tmp->data); memcpy(sleep_cfm_tmp->data + MWIFIEX_TYPE_LEN, adapter->sleep_cfm->data, sizeof(struct mwifiex_opt_sleep_confirm));