Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752334AbbBKJRj (ORCPT ); Wed, 11 Feb 2015 04:17:39 -0500 Received: from mail-pd0-f178.google.com ([209.85.192.178]:44580 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752148AbbBKJRf (ORCPT ); Wed, 11 Feb 2015 04:17:35 -0500 Date: Wed, 11 Feb 2015 14:47:27 +0530 From: Vaishali Thakkar To: Jonathan Cameron Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iio: gp2ap020a00f: Use put_unaligned_le32 Message-ID: <20150211091727.GA17552@vaishali-Ideapad-Z570> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1724 Lines: 55 This patch introduces the use of function put_unaligned_le32. This is done using Coccinelle and semantic patch used is as follows: @@ identifier tmp; expression ptr; expression y,e; type T; @@ - tmp = cpu_to_le32(y); <+... when != tmp - memcpy(ptr, (T)&tmp, ...); + put_unaligned_le32(y,ptr); ...+> ? tmp = e @@ type T; identifier tmp; @@ - T tmp; ...when != tmp Signed-off-by: Vaishali Thakkar --- drivers/iio/light/gp2ap020a00f.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c index 221ed16..650c05f 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c @@ -966,7 +966,6 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data) struct iio_dev *indio_dev = pf->indio_dev; struct gp2ap020a00f_data *priv = iio_priv(indio_dev); size_t d_size = 0; - __le32 light_lux; int i, out_val, ret; for_each_set_bit(i, indio_dev->active_scan_mask, @@ -981,8 +980,8 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data) i == GP2AP020A00F_SCAN_MODE_LIGHT_IR) { out_val = le16_to_cpup((__le16 *)&priv->buffer[d_size]); gp2ap020a00f_output_to_lux(priv, &out_val); - light_lux = cpu_to_le32(out_val); - memcpy(&priv->buffer[d_size], (u8 *)&light_lux, 4); + + put_unaligned_le32(out_val, &priv->buffer[d_size]); d_size += 4; } else { d_size += 2; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/