Skip to contentSkip to conversation

staging: iio: adc: Remove else after return in if statements

PATCH In review Janani Ravichandran 2 participants 3 messages Feb 18, 2016 – Feb 21, 2016

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

PATCH 1/1 staging: iio: adc: Remove else after return in if statements

This patch fixes the checkpatch warning that else is not generally useful after a break or return.
Coccinelle patch used:

@rule1@
expression e1;
@@

	if(e1) { ... return ...; }
-	else{
		...

- }

@rule2@
expression e2;
statement S1;
@@

	if(e2) { ... return ...; }
-	else
		S1
---
 drivers/staging/iio/adc/ad7816.c    | 12 ++++++++----
 drivers/staging/iio/adc/spear_adc.c |  5 ++---
 2 files changed, 10 insertions(+), 7 deletions(-)
drivers/staging/iio/adc/ad7816.c +8 -4
index 2226051..5a4fd84 100644
@@ -182,11 +182,13 @@ static ssize_t ad7816_store_channel(struct device *dev,
 		dev_err(&chip->spi_dev->dev, "Invalid channel id %lu for %s.\n",
 			data, indio_dev->name);
 		return -EINVAL;
-	} else if (strcmp(indio_dev->name, "ad7818") == 0 && data > 1) {
+	}
+	if (strcmp(indio_dev->name, "ad7818") == 0 && data > 1) {
 		dev_err(&chip->spi_dev->dev,
 			"Invalid channel id %lu for ad7818.\n", data);
 		return -EINVAL;
-	} else if (strcmp(indio_dev->name, "ad7816") == 0 && data > 0) {
+	}
+	if (strcmp(indio_dev->name, "ad7816") == 0 && data > 0) {
 		dev_err(&chip->spi_dev->dev,
 			"Invalid channel id %lu for ad7816.\n", data);
 		return -EINVAL;
@@ -268,7 +270,8 @@ static ssize_t ad7816_show_oti(struct device *dev,
 	if (chip->channel_id > AD7816_CS_MAX) {
 		dev_err(dev, "Invalid oti channel id %d.\n", chip->channel_id);
 		return -EINVAL;
-	} else if (chip->channel_id == 0) {
+	}
+	if (chip->channel_id == 0) {
 		value = AD7816_BOUND_VALUE_MIN +
 			(chip->oti_data[chip->channel_id] -
 			AD7816_BOUND_VALUE_BASE);
@@ -295,7 +298,8 @@ static inline ssize_t ad7816_set_oti(struct device *dev,
 	if (chip->channel_id > AD7816_CS_MAX) {
 		dev_err(dev, "Invalid oti channel id %d.\n", chip->channel_id);
 		return -EINVAL;
-	} else if (chip->channel_id == 0) {
+	}
+	if (chip->channel_id == 0) {
 		if (ret || value < AD7816_BOUND_VALUE_MIN ||
 		    value > AD7816_BOUND_VALUE_MAX)
 			return -EINVAL;
drivers/staging/iio/adc/spear_adc.c +2 -3
index f2c0065..b60e572 100644
@@ -118,10 +118,9 @@ static u32 spear_adc_get_average(struct spear_adc_state *st)
 	if (of_device_is_compatible(st->np, "st,spear600-adc")) {
 		return __raw_readl(&st->adc_base_spear6xx->average.msb) &
 			SPEAR_ADC_DATA_MASK;
-	} else {
-		return __raw_readl(&st->adc_base_spear3xx->average) &
-			SPEAR_ADC_DATA_MASK;
 	}
+	return __raw_readl(&st->adc_base_spear3xx->average) &
+			SPEAR_ADC_DATA_MASK;
 }
 
 static void spear_adc_set_scanrate(struct spear_adc_state *st, u32 rate)
Signature · 1 line
2.5.0
maintainer
#1 lore raw
Quoted 21 lines · Janani Ravichandran

This patch fixes the checkpatch warning that else is not generally useful after a break or return.
Coccinelle patch used:

@rule1@
expression e1;
@@

	if(e1) { ... return ...; }
(quoted diff) +0 -2
-	else{
...
-	}

@rule2@
expression e2;
statement S1;
@@

	if(e2) { ... return ...; }
(quoted diff) +0 -1
-	else
		S1
Quoted 5 lines
---
 drivers/staging/iio/adc/ad7816.c    | 12 ++++++++----
 drivers/staging/iio/adc/spear_adc.c |  5 ++---
 2 files changed, 10 insertions(+), 7 deletions(-)

This patch conflicts with a patch someone else sent in 2 days prior for one of these files. Can you please refresh your tree and rebase it and resend?

thanks,

greg k-h

#2 lore raw
Quoted 29 lines · gregkh
Quoted 21 lines · Janani Ravichandran

This patch fixes the checkpatch warning that else is not generally useful after a break or return.
Coccinelle patch used:

@rule1@
expression e1;
@@

        if(e1) { ... return ...; } 
(quoted diff) +0 -2
-        else{ 
...
-        } 

@rule2@
expression e2;
statement S1;
@@

        if(e2) { ... return ...; } 
-        else 
                S1 
Quoted 5 lines
Signed-off-by Janani Ravichandran <[email protected] <javascript:>>

---

 drivers/staging/iio/adc/ad7816.c    | 12 ++++++++---- 
 drivers/staging/iio/adc/spear_adc.c |  5 ++--- 
 2 files changed, 10 insertions(+), 7 deletions(-) 
Quoted 4 lines

This patch conflicts with a patch someone else sent in 2 days prior for one of these files. Can you please refresh your tree and rebase it and resend?

Sure, will send a v2.

Thanks!
Janani.

Quoted 5 lines

thanks,

greg k-h