diff options
author | Vaishali Thakkar <vthakkar1994@gmail.com> | 2015-02-11 04:17:27 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-02-14 12:28:41 -0500 |
commit | 9f59f970ec2128522a98f6826350a3bfbaf70163 (patch) | |
tree | 83251fefcba522333782377b7856269b3ea11f02 /drivers/iio/light | |
parent | 293487c8ecc1103f4625cea5e90e1ba0cc89660f (diff) |
iio: gp2ap020a00f: Use put_unaligned_le32
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 <vthakkar1994@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio/light')
-rw-r--r-- | drivers/iio/light/gp2ap020a00f.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/iio/light/gp2ap020a00f.c b/drivers/iio/light/gp2ap020a00f.c index 221ed16de1f7..32b6449833fa 100644 --- a/drivers/iio/light/gp2ap020a00f.c +++ b/drivers/iio/light/gp2ap020a00f.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/regmap.h> | 46 | #include <linux/regmap.h> |
47 | #include <linux/regulator/consumer.h> | 47 | #include <linux/regulator/consumer.h> |
48 | #include <linux/slab.h> | 48 | #include <linux/slab.h> |
49 | #include <asm/unaligned.h> | ||
49 | #include <linux/iio/buffer.h> | 50 | #include <linux/iio/buffer.h> |
50 | #include <linux/iio/events.h> | 51 | #include <linux/iio/events.h> |
51 | #include <linux/iio/iio.h> | 52 | #include <linux/iio/iio.h> |
@@ -966,7 +967,6 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data) | |||
966 | struct iio_dev *indio_dev = pf->indio_dev; | 967 | struct iio_dev *indio_dev = pf->indio_dev; |
967 | struct gp2ap020a00f_data *priv = iio_priv(indio_dev); | 968 | struct gp2ap020a00f_data *priv = iio_priv(indio_dev); |
968 | size_t d_size = 0; | 969 | size_t d_size = 0; |
969 | __le32 light_lux; | ||
970 | int i, out_val, ret; | 970 | int i, out_val, ret; |
971 | 971 | ||
972 | for_each_set_bit(i, indio_dev->active_scan_mask, | 972 | for_each_set_bit(i, indio_dev->active_scan_mask, |
@@ -981,8 +981,8 @@ static irqreturn_t gp2ap020a00f_trigger_handler(int irq, void *data) | |||
981 | i == GP2AP020A00F_SCAN_MODE_LIGHT_IR) { | 981 | i == GP2AP020A00F_SCAN_MODE_LIGHT_IR) { |
982 | out_val = le16_to_cpup((__le16 *)&priv->buffer[d_size]); | 982 | out_val = le16_to_cpup((__le16 *)&priv->buffer[d_size]); |
983 | gp2ap020a00f_output_to_lux(priv, &out_val); | 983 | gp2ap020a00f_output_to_lux(priv, &out_val); |
984 | light_lux = cpu_to_le32(out_val); | 984 | |
985 | memcpy(&priv->buffer[d_size], (u8 *)&light_lux, 4); | 985 | put_unaligned_le32(out_val, &priv->buffer[d_size]); |
986 | d_size += 4; | 986 | d_size += 4; |
987 | } else { | 987 | } else { |
988 | d_size += 2; | 988 | d_size += 2; |