From: Pekka Enberg <penberg@cs.helsinki.fi>
To: "Bryan O'Sullivan" <bos@pathscale.com>
Cc: linux-kernel@vger.kernel.org, openib-general@openib.org
Subject: Re: [PATCH 17 of 20] ipath - infiniband verbs support, part 3 of 3
Date: Thu, 29 Dec 2005 21:24:38 +0200 [thread overview]
Message-ID: <84144f020512291124sd895dfbp87ca9fd75552d671@mail.gmail.com> (raw)
In-Reply-To: <584777b6f4dc5269fa89.1135816296@eng-12.pathscale.com>
Hi,
[Copy-paste reuse alert!]
On 12/29/05, Bryan O'Sullivan <bos@pathscale.com> wrote:
> +static struct ib_mr *ipath_reg_phys_mr(struct ib_pd *pd,
> + struct ib_phys_buf *buffer_list,
> + int num_phys_buf,
> + int acc, u64 *iova_start)
> +{
> + struct ipath_mr *mr;
> + int n, m, i;
> +
> + /* Allocate struct plus pointers to first level page tables. */
> + m = (num_phys_buf + IPATH_SEGSZ - 1) / IPATH_SEGSZ;
> + mr = kmalloc(sizeof *mr + m * sizeof mr->mr.map[0], GFP_KERNEL);
> + if (!mr)
> + return ERR_PTR(-ENOMEM);
> +
> + /* Allocate first level page tables. */
> + for (i = 0; i < m; i++) {
> + mr->mr.map[i] = kmalloc(sizeof *mr->mr.map[0], GFP_KERNEL);
> + if (!mr->mr.map[i]) {
> + while (i)
> + kfree(mr->mr.map[--i]);
> + kfree(mr);
> + return ERR_PTR(-ENOMEM);
> + }
> + }
> + mr->mr.mapsz = m;
[snip, snip]
> +static struct ib_mr *ipath_reg_user_mr(struct ib_pd *pd,
> + struct ib_umem *region,
> + int mr_access_flags,
> + struct ib_udata *udata)
> +{
> + struct ipath_mr *mr;
> + struct ib_umem_chunk *chunk;
> + int n, m, i;
> +
> + n = 0;
> + list_for_each_entry(chunk, ®ion->chunk_list, list)
> + n += chunk->nents;
> +
> + /* Allocate struct plus pointers to first level page tables. */
> + m = (n + IPATH_SEGSZ - 1) / IPATH_SEGSZ;
> + mr = kmalloc(sizeof *mr + m * sizeof mr->mr.map[0], GFP_KERNEL);
> + if (!mr)
> + return ERR_PTR(-ENOMEM);
> +
> + /* Allocate first level page tables. */
> + for (i = 0; i < m; i++) {
> + mr->mr.map[i] = kmalloc(sizeof *mr->mr.map[0], GFP_KERNEL);
> + if (!mr->mr.map[i]) {
> + while (i)
> + kfree(mr->mr.map[--i]);
> + kfree(mr);
> + return ERR_PTR(-ENOMEM);
> + }
> + }
> + mr->mr.mapsz = m;
[snip, more duplicate code]
The above fragment is repeated at least three times. Please factor out
the common code into separate functions.
Pekka
next prev parent reply other threads:[~2005-12-29 19:24 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-29 0:31 [PATCH 0 of 20] [RFC] ipath - PathScale InfiniPath driver Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 1 of 20] Introduce __memcpy_toio32 Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 2 of 20] memcpy32 for x86_64 Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 3 of 20] Add memcpy_toio32 to each arch Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 4 of 20] Define BITS_PER_BYTE Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 5 of 20] ipath - driver core header files Bryan O'Sullivan
2005-12-29 8:18 ` Pekka Enberg
2005-12-29 14:15 ` Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 6 of 20] ipath - driver debugging headers Bryan O'Sullivan
2005-12-29 8:22 ` Pekka Enberg
2005-12-29 0:31 ` [PATCH 7 of 20] ipath - MMIO copy routines Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 8 of 20] ipath - core driver, part 1 of 4 Bryan O'Sullivan
2005-12-30 8:39 ` Greg KH
2005-12-30 23:47 ` Bryan O'Sullivan
2005-12-31 0:12 ` Greg KH
2005-12-29 0:31 ` [PATCH 9 of 20] ipath - core driver, part 2 " Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 10 of 20] ipath - core driver, part 3 " Bryan O'Sullivan
2005-12-30 18:46 ` Linus Torvalds
2005-12-30 23:50 ` Bryan O'Sullivan
2005-12-31 8:36 ` Arjan van de Ven
2005-12-29 0:31 ` [PATCH 11 of 20] ipath - core driver, part 4 " Bryan O'Sullivan
2005-12-29 2:19 ` [openib-general] " Roland Dreier
2005-12-29 14:21 ` Bryan O'Sullivan
2005-12-30 8:12 ` Greg KH
2005-12-30 23:17 ` Bryan O'Sullivan
2005-12-31 0:08 ` Greg KH
2005-12-29 0:31 ` [PATCH 12 of 20] ipath - misc driver support code Bryan O'Sullivan
2005-12-30 8:25 ` Greg KH
2005-12-30 23:10 ` Bryan O'Sullivan
2005-12-31 0:13 ` Greg KH
2005-12-30 18:15 ` Arjan van de Ven
2005-12-29 0:31 ` [PATCH 13 of 20] ipath - routines used by upper layer driver code Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 14 of 20] ipath - infiniband verbs header Bryan O'Sullivan
2005-12-29 8:21 ` Pekka Enberg
2005-12-29 14:22 ` Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 15 of 20] ipath - infiniband verbs support, part 1 of 3 Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 16 of 20] path - infiniband verbs support, part 2 " Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 17 of 20] ipath - infiniband verbs support, part 3 " Bryan O'Sullivan
2005-12-29 19:24 ` Pekka Enberg [this message]
2005-12-30 3:19 ` Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 18 of 20] ipath - infiniband management datagram support Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 19 of 20] ipath - kbuild infrastructure Bryan O'Sullivan
2005-12-29 0:31 ` [PATCH 20 of 20] ipath - integrate driver into infiniband " Bryan O'Sullivan
2005-12-29 19:01 ` [PATCH 0 of 20] [RFC] ipath - PathScale InfiniPath driver Horst von Brand
2005-12-29 19:26 ` Lee Revell
2005-12-31 5:36 ` Jan Engelhardt
2006-01-02 16:05 ` Horst von Brand
2006-01-02 16:22 ` Christoph Hellwig
2005-12-30 3:17 ` Bryan O'Sullivan
2005-12-30 8:00 ` Greg KH
2005-12-30 23:11 ` Bryan O'Sullivan
2005-12-31 0:10 ` Greg KH
2005-12-31 1:40 ` Bryan O'Sullivan
2006-01-02 20:35 ` Eric W. Biederman
2006-01-02 22:22 ` Bryan O'Sullivan
2006-01-04 21:26 ` Roland Dreier
2006-01-05 15:28 ` Bryan O'Sullivan
2006-01-03 17:27 ` Greg KH
2006-01-03 20:54 ` Bryan O'Sullivan
2006-01-03 20:57 ` Arjan van de Ven
2006-01-03 21:24 ` Bryan O'Sullivan
2006-01-03 21:26 ` Arjan van de Ven
2006-01-04 3:33 ` Bryan O'Sullivan
2006-01-04 21:28 ` [openib-general] " Roland Dreier
2006-01-05 15:31 ` Bryan O'Sullivan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84144f020512291124sd895dfbp87ca9fd75552d671@mail.gmail.com \
--to=penberg@cs.helsinki.fi \
--cc=bos@pathscale.com \
--cc=linux-kernel@vger.kernel.org \
--cc=openib-general@openib.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome