Skip to contentSkip to conversation

staging: pi433: remove unnecessary new line escape sequence characters

PATCH In review Paulo Miguel Almeida 2 participants 3 messages Jan 30, 2022 – Jan 31, 2022 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: pi433: remove unnecessary new line escape sequence characters

In this driver there were occurences of '\n'-ended strings when using dev_dbg function which isn't required which most likely were leftovers from a previous printk/pr_<level> implementation.

This patch removes the extraneous '\n' characters to make it consistent with the other dev_dbg instances.

---
Patch dependencies:

The following patches must be applied first given that changes are made to the same set of files:

- https://lore.kernel.org/lkml/[email protected]/
- https://lore.kernel.org/lkml/[email protected]/

---
 drivers/staging/pi433/pi433_if.c | 14 +++++++-------
 drivers/staging/pi433/rf69.c     | 16 ++++++++--------
 2 files changed, 15 insertions(+), 15 deletions(-)
drivers/staging/pi433/pi433_if.c +7 -7
index 02d4ccebf..db1b092e8 100644
@@ -124,13 +124,13 @@ static irqreturn_t DIO0_irq_handler(int irq, void *dev_id)
 
 	if (device->irq_state[DIO0] == DIO_PACKET_SENT) {
 		device->free_in_fifo = FIFO_SIZE;
-		dev_dbg(device->dev, "DIO0 irq: Packet sent\n");
+		dev_dbg(device->dev, "DIO0 irq: Packet sent");
 		wake_up_interruptible(&device->fifo_wait_queue);
 	} else if (device->irq_state[DIO0] == DIO_RSSI_DIO0) {
-		dev_dbg(device->dev, "DIO0 irq: RSSI level over threshold\n");
+		dev_dbg(device->dev, "DIO0 irq: RSSI level over threshold");
 		wake_up_interruptible(&device->rx_wait_queue);
 	} else if (device->irq_state[DIO0] == DIO_PAYLOAD_READY) {
-		dev_dbg(device->dev, "DIO0 irq: Payload ready\n");
+		dev_dbg(device->dev, "DIO0 irq: Payload ready");
 		device->free_in_fifo = 0;
 		wake_up_interruptible(&device->fifo_wait_queue);
 	}
@@ -151,7 +151,7 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
 			device->free_in_fifo = FIFO_SIZE - FIFO_THRESHOLD - 1;
 	}
 	dev_dbg(device->dev,
-		"DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo);
+		"DIO1 irq: %d bytes free in fifo", device->free_in_fifo);
 	wake_up_interruptible(&device->fifo_wait_queue);
 
 	return IRQ_HANDLED;
@@ -726,7 +726,7 @@ static int pi433_tx_thread(void *data)
 			retval = wait_event_interruptible(device->fifo_wait_queue,
 							  device->free_in_fifo > 0);
 			if (retval) {
-				dev_dbg(device->dev, "ABORT\n");
+				dev_dbg(device->dev, "ABORT");
 				goto abort;
 			}
 		}
@@ -1180,7 +1180,7 @@ static int pi433_probe(struct spi_device *spi)
 
 	retval = spi_setup(spi);
 	if (retval) {
-		dev_dbg(&spi->dev, "configuration of SPI interface failed!\n");
+		dev_dbg(&spi->dev, "configuration of SPI interface failed!");
 		return retval;
 	}
 
@@ -1283,7 +1283,7 @@ static int pi433_probe(struct spi_device *spi)
 		goto device_create_failed;
 	} else {
 		dev_dbg(device->dev,
-			"created device for major %d, minor %d\n",
+			"created device for major %d, minor %d",
 			MAJOR(pi433_dev),
 			device->minor);
 	}
drivers/staging/pi433/rf69.c +8 -8
index 2ab3bf46e..9a8f93fd7 100644
@@ -37,9 +37,9 @@ u8 rf69_read_reg(struct spi_device *spi, u8 addr)
 		 * that module is connected. Therefore no error
 		 * handling, just an optional error message...
 		 */
-		dev_dbg(&spi->dev, "read 0x%x FAILED\n", addr);
+		dev_dbg(&spi->dev, "read 0x%x FAILED", addr);
 	else
-		dev_dbg(&spi->dev, "read 0x%x from reg 0x%x\n", retval, addr);
+		dev_dbg(&spi->dev, "read 0x%x from reg 0x%x", retval, addr);
 #endif
 
 	return retval;
@@ -62,9 +62,9 @@ static int rf69_write_reg(struct spi_device *spi, u8 addr, u8 value)
 		 * that module is connected. Therefore no error
 		 * handling, just an optional error message...
 		 */
-		dev_dbg(&spi->dev, "write 0x%x to 0x%x FAILED\n", value, addr);
+		dev_dbg(&spi->dev, "write 0x%x to 0x%x FAILED", value, addr);
 	else
-		dev_dbg(&spi->dev, "wrote 0x%x to reg 0x%x\n", value, addr);
+		dev_dbg(&spi->dev, "wrote 0x%x to reg 0x%x", value, addr);
 #endif
 
 	return retval;
@@ -870,7 +870,7 @@ int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
 
 	if (size > FIFO_SIZE) {
 		dev_dbg(&spi->dev,
-			"read fifo: passed in buffer bigger then internal buffer\n");
+			"read fifo: passed in buffer bigger then internal buffer");
 		return -EMSGSIZE;
 	}
 
@@ -885,7 +885,7 @@ int rf69_read_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
 
 #ifdef DEBUG_FIFO_ACCESS
 	for (i = 0; i < size; i++)
-		dev_dbg(&spi->dev, "%d - 0x%x\n", i, local_buffer[i + 1]);
+		dev_dbg(&spi->dev, "%d - 0x%x", i, local_buffer[i + 1]);
 #endif
 
 	memcpy(buffer, &local_buffer[1], size);
@@ -902,7 +902,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
 
 	if (size > FIFO_SIZE) {
 		dev_dbg(&spi->dev,
-			"read fifo: passed in buffer bigger then internal buffer\n");
+			"read fifo: passed in buffer bigger then internal buffer");
 		return -EMSGSIZE;
 	}
 
@@ -911,7 +911,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, unsigned int size)
 
 #ifdef DEBUG_FIFO_ACCESS
 	for (i = 0; i < size; i++)
-		dev_dbg(&spi->dev, "0x%x\n", buffer[i]);
+		dev_dbg(&spi->dev, "0x%x", buffer[i]);
 #endif
 
 	return spi_write(spi, local_buffer, size + 1);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 26 lines · Paulo Miguel Almeida

In this driver there were occurences of '\n'-ended strings when using dev_dbg function which isn't required which most likely were leftovers from a previous printk/pr_<level> implementation.

This patch removes the extraneous '\n' characters to make it consistent with the other dev_dbg instances.

---
Patch dependencies:

The following patches must be applied first given that changes are made to the same set of files:

- https://lore.kernel.org/lkml/[email protected]/
- https://lore.kernel.org/lkml/[email protected]/

---
 drivers/staging/pi433/pi433_if.c | 14 +++++++-------
 drivers/staging/pi433/rf69.c     | 16 ++++++++--------
 2 files changed, 15 insertions(+), 15 deletions(-)
drivers/staging/pi433/pi433_if.c +0 -0
index 02d4ccebf..db1b092e8 100644

drivers/staging/pi433/pi433_if.c static irqreturn_t DIO0_irq_handler(int irq, void *dev_id) · line 127

Quoted 5 lines
drivers/staging/pi433/pi433_if.c +1 -1
@@ -124,13 +124,13 @@ static irqreturn_t DIO0_irq_handler(int irq, void *dev_id)
 
 	if (device->irq_state[DIO0] == DIO_PACKET_SENT) {
 		device->free_in_fifo = FIFO_SIZE;
-		dev_dbg(device->dev, "DIO0 irq: Packet sent\n");
+		dev_dbg(device->dev, "DIO0 irq: Packet sent");

Both the old and new code will do the same thing. You are correct. However in terms of style, I believe the preference is to add a newline.

I don't remember the reasoning behind this. But a lot of these style rules are just decided by consensus. If you do a
git grep -w dev_dbg | grep \;$ then it is 12391 places that add a new line and 622 which don't. Adding a newline is the clear winner.

regards,
dan carpenter

#2 lore raw
Quoted 8 lines · Dan Carpenter

drivers/staging/pi433/pi433_if.c static irqreturn_t DIO0_irq_handler(int irq, void *dev_id) · line 127

Quoted 4 lines
drivers/staging/pi433/pi433_if.c +1 -1
 	if (device->irq_state[DIO0] == DIO_PACKET_SENT) {
 		device->free_in_fifo = FIFO_SIZE;
-		dev_dbg(device->dev, "DIO0 irq: Packet sent\n");
+		dev_dbg(device->dev, "DIO0 irq: Packet sent");

Both the old and new code will do the same thing. You are correct. However in terms of style, I believe the preference is to add a newline.

Quoted 5 lines

I don't remember the reasoning behind this. But a lot of these style rules are just decided by consensus. If you do a
git grep -w dev_dbg | grep \;$ then it is 12391 places that add a new line and 622 which don't. Adding a newline is the clear winner.

it makes sense. I will send a different patch adding the newline escapes instead.

Thanks heaps!

Paulo Almeida