]> git.karo-electronics.de Git - linux-beck.git/commitdiff
IB: kmemdup() cleanup
authorEric Sesterhenn <snakebyte@gmx.de>
Mon, 23 Oct 2006 20:17:21 +0000 (22:17 +0200)
committerRoland Dreier <rolandd@cisco.com>
Wed, 29 Nov 2006 23:33:06 +0000 (15:33 -0800)
Replace open coded kmemdup() to save some screen space, and allow
inlining/not inlining to be triggered by gcc.

Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/cm.c
drivers/infiniband/core/iwcm.c
drivers/infiniband/core/ucm.c
drivers/infiniband/hw/mthca/mthca_provider.c

index 25b1018a476ceecb71739909324c11257d998fae..82bc83baceaf6e27019efb01baa1c905071611f8 100644 (file)
@@ -240,11 +240,10 @@ static void * cm_copy_private_data(const void *private_data,
        if (!private_data || !private_data_len)
                return NULL;
 
-       data = kmalloc(private_data_len, GFP_KERNEL);
+       data = kmemdup(private_data, private_data_len, GFP_KERNEL);
        if (!data)
                return ERR_PTR(-ENOMEM);
 
-       memcpy(data, private_data, private_data_len);
        return data;
 }
 
index c3fb304a4e866950f46c0136fb77a514b8409836..2bbcfa5c6e27c03249d1d48c0031322f71414901 100644 (file)
@@ -140,10 +140,9 @@ static int copy_private_data(struct iwcm_id_private *cm_id_priv,
 {
        void *p;
 
-       p = kmalloc(event->private_data_len, GFP_ATOMIC);
+       p = kmemdup(event->private_data, event->private_data_len, GFP_ATOMIC);
        if (!p)
                return -ENOMEM;
-       memcpy(p, event->private_data, event->private_data_len);
        event->private_data = p;
        return 0;
 }
index ad4f4d5c2924044cf9199fbad08406f2a5eae4ef..b4894ba223b75ef992d37b5a6641e0373f3dd75e 100644 (file)
@@ -328,20 +328,18 @@ static int ib_ucm_event_process(struct ib_cm_event *evt,
        }
 
        if (uvt->data_len) {
-               uvt->data = kmalloc(uvt->data_len, GFP_KERNEL);
+               uvt->data = kmemdup(evt->private_data, uvt->data_len, GFP_KERNEL);
                if (!uvt->data)
                        goto err1;
 
-               memcpy(uvt->data, evt->private_data, uvt->data_len);
                uvt->resp.present |= IB_UCM_PRES_DATA;
        }
 
        if (uvt->info_len) {
-               uvt->info = kmalloc(uvt->info_len, GFP_KERNEL);
+               uvt->info = kmemdup(info, uvt->info_len, GFP_KERNEL);
                if (!uvt->info)
                        goto err2;
 
-               memcpy(uvt->info, info, uvt->info_len);
                uvt->resp.present |= IB_UCM_PRES_INFO;
        }
        return 0;
index fc67f780581b284f4552c5d3ca72d05813cc48a0..21422a3336ad19d4e4f4c522d68d6bd1770a7613 100644 (file)
@@ -1100,11 +1100,10 @@ static struct ib_fmr *mthca_alloc_fmr(struct ib_pd *pd, int mr_access_flags,
        struct mthca_fmr *fmr;
        int err;
 
-       fmr = kmalloc(sizeof *fmr, GFP_KERNEL);
+       fmr = kmemdup(fmr_attr, sizeof *fmr, GFP_KERNEL);
        if (!fmr)
                return ERR_PTR(-ENOMEM);
 
-       memcpy(&fmr->attr, fmr_attr, sizeof *fmr_attr);
        err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num,
                             convert_access(mr_access_flags), fmr);