diff mbox series

[3/3] memstick/ms_block: Use the bitmap API when applicable

Message ID b216df8798f765ab14bce65739c220643320f376.1656155715.git.christophe.jaillet@wanadoo.fr
State New
Headers show
Series [1/3] memstick/ms_block: Fix some incorrect memory allocation | expand

Commit Message

Christophe JAILLET June 25, 2022, 12:56 p.m. UTC
Use bitmap_equal() instead of hand writing it. It improves semantic and
avoids some explicit computation to convert a number of bits to a number of
bytes.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/memstick/core/ms_block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Ulf Hansson July 12, 2022, 11:08 a.m. UTC | #1
On Sat, 25 Jun 2022 at 14:56, Christophe JAILLET
<christophe.jaillet@wanadoo.fr> wrote:
>
> Use bitmap_equal() instead of hand writing it. It improves semantic and
> avoids some explicit computation to convert a number of bits to a number of
> bytes.
>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/memstick/core/ms_block.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
> index f8fdf88fb240..c05edfc1c841 100644
> --- a/drivers/memstick/core/ms_block.c
> +++ b/drivers/memstick/core/ms_block.c
> @@ -2245,8 +2245,8 @@ static int msb_resume(struct memstick_dev *card)
>                 goto out;
>
>         if (msb->block_count != new_msb->block_count ||
> -               memcmp(msb->used_blocks_bitmap, new_msb->used_blocks_bitmap,
> -                                                       msb->block_count / 8))
> +           !bitmap_equal(msb->used_blocks_bitmap, new_msb->used_blocks_bitmap,
> +                                                       msb->block_count))
>                 goto out;
>
>         card_dead = false;
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c
index f8fdf88fb240..c05edfc1c841 100644
--- a/drivers/memstick/core/ms_block.c
+++ b/drivers/memstick/core/ms_block.c
@@ -2245,8 +2245,8 @@  static int msb_resume(struct memstick_dev *card)
 		goto out;
 
 	if (msb->block_count != new_msb->block_count ||
-		memcmp(msb->used_blocks_bitmap, new_msb->used_blocks_bitmap,
-							msb->block_count / 8))
+	    !bitmap_equal(msb->used_blocks_bitmap, new_msb->used_blocks_bitmap,
+							msb->block_count))
 		goto out;
 
 	card_dead = false;