* [PATCH] sh: sq: Use the bitmap API when applicable
@ 2022-06-25 7:40 Christophe JAILLET
2022-06-26 10:01 ` Geert Uytterhoeven
0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2022-06-25 7:40 UTC (permalink / raw)
To: Yoshinori Sato, Rich Felker
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-sh
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(-)
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);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sh: sq: Use the bitmap API when applicable
2022-06-25 7:40 [PATCH] sh: sq: Use the bitmap API when applicable Christophe JAILLET
@ 2022-06-26 10:01 ` Geert Uytterhoeven
2022-06-26 13:21 ` Christophe JAILLET
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2022-06-26 10:01 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Yoshinori Sato, Rich Felker, Linux Kernel Mailing List,
kernel-janitors, Linux-sh list
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sh: sq: Use the bitmap API when applicable
2022-06-26 10:01 ` Geert Uytterhoeven
@ 2022-06-26 13:21 ` Christophe JAILLET
0 siblings, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-06-26 13:21 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Yoshinori Sato, Rich Felker, Linux Kernel Mailing List,
kernel-janitors, Linux-sh list
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-26 13:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-25 7:40 [PATCH] sh: sq: Use the bitmap API when applicable Christophe JAILLET
2022-06-26 10:01 ` Geert Uytterhoeven
2022-06-26 13:21 ` Christophe JAILLET
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).