Skip to contentSkip to conversation

Code formatting clean up

PATCH In review Vladimir Petrigo 3 participants 10 messages Mar 17, 2019 – Mar 21, 2019

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

cover Code formatting clean up

Introduce small code formatting cleaning up in the staging AD drivers

Vladimir Petrigo (3):
staging: iio: ad7192: Fix style issue
staging: iio: ad7280a: Add parentheses to macros
staging: iio: ad7780: Add parentheses to macros

 drivers/staging/iio/adc/ad7192.c  | 2 +-
 drivers/staging/iio/adc/ad7280a.c | 6 +++---
 drivers/staging/iio/adc/ad7780.c  | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/3 staging: iio: ad7192: Fix style issue

---
 drivers/staging/iio/adc/ad7192.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7192.c +1 -1
index acdbc07..7c632cf 100644
@@ -355,7 +355,7 @@ ad7192_show_scale_available(struct device *dev,
 }
 
 static IIO_DEVICE_ATTR_NAMED(in_v_m_v_scale_available,
-			     in_voltage-voltage_scale_available,
+			     in_voltage - voltage_scale_available,
 			     0444, ad7192_show_scale_available, NULL, 0);
 
 static IIO_DEVICE_ATTR(in_voltage_scale_available, 0444,
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 1/3] staging: iio: ad7192: Fix style issue

Quoted 11 lines · Vladimir Petrigo
---
  drivers/staging/iio/adc/ad7192.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7192.c +0 -0
index acdbc07..7c632cf 100644

drivers/staging/iio/adc/ad7192.c ad7192_show_scale_available(struct device *dev, · line 361

Quoted 8 lines
drivers/staging/iio/adc/ad7192.c +1 -1
@@ -355,7 +355,7 @@ ad7192_show_scale_available(struct device *dev,
  }
 
  static IIO_DEVICE_ATTR_NAMED(in_v_m_v_scale_available,
-			     in_voltage-voltage_scale_available,
+			     in_voltage - voltage_scale_available,
  			     0444, ad7192_show_scale_available, NULL, 0);
 
  static IIO_DEVICE_ATTR(in_voltage_scale_available, 0444,

G'day Vladimir ,

This is not a mathematical op.
It gets passed to __ATTR() macro and converted to a string.

Signature · 2 lines
Regards
Phil
#3 lore raw

Re: [PATCH 1/3] staging: iio: ad7192: Fix style issue

Quoted 20 lines · Phil Reid
Quoted 10 lines · Vladimir Petrigo
---
 drivers/staging/iio/adc/ad7192.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7192.c +0 -0
index acdbc07..7c632cf 100644

drivers/staging/iio/adc/ad7192.c ad7192_show_scale_available(struct device *dev, · line 360

Quoted 7 lines
drivers/staging/iio/adc/ad7192.c +1 -1
@@ -355,7 +355,7 @@ ad7192_show_scale_available(struct device *dev,
 }
 static IIO_DEVICE_ATTR_NAMED(in_v_m_v_scale_available,
-			     in_voltage-voltage_scale_available,
+			     in_voltage - voltage_scale_available,
 			     0444, ad7192_show_scale_available, NULL, 0);
 static IIO_DEVICE_ATTR(in_voltage_scale_available, 0444,
 

G'day Vladimir ,

Quoted 7 lines

This is not a mathematical op.
It gets passed to __ATTR() macro and converted to a string.

Signature · 2 lines
Regards
Phil

Hello Phil,

Thank you for the prompt reply.
Should I remove that changes from the patchset v2 then?

--
Best regards,
Vladimir

#4 lore raw

PATCH 2/3 staging: iio: ad7280a: Add parentheses to macros

In reply to Vladimir Petrigo

Fix CHECK Macro argument 'c' may be better as '(c)' to avoid precedence issues

(quoted diff) +0 -0

b/drivers/staging/iio/adc/ad7280a.c index d9df126..98cf876 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -97,9 +97,9 @@
#define AD7280A_NUM_CH (AD7280A_AUX_ADC_6 - \
AD7280A_CELL_VOLTAGE_1
+ 1)

-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c) -#define AD7280A_CALC_TEMP_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + \ - c - AD7280A_CELLS_PER_DEV) +#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + (c)) +#define AD7280A_CALC_TEMP_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \ + (c) - AD7280A_CELLS_PER_DEV)

#define AD7280A_DEVADDR_MASTER 0 define #AD7280A_DEVADDR_ALL 0x1F

---
 drivers/staging/iio/adc/ad7280a.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7280a.c +3 -3
index d9df126..98cf876 100644
@@ -97,9 +97,9 @@
 #define AD7280A_NUM_CH			(AD7280A_AUX_ADC_6 - \
 					AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    ((d * AD7280A_CELLS_PER_DEV) + \
-					     c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + (c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER		0
 #define AD7280A_DEVADDR_ALL		0x1F
Signature · 1 line
2.7.4
#5 lore raw

Re: [PATCH 2/3] staging: iio: ad7280a: Add parentheses to macros

Quoted 22 lines · Vladimir Petrigo

Fix CHECK Macro argument 'c' may be better as '(c)' to avoid precedence issues

(quoted diff) +0 -0

b/drivers/staging/iio/adc/ad7280a.c index d9df126..98cf876 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -97,9 +97,9 @@
#define AD7280A_NUM_CH (AD7280A_AUX_ADC_6 - \

(quoted diff) +1 -1
 					AD7280A_CELL_VOLTAGE_1
+ 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d *

AD7280A_CELLS_PER_DEV) + c) -#define AD7280A_CALC_TEMP_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + \ - c - AD7280A_CELLS_PER_DEV) +#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + (c)) +#define AD7280A_CALC_TEMP_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \ + (c) - AD7280A_CELLS_PER_DEV)

Quoted 2 lines

#define AD7280A_DEVADDR_MASTER 0 define #AD7280A_DEVADDR_ALL 0x1F

I don't know how this diff got added to the commit message, but obviously we don't want that.

regards,
dan carpenter

Quoted 28 lines
---
 drivers/staging/iio/adc/ad7280a.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7280a.c +3 -3
index d9df126..98cf876 100644
@@ -97,9 +97,9 @@
 #define AD7280A_NUM_CH			(AD7280A_AUX_ADC_6 - \
 					AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    ((d * AD7280A_CELLS_PER_DEV) + \
-					     c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + (c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER		0
 #define AD7280A_DEVADDR_ALL		0x1F
Signature · 6 lines
2.7.4

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
#6 lore raw

Re: [PATCH 2/3] staging: iio: ad7280a: Add parentheses to macros

Quoted 56 lines · Dan Carpenter
Quoted 22 lines · Vladimir Petrigo

Fix CHECK Macro argument 'c' may be better as '(c)' to avoid precedence issues

(quoted diff) +0 -0

b/drivers/staging/iio/adc/ad7280a.c index d9df126..98cf876 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -97,9 +97,9 @@
#define AD7280A_NUM_CH (AD7280A_AUX_ADC_6 - \

(quoted diff) +1 -1
 					AD7280A_CELL_VOLTAGE_1
+ 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d *

AD7280A_CELLS_PER_DEV) + c) -#define AD7280A_CALC_TEMP_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + \ - c - AD7280A_CELLS_PER_DEV) +#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + (c)) +#define AD7280A_CALC_TEMP_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + \ + (c) - AD7280A_CELLS_PER_DEV)

Quoted 2 lines

#define AD7280A_DEVADDR_MASTER 0 define #AD7280A_DEVADDR_ALL 0x1F

I don't know how this diff got added to the commit message, but obviously we don't want that.

regards,
dan carpenter

Quoted 24 lines
---
 drivers/staging/iio/adc/ad7280a.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/adc/ad7280a.c +3 -3
index d9df126..98cf876 100644
@@ -97,9 +97,9 @@
 #define AD7280A_NUM_CH			(AD7280A_AUX_ADC_6 - \
 					AD7280A_CELL_VOLTAGE_1 + 1)
 
-#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) ((d * AD7280A_CELLS_PER_DEV) + c)
-#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    ((d * AD7280A_CELLS_PER_DEV) + \
-					     c - AD7280A_CELLS_PER_DEV)
+#define AD7280A_CALC_VOLTAGE_CHAN_NUM(d, c) (((d) * AD7280A_CELLS_PER_DEV) + (c))
+#define AD7280A_CALC_TEMP_CHAN_NUM(d, c)    (((d) * AD7280A_CELLS_PER_DEV) + \
+					     (c) - AD7280A_CELLS_PER_DEV)
 
 #define AD7280A_DEVADDR_MASTER		0
 #define AD7280A_DEVADDR_ALL		0x1F
Signature · 1 line
2.7.4
Quoted 4 lines
Quoted 4 lines

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Yes, something went wrong, will fix that in the v2.

Best regards,
Vladimir Petrigo

#7 lore raw

PATCH 3/3 staging: iio: ad7780: Add parentheses to macros

In reply to Vladimir Petrigo

- Fix CHECK Macro argument 'wordsize' may be better as '(wordsize)' to avoid precedence issues
- Fix CHECK Macro argument reuse 'bits' - possible side-effects?

---
 drivers/staging/iio/adc/ad7780.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7780.c +1 -1
index c4a8578..2dfd6f8 100644
@@ -142,7 +142,7 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = {
 };
 
 #define AD7780_CHANNEL(bits, wordsize) \
-	AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits)
+	AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, (bits), 32, ((wordsize) - (bits)))
 
 static const struct ad7780_chip_info ad7780_chip_info_tbl[] = {
 	[ID_AD7170] = {
Signature · 1 line
2.7.4
#8 lore raw

Re: [PATCH 3/3] staging: iio: ad7780: Add parentheses to macros

Quoted 13 lines · Vladimir Petrigo

- Fix CHECK Macro argument 'wordsize' may be better as '(wordsize)' to avoid precedence issues
- Fix CHECK Macro argument reuse 'bits' - possible side-effects?

---
 drivers/staging/iio/adc/ad7780.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7780.c +0 -0
index c4a8578..2dfd6f8 100644

drivers/staging/iio/adc/ad7780.c static const struct ad_sigma_delta_info ad7780_sigma_delta_info = { · line 145

Quoted 5 lines
drivers/staging/iio/adc/ad7780.c +1 -1
@@ -142,7 +142,7 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = {
 };
 
 #define AD7780_CHANNEL(bits, wordsize) \
-	AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits)
+	AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, (bits), 32, ((wordsize) - (bits)))
                                            ^^^^^^

These parentheses are not required.

This doesn't fix the "argument reuse" issue... It's not a reall issue though, and it isn't like this a core macro so it doesn't really matter too much.

regards,
dan carpenter

#9 lore raw

Re: [PATCH 3/3] staging: iio: ad7780: Add parentheses to macros

Quoted 20 lines · Dan Carpenter
Quoted 13 lines · Vladimir Petrigo

- Fix CHECK Macro argument 'wordsize' may be better as '(wordsize)' to avoid precedence issues
- Fix CHECK Macro argument reuse 'bits' - possible side-effects?

---
 drivers/staging/iio/adc/ad7780.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/adc/ad7780.c +0 -0
index c4a8578..2dfd6f8 100644

drivers/staging/iio/adc/ad7780.c static const struct ad_sigma_delta_info ad7780_sigma_delta_info = { · line 145

Quoted 5 lines
drivers/staging/iio/adc/ad7780.c +1 -1
@@ -142,7 +142,7 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = {
 };
 
 #define AD7780_CHANNEL(bits, wordsize) \
-	AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, bits, 32, wordsize - bits)
+	AD_SD_CHANNEL_NO_SAMP_FREQ(1, 0, 0, (bits), 32, ((wordsize) - (bits)))
                                            ^^^^^^
Quoted 9 lines

These parentheses are not required.

This doesn't fix the "argument reuse" issue... It's not a reall issue though, and it isn't like this a core macro so it doesn't really matter too much.

regards,
dan carpenter

Thank you for the reply. I'll get rid of that parentheses in the v2

Best regards,
Vladimir Petrigo