[PATCH 1/2] kexec,x86: remove duplicate get_memory_ranges

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ping...

? 2013?01?11? 16:57, Zhang Yanfei ??:
> At first, we have already filled the kexec_info.memory_ranges by
> calling my_load() -> get_memory_ranges(). So if we want to
> get the memory information, we could just use the existing
> one instead of calling get_memory_ranges again.
> 
> Signed-off-by: Zhang Yanfei <zhangyanfei at cn.fujitsu.com>
> ---
>  kexec/arch/i386/kexec-bzImage.c       |    2 +-
>  kexec/arch/i386/kexec-elf-x86.c       |    2 +-
>  kexec/arch/i386/kexec-multiboot-x86.c |    7 ++-----
>  kexec/arch/i386/x86-linux-setup.c     |   10 ++++------
>  kexec/arch/i386/x86-linux-setup.h     |    4 ++--
>  kexec/arch/x86_64/kexec-elf-x86_64.c  |    2 +-
>  6 files changed, 11 insertions(+), 16 deletions(-)
> 
> diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
> index 0605909..83a023d 100644
> --- a/kexec/arch/i386/kexec-bzImage.c
> +++ b/kexec/arch/i386/kexec-bzImage.c
> @@ -324,7 +324,7 @@ int do_bzImage_load(struct kexec_info *info,
>  
>  	/* Fill in the information BIOS calls would normally provide. */
>  	if (!real_mode_entry) {
> -		setup_linux_system_parameters(real_mode, info->kexec_flags);
> +		setup_linux_system_parameters(info, real_mode);
>  	}
>  
>  	return 0;
> diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
> index 8bd5ef6..e62ebcb 100644
> --- a/kexec/arch/i386/kexec-elf-x86.c
> +++ b/kexec/arch/i386/kexec-elf-x86.c
> @@ -272,7 +272,7 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
>  			ramdisk_buf, ramdisk_length);
>  
>  		/* Fill in the information bios calls would usually provide */
> -		setup_linux_system_parameters(&hdr->hdr, info->kexec_flags);
> +		setup_linux_system_parameters(info, &hdr->hdr);
>  
>  		/* Initialize the registers */
>  		elf_rel_get_symbol(&info->rhdr, "entry32_regs", &regs, sizeof(regs));
> diff --git a/kexec/arch/i386/kexec-multiboot-x86.c b/kexec/arch/i386/kexec-multiboot-x86.c
> index 23dab7b..de2a423 100644
> --- a/kexec/arch/i386/kexec-multiboot-x86.c
> +++ b/kexec/arch/i386/kexec-multiboot-x86.c
> @@ -248,11 +248,8 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
>  	mbi->boot_loader_name = sizeof(*mbi) + command_line_len; 
>  
>  	/* Memory map */
> -	if ((get_memory_ranges(&range, &ranges, info->kexec_flags) < 0)
> -			|| ranges == 0) {
> -		fprintf(stderr, "Cannot get memory information\n");
> -		return -1;
> -	}
> +	range = info->memory_range;
> +	ranges = info->memory_ranges;
>  	mmap = xmalloc(ranges * sizeof(*mmap));
>  	for (i=0; i<ranges; i++) {
>  		unsigned long long length;
> diff --git a/kexec/arch/i386/x86-linux-setup.c b/kexec/arch/i386/x86-linux-setup.c
> index b7ab8ea..ef62553 100644
> --- a/kexec/arch/i386/x86-linux-setup.c
> +++ b/kexec/arch/i386/x86-linux-setup.c
> @@ -441,8 +441,8 @@ close:
>  	close(data_file);
>  }
>  
> -void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
> -					unsigned long kexec_flags)
> +void setup_linux_system_parameters(struct kexec_info *info,
> +				   struct x86_linux_param_header *real_mode)
>  {
>  	/* Fill in information the BIOS would usually provide */
>  	struct memory_range *range;
> @@ -486,10 +486,8 @@ void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
>  	/* another safe default */
>  	real_mode->aux_device_info = 0;
>  
> -	/* Fill in the memory info */
> -	if ((get_memory_ranges(&range, &ranges, kexec_flags) < 0) || ranges == 0) {
> -		die("Cannot get memory information\n");
> -	}
> +	range = info->memory_range;
> +	ranges = info->memory_ranges;
>  	if (ranges > E820MAX) {
>  		fprintf(stderr, "Too many memory ranges, truncating...\n");
>  		ranges = E820MAX;
> diff --git a/kexec/arch/i386/x86-linux-setup.h b/kexec/arch/i386/x86-linux-setup.h
> index 8862513..96fbd33 100644
> --- a/kexec/arch/i386/x86-linux-setup.h
> +++ b/kexec/arch/i386/x86-linux-setup.h
> @@ -7,8 +7,8 @@ void setup_linux_bootloader_parameters(
>  	unsigned long real_mode_base, unsigned long cmdline_offset,
>  	const char *cmdline, off_t cmdline_len,
>  	const char *initrd_buf, off_t initrd_size);
> -void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
> -					unsigned long kexec_flags);
> +void setup_linux_system_parameters(struct kexec_info *info,
> +	struct x86_linux_param_header *real_mode);
>  
>  
>  #define SETUP_BASE    0x90000
> diff --git a/kexec/arch/x86_64/kexec-elf-x86_64.c b/kexec/arch/x86_64/kexec-elf-x86_64.c
> index fe4b76b..a3fc728 100644
> --- a/kexec/arch/x86_64/kexec-elf-x86_64.c
> +++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
> @@ -253,7 +253,7 @@ int elf_x86_64_load(int argc, char **argv, const char *buf, off_t len,
>  			ramdisk_buf, ramdisk_length);
>  
>  		/* Fill in the information bios calls would usually provide */
> -		setup_linux_system_parameters(&hdr->hdr, info->kexec_flags);
> +		setup_linux_system_parameters(info, &hdr->hdr);
>  
>  		/* Initialize the registers */
>  		elf_rel_get_symbol(&info->rhdr, "entry64_regs", &regs, sizeof(regs));




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux