2023-12-12 15:06:13

by Yuntao Wang

[permalink] [raw]
Subject: [PATCH] x86/kexec: Simplify the logic of mem_region_callback()

The expression `mstart + resource_size(res) - 1` is actually equivalent to
`res->end`, simplify the logic of this function to improve readability.

Signed-off-by: Yuntao Wang <[email protected]>
---
arch/x86/kernel/machine_kexec_64.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index 1a3e2c05a8a5..6f8df998890e 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -42,12 +42,9 @@ struct init_pgtable_data {
static int mem_region_callback(struct resource *res, void *arg)
{
struct init_pgtable_data *data = arg;
- unsigned long mstart, mend;
-
- mstart = res->start;
- mend = mstart + resource_size(res) - 1;

- return kernel_ident_mapping_init(data->info, data->level4p, mstart, mend);
+ return kernel_ident_mapping_init(data->info, data->level4p,
+ res->start, res->end);
}

static int
--
2.43.0


2023-12-13 02:48:16

by Baoquan He

[permalink] [raw]
Subject: Re: [PATCH] x86/kexec: Simplify the logic of mem_region_callback()

On 12/12/23 at 11:05pm, Yuntao Wang wrote:
> The expression `mstart + resource_size(res) - 1` is actually equivalent to
> `res->end`, simplify the logic of this function to improve readability.
>
> Signed-off-by: Yuntao Wang <[email protected]>
> ---
> arch/x86/kernel/machine_kexec_64.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)

LGTM,

Acked-by: Baoquan He <[email protected]>

>
> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
> index 1a3e2c05a8a5..6f8df998890e 100644
> --- a/arch/x86/kernel/machine_kexec_64.c
> +++ b/arch/x86/kernel/machine_kexec_64.c
> @@ -42,12 +42,9 @@ struct init_pgtable_data {
> static int mem_region_callback(struct resource *res, void *arg)
> {
> struct init_pgtable_data *data = arg;
> - unsigned long mstart, mend;
> -
> - mstart = res->start;
> - mend = mstart + resource_size(res) - 1;
>
> - return kernel_ident_mapping_init(data->info, data->level4p, mstart, mend);
> + return kernel_ident_mapping_init(data->info, data->level4p,
> + res->start, res->end);
> }
>
> static int
> --
> 2.43.0
>