Staging: iio/frequency: Fix style issues
Subsystems (4)
v2 cover Staging: iio/frequency: Fix style issues
This patchset involves removing style issues in iio/frequency and cleaning up as suggested by checkpatch.pl.
Changes in v2:
[PATCH v2 3/6]
- add BIT() macro implementation in ad9834.h for macros AD9834_REG_FREQ and AD9834_REG_PHASE involving phase and frequency registers. Checked against the datasheet.
[PATCH v2 5/6]
- make the commit message more clear
- align parameters in ad9834_show_out[0|1]_wavetype_available() functions, also.
Mention: Regarding the indentation, I applied the patches on a separate test branch and they aligned well. It shows up twisted only in the patch format for an unknown reason.
Cristina Opriceana (6):
Staging: iio: Remove space after type cast
Staging: iio: Remove explicit comparison to NULL
Staging: iio: Prefer using the BIT macro
Staging: iio: Do not use multiple blank lines
Staging: iio: Alignment should match open parenthesis
Staging: iio: Use braces on all arms of if statement
drivers/staging/iio/frequency/ad9832.c | 10 ++++---- drivers/staging/iio/frequency/ad9832.h | 12 ++++----- drivers/staging/iio/frequency/ad9834.c | 45 +++++++++++++++++----------------- drivers/staging/iio/frequency/ad9834.h | 37 ++++++++++++++-------------- 4 files changed, 52 insertions(+), 52 deletions(-)
Signature · 1 line
1.9.1
PATCH v2 1/6 Staging: iio: Remove space after type cast
This patch removes unnecessary space after type casts. Warning found by checkpatch.pl.
--- drivers/staging/iio/frequency/ad9832.c | 6 +++--- drivers/staging/iio/frequency/ad9834.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/staging/iio/frequency/ad9832.c +3 -3
@@ -24,8 +24,8 @@static unsigned long ad9832_calc_freqreg (unsigned long mclk,unsigned long fout) { -unsigned long long freqreg = (u64 ) fout * - (u64) ((u64 )1L <<AD9832_FREQ_BITS ); +unsigned long long freqreg = (u64 )fout * + (u64)((u64 )1L <<AD9832_FREQ_BITS );do_div (freqreg, mclk);return freqreg; }
@@ -86,7 +86,7 @@ static ssize_t ad9832_write(struct device *dev, struct device_attribute *attr, goto error_ret;mutex_lock (&indio_dev->mlock); -switch ((u32 ) this_attr->address) { +switch ((u32 )this_attr->address) {case AD9832_FREQ0HM :case AD9832_FREQ1HM : ret =ad9832_write_frequency (st, this_attr->address, val);
drivers/staging/iio/frequency/ad9834.c +3 -3
@@ -27,7 +27,7 @@static unsigned int ad9834_calc_freqreg (unsigned long mclk,unsigned long fout) { -unsigned long long freqreg = (u64 ) fout * (u64) (1 <<AD9834_FREQ_BITS ); +unsigned long long freqreg = (u64 )fout * (u64)(1 <<AD9834_FREQ_BITS );do_div (freqreg, mclk);return freqreg;
@@ -78,7 +78,7 @@ static ssize_t ad9834_write(struct device *dev, goto error_ret;mutex_lock (&indio_dev->mlock); -switch ((u32 ) this_attr->address) { +switch ((u32 )this_attr->address) {case AD9834_REG_FREQ0 :case AD9834_REG_FREQ1 : ret =ad9834_write_frequency (st, this_attr->address, val);
@@ -154,7 +154,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,mutex_lock (&indio_dev->mlock); -switch ((u32 ) this_attr->address) { +switch ((u32 )this_attr->address) {case 0 :if (sysfs_streq (buf,"sine" )) { st->control &= ~AD9834_MODE ;
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH v2 1/6] Staging: iio: Remove space after type cast
Quoted 4 lines · Cristina Opriceana
This patch removes unnecessary space after type casts. Warning found by checkpatch.pl.
Signed-off-by Cristina Opriceana <[email protected]>
Quoted 69 lines
--- drivers/staging/iio/frequency/ad9832.c | 6 +++--- drivers/staging/iio/frequency/ad9834.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)drivers/staging/iio/frequency/ad9832.c +3
-3@@ -24,8 +24,8 @@static unsigned long ad9832_calc_freqreg (unsigned long mclk,unsigned long fout) { -unsigned long long freqreg = (u64 ) fout * - (u64) ((u64 )1L <<AD9832_FREQ_BITS ); +unsigned long long freqreg = (u64 )fout * + (u64)((u64 )1L <<AD9832_FREQ_BITS );do_div (freqreg, mclk);return freqreg; }@@ -86,7 +86,7 @@ static ssize_t ad9832_write(struct device *dev, struct device_attribute *attr, goto error_ret;mutex_lock (&indio_dev->mlock); -switch ((u32 ) this_attr->address) { +switch ((u32 )this_attr->address) {case AD9832_FREQ0HM :case AD9832_FREQ1HM : ret =ad9832_write_frequency (st, this_attr->address, val);drivers/staging/iio/frequency/ad9834.c +3
-4@@ -27,7 +27,7 @@static unsigned int ad9834_calc_freqreg (unsigned long mclk,unsigned long fout) { -unsigned long long freqreg = (u64 ) fout * (u64) (1 <<AD9834_FREQ_BITS ); +unsigned long long freqreg = (u64 )fout * (u64)(1 <<AD9834_FREQ_BITS );do_div (freqreg, mclk);return freqreg;@@ -78,7 +78,7 @@ static ssize_t ad9834_write(struct device *dev, goto error_ret;mutex_lock (&indio_dev->mlock); -switch ((u32 ) this_attr->address) { +switch ((u32 )this_attr->address) {case AD9834_REG_FREQ0 :case AD9834_REG_FREQ1 : ret =ad9834_write_frequency (st, this_attr->address, val);@@ -154,7 +154,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,mutex_lock (&indio_dev->mlock); -switch ((u32 ) this_attr->address) { +switch ((u32 )this_attr->address) {case 0 :if (sysfs_streq (buf,"sine" )) { st->control &= ~AD9834_MODE ; --1.9.1
--
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/53f8f070c1f2a23bd5acfa61ef6153f99b10d0f6.1426353884.git.cristina.opriceana%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
PATCH v2 2/6 Staging: iio: Remove explicit comparison to NULL
In reply to Cristina OpriceanaThis patch simplifies pointer comparison to NULL and makes code easier to read. Warning found by checkpatch.pl.
--- drivers/staging/iio/frequency/ad9832.c | 2 +- drivers/staging/iio/frequency/ad9834.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9832.c +1 -1
@@ -220,7 +220,7 @@ static int ad9832_probe(struct spi_device *spi) } indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st)); -if (indio_dev ==NULL ) { +if (!indio_dev) { ret = -ENOMEM ; goto error_disable_reg; }
drivers/staging/iio/frequency/ad9834.c +1 -1
@@ -336,7 +336,7 @@ static int ad9834_probe(struct spi_device *spi) } indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st)); -if (indio_dev ==NULL ) { +if (!indio_dev) { ret = -ENOMEM ; goto error_disable_reg; }
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH v2 2/6] Staging: iio: Remove explicit comparison to NULL
Quoted 4 lines · Cristina Opriceana
This patch simplifies pointer comparison to NULL and makes code easier to read. Warning found by checkpatch.pl.
Signed-off-by Cristina Opriceana <[email protected]>
Quoted 40 lines
--- drivers/staging/iio/frequency/ad9832.c | 2 +- drivers/staging/iio/frequency/ad9834.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/staging/iio/frequency/ad9832.c +1
-1@@ -220,7 +220,7 @@ static int ad9832_probe(struct spi_device *spi) } indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st)); -if (indio_dev ==NULL ) { +if (!indio_dev) { ret = -ENOMEM ; goto error_disable_reg; }drivers/staging/iio/frequency/ad9834.c +1
-2@@ -336,7 +336,7 @@ static int ad9834_probe(struct spi_device *spi) } indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st)); -if (indio_dev ==NULL ) { +if (!indio_dev) { ret = -ENOMEM ; goto error_disable_reg; } --1.9.1
--
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/8fddb5ee8a8f3a53ebd4b337f08e475c2dce63ce.1426353884.git.cristina.opriceana%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
PATCH v2 3/6 Staging: iio: Prefer using the BIT macro
In reply to Cristina OpriceanaThis patch replaces bit shifting on 1 with the BIT(x) macro as it's extensively used by other function in this driver.
This was done with coccinelle:
@@ int g; @@
-(1 << g)
+BIT(g)
--- drivers/staging/iio/frequency/ad9832.c | 2 +- drivers/staging/iio/frequency/ad9832.h | 12 ++++++------ drivers/staging/iio/frequency/ad9834.c | 4 ++-- drivers/staging/iio/frequency/ad9834.h | 36 +++++++++++++++++----------------- 4 files changed, 27 insertions(+), 27 deletions(-)
drivers/staging/iio/frequency/ad9832.c +1 -1
@@ -59,7 +59,7 @@ static int ad9832_write_frequency(struct ad9832_state *st,static int ad9832_write_phase (struct ad9832_state *st,unsigned long addr,unsigned long phase) { -if (phase > (1 <<AD9832_PHASE_BITS )) +if (phase >BIT (AD9832_PHASE_BITS ))return -EINVAL ; st->phase_data[0] = cpu_to_be16((AD9832_CMD_PHA8BITSW << CMD_SHIFT) |
drivers/staging/iio/frequency/ad9832.h +6 -6
@@ -42,13 +42,13 @@#define AD9832_CMD_SYNCSELSRC 0x8#define AD9832_CMD_SLEEPRESCLR 0xC -#define AD9832_FREQ (1 << 11) +#define AD9832_FREQ BIT(11)#define AD9832_PHASE (x) (((x) & 3) << 9) -#define AD9832_SYNC (1 << 13) -#define AD9832_SELSRC (1 << 12) -#define AD9832_SLEEP (1 << 13) -#define AD9832_RESET (1 << 12) -#define AD9832_CLR (1 << 11) +#define AD9832_SYNC BIT(13) +#define AD9832_SELSRC BIT(12) +#define AD9832_SLEEP BIT(13) +#define AD9832_RESET BIT(12) +#define AD9832_CLR BIT(11)#define CMD_SHIFT 12#define ADD_SHIFT 8#define AD9832_FREQ_BITS 32
drivers/staging/iio/frequency/ad9834.c +2 -2
@@ -27,7 +27,7 @@static unsigned int ad9834_calc_freqreg (unsigned long mclk,unsigned long fout) { -unsigned long long freqreg = (u64 )fout * (u64)(1 <<AD9834_FREQ_BITS ); +unsigned long long freqreg = (u64 )fout * (u64 )BIT (AD9834_FREQ_BITS );do_div (freqreg, mclk);return freqreg;
@@ -55,7 +55,7 @@ static int ad9834_write_frequency(struct ad9834_state *st,static int ad9834_write_phase (struct ad9834_state *st,unsigned long addr,unsigned long phase) { -if (phase > (1 <<AD9834_PHASE_BITS )) +if (phase >BIT (AD9834_PHASE_BITS ))return -EINVAL ; st->data =cpu_to_be16 (addr | phase);
drivers/staging/iio/frequency/ad9834.h +18 -18
@@ -10,31 +10,31 @@/* Registers */ -#define AD9834_REG_CMD (0 << 14) -#define AD9834_REG_FREQ0 (1 << 14) -#define AD9834_REG_FREQ1 (2 << 14) -#define AD9834_REG_PHASE0 (6 << 13) -#define AD9834_REG_PHASE1 (7 << 13) +#define AD9834_REG_CMD 0 +#define AD9834_REG_FREQ0 BIT(14) +#define AD9834_REG_FREQ1 BIT(15) +#define AD9834_REG_PHASE0 (BIT(15) | BIT(14)) +#define AD9834_REG_PHASE1 (BIT(15) | BIT(14) | BIT(13))/* Command Control Bits */ -#define AD9834_B28 (1 << 13) -#define AD9834_HLB (1 << 12) -#define AD9834_FSEL (1 << 11) -#define AD9834_PSEL (1 << 10) -#define AD9834_PIN_SW (1 << 9) -#define AD9834_RESET (1 << 8) -#define AD9834_SLEEP1 (1 << 7) -#define AD9834_SLEEP12 (1 << 6) -#define AD9834_OPBITEN (1 << 5) -#define AD9834_SIGN_PIB (1 << 4) -#define AD9834_DIV2 (1 << 3) -#define AD9834_MODE (1 << 1) +#define AD9834_B28 BIT(13) +#define AD9834_HLB BIT(12) +#define AD9834_FSEL BIT(11) +#define AD9834_PSEL BIT(10) +#define AD9834_PIN_SW BIT(9) +#define AD9834_RESET BIT(8) +#define AD9834_SLEEP1 BIT(7) +#define AD9834_SLEEP12 BIT(6) +#define AD9834_OPBITEN BIT(5) +#define AD9834_SIGN_PIB BIT(4) +#define AD9834_DIV2 BIT(3) +#define AD9834_MODE BIT(1)#define AD9834_FREQ_BITS 28#define AD9834_PHASE_BITS 12 -#define RES_MASK (bits) ((1 << (bits)) - 1) +#define RES_MASK (bits) (BIT(bits) - 1)/** * struct ad9834_state - driver instance specific data
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH v2 3/6] Staging: iio: Prefer using the BIT macro
Quoted 10 lines · Cristina Opriceana
This patch replaces bit shifting on 1 with the BIT(x) macro as it's extensively used by other function in this driver.
This was done with coccinelle:
@@ int g; @@(quoted diff) +1
-1-(1 << g) +BIT(g)Signed-off-by Cristina Opriceana <[email protected]>
PATCH v2 4/6 Staging: iio: Do not use multiple blank lines
In reply to Cristina OpriceanaThis patch removes unnecessary blank lines between functions. Found by checkpatch.pl:
"CHECK: Please don't use multiple blank lines".
--- drivers/staging/iio/frequency/ad9834.c | 1 - drivers/staging/iio/frequency/ad9834.h | 1 - 2 files changed, 2 deletions(-)
drivers/staging/iio/frequency/ad9834.c +0 -1
@@ -218,7 +218,6 @@ static ssize_t ad9834_show_out0_wavetype_available(struct device *dev,return sprintf (buf,"%s\n" , str); } - static IIO_DEVICE_ATTR(out_altvoltage0_out0_wavetype_available, S_IRUGO, ad9834_show_out0_wavetype_available, NULL, 0);
drivers/staging/iio/frequency/ad9834.h +0 -1
@@ -69,7 +69,6 @@ struct ad9834_state {__be16 freq_data[2 ]; }; -/* * TODO: struct ad7887_platform_data needs to go into include/linux/iio */
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH v2 4/6] Staging: iio: Do not use multiple blank lines
Quoted 5 lines · Cristina Opriceana
This patch removes unnecessary blank lines between functions. Found by checkpatch.pl:
"CHECK: Please don't use multiple blank lines".Signed-off-by Cristina Opriceana <[email protected]>
PATCH v2 5/6 Staging: iio: Alignment should match open parenthesis
In reply to Cristina OpriceanaThis patch arranges multiple-line parameters in accordance with the parameter above them to improve coding style. Found by checkpatch.pl
--- drivers/staging/iio/frequency/ad9834.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/staging/iio/frequency/ad9834.c +16 -14
@@ -53,7 +53,7 @@ static int ad9834_write_frequency(struct ad9834_state *st, }static int ad9834_write_phase (struct ad9834_state *st, -unsigned long addr,unsigned long phase) +unsigned long addr,unsigned long phase) {if (phase >BIT (AD9834_PHASE_BITS ))return -EINVAL ;
@@ -63,9 +63,9 @@ static int ad9834_write_phase(struct ad9834_state *st, }static ssize_t ad9834_write (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t len) +struct device_attribute *attr, +const char *buf, +size_t len) {struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct ad9834_state *st =iio_priv (indio_dev);
@@ -142,9 +142,9 @@ error_ret: }static ssize_t ad9834_store_wavetype (struct device *dev, -struct device_attribute *attr, -const char *buf, -size_t len) +struct device_attribute *attr, +const char *buf, +size_t len) {struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct ad9834_state *st =iio_priv (indio_dev);
@@ -179,7 +179,7 @@ static ssize_t ad9834_store_wavetype(struct device *dev,break ;case 1 :if (sysfs_streq (buf,"square" ) && - !(st->control &AD9834_MODE )) { + !(st->control &AD9834_MODE )) { st->control &= ~AD9834_MODE ; st->control |=AD9834_OPBITEN ; }else {
@@ -200,9 +200,10 @@ static ssize_t ad9834_store_wavetype(struct device *dev,return ret ? ret : len; } -static ssize_t ad9834_show_out0_wavetype_available (struct device *dev, -struct device_attribute *attr, -char *buf) +static +ssize_t ad9834_show_out0_wavetype_available (struct device *dev, +struct device_attribute *attr, +char *buf) {struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct ad9834_state *st =iio_priv (indio_dev);
@@ -221,9 +222,10 @@ static ssize_t ad9834_show_out0_wavetype_available(struct device *dev, static IIO_DEVICE_ATTR(out_altvoltage0_out0_wavetype_available, S_IRUGO, ad9834_show_out0_wavetype_available, NULL, 0); -static ssize_t ad9834_show_out1_wavetype_available (struct device *dev, -struct device_attribute *attr, -char *buf) +static +ssize_t ad9834_show_out1_wavetype_available (struct device *dev, +struct device_attribute *attr, +char *buf) {struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct ad9834_state *st =iio_priv (indio_dev);
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH v2 5/6] Staging: iio: Alignment should match open parenthesis
Quoted 5 lines · Cristina Opriceana
This patch arranges multiple-line parameters in accordance with the parameter above them to improve coding style. Found by checkpatch.pl
Signed-off-by Cristina Opriceana <[email protected]>
PATCH v2 6/6 Staging: iio: Use braces on all arms of if statement
In reply to Cristina OpriceanaAdd braces to improve consistency when using if statements. Found by checkpatch.pl:
"CHECK: braces {} should be used on all arms of this statement".
--- drivers/staging/iio/frequency/ad9834.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/iio/frequency/ad9834.c +2 -2
@@ -111,9 +111,9 @@ static ssize_t ad9834_write(struct device *dev,break ;case AD9834_FSEL :case AD9834_PSEL : -if (val ==0 ) +if (val ==0 ) { st->control &= ~(this_attr->address |AD9834_PIN_SW ); -else if (val ==1 ) { + }else if (val ==1 ) { st->control |= this_attr->address; st->control &= ~AD9834_PIN_SW ; }else {
Signature · 1 line
1.9.1
Re: [Outreachy kernel] [PATCH v2 6/6] Staging: iio: Use braces on all arms of if statement
Quoted 5 lines · Cristina Opriceana
Add braces to improve consistency when using if statements. Found by checkpatch.pl:
"CHECK: braces {} should be used on all arms of this statement".Signed-off-by Cristina Opriceana <[email protected]>