]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: bcm: optimize kmalloc to kzalloc
authorAlexander Beregalov <a.beregalov@gmail.com>
Wed, 9 Mar 2011 00:53:34 +0000 (03:53 +0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 9 Mar 2011 23:54:31 +0000 (15:54 -0800)
Use kzalloc rather than kmalloc followed by memset with 0.
Found by coccinelle.

Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/bcm/Bcmchar.c
drivers/staging/bcm/Misc.c

index 3d9055aec97cda7109f8076aa231cc0892638b80..867dbf1c9926dee8078670692b520b5c334c08cf 100644 (file)
@@ -19,12 +19,10 @@ static int bcm_char_open(struct inode *inode, struct file * filp)
        PPER_TARANG_DATA    pTarang = NULL;
 
        Adapter = GET_BCM_ADAPTER(gblpnetdev);
-       pTarang = (PPER_TARANG_DATA)kmalloc(sizeof(PER_TARANG_DATA),
-                                           GFP_KERNEL);
+       pTarang = kzalloc(sizeof(PER_TARANG_DATA), GFP_KERNEL);
        if (!pTarang)
                return -ENOMEM;
 
-       memset(pTarang, 0, sizeof(PER_TARANG_DATA));
        pTarang->Adapter = Adapter;
        pTarang->RxCntrlMsgBitMask = 0xFFFFFFFF & ~(1 << 0xB);
 
index f585aae9cf8b255419cc8d8b2d0c90d0bd1caa62..d624f35d055139888f65f95029a82c94da4eedbb 100644 (file)
@@ -498,13 +498,12 @@ VOID LinkMessage(PMINI_ADAPTER Adapter)
        BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "=====>");
        if(Adapter->LinkStatus == SYNC_UP_REQUEST && Adapter->AutoSyncup)
        {
-               pstLinkRequest=kmalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
+               pstLinkRequest = kzalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
                if(!pstLinkRequest)
                {
                        BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
                        return;
                }
-               memset(pstLinkRequest,0,sizeof(LINK_REQUEST));
                //sync up request...
                Adapter->LinkStatus = WAIT_FOR_SYNC;// current link status
                BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For SyncUp...");
@@ -516,13 +515,12 @@ VOID LinkMessage(PMINI_ADAPTER Adapter)
        }
        else if(Adapter->LinkStatus == PHY_SYNC_ACHIVED && Adapter->AutoLinkUp)
        {
-               pstLinkRequest=kmalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
+               pstLinkRequest = kzalloc(sizeof(LINK_REQUEST), GFP_ATOMIC);
                if(!pstLinkRequest)
                {
                        BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Can not allocate memory for Link request!");
                        return;
                }
-               memset(pstLinkRequest,0,sizeof(LINK_REQUEST));
                //LINK_UP_REQUEST
                BCM_DEBUG_PRINT(Adapter,DBG_TYPE_OTHERS, LINK_UP_MSG, DBG_LVL_ALL, "Requesting For LinkUp...");
                pstLinkRequest->szData[0]=LINK_UP_REQ_PAYLOAD;