staging: wilc1000: simplified if conditions in spi_data_write()
authorAjay Singh <ajay.kathat@microchip.com>
Wed, 25 Apr 2018 17:18:12 +0000 (22:48 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 26 Apr 2018 07:43:04 +0000 (09:43 +0200)
Cleanup patch to simplify the if conditions logic in spi_data_write().

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wilc_spi.c

index 66ac7da4bb123c7478890cc8ff76375c8b9d6ead..c17f5d206e06f9790d9d751d2aaccb28de91d6c0 100644 (file)
@@ -617,28 +617,23 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 sz)
         */
        ix = 0;
        do {
-               if (sz <= DATA_PKT_SZ)
+               if (sz <= DATA_PKT_SZ) {
                        nbytes = sz;
-               else
+                       order = 0x3;
+               } else {
                        nbytes = DATA_PKT_SZ;
+                       if (ix == 0)
+                               order = 0x1;
+                       else
+                               order = 0x02;
+               }
 
                /*
                 * Write command
                 */
                cmd = 0xf0;
-               if (ix == 0) {
-                       if (sz <= DATA_PKT_SZ)
-
-                               order = 0x3;
-                       else
-                               order = 0x1;
-               } else {
-                       if (sz <= DATA_PKT_SZ)
-                               order = 0x3;
-                       else
-                               order = 0x2;
-               }
                cmd |= order;
+
                if (wilc_spi_tx(wilc, &cmd, 1)) {
                        dev_err(&spi->dev,
                                "Failed data block cmd write, bus error...\n");