From patchwork Wed Oct 4 18:28:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himanshu Jha X-Patchwork-Id: 9985291 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 24DDC6028E for ; Wed, 4 Oct 2017 18:28:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1969228BDA for ; Wed, 4 Oct 2017 18:28:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E13928BDE; Wed, 4 Oct 2017 18:28:45 +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 B88AF28BDA for ; Wed, 4 Oct 2017 18:28:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751182AbdJDS2g (ORCPT ); Wed, 4 Oct 2017 14:28:36 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37771 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750797AbdJDS2e (ORCPT ); Wed, 4 Oct 2017 14:28:34 -0400 Received: by mail-pf0-f195.google.com with SMTP id e69so12926669pfg.4; Wed, 04 Oct 2017 11:28:34 -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=UXJl4jDQnLwIkKsEbdblROI9xnIUMJhALCXaAilRlgc=; b=jGpGH1lr4ytZFGlcF9prIPyohaMWMfpSZSrIL9iZbuTnSwwKBz4rE1zOiV5Dx2U8JE HHxNHbTpsBhDqkVevRHVDfz3IX/pAg1c4AaSHR3a9Kb/Y1YWbjiegWdd81wcg/8iDusJ koQlhKy1LBx6wtUCkmAUJd8imIeYnHCCXNOoSeEzamkI50RjTCAPZSyR316jWuTIqJ4H +L0tqcGedRVn/iEr/v1HG8Xbb4mXqvOAOKsI76bBxFRGEFtRMqMcPLgkKTqo5NNLDmkE QqzkZNtHKs03wdRuJRvTd8u9Su/Ghm/SbCwTBkrhE/z9SEIQcQY+CaNRTzmy0UkMGl/Y DREg== 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=UXJl4jDQnLwIkKsEbdblROI9xnIUMJhALCXaAilRlgc=; b=Dfz2rDP+ut4r0Hgd90gaLUh2x0sK9BZJ1ZBDT+YfECD3Jo+6JrOsj/A2G+0eh5sbr2 OqemUF2F7F1SPlOwRmqMbMtgTZJYZHWWbnwvYh4egpu059hXDn+l7T45QcYEpwxGw+6r 6L6dHU9eoCxVpTu45sHBbICZQnzn5QWEI2iTiR/tZRIB/StbsifVaTW97NBsEti/GZ5S taHLMh0Wh1p41rtP3NCensaCoXuEyWDQa4JivRVV0ffj891jOFh8GFVi257ja2bi4Jiy 1jgAnv/5i6wpyRINGaThlvE8jzgKnFo+X3YyToGe6SyCjFg85VAr3ktUQ0yGCgGYtiCJ o7GA== X-Gm-Message-State: AHPjjUgCQR0dxaHkRUnL9uyn0KgbFtYcy/eY4v3cabkYbDK1BoUtvUI9 dzSGZZDkpfX6krPsbs0tiNQ= X-Google-Smtp-Source: AOwi7QDWNqkfYnB/39aW343gOCGCXn3puTAGG55k+SSMD3F2euPPX7X3idI7+bPA4vuC5rifkQ0O0w== X-Received: by 10.84.235.76 with SMTP id g12mr20855362plt.338.1507141713708; Wed, 04 Oct 2017 11:28:33 -0700 (PDT) Received: from localhost.localdomain ([103.254.204.108]) by smtp.gmail.com with ESMTPSA id m25sm209827pfi.113.2017.10.04.11.28.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Oct 2017 11:28:32 -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] mwifiex: Use put_unaligned_le32 Date: Wed, 4 Oct 2017 23:58:06 +0530 Message-Id: <1507141686-5178-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 --- 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));