Skip to contentSkip to conversation

staging: iio: Remove unneeded pointer casts in function arguments

PATCH In review Janani Ravichandran 2 participants 3 messages Feb 9, 2016 – Feb 10, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: iio: Remove unneeded pointer casts in function arguments

Remove pointer casts in function arguments as they are not required. This patch removes all such casts found in the driver iio by the following coccinelle patch.
@@
type t;
expression e;
identifier f;
@@

f(...,
- (t *)
e,
...)

---
 drivers/staging/iio/accel/adis16240_core.c      |  2 +-
 drivers/staging/iio/accel/lis3l02dq_core.c      |  4 ++--
 drivers/staging/iio/accel/sca3000_core.c        |  2 +-
 drivers/staging/iio/impedance-analyzer/ad5933.c | 12 ++++++------
 drivers/staging/iio/light/tsl2583.c             |  4 ++--
 drivers/staging/iio/light/tsl2x7x_core.c        |  8 ++++----
 drivers/staging/iio/meter/ade7854-spi.c         |  4 ++--
 drivers/staging/iio/resolver/ad2s1210.c         |  4 ++--
 8 files changed, 20 insertions(+), 20 deletions(-)
drivers/staging/iio/accel/adis16240_core.c +1 -1
index 1b5b685..5864bff 100644
@@ -39,7 +39,7 @@ static ssize_t adis16240_spi_read_signed(struct device *dev,
 	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
 
 	ret = adis_read_reg_16(st,
-			       this_attr->address, (u16 *)&val);
+			       this_attr->address, &val);
 	if (ret)
 		return ret;
 
drivers/staging/iio/accel/lis3l02dq_core.c +2 -2
index 7939ae6..8d75f1f 100644
@@ -288,7 +288,7 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
 
 	case IIO_CHAN_INFO_CALIBBIAS:
 		reg = lis3l02dq_axis_map[LIS3L02DQ_BIAS][chan->address];
-		ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, (u8 *)&stemp);
+		ret = lis3l02dq_spi_read_reg_8(indio_dev, reg, &stemp);
 		/* to match with what previous code does */
 		*val = stemp;
 		return IIO_VAL_INT;
@@ -307,7 +307,7 @@ static ssize_t lis3l02dq_read_frequency(struct device *dev,
 
 	ret = lis3l02dq_spi_read_reg_8(indio_dev,
 				       LIS3L02DQ_REG_CTRL_1_ADDR,
-				       (u8 *)&t);
+				       &t);
 	if (ret)
 		return ret;
 	t &= LIS3L02DQ_DEC_MASK;
drivers/staging/iio/accel/sca3000_core.c +1 -1
index 02e930c..a28c82a 100644
@@ -468,7 +468,7 @@ static int sca3000_read_raw(struct iio_dev *indio_dev,
 				mutex_unlock(&st->lock);
 				return ret;
 			}
-			*val = (be16_to_cpup((__be16 *)st->rx) >> 3) & 0x1FFF;
+			*val = (be16_to_cpup(st->rx) >> 3) & 0x1FFF;
 			*val = ((*val) << (sizeof(*val) * 8 - 13)) >>
 				(sizeof(*val) * 8 - 13);
 		} else {
drivers/staging/iio/impedance-analyzer/ad5933.c +6 -6
index 10c43dda..c888919 100644
@@ -261,14 +261,14 @@ static int ad5933_setup(struct ad5933_state *st)
 	dat = cpu_to_be16(st->settling_cycles);
 
 	ret = ad5933_i2c_write(st->client,
-			AD5933_REG_SETTLING_CYCLES, 2, (u8 *)&dat);
+			AD5933_REG_SETTLING_CYCLES, 2, &dat);
 	if (ret < 0)
 		return ret;
 
 	st->freq_points = 100;
 	dat = cpu_to_be16(st->freq_points);
 
-	return ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2, (u8 *)&dat);
+	return ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2, &dat);
 }
 
 static void ad5933_calc_out_ranges(struct ad5933_state *st)
@@ -443,7 +443,7 @@ static ssize_t ad5933_store(struct device *dev,
 
 		dat = cpu_to_be16(val);
 		ret = ad5933_i2c_write(st->client,
-				AD5933_REG_SETTLING_CYCLES, 2, (u8 *)&dat);
+				AD5933_REG_SETTLING_CYCLES, 2, &dat);
 		break;
 	case AD5933_FREQ_POINTS:
 		val = clamp(val, (u16)0, (u16)511);
@@ -451,7 +451,7 @@ static ssize_t ad5933_store(struct device *dev,
 
 		dat = cpu_to_be16(val);
 		ret = ad5933_i2c_write(st->client, AD5933_REG_INC_NUM, 2,
-				       (u8 *)&dat);
+				       &dat);
 		break;
 	default:
 		ret = -EINVAL;
@@ -538,7 +538,7 @@ static int ad5933_read_raw(struct iio_dev *indio_dev,
 
 		ret = ad5933_i2c_read(st->client,
 				AD5933_REG_TEMP_DATA, 2,
-				(u8 *)&dat);
+				&dat);
 		if (ret < 0)
 			goto out;
 		mutex_unlock(&indio_dev->mlock);
@@ -666,7 +666,7 @@ static void ad5933_work(struct work_struct *work)
 		ad5933_i2c_read(st->client,
 				test_bit(1, indio_dev->active_scan_mask) ?
 				AD5933_REG_REAL_DATA : AD5933_REG_IMAG_DATA,
-				scan_count * 2, (u8 *)buf);
+				scan_count * 2, buf);
 
 		if (scan_count == 2) {
 			val[0] = be16_to_cpu(buf[0]);
drivers/staging/iio/light/tsl2583.c +2 -2
index 3100d96..4f10e57 100644
@@ -254,8 +254,8 @@ static int taos_get_lux(struct iio_dev *indio_dev)
 	}
 
 	/* extract ALS/lux data */
-	ch0 = le16_to_cpup((const __le16 *)&buf[0]);
-	ch1 = le16_to_cpup((const __le16 *)&buf[2]);
+	ch0 = le16_to_cpup(&buf[0]);
+	ch1 = le16_to_cpup(&buf[2]);
 
 	chip->als_cur_info.als_ch0 = ch0;
 	chip->als_cur_info.als_ch1 = ch1;
drivers/staging/iio/light/tsl2x7x_core.c +4 -4
index 2a62718..2838c47 100644
@@ -392,8 +392,8 @@ static int tsl2x7x_get_lux(struct iio_dev *indio_dev)
 	}
 
 	/* extract ALS/lux data */
-	ch0 = le16_to_cpup((const __le16 *)&buf[0]);
-	ch1 = le16_to_cpup((const __le16 *)&buf[2]);
+	ch0 = le16_to_cpup(&buf[0]);
+	ch1 = le16_to_cpup(&buf[2]);
 
 	chip->als_cur_info.als_ch0 = ch0;
 	chip->als_cur_info.als_ch1 = ch1;
@@ -522,7 +522,7 @@ static int tsl2x7x_get_prox(struct iio_dev *indio_dev)
 	}
 
 	chip->prox_data =
-			le16_to_cpup((const __le16 *)&chdata[0]);
+			le16_to_cpup(&chdata[0]);
 
 prox_poll_err:
 
@@ -557,7 +557,7 @@ static void tsl2x7x_defaults(struct tsl2X7X_chip *chip)
 			sizeof(chip->pdata->platform_lux_table));
 	else
 		memcpy(chip->tsl2x7x_device_lux,
-		(struct tsl2x7x_lux *)tsl2x7x_default_lux_table_group[chip->id],
+		tsl2x7x_default_lux_table_group[chip->id],
 				MAX_DEFAULT_TABLE_BYTES);
 }
 
drivers/staging/iio/meter/ade7854-spi.c +2 -2
index 2413052..67cf18d 100644
@@ -189,7 +189,7 @@ static int ade7854_spi_read_reg_16(struct device *dev,
 				reg_address);
 		goto error_ret;
 	}
-	*val = be16_to_cpup((const __be16 *)st->rx);
+	*val = be16_to_cpup(st->rx);
 
 error_ret:
 	mutex_unlock(&st->buf_lock);
@@ -265,7 +265,7 @@ static int ade7854_spi_read_reg_32(struct device *dev,
 				reg_address);
 		goto error_ret;
 	}
-	*val = be32_to_cpup((const __be32 *)st->rx);
+	*val = be32_to_cpup(st->rx);
 
 error_ret:
 	mutex_unlock(&st->buf_lock);
drivers/staging/iio/resolver/ad2s1210.c +2 -2
index d97aa28..1e1f50d 100644
@@ -497,7 +497,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev,
 
 	switch (chan->type) {
 	case IIO_ANGL:
-		pos = be16_to_cpup((__be16 *) st->rx);
+		pos = be16_to_cpup(st->rx);
 		if (st->hysteresis)
 			pos >>= 16 - st->resolution;
 		*val = pos;
@@ -505,7 +505,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev,
 		break;
 	case IIO_ANGL_VEL:
 		negative = st->rx[0] & 0x80;
-		vel = be16_to_cpup((__be16 *) st->rx);
+		vel = be16_to_cpup(st->rx);
 		vel >>= 16 - st->resolution;
 		if (vel & 0x8000) {
 			negative = (0xffff >> st->resolution) << st->resolution;
Signature · 1 line
2.5.0
maintainer
#1 lore raw
Quoted 15 lines · Janani Ravichandran

Remove pointer casts in function arguments as they are not required. This patch removes all such casts found in the driver iio by the following coccinelle patch.
@@
type t;
expression e;
identifier f;
@@

f(...,
- (t *)
e,
...)

Quoted 10 lines
---
 drivers/staging/iio/accel/adis16240_core.c      |  2 +-
 drivers/staging/iio/accel/lis3l02dq_core.c      |  4 ++--
 drivers/staging/iio/accel/sca3000_core.c        |  2 +-
 drivers/staging/iio/impedance-analyzer/ad5933.c | 12 ++++++------
 drivers/staging/iio/light/tsl2583.c             |  4 ++--
 drivers/staging/iio/light/tsl2x7x_core.c        |  8 ++++----
 drivers/staging/iio/meter/ade7854-spi.c         |  4 ++--
 drivers/staging/iio/resolver/ad2s1210.c         |  4 ++--
 8 files changed, 20 insertions(+), 20 deletions(-)

Please always test-build your patches, this one blows up the build by adding a ton of warnings :(

#2 lore raw
Quoted 27 lines · Greg KH
Quoted 15 lines · Janani Ravichandran

Remove pointer casts in function arguments as they are not required. This patch removes all such casts found in the driver iio by the following coccinelle patch.
@@
type t;
expression e;
identifier f;
@@

f(...,
- (t *)
e,
...)

Quoted 10 lines
---
 drivers/staging/iio/accel/adis16240_core.c      |  2 +-
 drivers/staging/iio/accel/lis3l02dq_core.c      |  4 ++--
 drivers/staging/iio/accel/sca3000_core.c        |  2 +-
 drivers/staging/iio/impedance-analyzer/ad5933.c | 12 ++++++------
 drivers/staging/iio/light/tsl2583.c             |  4 ++--
 drivers/staging/iio/light/tsl2x7x_core.c        |  8 ++++----
 drivers/staging/iio/meter/ade7854-spi.c         |  4 ++--
 drivers/staging/iio/resolver/ad2s1210.c         |  4 ++--
 8 files changed, 20 insertions(+), 20 deletions(-)
Quoted 3 lines

Please always test-build your patches, this one blows up the build by adding a ton of warnings :(

I'm really sorry, I must have missed it. Will take care from next time.

Thanks.
Janani.