Fixes if-statement related warning and errors reported
by checkpatch.pl

Signed-off-by: Simo Koskinen <koskis...@gmail.com>
---
 drivers/staging/pi433/pi433_if.c | 253 +++++++++++++++++----------------------
 drivers/staging/pi433/rf69.c     |  69 ++++++-----
 2 files changed, 148 insertions(+), 174 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 1bc478a..3e4be2e 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -131,19 +131,14 @@ DIO0_irq_handler(unsigned int irq, void *dev_id, struct 
pt_regs *regs)
 {
        struct pi433_device *device = dev_id;
 
-       if      (device->irq_state[DIO0] == DIO_PacketSent)
-       {
+       if (device->irq_state[DIO0] == DIO_PacketSent) {
                device->free_in_fifo = FIFO_SIZE;
                printk("DIO0 irq: Packet sent\n"); // TODO: printk() should 
include KERN_ facility level
                wake_up_interruptible(&device->fifo_wait_queue);
-       }
-       else if (device->irq_state[DIO0] == DIO_Rssi_DIO0)
-       {
+       } else if (device->irq_state[DIO0] == DIO_Rssi_DIO0) {
                printk("DIO0 irq: RSSI level over threshold\n");
                wake_up_interruptible(&device->rx_wait_queue);
-       }
-       else if (device->irq_state[DIO0] == DIO_PayloadReady)
-       {
+       } else if (device->irq_state[DIO0] == DIO_PayloadReady) {
                printk("DIO0 irq: PayloadReady\n");
                device->free_in_fifo = 0;
                wake_up_interruptible(&device->fifo_wait_queue);
@@ -157,15 +152,15 @@ DIO1_irq_handler(unsigned int irq, void *dev_id, struct 
pt_regs *regs)
 {
        struct pi433_device *device = dev_id;
 
-       if      (device->irq_state[DIO1] == DIO_FifoNotEmpty_DIO1)
-       {
+       if (device->irq_state[DIO1] == DIO_FifoNotEmpty_DIO1) {
                device->free_in_fifo = FIFO_SIZE;
+       } else if (device->irq_state[DIO1] == DIO_FifoLevel) {
+               if (device->rx_active)
+                       device->free_in_fifo = FIFO_THRESHOLD - 1;
+               else
+                       device->free_in_fifo = FIFO_SIZE - FIFO_THRESHOLD - 1;
        }
-       else if (device->irq_state[DIO1] == DIO_FifoLevel)
-       {
-               if (device->rx_active)  device->free_in_fifo = FIFO_THRESHOLD - 
1;
-               else                    device->free_in_fifo = FIFO_SIZE - 
FIFO_THRESHOLD - 1;
-       }
+
        printk("DIO1 irq: %d bytes free in fifo\n", device->free_in_fifo); // 
TODO: printk() should include KERN_ facility level
        wake_up_interruptible(&device->fifo_wait_queue);
 
@@ -200,43 +195,38 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
        /* packet config */
        /* enable */
        SET_CHECKED(rf69_set_sync_enable(dev->spi, rx_cfg->enable_sync));
-       if (rx_cfg->enable_sync == optionOn)
-       {
+       if (rx_cfg->enable_sync == optionOn) {
                SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, 
afterSyncInterrupt));
-       }
-       else
-       {
+       } else {
                SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, always));
        }
+
        SET_CHECKED(rf69_set_packet_format  (dev->spi, 
rx_cfg->enable_length_byte));
        SET_CHECKED(rf69_set_adressFiltering(dev->spi, 
rx_cfg->enable_address_filtering));
        SET_CHECKED(rf69_set_crc_enable     (dev->spi, rx_cfg->enable_crc));
 
        /* lengths */
        SET_CHECKED(rf69_set_sync_size(dev->spi, rx_cfg->sync_length));
-       if (rx_cfg->enable_length_byte == optionOn)
-       {
+       if (rx_cfg->enable_length_byte == optionOn) {
                SET_CHECKED(rf69_set_payload_length(dev->spi, 0xff));
-       }
-       else if (rx_cfg->fixed_message_length != 0)
-       {
+       } else if (rx_cfg->fixed_message_length != 0) {
                payload_length = rx_cfg->fixed_message_length;
-               if (rx_cfg->enable_length_byte  == optionOn) payload_length++;
-               if (rx_cfg->enable_address_filtering != filteringOff) 
payload_length++;
+               if (rx_cfg->enable_length_byte == optionOn)
+                       payload_length++;
+               
+               if (rx_cfg->enable_address_filtering != filteringOff)
+                       payload_length++;
+
                SET_CHECKED(rf69_set_payload_length(dev->spi, payload_length));
-       }
-       else
-       {
+       } else {
                SET_CHECKED(rf69_set_payload_length(dev->spi, 0));
        }
 
        /* values */
        if (rx_cfg->enable_sync == optionOn)
-       {
                SET_CHECKED(rf69_set_sync_values(dev->spi, 
rx_cfg->sync_pattern));
-       }
-       if (rx_cfg->enable_address_filtering != filteringOff)
-       {
+
+       if (rx_cfg->enable_address_filtering != filteringOff) {
                SET_CHECKED(rf69_set_node_address     (dev->spi, 
rx_cfg->node_address));
                SET_CHECKED(rf69_set_broadcast_address(dev->spi, 
rx_cfg->broadcast_address));
        }
@@ -256,21 +246,18 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
        SET_CHECKED(rf69_set_tx_start_condition(dev->spi, 
tx_cfg->tx_start_condition));
 
        /* packet format enable */
-       if (tx_cfg->enable_preamble == optionOn)
-       {
+       if (tx_cfg->enable_preamble == optionOn) {
                SET_CHECKED(rf69_set_preamble_length(dev->spi, 
tx_cfg->preamble_length));
-       }
-       else
-       {
+       } else {
                SET_CHECKED(rf69_set_preamble_length(dev->spi, 0));
        }
+
        SET_CHECKED(rf69_set_sync_enable  (dev->spi, tx_cfg->enable_sync));
        SET_CHECKED(rf69_set_packet_format(dev->spi, 
tx_cfg->enable_length_byte));
        SET_CHECKED(rf69_set_crc_enable   (dev->spi, tx_cfg->enable_crc));
 
        /* configure sync, if enabled */
-       if (tx_cfg->enable_sync == optionOn)
-       {
+       if (tx_cfg->enable_sync == optionOn) {
                SET_CHECKED(rf69_set_sync_size(dev->spi, tx_cfg->sync_length));
                SET_CHECKED(rf69_set_sync_values(dev->spi, 
tx_cfg->sync_pattern));
        }
@@ -291,7 +278,8 @@ pi433_start_rx(struct pi433_device *dev)
 
        /* setup for receiving */
        retval = rf69_set_rx_cfg(dev, &dev->rx_cfg);
-       if (retval) return retval;
+       if (retval)
+               return retval;
 
        /* setup rssi irq */
        SET_CHECKED(rf69_set_dio_mapping(dev->spi, DIO0, DIO_Rssi_DIO0));
@@ -326,8 +314,7 @@ pi433_receive(void *data)
        /* wait for any tx to finish */
        dev_dbg(dev->dev,"rx: going to wait for any tx to finish");
        retval = wait_event_interruptible(dev->rx_wait_queue, !dev->tx_active);
-       if(retval) /* wait was interrupted */
-       {
+       if (retval) { /* wait was interrupted */
                dev->interrupt_rx_allowed = true;
                wake_up_interruptible(&dev->tx_wait_queue);
                return retval;
@@ -355,11 +342,14 @@ pi433_receive(void *data)
                retval = wait_event_interruptible(dev->rx_wait_queue,
                                                  rf69_get_flag(dev->spi,
                                                                
rssiExceededThreshold));
-               if (retval) goto abort; /* wait was interrupted */
+               if (retval)
+                       goto abort; /* wait was interrupted */
+
                dev->interrupt_rx_allowed = false;
 
                /* cross check for ongoing tx */
-               if (!dev->tx_active) break;
+               if (!dev->tx_active)
+                       break;
        }
 
        /* configure payload ready irq */
@@ -368,32 +358,27 @@ pi433_receive(void *data)
        irq_set_irq_type(dev->irq_num[DIO0], IRQ_TYPE_EDGE_RISING);
 
        /* fixed or unlimited length? */
-       if (dev->rx_cfg.fixed_message_length != 0)
-       {
-               if (dev->rx_cfg.fixed_message_length > dev->rx_buffer_size)
-               {
+       if (dev->rx_cfg.fixed_message_length != 0) {
+               if (dev->rx_cfg.fixed_message_length > dev->rx_buffer_size) {
                        retval = -1;
                        goto abort;
                }
                bytes_total = dev->rx_cfg.fixed_message_length;
                dev_dbg(dev->dev,"rx: msg len set to %d by fixed length", 
bytes_total);
-       }
-       else
-       {
+       } else {
                bytes_total = dev->rx_buffer_size;
                dev_dbg(dev->dev, "rx: msg len set to %d as requested by read", 
bytes_total);
        }
 
        /* length byte enabled? */
-       if (dev->rx_cfg.enable_length_byte == optionOn)
-       {
+       if (dev->rx_cfg.enable_length_byte == optionOn) {
                retval = wait_event_interruptible(dev->fifo_wait_queue,
                                                  dev->free_in_fifo < 
FIFO_SIZE);
-               if (retval) goto abort; /* wait was interrupted */
+               if (retval)
+                       goto abort; /* wait was interrupted */
 
                rf69_read_fifo(spi, (u8 *)&bytes_total, 1);
-               if (bytes_total > dev->rx_buffer_size)
-               {
+               if (bytes_total > dev->rx_buffer_size) {
                        retval = -1;
                        goto abort;
                }
@@ -402,15 +387,15 @@ pi433_receive(void *data)
        }
 
        /* address byte enabled? */
-       if (dev->rx_cfg.enable_address_filtering != filteringOff)
-       {
+       if (dev->rx_cfg.enable_address_filtering != filteringOff) {
                u8 dummy;
 
                bytes_total--;
 
                retval = wait_event_interruptible(dev->fifo_wait_queue,
                                                  dev->free_in_fifo < 
FIFO_SIZE);
-               if (retval) goto abort; /* wait was interrupted */
+               if (retval)
+                       goto abort; /* wait was interrupted */
 
                rf69_read_fifo(spi, &dummy, 1);
                dev->free_in_fifo++;
@@ -420,11 +405,11 @@ pi433_receive(void *data)
        /* get payload */
        while (dev->rx_position < bytes_total)
        {
-               if ( !rf69_get_flag(dev->spi, payloadReady) )
-               {
+               if (!rf69_get_flag(dev->spi, payloadReady)) {
                        retval = wait_event_interruptible(dev->fifo_wait_queue,
                                                          dev->free_in_fifo < 
FIFO_SIZE);
-                       if (retval) goto abort; /* wait was interrupted */
+                       if (retval)
+                               goto abort; /* wait was interrupted */
                }
 
                /* need to drop bytes or acquire? */
@@ -440,7 +425,9 @@ pi433_receive(void *data)
                retval = rf69_read_fifo(spi,
                                        &dev->rx_buffer[dev->rx_position],
                                        bytes_to_read);
-               if (retval) goto abort; /* read failed */
+               if (retval)
+                       goto abort; /* read failed */
+
                dev->free_in_fifo += bytes_to_read;
 
                /* adjust status vars */
@@ -482,7 +469,7 @@ pi433_tx_thread(void *data)
                wait_event_interruptible(device->tx_wait_queue,
                                         ( !kfifo_is_empty(&device->tx_fifo) ||
                                            kthread_should_stop() ));
-               if ( kthread_should_stop() )
+               if (kthread_should_stop())
                        return 0;
 
                /* get data from fifo in the following order:
@@ -492,17 +479,18 @@ pi433_tx_thread(void *data)
                mutex_lock(&device->tx_fifo_lock);
 
                retval = kfifo_out(&device->tx_fifo, &tx_cfg, sizeof(tx_cfg));
-               if (retval != sizeof(tx_cfg))
-               {
+               if (retval != sizeof(tx_cfg)) {
                        dev_dbg(device->dev, "reading tx_cfg from fifo failed: 
got %d byte(s), expected %d", retval, (unsigned int)sizeof(tx_cfg) );
                        mutex_unlock(&device->tx_fifo_lock);
                        continue;
                }
 
                retval = kfifo_out(&device->tx_fifo, &size, sizeof(size_t));
-               if (retval != sizeof(size_t))
-               {
-                       dev_dbg(device->dev, "reading msg size from fifo 
failed: got %d, expected %d", retval, (unsigned int)sizeof(size_t) );
+               if (retval != sizeof(size_t)) {
+                       dev_dbg(device->dev,
+                               "reading msg size from fifo failed: got %d, 
expected %d",
+                               retval, (unsigned int)sizeof(size_t) );
+
                        mutex_unlock(&device->tx_fifo_lock);
                        continue;
                }
@@ -550,8 +538,7 @@ pi433_tx_thread(void *data)
                disable_irq(device->irq_num[DIO0]);
                device->tx_active = true;
 
-               if (device->rx_active && rx_interrupted == false)
-               {
+               if (device->rx_active && rx_interrupted == false) {
                        /* rx is currently waiting for a telegram;
                           we need to set the radio module to standby */
                        SET_CHECKED(rf69_set_mode(device->spi, standby));
@@ -561,12 +548,9 @@ pi433_tx_thread(void *data)
                /* clear fifo, set fifo threshold, set payload length */
                SET_CHECKED(rf69_set_mode(spi, standby)); /* this clears the 
fifo */
                SET_CHECKED(rf69_set_fifo_threshold(spi, FIFO_THRESHOLD));
-               if (tx_cfg.enable_length_byte == optionOn)
-               {
+               if (tx_cfg.enable_length_byte == optionOn) {
                        SET_CHECKED(rf69_set_payload_length(spi, size * 
tx_cfg.repetitions));
-               }
-               else
-               {
+               } else {
                        SET_CHECKED(rf69_set_payload_length(spi, 0));
                }
 
@@ -593,17 +577,16 @@ pi433_tx_thread(void *data)
                repetitions = tx_cfg.repetitions;
                while( (repetitions > 0) && (size > position) )
                {
-                       if ( (size - position) > device->free_in_fifo)
-                       {       /* msg to big for fifo - take a part */
+                       if ((size - position) > device->free_in_fifo) {
+                               /* msg to big for fifo - take a part */
                                int temp = device->free_in_fifo;
                                device->free_in_fifo = 0;
                                rf69_write_fifo(spi,
                                                &buffer[position],
                                                temp);
                                position +=temp;
-                       }
-                       else
-                       {       /* msg fits into fifo - take all */
+                       } else {
+                               /* msg fits into fifo - take all */
                                device->free_in_fifo -= size;
                                repetitions--;
                                rf69_write_fifo(spi,
@@ -614,7 +597,10 @@ pi433_tx_thread(void *data)
 
                        retval = 
wait_event_interruptible(device->fifo_wait_queue,
                                                          device->free_in_fifo 
> 0);
-                       if (retval) { printk("ABORT\n"); goto abort; }
+                       if (retval) { 
+                               printk("ABORT\n"); 
+                               goto abort; 
+                       }
                }
 
                /* we are done. Wait for packet to get sent */
@@ -622,7 +608,8 @@ pi433_tx_thread(void *data)
                wait_event_interruptible(device->fifo_wait_queue,
                                         device->free_in_fifo == FIFO_SIZE ||
                                         kthread_should_stop() );
-               if ( kthread_should_stop() )    printk("ABORT\n");
+               if (kthread_should_stop())
+                       printk("ABORT\n");
 
 
                /* STOP_TRANSMISSION */
@@ -630,11 +617,9 @@ pi433_tx_thread(void *data)
                SET_CHECKED(rf69_set_mode(spi, standby));
 
                /* everything sent? */
-               if ( kfifo_is_empty(&device->tx_fifo) )
-               {
+               if (kfifo_is_empty(&device->tx_fifo)) {
 abort:
-                       if (rx_interrupted)
-                       {
+                       if (rx_interrupted) {
                                rx_interrupted = false;
                                pi433_start_rx(device);
                        }
@@ -663,13 +648,10 @@ pi433_read(struct file *filp, char __user *buf, size_t 
size, loff_t *f_pos)
 
        /* just one read request at a time */
        mutex_lock(&device->rx_lock);
-       if (device->rx_active)
-       {
+       if (device->rx_active) {
                mutex_unlock(&device->rx_lock);
                return -EAGAIN;
-       }
-       else
-       {
+       } else {
                device->rx_active = true;
                mutex_unlock(&device->rx_lock);
        }
@@ -685,8 +667,7 @@ pi433_read(struct file *filp, char __user *buf, size_t 
size, loff_t *f_pos)
        mutex_unlock(&device->rx_lock);
 
        /* if read was successful copy to user space*/
-       if (bytes_received > 0)
-       {
+       if (bytes_received > 0) {
                retval = copy_to_user(buf, device->rx_buffer, bytes_received);
                if (retval)
                        return retval;
@@ -717,11 +698,11 @@ pi433_write(struct file *filp, const char __user *buf,
           - message */
        mutex_lock(&device->tx_fifo_lock);
        retval = kfifo_in(&device->tx_fifo, &instance->tx_cfg, 
sizeof(instance->tx_cfg));
-       if ( retval != sizeof(instance->tx_cfg) )
+       if (retval != sizeof(instance->tx_cfg))
                goto abort;
 
        retval = kfifo_in (&device->tx_fifo, &count, sizeof(size_t));
-       if ( retval != sizeof(size_t) )
+       if (retval != sizeof(size_t))
                goto abort;
 
        retval = kfifo_from_user(&device->tx_fifo, buf, count, &copied);
@@ -785,16 +766,14 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
        switch (cmd) {
        case PI433_IOC_RD_TX_CFG:
                tmp = _IOC_SIZE(cmd);
-               if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-               {
+               if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
                        retval = -EINVAL;
                        break;
                }
 
                if (__copy_to_user((void __user *)arg,
                                    &instance->tx_cfg,
-                                   tmp))
-               {
+                                   tmp)) {
                        retval = -EFAULT;
                        break;
                }
@@ -802,16 +781,14 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
                break;
        case PI433_IOC_WR_TX_CFG:
                tmp = _IOC_SIZE(cmd);
-               if ( (tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0) )
-               {
+               if ((tmp == 0) || ((tmp % sizeof(struct pi433_tx_cfg)) != 0)) {
                        retval = -EINVAL;
                        break;
                }
 
                if (__copy_from_user(&instance->tx_cfg,
                                     (void __user *)arg,
-                                    tmp))
-               {
+                                    tmp)) {
                        retval = -EFAULT;
                        break;
                }
@@ -820,15 +797,14 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
 
        case PI433_IOC_RD_RX_CFG:
                tmp = _IOC_SIZE(cmd);
-               if ( (tmp == 0) || ((tmp % sizeof(struct pi433_rx_cfg)) != 0) ) 
{
+               if ((tmp == 0) || ((tmp % sizeof(struct pi433_rx_cfg)) != 0)) {
                        retval = -EINVAL;
                        break;
                }
 
                if (__copy_to_user((void __user *)arg,
                                   &device->rx_cfg,
-                                  tmp))
-               {
+                                  tmp)) {
                        retval = -EFAULT;
                        break;
                }
@@ -845,7 +821,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
                        break;
                }
 
-               if ( (tmp == 0) || ((tmp % sizeof(struct pi433_rx_cfg)) != 0) ) 
{
+               if ((tmp == 0) || ((tmp % sizeof(struct pi433_rx_cfg)) != 0)) {
                        retval = -EINVAL;
                        mutex_unlock(&device->rx_lock);
                        break;
@@ -853,8 +829,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
 
                if (__copy_from_user(&device->rx_cfg,
                                     (void __user *)arg,
-                                    tmp))
-               {
+                                    tmp)) {
                        retval = -EFAULT;
                        mutex_unlock(&device->rx_lock);
                        break;
@@ -896,8 +871,7 @@ 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)
-               {
+               if (!device->rx_buffer) {
                        dev_dbg(device->dev, "open/ENOMEM\n");
                        return -ENOMEM;
                }
@@ -905,8 +879,7 @@ static int pi433_open(struct inode *inode, struct file 
*filp)
 
        device->users++;
        instance = kzalloc(sizeof(*instance), GFP_KERNEL);
-       if (!instance)
-       {
+       if (!instance) {
                kfree(device->rx_buffer);
                device->rx_buffer = NULL;
                return -ENOMEM;
@@ -962,18 +935,20 @@ static int setup_GPIOs(struct pi433_device *device)
                snprintf(name, sizeof(name), "DIO%d", i);
                device->gpiod[i] = gpiod_get(&device->spi->dev, name, 0 
/*GPIOD_IN*/);
 
-               if (device->gpiod[i] == ERR_PTR(-ENOENT))
-               {
-                       dev_dbg(&device->spi->dev, "Could not find entry for 
%s. Ignoring.", name);
+               if (device->gpiod[i] == ERR_PTR(-ENOENT)) {
+                       dev_dbg(&device->spi->dev,
+                               "Could not find entry for %s. Ignoring.",
+                               name);
+
                        continue;
                }
 
                if (device->gpiod[i] == ERR_PTR(-EBUSY))
                        dev_dbg(&device->spi->dev, "%s is busy.", name);
 
-               if ( IS_ERR(device->gpiod[i]) )
-               {
+               if (IS_ERR(device->gpiod[i])) {
                        retval = PTR_ERR(device->gpiod[i]);
+
                        /* release already allocated gpios */
                        for (i--; i>=0; i--)
                        {
@@ -987,13 +962,13 @@ static int setup_GPIOs(struct pi433_device *device)
                /* configure the pin */
                gpiod_unexport(device->gpiod[i]);
                retval = gpiod_direction_input(device->gpiod[i]);
-               if (retval) return retval;
+               if (retval)
+                       return retval;
 
 
                /* configure irq */
                device->irq_num[i] = gpiod_to_irq(device->gpiod[i]);
-               if (device->irq_num[i] < 0)
-               {
+               if (device->irq_num[i] < 0) {
                        device->gpiod[i] = ERR_PTR(-EINVAL);//(struct gpio_desc 
*)device->irq_num[i];
                        return device->irq_num[i];
                }
@@ -1019,7 +994,7 @@ static void free_GPIOs(struct pi433_device *device)
        for (i=0; i<NUM_DIO; i++)
        {
                /* check if gpiod is valid */
-               if ( IS_ERR(device->gpiod[i]) )
+               if (IS_ERR(device->gpiod[i]))
                        continue;
 
                free_irq(device->irq_num[i], device);
@@ -1081,13 +1056,10 @@ static int pi433_probe(struct spi_device *spi)
        /* spi->max_speed_hz = 10000000;  1MHz already set by device tree 
overlay */
 
        retval = spi_setup(spi);
-       if (retval)
-       {
+       if (retval) {
                dev_dbg(&spi->dev, "configuration of SPI interface failed!\n");
                return retval;
-       }
-       else
-       {
+       } 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);
@@ -1133,8 +1105,7 @@ static int pi433_probe(struct spi_device *spi)
 
        /* setup GPIO (including irq_handler) for the different DIOs */
        retval = setup_GPIOs(device);
-       if (retval)
-       {
+       if (retval) {
                dev_dbg(&spi->dev, "setup of GPIOs failed");
                goto GPIO_failed;
        }
@@ -1152,16 +1123,14 @@ static int pi433_probe(struct spi_device *spi)
        device->tx_task_struct = kthread_run(pi433_tx_thread,
                                             device,
                                             "pi433_tx_task");
-       if (device->tx_task_struct < 0)
-       {
+       if (device->tx_task_struct < 0) {
                dev_dbg(device->dev, "start of send thread failed");
                goto send_thread_failed;
        }
 
        /* determ minor number */
        retval = pi433_get_minor(device);
-       if (retval)
-       {
+       if (retval) {
                dev_dbg(device->dev, "get of minor number failed");
                goto minor_failed;
        }
@@ -1177,8 +1146,7 @@ static int pi433_probe(struct spi_device *spi)
                pr_err("pi433: device register failed\n");
                retval = PTR_ERR(device->dev);
                goto device_create_failed;
-       }
-       else {
+       } else {
                dev_dbg(device->dev,
                        "created device for major %d, minor %d\n",
                        MAJOR(pi433_dev),
@@ -1190,8 +1158,7 @@ static int pi433_probe(struct spi_device *spi)
        device->cdev->owner = THIS_MODULE;
        cdev_init(device->cdev, &pi433_fops);
        retval = cdev_add(device->cdev, device->devt, 1);
-       if (retval)
-       {
+       if (retval) {
                dev_dbg(device->dev, "register of cdev failed");
                goto cdev_failed;
        }
@@ -1282,15 +1249,13 @@ static int __init pi433_init(void)
                return status;
 
        pi433_class = class_create(THIS_MODULE, "pi433");
-       if (IS_ERR(pi433_class))
-       {
+       if (IS_ERR(pi433_class)) {
                unregister_chrdev(MAJOR(pi433_dev), 
pi433_spi_driver.driver.name);
                return PTR_ERR(pi433_class);
        }
 
        status = spi_register_driver(&pi433_spi_driver);
-       if (status < 0)
-       {
+       if (status < 0) {
                class_destroy(pi433_class);
                unregister_chrdev(MAJOR(pi433_dev), 
pi433_spi_driver.driver.name);
        }
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index e391ce7..011cd1e 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -115,8 +115,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi, 
enum modShaping modShapi
                dev_dbg(&spi->dev, "set: mod shaping");
        #endif
 
-       if (rf69_get_modulation(spi) == FSK)
-       {
+       if (rf69_get_modulation(spi) == FSK) {
                switch (modShaping) {
                case shapingOff: return WRITE_REG(REG_DATAMODUL, 
(READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | 
DATAMODUL_MODULATION_SHAPE_NONE);
                case shaping1_0: return WRITE_REG(REG_DATAMODUL, 
(READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | 
DATAMODUL_MODULATION_SHAPE_1_0);
@@ -124,9 +123,7 @@ int rf69_set_modulation_shaping(struct spi_device *spi, 
enum modShaping modShapi
                case shaping0_3: return WRITE_REG(REG_DATAMODUL, 
(READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | 
DATAMODUL_MODULATION_SHAPE_0_5);
                default:         INVALID_PARAM;
                }
-       }
-       else
-       {
+       } else {
                switch (modShaping) {
                case shapingOff: return WRITE_REG(REG_DATAMODUL, 
(READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | 
DATAMODUL_MODULATION_SHAPE_NONE);
                case shapingBR:  return WRITE_REG(REG_DATAMODUL, 
(READ_REG(REG_DATAMODUL) & ~MASK_DATAMODUL_MODULATION_SHAPE) | 
DATAMODUL_MODULATION_SHAPE_BR);
@@ -150,8 +147,7 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
 
        // check input value
        bitRate_min = F_OSC / 8388608; // 8388608 = 2^23;
-       if (bitRate < bitRate_min)
-       {
+       if (bitRate < bitRate_min) {
                dev_dbg(&spi->dev, "setBitRate: illegal input param");
                INVALID_PARAM;
        }
@@ -164,9 +160,12 @@ int rf69_set_bit_rate(struct spi_device *spi, u16 bitRate)
 
        // transmit to RF 69
        retval = WRITE_REG(REG_BITRATE_MSB, msb);
-       if (retval)  return retval;
+       if (retval)
+               return retval;
+
        retval = WRITE_REG(REG_BITRATE_LSB, lsb);
-       if (retval)  return retval;
+       if (retval)
+               return retval;
 
        return 0;
 }
@@ -185,8 +184,8 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
                dev_dbg(&spi->dev, "set: deviation");
        #endif
 
-       if (deviation < 600 || deviation > 500000) //TODO: Abh�ngigkeit von 
Bitrate beachten!!
-       {
+       /* todo: abh�ngigkeit von bitrate beachten!! */
+       if (deviation < 600 || deviation > 500000) {
                dev_dbg(&spi->dev, "set_deviation: illegal input param");
                INVALID_PARAM;
        }
@@ -203,17 +202,19 @@ int rf69_set_deviation(struct spi_device *spi, u32 
deviation)
        lsb = (f_reg&0xff);
 
        // check msb
-       if (msb & !FDEVMASB_MASK)
-       {
+       if (msb & !FDEVMASB_MASK) {
                dev_dbg(&spi->dev, "set_deviation: err in calc of msb");
                INVALID_PARAM;
        }
 
        // write to chip
        retval = WRITE_REG(REG_FDEV_MSB, msb);
-       if (retval)  return retval;
+       if (retval)
+               return retval;
+
        retval = WRITE_REG(REG_FDEV_LSB, lsb);
-       if (retval)  return retval;
+       if (retval)
+               return retval;
 
        return 0;
 }
@@ -239,8 +240,7 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
 
        // check input value
        f_max = f_step * 8388608 / factor;
-       if (frequency > f_max)
-       {
+       if (frequency > f_max) {
                dev_dbg(&spi->dev, "setFrequency: illegal input param");
                INVALID_PARAM;
        }
@@ -255,11 +255,16 @@ int rf69_set_frequency(struct spi_device *spi, u32 
frequency)
 
        // write to chip
        retval = WRITE_REG(REG_FRF_MSB, msb);
-       if (retval)  return retval;
+       if (retval)
+               return retval;
+
        retval = WRITE_REG(REG_FRF_MID, mid);
-       if (retval)  return retval;
+       if (retval)
+               return retval;
+
        retval = WRITE_REG(REG_FRF_LSB, lsb);
-       if (retval)  return retval;
+       if (retval)
+              return retval;
 
        return 0;
 }
@@ -438,10 +443,13 @@ int rf69_set_bandwidth_intern(struct spi_device *spi, u8 
reg, enum mantisse mant
        u8 newValue;
 
        // check value for mantisse and exponent
-       if (exponent > 7)   INVALID_PARAM;
-       if ( (mantisse!=mantisse16) &&
-            (mantisse!=mantisse20) &&
-             (mantisse!=mantisse24) ) INVALID_PARAM;
+       if (exponent > 7)
+               INVALID_PARAM;
+
+       if ((mantisse != mantisse16) &&
+           (mantisse != mantisse20) &&
+           (mantisse != mantisse24))
+               INVALID_PARAM;
 
        // read old value
        newValue = READ_REG(reg);
@@ -546,7 +554,8 @@ int rf69_set_dio_mapping(struct spi_device *spi, u8 
DIONumber, u8 value)
        #endif
 
        // check DIO number
-       if (DIONumber > 5) INVALID_PARAM;
+       if (DIONumber > 5)
+               INVALID_PARAM;
 
        switch (DIONumber) {
        case 0: mask=MASK_DIO0; shift=SHIFT_DIO0; regaddr=REG_DIOMAPPING1; 
break;
@@ -659,7 +668,9 @@ int rf69_set_preamble_length(struct spi_device *spi, u16 
preambleLength)
 
        /* transmit to chip */
        retval = WRITE_REG(REG_PREAMBLE_MSB, msb);
-       if (retval) return retval;
+       if (retval)
+               return retval;
+       
        retval = WRITE_REG(REG_PREAMBLE_LSB, lsb);
 
        return retval;
@@ -874,8 +885,7 @@ int rf69_read_fifo (struct spi_device *spi, u8 *buffer, 
unsigned int size)
        u8 local_buffer[FIFO_SIZE + 1];
        int retval;
 
-       if (size > FIFO_SIZE)
-       {
+       if (size > FIFO_SIZE) {
                #ifdef DEBUG
                        dev_dbg(&spi->dev, "read fifo: passed in buffer bigger 
then internal buffer \n");
                #endif
@@ -909,8 +919,7 @@ int rf69_write_fifo(struct spi_device *spi, u8 *buffer, 
unsigned int size)
        char spi_address = REG_FIFO | WRITE_BIT;
        u8 local_buffer[FIFO_SIZE + 1];
 
-       if (size > FIFO_SIZE)
-       {
+       if (size > FIFO_SIZE) {
                #ifdef DEBUG
                        dev_dbg(&spi->dev, "read fifo: passed in buffer bigger 
then internal buffer \n");
                #endif
-- 
2.7.4

Reply via email to