staging: pi433: collapse else block after return statement
PATCH v5 1/6 staging: pi433: collapse else block after return statement
Fixes checkpatch warning:
WARNING: else is not generally useful after a break or return
---
v5: resend patchset based on comments
drivers/staging/pi433/pi433_if.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/pi433/pi433_if.c +7 -7
@@ -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 )
Signature · 1 line
2.15.0
PATCH v5 2/6 staging: pi433: cleanup local variable declaration
Fix variable naming and checkpatch warning:
WARNING: Missing a blank line after declarations
---
v5: resend patchset based on comments
drivers/staging/pi433/pi433_if.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/staging/pi433/pi433_if.c +5 -3
@@ -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;
Signature · 1 line
2.15.0
PATCH v5 3/6 staging: pi433: replace unsigned with unsigned int
In reply to Valentin VidicFixes checkpatch warning:
WARNING: Prefer 'unsigned int' to bare use of 'unsigned'
---
v5: resend patchset based on comments
drivers/staging/pi433/pi433_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/pi433/pi433_if.c +1 -1
@@ -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 ];
Signature · 1 line
2.15.0
PATCH v5 4/6 staging: pi433: avoid logging ENOMEM messages
In reply to Valentin VidicFixes checkpatch warning:
WARNING: Possible unnecessary 'out of memory' message
---
v5: resend patchset based on comments
drivers/staging/pi433/pi433_if.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/pi433/pi433_if.c +1 -3
@@ -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++;
Signature · 1 line
2.15.0
PATCH v5 5/6 staging: pi433: replace printk calls with dev_dbg
In reply to Valentin VidicFixes checkpatch warning:
WARNING: printk() should include KERN_<LEVEL> facility level
---
v5: resend patchset based on comments
drivers/staging/pi433/pi433_if.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/pi433/pi433_if.c +2 -2
@@ -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." );
Signature · 1 line
2.15.0
PATCH v5 6/6 staging: pi433: remove unused function
In reply to Valentin VidicAs it turns out rf69_get_lna_gain is not used at all.
---
v5: resend patchset based on comments
drivers/staging/pi433/rf69.c | 18 ------------------ drivers/staging/pi433/rf69.h | 1 - 2 files changed, 19 deletions(-)
drivers/staging/pi433/rf69.c +0 -18
@@ -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) {
drivers/staging/pi433/rf69.h +0 -1
@@ -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);
Signature · 1 line
2.15.0