2020-01-01 18:27:30

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 08/10] MIPS: use resource_size

Use resource_size rather than a verbose computation on
the end and start fields.

The semantic patch that makes these changes is as follows:
(http://coccinelle.lip6.fr/)

<smpl>
@@ struct resource ptr; @@
- (ptr.end - ptr.start + 1)
+ resource_size(&ptr)
</smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
arch/mips/kernel/setup.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index c3d4212b5f1d..701f4bc3046f 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -515,8 +515,7 @@ static void __init request_crashkernel(struct resource *res)
ret = request_resource(res, &crashk_res);
if (!ret)
pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
- (unsigned long)((crashk_res.end -
- crashk_res.start + 1) >> 20),
+ (unsigned long)(resource_size(&crashk_res) >> 20),
(unsigned long)(crashk_res.start >> 20));
}
#else /* !defined(CONFIG_KEXEC) */
@@ -698,8 +697,7 @@ static void __init arch_mem_init(char **cmdline_p)
mips_parse_crashkernel();
#ifdef CONFIG_KEXEC
if (crashk_res.start != crashk_res.end)
- memblock_reserve(crashk_res.start,
- crashk_res.end - crashk_res.start + 1);
+ memblock_reserve(crashk_res.start, resource_size(&crashk_res));
#endif
device_tree_init();
sparse_init();


2020-01-01 22:25:33

by Philippe Mathieu-Daudé

[permalink] [raw]
Subject: Re: [PATCH 08/10] MIPS: use resource_size

On Wed, Jan 1, 2020 at 7:26 PM Julia Lawall <[email protected]> wrote:
>
> Use resource_size rather than a verbose computation on
> the end and start fields.
>
> The semantic patch that makes these changes is as follows:
> (http://coccinelle.lip6.fr/)
>
> <smpl>
> @@ struct resource ptr; @@
> - (ptr.end - ptr.start + 1)
> + resource_size(&ptr)
> </smpl>
>
> Signed-off-by: Julia Lawall <[email protected]>
>
> ---
> arch/mips/kernel/setup.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index c3d4212b5f1d..701f4bc3046f 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -515,8 +515,7 @@ static void __init request_crashkernel(struct resource *res)
> ret = request_resource(res, &crashk_res);
> if (!ret)
> pr_info("Reserving %ldMB of memory at %ldMB for crashkernel\n",
> - (unsigned long)((crashk_res.end -
> - crashk_res.start + 1) >> 20),
> + (unsigned long)(resource_size(&crashk_res) >> 20),
> (unsigned long)(crashk_res.start >> 20));
> }
> #else /* !defined(CONFIG_KEXEC) */
> @@ -698,8 +697,7 @@ static void __init arch_mem_init(char **cmdline_p)
> mips_parse_crashkernel();
> #ifdef CONFIG_KEXEC
> if (crashk_res.start != crashk_res.end)
> - memblock_reserve(crashk_res.start,
> - crashk_res.end - crashk_res.start + 1);
> + memblock_reserve(crashk_res.start, resource_size(&crashk_res));
> #endif
> device_tree_init();
> sparse_init();
>

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

Thanks Julia!

2020-01-10 19:38:13

by Paul Burton

[permalink] [raw]
Subject: Re: [PATCH 08/10] MIPS: use resource_size

Hello,

Julia Lawall wrote:
> Use resource_size rather than a verbose computation on
> the end and start fields.
>
> The semantic patch that makes these changes is as follows:
> (http://coccinelle.lip6.fr/)
>
> <smpl>
> @@ struct resource ptr; @@
> - (ptr.end - ptr.start + 1)
> + resource_size(&ptr)
> </smpl>

Applied to mips-next.

> commit ecb983790fe8
> https://git.kernel.org/mips/c/ecb983790fe8
>
> Signed-off-by: Julia Lawall <[email protected]>
> Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
> Signed-off-by: Paul Burton <[email protected]>

Thanks,
Paul

[ This message was auto-generated; if you believe anything is incorrect
then please email [email protected] to report it. ]