Skip to contentSkip to conversation

staging: iio: Remove parentheses on the right hand side of assignment

PATCH In review Janani Ravichandran 2 participants 3 messages Feb 11, 2016

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

PATCH 1/1 staging: iio: Remove parentheses on the right hand side of assignment

Remove parentheses on the right hand side of assignment as they are not needed. Semantic patch used:

@@
expression a, b, c, d;
@@

(
a = (c == d)
|
a =
- (
b
- )
)

---
 drivers/staging/iio/accel/lis3l02dq_core.c | 4 ++--
 drivers/staging/iio/cdc/ad7746.c           | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/accel/lis3l02dq_core.c +2 -2
index 7939ae6..7a6fed3 100644
@@ -567,7 +567,7 @@ static int lis3l02dq_read_event_config(struct iio_dev *indio_dev,
 {
 	u8 val;
 	int ret;
-	u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)));
+	u8 mask = 1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING));
 
 	ret = lis3l02dq_spi_read_reg_8(indio_dev,
 				       LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
@@ -622,7 +622,7 @@ static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,
 	u8 val, control;
 	u8 currentlyset;
 	bool changed = false;
-	u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)));
+	u8 mask = 1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING));
 
 	mutex_lock(&indio_dev->mlock);
 	/* read current control */
drivers/staging/iio/cdc/ad7746.c +2 -2
index 2c5d277..5771d4ee 100644
@@ -529,8 +529,8 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
 
 		val /= 338646;
 
-		chip->capdac[chan->channel][chan->differential] = (val > 0 ?
-			AD7746_CAPDAC_DACP(val) | AD7746_CAPDAC_DACEN : 0);
+		chip->capdac[chan->channel][chan->differential] = val > 0 ?
+			AD7746_CAPDAC_DACP(val) | AD7746_CAPDAC_DACEN : 0;
 
 		ret = i2c_smbus_write_byte_data(chip->client,
 			AD7746_REG_CAPDACA,
Signature · 1 line
2.5.0
#1 lore raw
Quoted 7 lines · Janani Ravichandran

Remove parentheses on the right hand side of assignment as they are not needed. Semantic patch used:

@@
expression a, b, c, d;
@@

Quoted 7 lines

(
a = (c == d)
|
a =
- (
b
- )

Just for information, not because you should do anything about it, you could write this semantic patch with three metavariables rather than four. The metavariables in the different branches of a disjunction don't interfere with each other.

julia

Quoted 54 lines

)

---
 drivers/staging/iio/accel/lis3l02dq_core.c | 4 ++--
 drivers/staging/iio/cdc/ad7746.c           | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/accel/lis3l02dq_core.c +2 -2
index 7939ae6..7a6fed3 100644
@@ -567,7 +567,7 @@ static int lis3l02dq_read_event_config(struct iio_dev *indio_dev,
 {
 	u8 val;
 	int ret;
-	u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)));
+	u8 mask = 1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING));
 
 	ret = lis3l02dq_spi_read_reg_8(indio_dev,
 				       LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
@@ -622,7 +622,7 @@ static int lis3l02dq_write_event_config(struct iio_dev *indio_dev,
 	u8 val, control;
 	u8 currentlyset;
 	bool changed = false;
-	u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)));
+	u8 mask = 1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING));
 
 	mutex_lock(&indio_dev->mlock);
 	/* read current control */
drivers/staging/iio/cdc/ad7746.c +2 -3
index 2c5d277..5771d4ee 100644
@@ -529,8 +529,8 @@ static int ad7746_write_raw(struct iio_dev *indio_dev,
 
 		val /= 338646;
 
-		chip->capdac[chan->channel][chan->differential] = (val > 0 ?
-			AD7746_CAPDAC_DACP(val) | AD7746_CAPDAC_DACEN : 0);
+		chip->capdac[chan->channel][chan->differential] = val > 0 ?
+			AD7746_CAPDAC_DACP(val) | AD7746_CAPDAC_DACEN : 0;
 
 		ret = i2c_smbus_write_byte_data(chip->client,
 			AD7746_REG_CAPDACA,
--

2.5.0

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160211204155.GA3822%40janani-Inspiron-3521.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 19 lines · Julia Lawall
Quoted 7 lines · Janani Ravichandran

Remove parentheses on the right hand side of assignment as they are not needed. Semantic patch used:

@@
expression a, b, c, d;
@@

Quoted 7 lines

(
a = (c == d)
|
a =
- (
b
- )

Quoted 5 lines

Just for information, not because you should do anything about it, you could write this semantic patch with three metavariables rather than four. The metavariables in the different branches of a disjunction don't interfere with each other.

Sure, I'll write my next patch with three variables instead of four. Thanks for
telling me this.

Janani.

Quoted 68 lines

julia

Review

Quoted 8 lines

)

---
 drivers/staging/iio/accel/lis3l02dq_core.c | 4 ++--
 drivers/staging/iio/cdc/ad7746.c           | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/iio/accel/lis3l02dq_core.c

drivers/staging/iio/accel/lis3l02dq_core.c static int lis3l02dq_read_event_config(struct

Quoted 4 lines

index 7939ae6..7a6fed3 100644

drivers/staging/iio/accel/lis3l02dq_core.c +0 -0
@@ -567,7 +567,7 @@ static int lis3l02dq_read_event_config(struct

iio_dev *indio_dev,

drivers/staging/iio/accel/lis3l02dq_core.c static int lis3l02dq_write_event_config(struct

Quoted 9 lines
drivers/staging/iio/accel/lis3l02dq_core.c +1 -1
 {
      u8 val;
      int ret;
-     u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)));
+     u8 mask = 1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING));
 
      ret = lis3l02dq_spi_read_reg_8(indio_dev,
                                     LIS3L02DQ_REG_WAKE_UP_CFG_ADDR,
@@ -622,7 +622,7 @@ static int lis3l02dq_write_event_config(struct

iio_dev *indio_dev,

Review

Quoted 9 lines
drivers/staging/iio/accel/lis3l02dq_core.c +1 -1
      u8 val, control;
      u8 currentlyset;
      bool changed = false;
-     u8 mask = (1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING)));
+     u8 mask = 1 << (chan->channel2 * 2 + (dir == IIO_EV_DIR_RISING));
 
      mutex_lock(&indio_dev->mlock);
      /* read current control */
(quoted diff) +0 -0

b/drivers/staging/iio/cdc/ad7746.c

drivers/staging/iio/cdc/ad7746.c static int ad7746_write_raw(struct iio_dev

Quoted 4 lines

index 2c5d277..5771d4ee 100644

drivers/staging/iio/cdc/ad7746.c +0 -0
@@ -529,8 +529,8 @@ static int ad7746_write_raw(struct iio_dev

*indio_dev,

drivers/staging/iio/cdc/ad7746.c static int ad7746_write_raw(struct iio_dev *indio_dev,

Quoted 4 lines
drivers/staging/iio/cdc/ad7746.c +0 -1
              val /= 338646;
 
-             chip->capdac[chan->channel][chan->differential] = (val > 0

?

Quoted 11 lines
drivers/staging/iio/cdc/ad7746.c +2 -2
-                     AD7746_CAPDAC_DACP(val) | AD7746_CAPDAC_DACEN : 0);
+             chip->capdac[chan->channel][chan->differential] = val > 0 ?
+                     AD7746_CAPDAC_DACP(val) | AD7746_CAPDAC_DACEN : 0;
 
              ret = i2c_smbus_write_byte_data(chip->client,
                      AD7746_REG_CAPDACA,
--

2.5.0

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines

To post to this group, send email to [email protected]. To view this discussion on the web visit

https://groups.google.com/d/msgid/outreachy-kernel/20160211204155.GA3822%40janani-Inspiron-3521
.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.