2017-12-19 14:57:34

by Valentin Vidic

[permalink] [raw]
Subject: [PATCH 1/6 v5] staging: pi433: collapse else block after return statement

Fixes checkpatch warning:

WARNING: else is not generally useful after a break or return

Signed-off-by: Valentin Vidic <[email protected]>
---
v5: resend patchset based on comments

drivers/staging/pi433/pi433_if.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index b4e6094ad553..02887988d2ea 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -773,11 +773,11 @@ pi433_read(struct file *filp, char __user *buf, size_t size, loff_t *f_pos)
if (device->rx_active) {
mutex_unlock(&device->rx_lock);
return -EAGAIN;
- } else {
- device->rx_active = true;
- mutex_unlock(&device->rx_lock);
}

+ device->rx_active = true;
+ mutex_unlock(&device->rx_lock);
+
/* start receiving */
/* will block until something was received*/
device->rx_buffer_size = size;
@@ -1117,12 +1117,12 @@ static int pi433_probe(struct spi_device *spi)
if (retval) {
dev_dbg(&spi->dev, "configuration of SPI interface failed!\n");
return retval;
- } else {
- dev_dbg(&spi->dev,
- "spi interface setup: mode 0x%2x, %d bits per word, %dhz max speed",
- spi->mode, spi->bits_per_word, spi->max_speed_hz);
}

+ dev_dbg(&spi->dev,
+ "spi interface setup: mode 0x%2x, %d bits per word, %dhz max speed",
+ spi->mode, spi->bits_per_word, spi->max_speed_hz);
+
/* Ping the chip by reading the version register */
retval = spi_w8r8(spi, 0x10);
if (retval < 0)
--
2.15.0


2017-12-19 14:56:40

by Valentin Vidic

[permalink] [raw]
Subject: [PATCH 4/6 v5] staging: pi433: avoid logging ENOMEM messages

Fixes checkpatch warning:

WARNING: Possible unnecessary 'out of memory' message

Signed-off-by: Valentin Vidic <[email protected]>
---
v5: resend patchset based on comments

drivers/staging/pi433/pi433_if.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 6e147cd351c7..287bfa4e270f 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -937,10 +937,8 @@ static int pi433_open(struct inode *inode, struct file *filp)

if (!device->rx_buffer) {
device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL);
- if (!device->rx_buffer) {
- dev_dbg(device->dev, "open/ENOMEM\n");
+ if (!device->rx_buffer)
return -ENOMEM;
- }
}

device->users++;
--
2.15.0

2017-12-19 14:56:46

by Valentin Vidic

[permalink] [raw]
Subject: [PATCH 3/6 v5] staging: pi433: replace unsigned with unsigned int

Fixes checkpatch warning:

WARNING: Prefer 'unsigned int' to bare use of 'unsigned'

Signed-off-by: Valentin Vidic <[email protected]>
---
v5: resend patchset based on comments

drivers/staging/pi433/pi433_if.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 86709a7100ad..6e147cd351c7 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -78,7 +78,7 @@ struct pi433_device {
struct device *dev;
struct cdev *cdev;
struct spi_device *spi;
- unsigned users;
+ unsigned int users;

/* irq related values */
struct gpio_desc *gpiod[NUM_DIO];
--
2.15.0

2017-12-19 14:56:44

by Valentin Vidic

[permalink] [raw]
Subject: [PATCH 2/6 v5] staging: pi433: cleanup local variable declaration

Fix variable naming and checkpatch warning:

WARNING: Missing a blank line after declarations

Signed-off-by: Valentin Vidic <[email protected]>
---
v5: resend patchset based on comments

drivers/staging/pi433/pi433_if.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 02887988d2ea..86709a7100ad 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -699,13 +699,15 @@ pi433_tx_thread(void *data)
repetitions = tx_cfg.repetitions;
while ((repetitions > 0) && (size > position)) {
if ((size - position) > device->free_in_fifo) {
+ int write_size;
+
/* msg to big for fifo - take a part */
- int temp = device->free_in_fifo;
+ write_size = device->free_in_fifo;
device->free_in_fifo = 0;
rf69_write_fifo(spi,
&buffer[position],
- temp);
- position += temp;
+ write_size);
+ position += write_size;
} else {
/* msg fits into fifo - take all */
device->free_in_fifo -= size;
--
2.15.0

2017-12-19 14:57:32

by Valentin Vidic

[permalink] [raw]
Subject: [PATCH 5/6 v5] staging: pi433: replace printk calls with dev_dbg

Fixes checkpatch warning:

WARNING: printk() should include KERN_<LEVEL> facility level

Signed-off-by: Valentin Vidic <[email protected]>
---
v5: resend patchset based on comments

drivers/staging/pi433/pi433_if.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 287bfa4e270f..1aa83cb3f15a 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -721,7 +721,7 @@ pi433_tx_thread(void *data)
retval = wait_event_interruptible(device->fifo_wait_queue,
device->free_in_fifo > 0);
if (retval) {
- printk("ABORT\n");
+ dev_dbg(device->dev, "ABORT\n");
goto abort;
}
}
@@ -732,7 +732,7 @@ pi433_tx_thread(void *data)
device->free_in_fifo == FIFO_SIZE ||
kthread_should_stop());
if (kthread_should_stop())
- printk("ABORT\n");
+ dev_dbg(device->dev, "ABORT\n");

/* STOP_TRANSMISSION */
dev_dbg(device->dev, "thread: Packet sent. Set mode to stby.");
--
2.15.0

2017-12-19 14:57:30

by Valentin Vidic

[permalink] [raw]
Subject: [PATCH 6/6 v5] staging: pi433: remove unused function

As it turns out rf69_get_lna_gain is not used at all.

Signed-off-by: Valentin Vidic <[email protected]>
---
v5: resend patchset based on comments

drivers/staging/pi433/rf69.c | 18 ------------------
drivers/staging/pi433/rf69.h | 1 -
2 files changed, 19 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index d777e31688ad..f58b925bb1da 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -334,24 +334,6 @@ int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain)
}
}

-enum lnaGain rf69_get_lna_gain(struct spi_device *spi)
-{
- u8 currentValue;
-
- currentValue = rf69_read_reg(spi, REG_LNA);
-
- switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define
- case LNA_GAIN_AUTO: return automatic;
- case LNA_GAIN_MAX: return max;
- case LNA_GAIN_MAX_MINUS_6: return maxMinus6;
- case LNA_GAIN_MAX_MINUS_12: return maxMinus12;
- case LNA_GAIN_MAX_MINUS_24: return maxMinus24;
- case LNA_GAIN_MAX_MINUS_36: return maxMinus36;
- case LNA_GAIN_MAX_MINUS_48: return maxMinus48;
- default: return undefined;
- }
-}
-
int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dcc_percent dcc_percent)
{
switch (dcc_percent) {
diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h
index 079acbd8a366..e90228a0ca29 100644
--- a/drivers/staging/pi433/rf69.h
+++ b/drivers/staging/pi433/rf69.h
@@ -39,7 +39,6 @@ int rf69_set_output_power_level(struct spi_device *spi, u8 powerLevel);
int rf69_set_pa_ramp(struct spi_device *spi, enum paRamp paRamp);
int rf69_set_antenna_impedance(struct spi_device *spi, enum antennaImpedance antennaImpedance);
int rf69_set_lna_gain(struct spi_device *spi, enum lnaGain lnaGain);
-enum lnaGain rf69_get_lna_gain(struct spi_device *spi);
int rf69_set_dc_cut_off_frequency_intern(struct spi_device *spi, u8 reg, enum dcc_percent dcc_percent);
int rf69_set_dc_cut_off_frequency(struct spi_device *spi, enum dcc_percent dcc_percent);
int rf69_set_dc_cut_off_frequency_during_afc(struct spi_device *spi, enum dcc_percent dcc_percent);
--
2.15.0