linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Solve checkstyle problems
@ 2019-02-22 20:31 Bárbara Fernandes
  2019-02-22 20:31 ` [PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis Bárbara Fernandes
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Bárbara Fernandes @ 2019-02-22 20:31 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler
  Cc: linux-iio, linux-kernel, kernel-usp, Bárbara Fernandes

Solve checkpath.pl's CHECK messages:

Bárbara Fernandes (4):
  iio:adc:ad7923: Align broken line to parenthesis
  iio:adc:ad7923: Use BIT macro instead of bitshift
  iio:adc:ad7923: Put macro argument between ()'s
  iio:adc:ad7923: Rewrite comparison to NULL

 drivers/iio/adc/ad7923.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis
  2019-02-22 20:31 [PATCH 0/4] Solve checkstyle problems Bárbara Fernandes
@ 2019-02-22 20:31 ` Bárbara Fernandes
  2019-03-03 14:43   ` Jonathan Cameron
  2019-02-22 20:31 ` [PATCH 2/4] iio:adc:ad7923: Use BIT macro instead of bitshift Bárbara Fernandes
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Bárbara Fernandes @ 2019-02-22 20:31 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler
  Cc: linux-iio, linux-kernel, kernel-usp, Bárbara Fernandes

Get broken line aligned with parenthesis on upper line. Solves
checkpatch.pl's message:

CHECK: Alignment should match open parenthesis

Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
---
 drivers/iio/adc/ad7923.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index d62dbb62be45..ebae7522710a 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -130,7 +130,7 @@ static const struct ad7923_chip_info ad7923_chip_info[] = {
  * ad7923_update_scan_mode() setup the spi transfer buffer for the new scan mask
  **/
 static int ad7923_update_scan_mode(struct iio_dev *indio_dev,
-	const unsigned long *active_scan_mask)
+				   const unsigned long *active_scan_mask)
 {
 	struct ad7923_state *st = iio_priv(indio_dev);
 	int i, cmd, len;
@@ -181,7 +181,7 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p)
 		goto done;
 
 	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
-		iio_get_time_ns(indio_dev));
+					   iio_get_time_ns(indio_dev));
 
 done:
 	iio_trigger_notify_done(indio_dev->trig);
@@ -314,7 +314,7 @@ static int ad7923_probe(struct spi_device *spi)
 		return ret;
 
 	ret = iio_triggered_buffer_setup(indio_dev, NULL,
-			&ad7923_trigger_handler, NULL);
+					 &ad7923_trigger_handler, NULL);
 	if (ret)
 		goto error_disable_reg;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] iio:adc:ad7923: Use BIT macro instead of bitshift
  2019-02-22 20:31 [PATCH 0/4] Solve checkstyle problems Bárbara Fernandes
  2019-02-22 20:31 ` [PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis Bárbara Fernandes
@ 2019-02-22 20:31 ` Bárbara Fernandes
  2019-03-03 14:44   ` Jonathan Cameron
  2019-02-22 20:31 ` [PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s Bárbara Fernandes
  2019-02-22 20:31 ` [PATCH 4/4] iio:adc:ad7923: Rewrite comparison to NULL Bárbara Fernandes
  3 siblings, 1 reply; 9+ messages in thread
From: Bárbara Fernandes @ 2019-02-22 20:31 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler
  Cc: linux-iio, linux-kernel, kernel-usp, Bárbara Fernandes

Replace use of the operation '<<' by the BIT macro. Solves checkpath.pl's
message:

CHECK: Prefer using the BIT macro

Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
---
 drivers/iio/adc/ad7923.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index ebae7522710a..b39ea834cdd6 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -24,9 +24,9 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 
-#define AD7923_WRITE_CR		(1 << 11)	/* write control register */
-#define AD7923_RANGE		(1 << 1)	/* range to REFin */
-#define AD7923_CODING		(1 << 0)	/* coding is straight binary */
+#define AD7923_WRITE_CR		BIT(11)		/* write control register */
+#define AD7923_RANGE		BIT(1)		/* range to REFin */
+#define AD7923_CODING		BIT(0)		/* coding is straight binary */
 #define AD7923_PM_MODE_AS	(1)		/* auto shutdown */
 #define AD7923_PM_MODE_FS	(2)		/* full shutdown */
 #define AD7923_PM_MODE_OPS	(3)		/* normal operation */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s
  2019-02-22 20:31 [PATCH 0/4] Solve checkstyle problems Bárbara Fernandes
  2019-02-22 20:31 ` [PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis Bárbara Fernandes
  2019-02-22 20:31 ` [PATCH 2/4] iio:adc:ad7923: Use BIT macro instead of bitshift Bárbara Fernandes
@ 2019-02-22 20:31 ` Bárbara Fernandes
  2019-03-03 14:45   ` Jonathan Cameron
  2019-02-22 20:31 ` [PATCH 4/4] iio:adc:ad7923: Rewrite comparison to NULL Bárbara Fernandes
  3 siblings, 1 reply; 9+ messages in thread
From: Bárbara Fernandes @ 2019-02-22 20:31 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler
  Cc: linux-iio, linux-kernel, kernel-usp, Bárbara Fernandes

Put macro argument between parenthesis in order to avoid precedence
issues. Solves the following checkpath.pl's messages:

CHECK: Macro argument 'mode' may be better as '(mode)' to avoid
precedence issues
CHECK: Macro argument 'channel' may be better as '(channel)' to
avoid precedence issues
CHECK: Macro argument reuse 'sequence' - possible side-effects?
CHECK: Macro argument 'sequence' may be better as '(sequence)' to
avoid precedence issues
CHECK: Macro argument 'val' may be better as '(val)' to avoid
precedence issues
CHECK: Macro argument 'dec' may be better as '(dec)' to avoid precedence
issues
CHECK: Macro argument 'bits' may be better as '(bits)' to avoid
precedence issues

Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
---
 drivers/iio/adc/ad7923.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index b39ea834cdd6..dbece44e26e4 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -40,16 +40,16 @@
 
 #define AD7923_MAX_CHAN		4
 
-#define AD7923_PM_MODE_WRITE(mode)	(mode << 4)	/* write mode */
-#define AD7923_CHANNEL_WRITE(channel)	(channel << 6)	/* write channel */
-#define AD7923_SEQUENCE_WRITE(sequence)	(((sequence & 1) << 3) \
-					+ ((sequence & 2) << 9))
+#define AD7923_PM_MODE_WRITE(mode)	((mode) << 4)	 /* write mode */
+#define AD7923_CHANNEL_WRITE(channel)	((channel) << 6) /* write channel */
+#define AD7923_SEQUENCE_WRITE(sequence)	((((sequence) & 1) << 3) \
+					+ (((sequence) & 2) << 9))
 						/* write sequence fonction */
 /* left shift for CR : bit 11 transmit in first */
 #define AD7923_SHIFT_REGISTER	4
 
 /* val = value, dec = left shift, bits = number of bits of the mask */
-#define EXTRACT(val, dec, bits)		((val >> dec) & ((1 << bits) - 1))
+#define EXTRACT(val, dec, bits)		(((val) >> (dec)) & ((1 << (bits)) - 1))
 
 struct ad7923_state {
 	struct spi_device		*spi;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] iio:adc:ad7923: Rewrite comparison to NULL
  2019-02-22 20:31 [PATCH 0/4] Solve checkstyle problems Bárbara Fernandes
                   ` (2 preceding siblings ...)
  2019-02-22 20:31 ` [PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s Bárbara Fernandes
@ 2019-02-22 20:31 ` Bárbara Fernandes
  2019-03-03 14:47   ` Jonathan Cameron
  3 siblings, 1 reply; 9+ messages in thread
From: Bárbara Fernandes @ 2019-02-22 20:31 UTC (permalink / raw)
  To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
	Hartmut Knaack, Peter Meerwald-Stadler
  Cc: linux-iio, linux-kernel, kernel-usp, Bárbara Fernandes

Solves checkpath.pl's message:

CHECK: Comparison to NULL could be written "!indio_dev"

Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
---
 drivers/iio/adc/ad7923.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
index dbece44e26e4..cb7b854df00c 100644
--- a/drivers/iio/adc/ad7923.c
+++ b/drivers/iio/adc/ad7923.c
@@ -272,7 +272,7 @@ static int ad7923_probe(struct spi_device *spi)
 	int ret;
 
 	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
-	if (indio_dev == NULL)
+	if (!indio_dev)
 		return -ENOMEM;
 
 	st = iio_priv(indio_dev);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis
  2019-02-22 20:31 ` [PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis Bárbara Fernandes
@ 2019-03-03 14:43   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2019-03-03 14:43 UTC (permalink / raw)
  To: Bárbara Fernandes
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio, linux-kernel, kernel-usp

On Fri, 22 Feb 2019 17:31:56 -0300
Bárbara Fernandes <barbara.fernandes@usp.br> wrote:

> Get broken line aligned with parenthesis on upper line. Solves
> checkpatch.pl's message:
> 
> CHECK: Alignment should match open parenthesis
> 
> Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/ad7923.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index d62dbb62be45..ebae7522710a 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -130,7 +130,7 @@ static const struct ad7923_chip_info ad7923_chip_info[] = {
>   * ad7923_update_scan_mode() setup the spi transfer buffer for the new scan mask
>   **/
>  static int ad7923_update_scan_mode(struct iio_dev *indio_dev,
> -	const unsigned long *active_scan_mask)
> +				   const unsigned long *active_scan_mask)
>  {
>  	struct ad7923_state *st = iio_priv(indio_dev);
>  	int i, cmd, len;
> @@ -181,7 +181,7 @@ static irqreturn_t ad7923_trigger_handler(int irq, void *p)
>  		goto done;
>  
>  	iio_push_to_buffers_with_timestamp(indio_dev, st->rx_buf,
> -		iio_get_time_ns(indio_dev));
> +					   iio_get_time_ns(indio_dev));
>  
>  done:
>  	iio_trigger_notify_done(indio_dev->trig);
> @@ -314,7 +314,7 @@ static int ad7923_probe(struct spi_device *spi)
>  		return ret;
>  
>  	ret = iio_triggered_buffer_setup(indio_dev, NULL,
> -			&ad7923_trigger_handler, NULL);
> +					 &ad7923_trigger_handler, NULL);
>  	if (ret)
>  		goto error_disable_reg;
>  


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] iio:adc:ad7923: Use BIT macro instead of bitshift
  2019-02-22 20:31 ` [PATCH 2/4] iio:adc:ad7923: Use BIT macro instead of bitshift Bárbara Fernandes
@ 2019-03-03 14:44   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2019-03-03 14:44 UTC (permalink / raw)
  To: Bárbara Fernandes
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio, linux-kernel, kernel-usp

On Fri, 22 Feb 2019 17:31:57 -0300
Bárbara Fernandes <barbara.fernandes@usp.br> wrote:

> Replace use of the operation '<<' by the BIT macro. Solves checkpath.pl's
> message:
> 
> CHECK: Prefer using the BIT macro
> 
> Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
Applied.  Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7923.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index ebae7522710a..b39ea834cdd6 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -24,9 +24,9 @@
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
>  
> -#define AD7923_WRITE_CR		(1 << 11)	/* write control register */
> -#define AD7923_RANGE		(1 << 1)	/* range to REFin */
> -#define AD7923_CODING		(1 << 0)	/* coding is straight binary */
> +#define AD7923_WRITE_CR		BIT(11)		/* write control register */
> +#define AD7923_RANGE		BIT(1)		/* range to REFin */
> +#define AD7923_CODING		BIT(0)		/* coding is straight binary */
>  #define AD7923_PM_MODE_AS	(1)		/* auto shutdown */
>  #define AD7923_PM_MODE_FS	(2)		/* full shutdown */
>  #define AD7923_PM_MODE_OPS	(3)		/* normal operation */


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s
  2019-02-22 20:31 ` [PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s Bárbara Fernandes
@ 2019-03-03 14:45   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2019-03-03 14:45 UTC (permalink / raw)
  To: Bárbara Fernandes
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio, linux-kernel, kernel-usp

On Fri, 22 Feb 2019 17:31:58 -0300
Bárbara Fernandes <barbara.fernandes@usp.br> wrote:

> Put macro argument between parenthesis in order to avoid precedence
> issues. Solves the following checkpath.pl's messages:
> 
> CHECK: Macro argument 'mode' may be better as '(mode)' to avoid
> precedence issues
> CHECK: Macro argument 'channel' may be better as '(channel)' to
> avoid precedence issues
> CHECK: Macro argument reuse 'sequence' - possible side-effects?
> CHECK: Macro argument 'sequence' may be better as '(sequence)' to
> avoid precedence issues
> CHECK: Macro argument 'val' may be better as '(val)' to avoid
> precedence issues
> CHECK: Macro argument 'dec' may be better as '(dec)' to avoid precedence
> issues
> CHECK: Macro argument 'bits' may be better as '(bits)' to avoid
> precedence issues
> 
> Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
Applied.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7923.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index b39ea834cdd6..dbece44e26e4 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -40,16 +40,16 @@
>  
>  #define AD7923_MAX_CHAN		4
>  
> -#define AD7923_PM_MODE_WRITE(mode)	(mode << 4)	/* write mode */
> -#define AD7923_CHANNEL_WRITE(channel)	(channel << 6)	/* write channel */
> -#define AD7923_SEQUENCE_WRITE(sequence)	(((sequence & 1) << 3) \
> -					+ ((sequence & 2) << 9))
> +#define AD7923_PM_MODE_WRITE(mode)	((mode) << 4)	 /* write mode */
> +#define AD7923_CHANNEL_WRITE(channel)	((channel) << 6) /* write channel */
> +#define AD7923_SEQUENCE_WRITE(sequence)	((((sequence) & 1) << 3) \
> +					+ (((sequence) & 2) << 9))
>  						/* write sequence fonction */
>  /* left shift for CR : bit 11 transmit in first */
>  #define AD7923_SHIFT_REGISTER	4
>  
>  /* val = value, dec = left shift, bits = number of bits of the mask */
> -#define EXTRACT(val, dec, bits)		((val >> dec) & ((1 << bits) - 1))
> +#define EXTRACT(val, dec, bits)		(((val) >> (dec)) & ((1 << (bits)) - 1))
>  
>  struct ad7923_state {
>  	struct spi_device		*spi;


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4/4] iio:adc:ad7923: Rewrite comparison to NULL
  2019-02-22 20:31 ` [PATCH 4/4] iio:adc:ad7923: Rewrite comparison to NULL Bárbara Fernandes
@ 2019-03-03 14:47   ` Jonathan Cameron
  0 siblings, 0 replies; 9+ messages in thread
From: Jonathan Cameron @ 2019-03-03 14:47 UTC (permalink / raw)
  To: Bárbara Fernandes
  Cc: Lars-Peter Clausen, Michael Hennerich, Hartmut Knaack,
	Peter Meerwald-Stadler, linux-iio, linux-kernel, kernel-usp

On Fri, 22 Feb 2019 17:31:59 -0300
Bárbara Fernandes <barbara.fernandes@usp.br> wrote:

> Solves checkpath.pl's message:
> 
> CHECK: Comparison to NULL could be written "!indio_dev"
> 
> Signed-off-by: Bárbara Fernandes <barbara.fernandes@usp.br>
Applied, thanks.

It's nice to get some cleanup for drivers that aren't in staging
sometimes.  After all, in recent years the kernel coding style
and tools to check it have improved considerably.

Thanks,

Jonathan

> ---
>  drivers/iio/adc/ad7923.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/ad7923.c b/drivers/iio/adc/ad7923.c
> index dbece44e26e4..cb7b854df00c 100644
> --- a/drivers/iio/adc/ad7923.c
> +++ b/drivers/iio/adc/ad7923.c
> @@ -272,7 +272,7 @@ static int ad7923_probe(struct spi_device *spi)
>  	int ret;
>  
>  	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> -	if (indio_dev == NULL)
> +	if (!indio_dev)
>  		return -ENOMEM;
>  
>  	st = iio_priv(indio_dev);


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-03-03 14:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-22 20:31 [PATCH 0/4] Solve checkstyle problems Bárbara Fernandes
2019-02-22 20:31 ` [PATCH 1/4] iio:adc:ad7923: Align broken line to parenthesis Bárbara Fernandes
2019-03-03 14:43   ` Jonathan Cameron
2019-02-22 20:31 ` [PATCH 2/4] iio:adc:ad7923: Use BIT macro instead of bitshift Bárbara Fernandes
2019-03-03 14:44   ` Jonathan Cameron
2019-02-22 20:31 ` [PATCH 3/4] iio:adc:ad7923: Put macro argument between ()'s Bárbara Fernandes
2019-03-03 14:45   ` Jonathan Cameron
2019-02-22 20:31 ` [PATCH 4/4] iio:adc:ad7923: Rewrite comparison to NULL Bárbara Fernandes
2019-03-03 14:47   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).