linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Richard Weinberger <richard@nod.at>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	"Vignesh Raghavendra" <vigneshr@ti.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: <linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>,
	<linux-mtd@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] ubi: fastmap: Use the bitmap API to allocate bitmaps
Date: Fri, 8 Jul 2022 17:07:44 +0800	[thread overview]
Message-ID: <16e6eef2-bf83-f5c1-6543-8c49a70c7d85@huawei.com> (raw)
In-Reply-To: <64cde893efca8f4dc381184cd7f6e5a54cd000f9.1656960335.git.christophe.jaillet@wanadoo.fr>

在 2022/7/5 2:46, Christophe JAILLET 写道:
> Use bitmap_zalloc()/bitmap_free() instead of hand-writing them.
> 
> It is less verbose and it improves the semantic.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>   drivers/mtd/ubi/fastmap.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
> index 6e95c4b1473e..ca2d9efe62c3 100644
> --- a/drivers/mtd/ubi/fastmap.c
> +++ b/drivers/mtd/ubi/fastmap.c
> @@ -20,8 +20,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
>   	if (!ubi_dbg_chk_fastmap(ubi))
>   		return NULL;
>   
> -	ret = kcalloc(BITS_TO_LONGS(ubi->peb_count), sizeof(unsigned long),
> -		      GFP_KERNEL);
> +	ret = bitmap_zalloc(ubi->peb_count, GFP_KERNEL);
>   	if (!ret)
>   		return ERR_PTR(-ENOMEM);
>   
> @@ -34,7 +33,7 @@ static inline unsigned long *init_seen(struct ubi_device *ubi)
>    */
>   static inline void free_seen(unsigned long *seen)
>   {
> -	kfree(seen);
> +	bitmap_free(seen);
>   }
>   
>   /**
> @@ -1108,8 +1107,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
>   	if (!ubi->fast_attach)
>   		return 0;
>   
> -	vol->checkmap = kcalloc(BITS_TO_LONGS(leb_count), sizeof(unsigned long),
> -				GFP_KERNEL);
> +	vol->checkmap = bitmap_zalloc(leb_count, GFP_KERNEL);
>   	if (!vol->checkmap)
>   		return -ENOMEM;
>   
> @@ -1118,7 +1116,7 @@ int ubi_fastmap_init_checkmap(struct ubi_volume *vol, int leb_count)
>   
>   void ubi_fastmap_destroy_checkmap(struct ubi_volume *vol)
>   {
> -	kfree(vol->checkmap);
> +	bitmap_free(vol->checkmap);
>   }
>   
>   /**
> 
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2022-07-08  9:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04 18:46 [PATCH] ubi: fastmap: Use the bitmap API to allocate bitmaps Christophe JAILLET
2022-07-08  9:07 ` Zhihao Cheng [this message]

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=16e6eef2-bf83-f5c1-6543-8c49a70c7d85@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /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;
as well as URLs for NNTP newsgroup(s).