diff options
author | Eric Sesterhenn <snakebyte@gmx.de> | 2006-10-23 16:17:21 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-11-29 18:33:06 -0500 |
commit | bed8bdfddd851657cf9e5fd16bb44abb02ae7f42 (patch) | |
tree | ac021f613071dc4a274d071ea900709cd4e17374 /drivers | |
parent | a1a733f65b091fdad3d0783e648c92b491933ab6 (diff) |
IB: kmemdup() cleanup
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/core/cm.c | 3 | ||||
-rw-r--r-- | drivers/infiniband/core/iwcm.c | 3 | ||||
-rw-r--r-- | drivers/infiniband/core/ucm.c | 6 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_provider.c | 3 |
4 files changed, 5 insertions, 10 deletions
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 25b1018a476c..82bc83baceaf 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c | |||
@@ -240,11 +240,10 @@ static void * cm_copy_private_data(const void *private_data, | |||
240 | if (!private_data || !private_data_len) | 240 | if (!private_data || !private_data_len) |
241 | return NULL; | 241 | return NULL; |
242 | 242 | ||
243 | data = kmalloc(private_data_len, GFP_KERNEL); | 243 | data = kmemdup(private_data, private_data_len, GFP_KERNEL); |
244 | if (!data) | 244 | if (!data) |
245 | return ERR_PTR(-ENOMEM); | 245 | return ERR_PTR(-ENOMEM); |
246 | 246 | ||
247 | memcpy(data, private_data, private_data_len); | ||
248 | return data; | 247 | return data; |
249 | } | 248 | } |
250 | 249 | ||
diff --git a/drivers/infiniband/core/iwcm.c b/drivers/infiniband/core/iwcm.c index c3fb304a4e86..2bbcfa5c6e27 100644 --- a/drivers/infiniband/core/iwcm.c +++ b/drivers/infiniband/core/iwcm.c | |||
@@ -140,10 +140,9 @@ static int copy_private_data(struct iwcm_id_private *cm_id_priv, | |||
140 | { | 140 | { |
141 | void *p; | 141 | void *p; |
142 | 142 | ||
143 | p = kmalloc(event->private_data_len, GFP_ATOMIC); | 143 | p = kmemdup(event->private_data, event->private_data_len, GFP_ATOMIC); |
144 | if (!p) | 144 | if (!p) |
145 | return -ENOMEM; | 145 | return -ENOMEM; |
146 | memcpy(p, event->private_data, event->private_data_len); | ||
147 | event->private_data = p; | 146 | event->private_data = p; |
148 | return 0; | 147 | return 0; |
149 | } | 148 | } |
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index ad4f4d5c2924..b4894ba223b7 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -328,20 +328,18 @@ static int ib_ucm_event_process(struct ib_cm_event *evt, | |||
328 | } | 328 | } |
329 | 329 | ||
330 | if (uvt->data_len) { | 330 | if (uvt->data_len) { |
331 | uvt->data = kmalloc(uvt->data_len, GFP_KERNEL); | 331 | uvt->data = kmemdup(evt->private_data, uvt->data_len, GFP_KERNEL); |
332 | if (!uvt->data) | 332 | if (!uvt->data) |
333 | goto err1; | 333 | goto err1; |
334 | 334 | ||
335 | memcpy(uvt->data, evt->private_data, uvt->data_len); | ||
336 | uvt->resp.present |= IB_UCM_PRES_DATA; | 335 | uvt->resp.present |= IB_UCM_PRES_DATA; |
337 | } | 336 | } |
338 | 337 | ||
339 | if (uvt->info_len) { | 338 | if (uvt->info_len) { |
340 | uvt->info = kmalloc(uvt->info_len, GFP_KERNEL); | 339 | uvt->info = kmemdup(info, uvt->info_len, GFP_KERNEL); |
341 | if (!uvt->info) | 340 | if (!uvt->info) |
342 | goto err2; | 341 | goto err2; |
343 | 342 | ||
344 | memcpy(uvt->info, info, uvt->info_len); | ||
345 | uvt->resp.present |= IB_UCM_PRES_INFO; | 343 | uvt->resp.present |= IB_UCM_PRES_INFO; |
346 | } | 344 | } |
347 | return 0; | 345 | return 0; |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index fc67f780581b..21422a3336ad 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -1100,11 +1100,10 @@ static struct ib_fmr *mthca_alloc_fmr(struct ib_pd *pd, int mr_access_flags, | |||
1100 | struct mthca_fmr *fmr; | 1100 | struct mthca_fmr *fmr; |
1101 | int err; | 1101 | int err; |
1102 | 1102 | ||
1103 | fmr = kmalloc(sizeof *fmr, GFP_KERNEL); | 1103 | fmr = kmemdup(fmr_attr, sizeof *fmr, GFP_KERNEL); |
1104 | if (!fmr) | 1104 | if (!fmr) |
1105 | return ERR_PTR(-ENOMEM); | 1105 | return ERR_PTR(-ENOMEM); |
1106 | 1106 | ||
1107 | memcpy(&fmr->attr, fmr_attr, sizeof *fmr_attr); | ||
1108 | err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num, | 1107 | err = mthca_fmr_alloc(to_mdev(pd->device), to_mpd(pd)->pd_num, |
1109 | convert_access(mr_access_flags), fmr); | 1108 | convert_access(mr_access_flags), fmr); |
1110 | 1109 | ||