From patchwork Wed Dec 24 13:15:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 5539351 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CB9FBBEEA8 for ; Wed, 24 Dec 2014 13:16:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 14484201E4 for ; Wed, 24 Dec 2014 13:16:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EE52201D3 for ; Wed, 24 Dec 2014 13:16:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751990AbaLXNQG (ORCPT ); Wed, 24 Dec 2014 08:16:06 -0500 Received: from mail-pd0-f173.google.com ([209.85.192.173]:64285 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751623AbaLXNQE (ORCPT ); Wed, 24 Dec 2014 08:16:04 -0500 Received: by mail-pd0-f173.google.com with SMTP id ft15so9942361pdb.4; Wed, 24 Dec 2014 05:16:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=19J/IsJ7o/TrbsjY4xMwR70YvtBJVwo7NyxSLUxB54E=; b=iaC8ofrEGqol/X84nsGWvMssHLs7hHedg1rXbADuu5CwKK5GqOCahgx8Abhd+HtRiU KngjZJU6vPErcrMJVrV8flQz1P/R9w2kJhkjSK6+w6hfCDmt0f4ZsuZ0vo40ow/thuLN UibRONteQqyzJPlAwMEFuWI7lGceEENpBQiDAvsopG9y5OVp48mQY1a0lSgz7rj3SZ2a yIisB6XdJ8PBHRD0zvjRxQbp5S9O16D53xpn9qFz9EVhn1Es3lrjbyt1tnOSrdvCw8Hs RKkP5sKzCEqTZrwDVoSGinxI4KHT0/yX/PFgah9laxNfk4zJ5Eiv2kLkKfcMnaaEzNJq tZ2w== X-Received: by 10.70.48.37 with SMTP id i5mr52492900pdn.87.1419426963953; Wed, 24 Dec 2014 05:16:03 -0800 (PST) Received: from vaishali-Ideapad-Z570 ([182.237.15.100]) by mx.google.com with ESMTPSA id t4sm2019473pdh.9.2014.12.24.05.16.01 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 24 Dec 2014 05:16:02 -0800 (PST) Date: Wed, 24 Dec 2014 18:45:57 +0530 From: Vaishali Thakkar To: linux-wireless@vger.kernel.org Cc: lauro.venancio@openbossa.org, aloisio.almeida@openbossa.org, sameo@linux.intel.com, linux-kernel@vger.kernel.org, johannes.berg@intel.com, arend@broadcom.com Subject: [PATCH v3] NFC: port100: Introduce the use of function put_unaligned_le16 Message-ID: <20141224131557.GA2591@vaishali-Ideapad-Z570> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces the use of function put_unaligned_le16. This is done using Coccinelle and semantic patch used is as follows: @a@ typedef u16, __le16; {u16,__le16} e16; identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_le16(y); <+... when != tmp ( - memcpy(ptr, (T)&tmp, \(2\|sizeof(u16)\|sizeof(__le16)\|sizeof(e16)\)); + put_unaligned_le16(y,ptr); | - memcpy(ptr, (T)&tmp, ...); + put_unaligned_le16(y,ptr); ) ...+> ? tmp = e @@ type T; identifier a.tmp; @@ - T tmp; ...when != tmp Signed-off-by: Vaishali Thakkar --- Changes since v1: has arch-specific knowlege of which of the implementations needs to be used. So, include it instaed of . Changes since v2: Fix typing mistake in subject drivers/nfc/port100.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nfc/port100.c b/drivers/nfc/port100.c index 4ac4d31..440f0f3 100644 --- a/drivers/nfc/port100.c +++ b/drivers/nfc/port100.c @@ -18,6 +18,7 @@ #include #include #include +#include #define VERSION "0.1" @@ -1136,7 +1137,6 @@ static int port100_in_send_cmd(struct nfc_digital_dev *ddev, { struct port100 *dev = nfc_digital_get_drvdata(ddev); struct port100_cb_arg *cb_arg; - __le16 timeout; cb_arg = kzalloc(sizeof(struct port100_cb_arg), GFP_KERNEL); if (!cb_arg) @@ -1145,9 +1145,7 @@ static int port100_in_send_cmd(struct nfc_digital_dev *ddev, cb_arg->complete_cb = cb; cb_arg->complete_arg = arg; - timeout = cpu_to_le16(_timeout * 10); - - memcpy(skb_push(skb, sizeof(__le16)), &timeout, sizeof(__le16)); + put_unaligned_le16(_timeout * 10, skb_push(skb, sizeof(__le16))); return port100_send_cmd_async(dev, PORT100_CMD_IN_COMM_RF, skb, port100_in_comm_rf_complete, cb_arg);