Fix brace style of if-else case

Signed-off-by: Pushkar Jambhlekar <pushkar....@gmail.com>
---
 drivers/staging/pi433/pi433_if.c | 162 +++++++++++++--------------------------
 1 file changed, 54 insertions(+), 108 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index 93c0168..c070cf3 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -133,19 +133,16 @@ static irqreturn_t DIO0_irq_handler(int irq, void *dev_id)
 {
        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);
@@ -158,12 +155,10 @@ static irqreturn_t DIO1_irq_handler(int irq, void *dev_id)
 {
        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)
-       {
+       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;
        }
@@ -197,12 +192,10 @@ 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));
        }
        if (rx_cfg->enable_length_byte == optionOn) {
@@ -219,29 +212,24 @@ rf69_set_rx_cfg(struct pi433_device *dev, struct 
pi433_rx_cfg *rx_cfg)
 
        /* 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++;
                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)
-       {
+       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));
        }
@@ -263,12 +251,10 @@ 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));
@@ -284,8 +270,7 @@ rf69_set_tx_cfg(struct pi433_device *dev, struct 
pi433_tx_cfg *tx_cfg)
        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));
        }
@@ -341,8 +326,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;
@@ -383,32 +367,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 */
 
                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;
                }
@@ -417,8 +396,7 @@ 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--;
@@ -435,8 +413,7 @@ 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 */
@@ -508,16 +485,14 @@ 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))
-               {
+               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;
@@ -568,8 +543,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
                         */
@@ -580,12 +554,10 @@ 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));
                }
 
@@ -612,8 +584,7 @@ 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,
@@ -621,8 +592,7 @@ pi433_tx_thread(void *data)
                                                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,
@@ -649,11 +619,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);
                        }
@@ -682,13 +650,11 @@ 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);
        }
@@ -704,8 +670,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 -EFAULT;
@@ -805,16 +770,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;
                }
@@ -822,16 +785,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;
                }
@@ -847,8 +808,7 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned 
long arg)
 
                if (__copy_to_user((void __user *)arg,
                                   &device->rx_cfg,
-                                  tmp))
-               {
+                                  tmp)) {
                        retval = -EFAULT;
                        break;
                }
@@ -873,8 +833,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;
@@ -916,8 +875,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;
                }
@@ -925,8 +883,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;
@@ -986,8 +943,7 @@ 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))
-               {
+               if (device->gpiod[i] == ERR_PTR(-ENOENT)) {
                        dev_dbg(&device->spi->dev, "Could not find entry for 
%s. Ignoring.", name);
                        continue;
                }
@@ -995,8 +951,7 @@ static int setup_GPIOs(struct pi433_device *device)
                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--)
@@ -1016,8 +971,7 @@ static int setup_GPIOs(struct pi433_device *device)
 
                /* 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];
                }
@@ -1105,13 +1059,11 @@ 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);
@@ -1156,8 +1108,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;
        }
@@ -1175,16 +1126,14 @@ static int pi433_probe(struct spi_device *spi)
        device->tx_task_struct = kthread_run(pi433_tx_thread,
                                             device,
                                             "pi433_tx_task");
-       if (IS_ERR(device->tx_task_struct))
-       {
+       if (IS_ERR(device->tx_task_struct)) {
                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;
        }
@@ -1213,8 +1162,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;
        }
@@ -1306,15 +1254,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);
        }
-- 
2.7.4

Reply via email to