lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <cddeb5c9-6f79-d0a4-9cd9-85a93c23cd8f@gmail.com>
Date:   Sat, 24 Sep 2016 18:08:34 +0200
From:   Marcel Xubuntu <fooglesucks@...il.com>
To:     gregkh@...uxfoundation.org, wsa@...-dreams.de,
        linux-kernel@...r.kernel.org
Subject: Fwd: Re: Patchwork [1/1] staging: ks7010: Attempt to structure and
 format to standards


Code formatting and structuring.

Signed-off-by: Marcel Ricquier <fooglesucks@...il.com>

---

Tested-by: Marcel Ricquier <fooglesucks@...il.com>

Mostly code formatting, unapologetically a stepping stone for a potential
refactoring with a knowledge seeking, following complete disclosure,
ultimate goal.
In case this fails, my backup plan is to have the world's record for the
quickest kernel patch dismissal, either way it's a win. Did I win ?!

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b7337fd..8de2713 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -14,7 +14,7 @@
   #include <linux/mmc/card.h>
   #include <linux/mmc/sdio_func.h>
   #include <linux/workqueue.h>
-#include <asm/atomic.h>
+#include <linux/atomic.h>

   #include "ks_wlan.h"
   #include "ks_wlan_ioctl.h"
@@ -35,18 +35,18 @@ MODULE_DEVICE_TABLE(sdio, ks7010_sdio_ids);
   /* macro */

   #define inc_txqhead(priv) \
-        ( priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % 
TX_DEVICE_BUFF_SIZE )
+    (priv->tx_dev.qhead = (priv->tx_dev.qhead + 1) % TX_DEVICE_BUFF_SIZE)
   #define inc_txqtail(priv) \
-        ( priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % 
TX_DEVICE_BUFF_SIZE )
+    (priv->tx_dev.qtail = (priv->tx_dev.qtail + 1) % TX_DEVICE_BUFF_SIZE)
   #define cnt_txqbody(priv) \
-        (((priv->tx_dev.qtail + TX_DEVICE_BUFF_SIZE) - 
(priv->tx_dev.qhead)) % TX_DEVICE_BUFF_SIZE )
+    (((priv->tx_dev.qtail + TX_DEVICE_BUFF_SIZE) - 
(priv->tx_dev.qhead)) % TX_DEVICE_BUFF_SIZE)

   #define inc_rxqhead(priv) \
-        ( priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % 
RX_DEVICE_BUFF_SIZE )
+    (priv->rx_dev.qhead = (priv->rx_dev.qhead + 1) % RX_DEVICE_BUFF_SIZE)
   #define inc_rxqtail(priv) \
-        ( priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % 
RX_DEVICE_BUFF_SIZE )
+    (priv->rx_dev.qtail = (priv->rx_dev.qtail + 1) % RX_DEVICE_BUFF_SIZE)
   #define cnt_rxqbody(priv) \
-        (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - 
(priv->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE )
+    (((priv->rx_dev.qtail + RX_DEVICE_BUFF_SIZE) - 
(priv->rx_dev.qhead)) % RX_DEVICE_BUFF_SIZE)

   static int ks7010_sdio_read(struct ks_wlan_private *priv, unsigned 
int address,
                   unsigned char *buffer, int length)
@@ -115,7 +115,6 @@ void ks_wlan_hw_sleep_doze_request(struct 
ks_wlan_private *priv)

    out:
       priv->sleep_mode = atomic_read(&priv->sleepstatus.status);
-    return;
   }

   void ks_wlan_hw_sleep_wakeup_request(struct ks_wlan_private *priv)
@@ -146,7 +145,6 @@ void ks_wlan_hw_sleep_wakeup_request(struct 
ks_wlan_private *priv)

    out:
       priv->sleep_mode = atomic_read(&priv->sleepstatus.status);
-    return;
   }

   void ks_wlan_hw_wakeup_request(struct ks_wlan_private *priv)
@@ -159,9 +157,8 @@ void ks_wlan_hw_wakeup_request(struct 
ks_wlan_private *priv)
           rw_data = WAKEUP_REQ;
           retval =
               ks7010_sdio_write(priv, WAKEUP, &rw_data, sizeof(rw_data));
-        if (retval) {
+        if (retval)
               DPRINTK(1, " error : WAKEUP=%02X\n", rw_data);
-        }
           DPRINTK(4, "wake up : WAKEUP=%02X\n", rw_data);
           priv->last_wakeup = jiffies;
           ++priv->wakeup_count;
@@ -182,8 +179,6 @@ int _ks_wlan_hw_power_save(struct ks_wlan_private *priv)

       if (priv->reg.operation_mode == MODE_INFRASTRUCTURE &&
           (priv->connect_status & CONNECT_STATUS_MASK) == CONNECT_STATUS) {
-
-  //DPRINTK(1,"psstatus.status=%d\n",atomic_read(&priv->psstatus.status));
           if (priv->dev_state == DEVICE_STATE_SLEEP) {
               switch (atomic_read(&priv->psstatus.status)) {
               case PS_SNOOZE:    /* 4 */
@@ -261,7 +256,7 @@ int ks_wlan_hw_power_save(struct ks_wlan_private *priv)

   static int enqueue_txdev(struct ks_wlan_private *priv, unsigned char *p,
                unsigned long size,
-             void (*complete_handler) (void *arg1, void *arg2),
+             void (*complete_handler)(void *arg1, void *arg2),
                void *arg1, void *arg2)
   {
       struct tx_device_buffer *sp;
@@ -300,6 +295,7 @@ static int write_to_device(struct ks_wlan_private 
*priv, unsigned char *buffer,
       int rc, retval;
       unsigned char rw_data;
       struct hostif_hdr *hdr;
+
       hdr = (struct hostif_hdr *)buffer;
       rc = 0;

@@ -358,15 +354,15 @@ static void tx_device_task(void *dev)
                          &priv->ks_wlan_hw.rw_wq, 0);
           }
       }
-    return;
   }

   int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned 
long size,
-          void (*complete_handler) (void *arg1, void *arg2),
+          void (*complete_handler)(void *arg1, void *arg2),
             void *arg1, void *arg2)
   {
       int result = 0;
       struct hostif_hdr *hdr;
+
       hdr = (struct hostif_hdr *)p;

       if (hdr->event < HIF_DATA_REQ || HIF_REQ_MAX < hdr->event) {
@@ -402,12 +398,9 @@ static void rx_event_task(unsigned long dev)
           hostif_receive(priv, rp->data, rp->size);
           inc_rxqhead(priv);

-        if (cnt_rxqbody(priv) > 0) {
+        if (cnt_rxqbody(priv) > 0)
               tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task);
-        }
       }
-
-    return;
   }

   static void ks_wlan_hw_rx(void *dev, uint16_t size)
@@ -424,7 +417,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
       /* receive data */
       if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) {
           /* in case of buffer overflow */
-        DPRINTK(1, "rx buffer overflow \n");
+        DPRINTK(1, "rx buffer overflow\n");
           goto error_out;
       }
       rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail];
@@ -432,9 +425,8 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
       retval =
           ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0],
                    hif_align_size(size));
-    if (retval) {
+    if (retval)
           goto error_out;
-    }

       /* length check */
       if (size > 2046 || size == 0) {
@@ -446,12 +438,10 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
   #endif
           /* rx_status update */
           read_status = READ_STATUS_IDLE;
-        retval =
-            ks7010_sdio_write(priv, READ_STATUS, &read_status,
-                      sizeof(read_status));
-        if (retval) {
+        retval = ks7010_sdio_write(priv, READ_STATUS, &read_status,
+                sizeof(read_status));
+        if (retval)
               DPRINTK(1, " error : READ_STATUS=%02X\n", read_status);
-        }
           goto error_out;
       }

@@ -462,12 +452,10 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)

       /* read status update */
       read_status = READ_STATUS_IDLE;
-    retval =
-        ks7010_sdio_write(priv, READ_STATUS, &read_status,
-                  sizeof(read_status));
-    if (retval) {
+    retval = ks7010_sdio_write(priv, READ_STATUS, &read_status,
+                sizeof(read_status));
+    if (retval)
           DPRINTK(1, " error : READ_STATUS=%02X\n", read_status);
-    }
       DPRINTK(4, "READ_STATUS=%02X\n", read_status);

       if (atomic_read(&priv->psstatus.confirm_wait)) {
@@ -496,20 +484,17 @@ static void ks7010_rw_function(struct work_struct 
*work)

       DPRINTK(4, "\n");

-    /* wiat after DOZE */
+    /* wait after DOZE */
       if (time_after(priv->last_doze + ((30 * HZ) / 1000), jiffies)) {
-        DPRINTK(4, "wait after DOZE \n");
+        DPRINTK(4, "wait after DOZE\n");
           queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
                      &priv->ks_wlan_hw.rw_wq, 1);
-        return;
       }

-    /* wiat after WAKEUP */
+    /* wait after WAKEUP */
       while (time_after(priv->last_wakeup + ((30 * HZ) / 1000), jiffies)) {
-        DPRINTK(4, "wait after WAKEUP \n");
-/* 
queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,&priv->ks_wlan_hw.rw_wq,
-        (priv->last_wakeup + ((30*HZ)/1000) - jiffies));*/
-        printk("wake: %lu %lu\n", priv->last_wakeup + (30 * HZ) / 1000,
+        DPRINTK(4, "wait after WAKEUP\n");
+        pr_info("wake: %lu %lu\n", priv->last_wakeup + (30 * HZ) / 1000,
                  jiffies);
           msleep(30);
       }
@@ -551,15 +536,12 @@ static void ks7010_rw_function(struct work_struct 
*work)
           ks_wlan_hw_rx((void *)priv,
                     (uint16_t) (((rw_data & RSIZE_MASK) << 4)));
       }
-    if ((rw_data & WSTATUS_MASK)) {
+    if ((rw_data & WSTATUS_MASK))
           tx_device_task((void *)priv);
-    }
       _ks_wlan_hw_power_save(priv);

    err_out:
       sdio_release_host(priv->ks_wlan_hw.sdio_card->func);
-
-    return;
   }

   static void ks_sdio_interrupt(struct sdio_func *func)
@@ -644,19 +626,19 @@ static void ks_sdio_interrupt(struct sdio_func *func)
                       status &= ~INT_WRITE_STATUS;
                   } else {
   #endif
-                    if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
-                        if (cnt_txqbody(priv)) {
-                            ks_wlan_hw_wakeup_request(priv);
-                            queue_delayed_work
-                                (priv->ks_wlan_hw.
-                                 ks7010sdio_wq,
-                                 &priv->ks_wlan_hw.
-                                 rw_wq, 1);
-                            return;
-                        }
-                    } else {
-                        tx_device_task((void *)priv);
+                if (atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
+                    if (cnt_txqbody(priv)) {
+                        ks_wlan_hw_wakeup_request(priv);
+                        queue_delayed_work
+                            (priv->ks_wlan_hw.
+                             ks7010sdio_wq,
+                             &priv->ks_wlan_hw.
+                             rw_wq, 1);
+                        return;
                       }
+                } else {
+                    tx_device_task((void *)priv);
+                }
   #if 0
                   }
   #endif
@@ -667,7 +649,6 @@ static void ks_sdio_interrupt(struct sdio_func *func)
    intr_out:
       queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
                  &priv->ks_wlan_hw.rw_wq, 0);
-    return;
   }

   static int trx_device_init(struct ks_wlan_private *priv)
@@ -702,8 +683,6 @@ static void trx_device_exit(struct ks_wlan_private 
*priv)
       }

       tasklet_kill(&priv->ks_wlan_hw.rx_bh_task);
-
-    return;
   }

   static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 
index)
@@ -711,6 +690,7 @@ static int ks7010_sdio_update_index(struct 
ks_wlan_private *priv, u32 index)
       int rc = 0;
       int retval;
       unsigned char *data_buf;
+
       data_buf = NULL;

       data_buf = kmalloc(sizeof(u32), GFP_KERNEL);
@@ -732,8 +712,7 @@ static int ks7010_sdio_update_index(struct 
ks_wlan_private *priv, u32 index)
           goto error_out;
       }
    error_out:
-    if (data_buf)
-        kfree(data_buf);
+    kfree(data_buf);
       return rc;
   }

@@ -744,6 +723,7 @@ static int ks7010_sdio_data_compare(struct 
ks_wlan_private *priv, u32 address,
       int rc = 0;
       int retval;
       unsigned char *read_buf;
+
       read_buf = NULL;
       read_buf = kmalloc(ROM_BUFF_SIZE, GFP_KERNEL);
       if (!read_buf) {
@@ -758,13 +738,12 @@ static int ks7010_sdio_data_compare(struct 
ks_wlan_private *priv, u32 address,
       retval = memcmp(data, read_buf, size);

       if (retval) {
-        DPRINTK(0, "data compare error (%d) \n", retval);
+        DPRINTK(0, "data compare error (%d)\n", retval);
           rc = 3;
           goto error_out;
       }
    error_out:
-    if (read_buf)
-        kfree(read_buf);
+    kfree(read_buf);
       return rc;
   }

@@ -879,8 +858,7 @@ static int ks7010_upload_firmware(struct 
ks_wlan_private *priv,
       release_firmware(fw_entry);
    error_out0:
       sdio_release_host(card->func);
-    if (rom_buf)
-        kfree(rom_buf);
+    kfree(rom_buf);
       return rc;
   }

@@ -903,9 +881,8 @@ static void ks7010_card_init(struct ks_wlan_private 
*priv)
           DPRINTK(1, "wait time out!! SME_START\n");
       }

-    if (priv->mac_address_valid && priv->version_size) {
+    if (priv->mac_address_valid && priv->version_size)
           priv->dev_state = DEVICE_STATE_PREINIT;
-    }

       hostif_sme_enqueue(priv, SME_GET_EEPROM_CKSUM);

@@ -1024,17 +1001,17 @@ static int ks7010_sdio_probe(struct sdio_func *func,

       sdio_set_drvdata(func, card);

-    DPRINTK(5, "class = 0x%X, vendor = 0x%X, "
-        "device = 0x%X\n", func->class, func->vendor, func->device);
+    DPRINTK(5, "class = 0x%X, vendor = 0x%X, device = 0x%X\n",
+        func->class, func->vendor, func->device);

       /* private memory allocate */
       netdev = alloc_etherdev(sizeof(*priv));
       if (netdev == NULL) {
-        printk(KERN_ERR "ks7010 : Unable to alloc new net device\n");
+        pr_err("ks7010 : Unable to alloc new net device\n");
           goto error_release_irq;
       }
       if (dev_alloc_name(netdev, "wlan%d") < 0) {
-        printk(KERN_ERR "ks7010 :  Couldn't get name!\n");
+        pr_err("ks7010 :  Couldn't get name!\n");
           goto error_free_netdev;
       }

@@ -1048,9 +1025,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,
       init_completion(&priv->ks_wlan_hw.ks7010_sdio_wait);
       priv->ks_wlan_hw.read_buf = NULL;
       priv->ks_wlan_hw.read_buf = kmalloc(RX_DATA_SIZE, GFP_KERNEL);
-    if (!priv->ks_wlan_hw.read_buf) {
+    if (!priv->ks_wlan_hw.read_buf)
           goto error_free_netdev;
-    }
       priv->dev_state = DEVICE_STATE_PREBOOT;
       priv->net_dev = netdev;
       priv->firmware_version[0] = '\0';
@@ -1074,9 +1050,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
       /* Upload firmware */
       ret = ks7010_upload_firmware(priv, card);    /* firmware load */
       if (ret) {
-        printk(KERN_ERR
-               "ks7010: firmware load failed !! retern code = %d\n",
-               ret);
+        pr_err("ks7010: firmware load failed !! return code = %d\n", ret);
           goto error_free_read_buf;
       }

@@ -1086,9 +1060,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,
       sdio_claim_host(func);
       ret = ks7010_sdio_write(priv, INT_PENDING, &rw_data, 
sizeof(rw_data));
       sdio_release_host(func);
-    if (ret) {
+    if (ret)
           DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data);
-    }
       DPRINTK(4, " clear Interrupt : INT_PENDING=%02X\n", rw_data);

       /* enable ks7010sdio interrupt 
(INT_GCR_B|INT_READ_STATUS|INT_WRITE_STATUS) */
@@ -1096,9 +1069,8 @@ static int ks7010_sdio_probe(struct sdio_func *func,
       sdio_claim_host(func);
       ret = ks7010_sdio_write(priv, INT_ENABLE, &rw_data, sizeof(rw_data));
       sdio_release_host(func);
-    if (ret) {
+    if (ret)
           DPRINTK(1, " error : INT_ENABLE=%02X\n", rw_data);
-    }
       DPRINTK(4, " enable Interrupt : INT_ENABLE=%02X\n", rw_data);
       priv->dev_state = DEVICE_STATE_BOOT;

@@ -1142,6 +1114,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)
       struct ks_sdio_card *card;
       struct ks_wlan_private *priv;
       struct net_device *netdev;
+
       DPRINTK(1, "ks7010_sdio_remove()\n");

       card = sdio_get_drvdata(func);
@@ -1166,6 +1139,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)
           /* send stop request to MAC */
           {
               struct hostif_stop_request_t *pp;
+
               pp = (struct hostif_stop_request_t *)
                   kzalloc(hif_align_size(sizeof(*pp)), GFP_KERNEL);
               if (pp == NULL) {
@@ -1199,9 +1173,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)
           unregister_netdev(netdev);

           trx_device_exit(priv);
-        if (priv->ks_wlan_hw.read_buf) {
-            kfree(priv->ks_wlan_hw.read_buf);
-        }
+        kfree(priv->ks_wlan_hw.read_buf);
           free_netdev(priv->net_dev);
           card->priv = NULL;
       }
@@ -1219,7 +1191,6 @@ static void ks7010_sdio_remove(struct sdio_func *func)
       DPRINTK(1, "kfree()\n");

       DPRINTK(5, " Bye !!\n");
-    return;
   }

   static struct sdio_driver ks7010_sdio_driver = {
diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index a8822fe..3334eb5 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -22,7 +22,7 @@

   extern int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p,
                unsigned long size,
-             void (*complete_handler) (void *arg1, void *arg2),
+             void (*complete_handler)(void *arg1, void *arg2),
                void *arg1, void *arg2);
   extern void send_packet_complete(void *, void *);

@@ -31,11 +31,11 @@ extern int ks_wlan_hw_power_save(struct 
ks_wlan_private *priv);

   /* macro */
   #define inc_smeqhead(priv) \
-        ( priv->sme_i.qhead = (priv->sme_i.qhead + 1) % 
SME_EVENT_BUFF_SIZE )
+    (priv->sme_i.qhead = (priv->sme_i.qhead + 1) % SME_EVENT_BUFF_SIZE)
   #define inc_smeqtail(priv) \
-        ( priv->sme_i.qtail = (priv->sme_i.qtail + 1) % 
SME_EVENT_BUFF_SIZE )
+    (priv->sme_i.qtail = (priv->sme_i.qtail + 1) % SME_EVENT_BUFF_SIZE)
   #define cnt_smeqbody(priv) \
-        (((priv->sme_i.qtail + SME_EVENT_BUFF_SIZE) - 
(priv->sme_i.qhead)) % SME_EVENT_BUFF_SIZE )
+    (((priv->sme_i.qtail + SME_EVENT_BUFF_SIZE) - (priv->sme_i.qhead)) 
% SME_EVENT_BUFF_SIZE)

   #define KS_WLAN_MEM_FLAG (GFP_ATOMIC)

@@ -43,6 +43,7 @@ static
   inline u8 get_BYTE(struct ks_wlan_private *priv)
   {
       u8 data;
+
       data = *(priv->rxp)++;
       /* length check in advance ! */
       --(priv->rx_size);
@@ -53,6 +54,7 @@ static
   inline u16 get_WORD(struct ks_wlan_private *priv)
   {
       u16 data;
+
       data = (get_BYTE(priv) & 0xff);
       data |= ((get_BYTE(priv) << 8) & 0xff00);
       return data;
@@ -62,6 +64,7 @@ static
   inline u32 get_DWORD(struct ks_wlan_private *priv)
   {
       u32 data;
+
       data = (get_BYTE(priv) & 0xff);
       data |= ((get_BYTE(priv) << 8) & 0x0000ff00);
       data |= ((get_BYTE(priv) << 16) & 0x00ff0000);
@@ -240,13 +243,13 @@ int get_ap_information(struct ks_wlan_private 
*priv, struct ap_info_t *ap_info,
       offset = 0;

       while (bsize > offset) {
-        /* DPRINTK(4, "Element ID=%d \n",*bp); */
+        /* DPRINTK(4, "Element ID=%d\n",*bp); */
           switch (*bp) {
           case 0:    /* ssid */
               if (*(bp + 1) <= SSID_MAX_SIZE) {
                   ap->ssid.size = *(bp + 1);
               } else {
-                DPRINTK(1, "size over :: ssid size=%d \n",
+                DPRINTK(1, "size over :: ssid size=%d\n",
                       *(bp + 1));
                   ap->ssid.size = SSID_MAX_SIZE;
               }
@@ -260,7 +263,7 @@ int get_ap_information(struct ks_wlan_private *priv, 
struct ap_info_t *ap_info,
                          bp + 2, *(bp + 1));
                   ap->rate_set.size += *(bp + 1);
               } else {
-                DPRINTK(1, "size over :: rate size=%d \n",
+                DPRINTK(1, "size over :: rate size=%d\n",
                       (*(bp + 1) + ap->rate_set.size));
   memcpy(&(ap->rate_set.body[ap->rate_set.size]),
                          bp + 2,
@@ -276,7 +279,7 @@ int get_ap_information(struct ks_wlan_private *priv, 
struct ap_info_t *ap_info,
               if (*(bp + 1) <= RSN_IE_BODY_MAX) {
                   ap->rsn_ie.size = *(bp + 1);
               } else {
-                DPRINTK(1, "size over :: rsn size=%d \n",
+                DPRINTK(1, "size over :: rsn size=%d\n",
                       *(bp + 1));
                   ap->rsn_ie.size = RSN_IE_BODY_MAX;
               }
@@ -289,7 +292,7 @@ int get_ap_information(struct ks_wlan_private *priv, 
struct ap_info_t *ap_info,
                       ap->wpa_ie.size = *(bp + 1);
                   } else {
                       DPRINTK(1,
-                        "size over :: wpa size=%d \n",
+                        "size over :: wpa size=%d\n",
                           *(bp + 1));
                       ap->wpa_ie.size = RSN_IE_BODY_MAX;
                   }
@@ -307,7 +310,7 @@ int get_ap_information(struct ks_wlan_private *priv, 
struct ap_info_t *ap_info,
           case 47:    /* Reserve ID 47 Broadcom AP */
               break;
           default:
-            DPRINTK(4, "unknown Element ID=%d \n", *bp);
+            DPRINTK(4, "unknown Element ID=%d\n", *bp);
               break;
           }
           offset += 2;    /* id & size field */
@@ -404,7 +407,7 @@ void hostif_data_indication(struct ks_wlan_private 
*priv)
                           HZ >= 60) {
                           mic_failure->failure = 0;
                       }
-                    DPRINTK(4, "MIC FAILURE \n");
+                    DPRINTK(4, "MIC FAILURE\n");
                       if (mic_failure->failure == 0) {
                           mic_failure->failure = 1;
                           mic_failure->counter = 0;
@@ -423,8 +426,7 @@ void hostif_data_indication(struct ks_wlan_private 
*priv)
                           last_failure_time = now;
                       /*  needed parameters: count, keyid, key type, TSC */
                       sprintf(buf,
-                        "MLME-MICHAELMICFAILURE.indication(keyid=%d 
%scast addr="
-                        "%02x:%02x:%02x:%02x:%02x:%02x)",
+                        "MLME-MICHAELMICFAILURE.indication(keyid=%d 
%scast addr=%02x:%02x:%02x:%02x:%02x:%02x)",
                           auth_type - 1,
                           eth_hdr->
                           h_dest[0] & 0x01 ? "broad" :
@@ -556,7 +558,7 @@ void hostif_mib_get_confirm(struct ks_wlan_private 
*priv)
           /* MAC address */
           DPRINTK(3, " mib_attribute=DOT11_MAC_ADDRESS\n");
           hostif_sme_enqueue(priv, SME_GET_MAC_ADDRESS);
-        memcpy(priv->eth_addr, priv->rxp, ETH_ALEN);
+        ether_addr_copy(priv->eth_addr, priv->rxp);
           priv->mac_address_valid = 1;
           dev->dev_addr[0] = priv->eth_addr[0];
           dev->dev_addr[1] = priv->eth_addr[1];
@@ -772,8 +774,9 @@ void hostif_sleep_confirm(struct ks_wlan_private *priv)
   static
   void hostif_start_confirm(struct ks_wlan_private *priv)
   {
-#ifdef  WPS
+#ifdef WPS
       union iwreq_data wrqu;
+
       wrqu.data.length = 0;
       wrqu.data.flags = 0;
       wrqu.ap_addr.sa_family = ARPHRD_ETHER;
@@ -795,6 +798,7 @@ void hostif_connect_indication(struct 
ks_wlan_private *priv)
       unsigned int old_status = priv->connect_status;
       struct net_device *netdev = priv->net_dev;
       union iwreq_data wrqu0;
+
       connect_code = get_WORD(priv);

       switch (connect_code) {
@@ -934,6 +938,7 @@ static
   void hostif_infrastructure_set_confirm(struct ks_wlan_private *priv)
   {
       uint16_t result_code;
+
       DPRINTK(3, "\n");
       result_code = get_WORD(priv);
       DPRINTK(3, "result code = %d\n", result_code);
@@ -999,6 +1004,7 @@ void hostif_bss_scan_confirm(struct ks_wlan_private 
*priv)
       unsigned int result_code;
       struct net_device *dev = priv->net_dev;
       union iwreq_data wrqu;
+
       result_code = get_DWORD(priv);
       DPRINTK(2, "result=%d :: scan_ind_count=%d\n", result_code,
           priv->scan_ind_count);
@@ -1148,7 +1154,7 @@ int hostif_data_request(struct ks_wlan_private 
*priv, struct sk_buff *packet)

       packet_len = packet->len;
       if (packet_len > ETH_FRAME_LEN) {
-        DPRINTK(1, "bad length packet_len=%d \n", packet_len);
+        DPRINTK(1, "bad length packet_len=%d\n", packet_len);
           dev_kfree_skb(packet);
           return -1;
       }
@@ -1249,7 +1255,7 @@ int hostif_data_request(struct ks_wlan_private 
*priv, struct sk_buff *packet)
               pp->auth_type = cpu_to_le16((uint16_t) TYPE_AUTH);  /* no 
encryption */
           } else {
               if (priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP) {
-                MichaelMICFunction(&michel_mic, (uint8_t *) 
priv->wpa.key[0].tx_mic_key, (uint8_t *) & pp->data[0], (int)packet_len, 
(uint8_t) 0,    /* priority */
+                MichaelMICFunction(&michel_mic, (uint8_t *) 
priv->wpa.key[0].tx_mic_key, (uint8_t *) &pp->data[0], (int)packet_len, 
(uint8_t) 0,    /* priority */
                              (uint8_t *) michel_mic.
                              Result);
                   memcpy(p, michel_mic.Result, 8);
@@ -1299,10 +1305,10 @@ int hostif_data_request(struct ks_wlan_private 
*priv, struct sk_buff *packet)
       return result;
   }

-#define ps_confirm_wait_inc(priv) 
do{if(atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET){ \
- atomic_inc(&priv->psstatus.confirm_wait); \
-                                                  /* 
atomic_set(&priv->psstatus.status, PS_CONF_WAIT);*/ \
-                                      } }while(0)
+#define ps_confirm_wait_inc(priv) do { if 
(atomic_read(&priv->psstatus.status) > PS_ACTIVE_SET) { \
+ atomic_inc(&priv->psstatus.confirm_wait); \
+                          /* atomic_set(&priv->psstatus.status, 
PS_CONF_WAIT);*/ \
+                      } } while (0)

   static
   void hostif_mib_get_request(struct ks_wlan_private *priv,
@@ -1443,7 +1449,7 @@ void hostif_infrastructure_set_request(struct 
ks_wlan_private *priv)
       struct hostif_infrastructure_set_request_t *pp;
       uint16_t capability;

-    DPRINTK(3, "ssid.size=%d \n", priv->reg.ssid.size);
+    DPRINTK(3, "ssid.size=%d\n", priv->reg.ssid.size);

       /* make primitive */
       pp = (struct hostif_infrastructure_set_request_t *)
@@ -1510,7 +1516,7 @@ void hostif_infrastructure_set2_request(struct 
ks_wlan_private *priv)
       struct hostif_infrastructure_set2_request_t *pp;
       uint16_t capability;

-    DPRINTK(2, "ssid.size=%d \n", priv->reg.ssid.size);
+    DPRINTK(2, "ssid.size=%d\n", priv->reg.ssid.size);

       /* make primitive */
       pp = (struct hostif_infrastructure_set2_request_t *)
@@ -1567,7 +1573,7 @@ void hostif_infrastructure_set2_request(struct 
ks_wlan_private *priv)
           pp->channel_list.size = 14;
       }

-    memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
+    ether_addr_copy(pp->bssid, priv->reg.bssid);

       /* send to device request */
       ps_confirm_wait_inc(priv);
@@ -1662,7 +1668,7 @@ void hostif_adhoc_set2_request(struct 
ks_wlan_private *priv)

       pp->channel_list.body[0] = priv->reg.channel;
       pp->channel_list.size = 1;
-    memcpy(pp->bssid, priv->reg.bssid, ETH_ALEN);
+    ether_addr_copy(pp->bssid, priv->reg.bssid);

       /* send to device request */
       ps_confirm_wait_inc(priv);
@@ -1755,7 +1761,7 @@ void hostif_sleep_request(struct ks_wlan_private 
*priv, unsigned long mode)
   {
       struct hostif_sleep_request_t *pp;

-    DPRINTK(3, "mode=%lu \n", mode);
+    DPRINTK(3, "mode=%lu\n", mode);

       if (mode == SLP_SLEEP) {
           /* make primitive */
@@ -1779,14 +1785,14 @@ void hostif_sleep_request(struct ks_wlan_private 
*priv, unsigned long mode)
           queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
                      &priv->ks_wlan_hw.rw_wq, 1);
       } else {
-        DPRINTK(3, "invalid mode %ld \n", mode);
+        DPRINTK(3, "invalid mode %ld\n", mode);
           return;
       }
   }

   static
   void hostif_bss_scan_request(struct ks_wlan_private *priv,
-                 unsigned long scan_type, uint8_t * scan_ssid,
+                 unsigned long scan_type, uint8_t *scan_ssid,
                    uint8_t scan_ssid_len)
   {
       struct hostif_bss_scan_request_t *pp;
@@ -1910,6 +1916,7 @@ static
   void hostif_sme_set_wep(struct ks_wlan_private *priv, int type)
   {
       uint32_t val;
+
       switch (type) {
       case SME_WEP_INDEX_REQUEST:
           val = cpu_to_le32((uint32_t) (priv->reg.wep_index));
@@ -2384,6 +2391,7 @@ static
   void hostif_sme_set_key(struct ks_wlan_private *priv, int type)
   {
       uint32_t val;
+
       switch (type) {
       case SME_SET_FLAG:
           val = cpu_to_le32((uint32_t) (priv->reg.privacy_invoked));
@@ -2457,7 +2465,7 @@ void hostif_sme_set_pmksa(struct ks_wlan_private 
*priv)
       list_for_each(ptr, &priv->pmklist.head) {
           pmk = list_entry(ptr, struct pmk_t, list);
           if (i < PMK_LIST_MAX) {
-            memcpy(pmkcache.list[i].bssid, pmk->bssid, ETH_ALEN);
+            ether_addr_copy(pmkcache.list[i].bssid, pmk->bssid);
               memcpy(pmkcache.list[i].pmkid, pmk->pmkid,
                      IW_PMKID_LEN);
               i++;
@@ -2667,7 +2675,7 @@ void hostif_sme_task(unsigned long dev)
                          priv->sme_i.event_buff[priv->sme_i.
                                     qhead]);
               inc_smeqhead(priv);
-            if (0 < cnt_smeqbody(priv))
+            if (cnt_smeqbody(priv) > 0)
                   tasklet_schedule(&priv->sme_task);
           }
       }
@@ -2683,7 +2691,7 @@ void hostif_sme_enqueue(struct ks_wlan_private 
*priv, unsigned short event)
       if (cnt_smeqbody(priv) < (SME_EVENT_BUFF_SIZE - 1)) {
           priv->sme_i.event_buff[priv->sme_i.qtail] = event;
           inc_smeqtail(priv);
-        //DPRINTK(3,"inc_smeqtail \n");
+        //DPRINTK(3,"inc_smeqtail\n");
   #ifdef KS_WLAN_DEBUG
           if (priv->sme_i.max_event_count < cnt_smeqbody(priv))
               priv->sme_i.max_event_count = cnt_smeqbody(priv);
diff --git a/drivers/staging/ks7010/michael_mic.c 
b/drivers/staging/ks7010/michael_mic.c
index e14c109..aa7a5ab 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -14,24 +14,24 @@
   #include "michael_mic.h"

   // Rotation functions on 32 bit values
-#define ROL32( A, n )     ( ((A) << (n)) | ( ((A)>>(32-(n))) & ( (1UL 
<< (n)) - 1 ) ) )
-#define ROR32( A, n )     ROL32( (A), 32-(n) )
+#define ROL32(A, n)    (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) 
- 1)))
+#define ROR32(A, n)    ROL32((A), 32-(n))
   // Convert from Byte[] to UInt32 in a portable way
-#define getUInt32( A, B )     (uint32_t)(A[B+0] << 0) + (A[B+1] << 8) + 
(A[B+2] << 16) + (A[B+3] << 24)
+#define getUInt32(A, B)    (uint32_t)(A[B+0] << 0) + (A[B+1] << 8) + 
(A[B+2] << 16) + (A[B+3] << 24)

   // Convert from UInt32 to Byte[] in a portable way
-#define putUInt32( A, B, C )     A[B+0] = (uint8_t) (C & 0xff);        \
+#define putUInt32(A, B, C)    A[B+0] = (uint8_t) (C & 0xff);      \
                   A[B+1] = (uint8_t) ((C>>8) & 0xff);    \
                   A[B+2] = (uint8_t) ((C>>16) & 0xff);    \
                   A[B+3] = (uint8_t) ((C>>24) & 0xff)

   // Reset the state to the empty message.
-#define MichaelClear( A )     A->L = A->K0; \
+#define MichaelClear(A)    A->L = A->K0; \
                   A->R = A->K1; \
                   A->nBytesInM = 0;

   static
-void MichaelInitializeFunction(struct michel_mic_t *Mic, uint8_t * key)
+void MichaelInitializeFunction(struct michel_mic_t *Mic, uint8_t *key)
   {
       // Set the key
       Mic->K0 = getUInt32(key, 0);
@@ -42,21 +42,22 @@ void MichaelInitializeFunction(struct michel_mic_t 
*Mic, uint8_t * key)
   }

   #define MichaelBlockFunction(L, R)                \
-do{                                \
-    R ^= ROL32( L, 17 );                    \
+do {                                \
+    R ^= ROL32(L, 17);                    \
       L += R;                            \
       R ^= ((L & 0xff00ff00) >> 8) | ((L & 0x00ff00ff) << 8);    \
       L += R;                            \
-    R ^= ROL32( L, 3 );                    \
+    R ^= ROL32(L, 3);                    \
       L += R;                            \
-    R ^= ROR32( L, 2 );                    \
+    R ^= ROR32(L, 2);                    \
       L += R;                            \
-}while(0)
+} while (0)

   static
-void MichaelAppend(struct michel_mic_t *Mic, uint8_t * src, int nBytes)
+void MichaelAppend(struct michel_mic_t *Mic, uint8_t *src, int nBytes)
   {
       int addlen;
+
       if (Mic->nBytesInM) {
           addlen = 4 - Mic->nBytesInM;
           if (addlen > nBytes)
@@ -88,9 +89,10 @@ void MichaelAppend(struct michel_mic_t *Mic, uint8_t 
* src, int nBytes)
   }

   static
-void MichaelGetMIC(struct michel_mic_t *Mic, uint8_t * dst)
+void MichaelGetMIC(struct michel_mic_t *Mic, uint8_t *dst)
   {
       uint8_t *data = Mic->M;
+
       switch (Mic->nBytesInM) {
       case 0:
           Mic->L ^= 0x5a;
@@ -116,9 +118,9 @@ void MichaelGetMIC(struct michel_mic_t *Mic, uint8_t 
* dst)
       MichaelClear(Mic);
   }

-void MichaelMICFunction(struct michel_mic_t *Mic, uint8_t * Key,
-            uint8_t * Data, int Len, uint8_t priority,
-            uint8_t * Result)
+void MichaelMICFunction(struct michel_mic_t *Mic, uint8_t *Key,
+            uint8_t *Data, int Len, uint8_t priority,
+            uint8_t *Result)
   {
       uint8_t pad_data[4] = { priority, 0, 0, 0 };
       // Compute the MIC value

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ