Message ID | 521788e22ad8f7a5058c154f068b061525321841.1656142814.git.christophe.jaillet@wanadoo.fr (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | sh: sq: Use the bitmap API when applicable | expand |
Hi Christophe, On Sat, Jun 25, 2022 at 9:45 AM Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote: > Using the bitmap API is less verbose than hand writing them. > It also improves the semantic. Thanks for your patch! > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > I don't cross compile, so this patch is NOT compile-tested. Why not? Cross-compiling is so easy nowadays? Many distros even provide cross-compilers ("apt install gcc-sh4-linux-gnu"). Else try https://mirrors.edge.kernel.org/pub/tools/crosstool/. > --- a/arch/sh/kernel/cpu/sh4/sq.c > +++ b/arch/sh/kernel/cpu/sh4/sq.c > @@ -382,7 +381,7 @@ static int __init sq_api_init(void) > if (unlikely(!sq_cache)) > return ret; > > - sq_bitmap = kzalloc(size, GFP_KERNEL); > + sq_bitmap = bitmap_zalloc(nr_pages, GFP_KERNEL); Perhaps you need #include <linux/bitmap.h>? I don't know, I also didn't bother to cross-compile. Why would I? ;-) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Le 26/06/2022 à 12:01, Geert Uytterhoeven a écrit : > Hi Christophe, > > On Sat, Jun 25, 2022 at 9:45 AM Christophe JAILLET > <christophe.jaillet@wanadoo.fr> wrote: >> Using the bitmap API is less verbose than hand writing them. >> It also improves the semantic. > > Thanks for your patch! > >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> >> --- >> I don't cross compile, so this patch is NOT compile-tested. > > Why not? The main reason is: df /dev/sdc3 ... 98% / > Cross-compiling is so easy nowadays? > Many distros even provide cross-compilers ("apt install gcc-sh4-linux-gnu"). > Else try https://mirrors.edge.kernel.org/pub/tools/crosstool/. > >> --- a/arch/sh/kernel/cpu/sh4/sq.c >> +++ b/arch/sh/kernel/cpu/sh4/sq.c > >> @@ -382,7 +381,7 @@ static int __init sq_api_init(void) >> if (unlikely(!sq_cache)) >> return ret; >> >> - sq_bitmap = kzalloc(size, GFP_KERNEL); >> + sq_bitmap = bitmap_zalloc(nr_pages, GFP_KERNEL); > > Perhaps you need #include <linux/bitmap.h>? or not. See [1]. > > I don't know, I also didn't bother to cross-compile. Why would I? ;-) I'll refrain from posting things that I can't compile-test myself in the future. Sorry for the noise, please just ignore the patch, it was just a clean-up anyway. CJ [1]: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/arch/sh/kernel/cpu/sh4/sq.c#n12 > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds >
diff --git a/arch/sh/kernel/cpu/sh4/sq.c b/arch/sh/kernel/cpu/sh4/sq.c index a76b94e41e91..c3101427d9a9 100644 --- a/arch/sh/kernel/cpu/sh4/sq.c +++ b/arch/sh/kernel/cpu/sh4/sq.c @@ -372,7 +372,6 @@ static struct subsys_interface sq_interface = { static int __init sq_api_init(void) { unsigned int nr_pages = 0x04000000 >> PAGE_SHIFT; - unsigned int size = (nr_pages + (BITS_PER_LONG - 1)) / BITS_PER_LONG; int ret = -ENOMEM; printk(KERN_NOTICE "sq: Registering store queue API.\n"); @@ -382,7 +381,7 @@ static int __init sq_api_init(void) if (unlikely(!sq_cache)) return ret; - sq_bitmap = kzalloc(size, GFP_KERNEL); + sq_bitmap = bitmap_zalloc(nr_pages, GFP_KERNEL); if (unlikely(!sq_bitmap)) goto out; @@ -393,7 +392,7 @@ static int __init sq_api_init(void) return 0; out: - kfree(sq_bitmap); + bitmap_free(sq_bitmap); kmem_cache_destroy(sq_cache); return ret; @@ -402,7 +401,7 @@ static int __init sq_api_init(void) static void __exit sq_api_exit(void) { subsys_interface_unregister(&sq_interface); - kfree(sq_bitmap); + bitmap_free(sq_bitmap); kmem_cache_destroy(sq_cache); }
Using the bitmap API is less verbose than hand writing them. It also improves the semantic. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> --- I don't cross compile, so this patch is NOT compile-tested. --- arch/sh/kernel/cpu/sh4/sq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)