DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] pi433: Fix indentation according to coding style
@ 2019-12-03 17:54 Sven Leykauf
  2019-12-03 17:54 ` [PATCH 2/2] " Sven Leykauf
  2019-12-03 18:06 ` [PATCH 1/2] " Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Sven Leykauf @ 2019-12-03 17:54 UTC (permalink / raw)
  To: devel; +Cc: Daniel Bauer, Sven Leykauf, linux-kernel

Fix indentation so that no line exceeds the 80 character border.

Co-developed-by: Daniel Bauer <daniel.j.bauer@fau.de>
Signed-off-by: Daniel Bauer <daniel.j.bauer@fau.de>
Signed-off-by: Sven Leykauf <sven_leykauf1@web.de>
---
 drivers/staging/pi433/rf69.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 7d86bb8be245..6b13f92028c7 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -176,20 +176,20 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
 		switch (mod_shaping) {
 		case SHAPING_OFF:
 			return rf69_read_mod_write(spi, REG_DATAMODUL,
-						   MASK_DATAMODUL_MODULATION_SHAPE,
-						   DATAMODUL_MODULATION_SHAPE_NONE);
+					MASK_DATAMODUL_MODULATION_SHAPE,
+					DATAMODUL_MODULATION_SHAPE_NONE);
 		case SHAPING_1_0:
 			return rf69_read_mod_write(spi, REG_DATAMODUL,
-						   MASK_DATAMODUL_MODULATION_SHAPE,
-						   DATAMODUL_MODULATION_SHAPE_1_0);
+					MASK_DATAMODUL_MODULATION_SHAPE,
+					DATAMODUL_MODULATION_SHAPE_1_0);
 		case SHAPING_0_5:
 			return rf69_read_mod_write(spi, REG_DATAMODUL,
-						   MASK_DATAMODUL_MODULATION_SHAPE,
-						   DATAMODUL_MODULATION_SHAPE_0_5);
+					MASK_DATAMODUL_MODULATION_SHAPE,
+					DATAMODUL_MODULATION_SHAPE_0_5);
 		case SHAPING_0_3:
 			return rf69_read_mod_write(spi, REG_DATAMODUL,
-						   MASK_DATAMODUL_MODULATION_SHAPE,
-						   DATAMODUL_MODULATION_SHAPE_0_3);
+					MASK_DATAMODUL_MODULATION_SHAPE,
+					DATAMODUL_MODULATION_SHAPE_0_3);
 		default:
 			dev_dbg(&spi->dev, "set: illegal input param");
 			return -EINVAL;
@@ -198,16 +198,16 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
 		switch (mod_shaping) {
 		case SHAPING_OFF:
 			return rf69_read_mod_write(spi, REG_DATAMODUL,
-						   MASK_DATAMODUL_MODULATION_SHAPE,
-						   DATAMODUL_MODULATION_SHAPE_NONE);
+					MASK_DATAMODUL_MODULATION_SHAPE,
+					DATAMODUL_MODULATION_SHAPE_NONE);
 		case SHAPING_BR:
 			return rf69_read_mod_write(spi, REG_DATAMODUL,
-						   MASK_DATAMODUL_MODULATION_SHAPE,
-						   DATAMODUL_MODULATION_SHAPE_BR);
+					MASK_DATAMODUL_MODULATION_SHAPE,
+					DATAMODUL_MODULATION_SHAPE_BR);
 		case SHAPING_2BR:
 			return rf69_read_mod_write(spi, REG_DATAMODUL,
-						   MASK_DATAMODUL_MODULATION_SHAPE,
-						   DATAMODUL_MODULATION_SHAPE_2BR);
+					MASK_DATAMODUL_MODULATION_SHAPE,
+					DATAMODUL_MODULATION_SHAPE_2BR);
 		default:
 			dev_dbg(&spi->dev, "set: illegal input param");
 			return -EINVAL;
-- 
2.20.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH 2/2] pi433: Fix indentation according to coding style
  2019-12-03 17:54 [PATCH 1/2] pi433: Fix indentation according to coding style Sven Leykauf
@ 2019-12-03 17:54 ` " Sven Leykauf
  2019-12-03 18:14   ` Dan Carpenter
  2019-12-03 18:06 ` [PATCH 1/2] " Dan Carpenter
  1 sibling, 1 reply; 5+ messages in thread
From: Sven Leykauf @ 2019-12-03 17:54 UTC (permalink / raw)
  To: devel; +Cc: Daniel Bauer, Sven Leykauf, linux-kernel

Fix indentation so that no line exceeds the 80 character border.

Put the return command one line under the default case, so it looks
better.

Co-developed-by: Daniel Bauer <daniel.j.bauer@fau.de>
Signed-off-by: Daniel Bauer <daniel.j.bauer@fau.de>
Signed-off-by: Sven Leykauf <sven_leykauf1@web.de>
---
 drivers/staging/pi433/rf69.c | 56 ++++++++++++++++++++++++------------
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index 6b13f92028c7..6cdd46682aa9 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -596,42 +596,60 @@ bool rf69_get_flag(struct spi_device *spi, enum flag flag)
 {
 	switch (flag) {
 	case mode_switch_completed:
-		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY);
+		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
+				MASK_IRQFLAGS1_MODE_READY);
 	case ready_to_receive:
-		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RX_READY);
+		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
+				MASK_IRQFLAGS1_RX_READY);
 	case ready_to_send:
-		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_TX_READY);
+		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
+				MASK_IRQFLAGS1_TX_READY);
 	case pll_locked:
-		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_PLL_LOCK);
+		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
+				MASK_IRQFLAGS1_PLL_LOCK);
 	case rssi_exceeded_threshold:
-		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_RSSI);
+		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
+				MASK_IRQFLAGS1_RSSI);
 	case timeout:
-		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_TIMEOUT);
+		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
+				MASK_IRQFLAGS1_TIMEOUT);
 	case automode:
-		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_AUTOMODE);
+		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
+				MASK_IRQFLAGS1_AUTOMODE);
 	case sync_address_match:
-		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH);
+		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
+				MASK_IRQFLAGS1_SYNC_ADDRESS_MATCH);
 	case fifo_full:
-		return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_FULL);
+		return (rf69_read_reg(spi, REG_IRQFLAGS2) &
+				MASK_IRQFLAGS2_FIFO_FULL);
 /*
  *	case fifo_not_empty:
- *		return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY);
+ *		return (rf69_read_reg(spi, REG_IRQFLAGS2) &
+ *		MASK_IRQFLAGS2_FIFO_NOT_EMPTY);
  */
 	case fifo_empty:
-		return !(rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_NOT_EMPTY);
+		return !(rf69_read_reg(spi, REG_IRQFLAGS2) &
+				MASK_IRQFLAGS2_FIFO_NOT_EMPTY);
 	case fifo_level_below_threshold:
-		return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_LEVEL);
+		return (rf69_read_reg(spi, REG_IRQFLAGS2) &
+				MASK_IRQFLAGS2_FIFO_LEVEL);
 	case fifo_overrun:
-		return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_FIFO_OVERRUN);
+		return (rf69_read_reg(spi, REG_IRQFLAGS2) &
+				MASK_IRQFLAGS2_FIFO_OVERRUN);
 	case packet_sent:
-		return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PACKET_SENT);
+		return (rf69_read_reg(spi, REG_IRQFLAGS2) &
+				MASK_IRQFLAGS2_PACKET_SENT);
 	case payload_ready:
-		return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_PAYLOAD_READY);
+		return (rf69_read_reg(spi, REG_IRQFLAGS2) &
+				MASK_IRQFLAGS2_PAYLOAD_READY);
 	case crc_ok:
-		return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_CRC_OK);
+		return (rf69_read_reg(spi, REG_IRQFLAGS2) &
+				MASK_IRQFLAGS2_CRC_OK);
 	case battery_low:
-		return (rf69_read_reg(spi, REG_IRQFLAGS2) & MASK_IRQFLAGS2_LOW_BAT);
-	default:			 return false;
+		return (rf69_read_reg(spi, REG_IRQFLAGS2) &
+				MASK_IRQFLAGS2_LOW_BAT);
+	default:
+		return false;
 	}
 }
 
@@ -725,7 +743,7 @@ int rf69_set_packet_format(struct spi_device *spi,
 				    MASK_PACKETCONFIG1_PACKET_FORMAT_VARIABLE);
 	case packet_length_fix:
 		return rf69_clear_bit(spi, REG_PACKETCONFIG1,
-				      MASK_PACKETCONFIG1_PACKET_FORMAT_VARIABLE);
+				    MASK_PACKETCONFIG1_PACKET_FORMAT_VARIABLE);
 	default:
 		dev_dbg(&spi->dev, "set: illegal input param");
 		return -EINVAL;
-- 
2.20.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 1/2] pi433: Fix indentation according to coding style
  2019-12-03 17:54 [PATCH 1/2] pi433: Fix indentation according to coding style Sven Leykauf
  2019-12-03 17:54 ` [PATCH 2/2] " Sven Leykauf
@ 2019-12-03 18:06 ` " Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-12-03 18:06 UTC (permalink / raw)
  To: Sven Leykauf; +Cc: devel, Daniel Bauer, linux-kernel

On Tue, Dec 03, 2019 at 06:54:47PM +0100, Sven Leykauf wrote:
> Fix indentation so that no line exceeds the 80 character border.
> 
> Co-developed-by: Daniel Bauer <daniel.j.bauer@fau.de>
> Signed-off-by: Daniel Bauer <daniel.j.bauer@fau.de>
> Signed-off-by: Sven Leykauf <sven_leykauf1@web.de>
> ---
>  drivers/staging/pi433/rf69.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
> index 7d86bb8be245..6b13f92028c7 100644
> --- a/drivers/staging/pi433/rf69.c
> +++ b/drivers/staging/pi433/rf69.c
> @@ -176,20 +176,20 @@ int rf69_set_modulation_shaping(struct spi_device *spi,
>  		switch (mod_shaping) {
>  		case SHAPING_OFF:
>  			return rf69_read_mod_write(spi, REG_DATAMODUL,
> -						   MASK_DATAMODUL_MODULATION_SHAPE,
> -						   DATAMODUL_MODULATION_SHAPE_NONE);
> +					MASK_DATAMODUL_MODULATION_SHAPE,
> +					DATAMODUL_MODULATION_SHAPE_NONE);

It was a choice to align with the ( or be less than 80 characters and
the original author decided to go over 80 characters...  They're both
equally valid options, but we generally let the original author choose
pick which one they prefer.  So just leave it as is.

There are better ways to write this function which avoid both problems...

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 2/2] pi433: Fix indentation according to coding style
  2019-12-03 17:54 ` [PATCH 2/2] " Sven Leykauf
@ 2019-12-03 18:14   ` Dan Carpenter
  2019-12-03 18:30     ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2019-12-03 18:14 UTC (permalink / raw)
  To: Sven Leykauf; +Cc: devel, Daniel Bauer, linux-kernel

You can't have two patches with the same subject.

On Tue, Dec 03, 2019 at 06:54:49PM +0100, Sven Leykauf wrote:
> Fix indentation so that no line exceeds the 80 character border.
> 
> Put the return command one line under the default case, so it looks
> better.
> 
> Co-developed-by: Daniel Bauer <daniel.j.bauer@fau.de>
> Signed-off-by: Daniel Bauer <daniel.j.bauer@fau.de>
> Signed-off-by: Sven Leykauf <sven_leykauf1@web.de>
> ---
>  drivers/staging/pi433/rf69.c | 56 ++++++++++++++++++++++++------------
>  1 file changed, 37 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
> index 6b13f92028c7..6cdd46682aa9 100644
> --- a/drivers/staging/pi433/rf69.c
> +++ b/drivers/staging/pi433/rf69.c
> @@ -596,42 +596,60 @@ bool rf69_get_flag(struct spi_device *spi, enum flag flag)
>  {
>  	switch (flag) {
>  	case mode_switch_completed:
> -		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY);
> +		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
> +				MASK_IRQFLAGS1_MODE_READY);


This isn't how we align things.  The ( and the next line should match.

		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
			MASK_IRQFLAGS1_MODE_READY);

But actually the original is probably better than the new version so
lets just leave it as is.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH 2/2] pi433: Fix indentation according to coding style
  2019-12-03 18:14   ` Dan Carpenter
@ 2019-12-03 18:30     ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2019-12-03 18:30 UTC (permalink / raw)
  To: Sven Leykauf; +Cc: devel, Daniel Bauer, linux-kernel

On Tue, Dec 03, 2019 at 09:14:17PM +0300, Dan Carpenter wrote:
> You can't have two patches with the same subject.
> 
> On Tue, Dec 03, 2019 at 06:54:49PM +0100, Sven Leykauf wrote:
> > Fix indentation so that no line exceeds the 80 character border.
> > 
> > Put the return command one line under the default case, so it looks
> > better.
> > 
> > Co-developed-by: Daniel Bauer <daniel.j.bauer@fau.de>
> > Signed-off-by: Daniel Bauer <daniel.j.bauer@fau.de>
> > Signed-off-by: Sven Leykauf <sven_leykauf1@web.de>
> > ---
> >  drivers/staging/pi433/rf69.c | 56 ++++++++++++++++++++++++------------
> >  1 file changed, 37 insertions(+), 19 deletions(-)
> > 
> > diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
> > index 6b13f92028c7..6cdd46682aa9 100644
> > --- a/drivers/staging/pi433/rf69.c
> > +++ b/drivers/staging/pi433/rf69.c
> > @@ -596,42 +596,60 @@ bool rf69_get_flag(struct spi_device *spi, enum flag flag)
> >  {
> >  	switch (flag) {
> >  	case mode_switch_completed:
> > -		return (rf69_read_reg(spi, REG_IRQFLAGS1) & MASK_IRQFLAGS1_MODE_READY);
> > +		return (rf69_read_reg(spi, REG_IRQFLAGS1) &
> > +				MASK_IRQFLAGS1_MODE_READY);

For patch 1 it would be pretty easy to re-write the function to be
cleaner and under 80 characters.  For this function it's quite a bit
trickier.  You could sit for a long time thinking about it.

Is MASK_IRQFLAGS1_MODE_READY the exact perfect name?  Why does the
"enum flag flag" enum exist?  Is it perfectly named?  How much of this
function is dead code?

It's probably better to start cleaning up the rest of the driver and
then by the time you get back to this function maybe the answer will
be obvious.

regards,
dan carpenter
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-03 17:54 [PATCH 1/2] pi433: Fix indentation according to coding style Sven Leykauf
2019-12-03 17:54 ` [PATCH 2/2] " Sven Leykauf
2019-12-03 18:14   ` Dan Carpenter
2019-12-03 18:30     ` Dan Carpenter
2019-12-03 18:06 ` [PATCH 1/2] " Dan Carpenter

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git