treewide: use PHYS_ADDR_MAX to avoid type casting ULLONG_MAX
Subsystems (11)
PATCH 1/1 treewide: use PHYS_ADDR_MAX to avoid type casting ULLONG_MAX
With PHYS_ADDR_MAX there is now a type safe variant for all bits set. Make use of it.
Patch created using a sematic patch as follows:
// <smpl>
@@
typedef phys_addr_t;
@@
-(phys_addr_t)ULLONG_MAX
+PHYS_ADDR_MAX
// </smpl>
--- arch/arm64/mm/init.c | 6 +++--- arch/mips/kernel/setup.c | 4 ++-- arch/powerpc/mm/mem.c | 2 +- arch/sparc/mm/init_64.c | 2 +- arch/x86/mm/init_32.c | 2 +- arch/x86/mm/init_64.c | 2 +- drivers/firmware/efi/arm-init.c | 2 +- drivers/remoteproc/qcom_q6v5_pil.c | 2 +- drivers/soc/qcom/mdt_loader.c | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-)
arch/arm64/mm/init.c +3 -3
@@ -310,7 +310,7 @@ static void __init arm64_memory_present(void) }#endif -static phys_addr_t memory_limit = (phys_addr_t )ULLONG_MAX ; +static phys_addr_t memory_limit =PHYS_ADDR_MAX ;/* * Limit the memory size that was specified via FDT.
@@ -401,7 +401,7 @@ void __init arm64_memblock_init(void)* high up in memory, add back the kernel region that must be accessible * via the linear mapping. */ -if (memory_limit != (phys_addr_t )ULLONG_MAX ) { +if (memory_limit !=PHYS_ADDR_MAX ) {memblock_mem_limit_remove_map (memory_limit);memblock_add (__pa_symbol (_text), (u64)(_end - _text)); }
@@ -664,7 +664,7 @@ __setup("keepinitrd", keepinitrd_setup);*/ static int dump_mem_limit (struct notifier_block *self,unsigned long v,void *p) { -if (memory_limit != (phys_addr_t )ULLONG_MAX ) { +if (memory_limit !=PHYS_ADDR_MAX ) {pr_emerg ("Memory Limit: %llu MB\n" , memory_limit >>20 ); }else {pr_emerg ("Memory Limit: none\n" );
arch/mips/kernel/setup.c +2 -2
@@ -93,7 +93,7 @@ void __init add_memory_region(phys_addr_t start, phys_addr_t size, long type)* If the region reaches the top of the physical address space, adjust * the size slightly so that (start + size) doesn't overflow */ -if (start + size -1 == (phys_addr_t )ULLONG_MAX ) +if (start + size -1 ==PHYS_ADDR_MAX ) --size;/* Sanity check */
@@ -376,7 +376,7 @@ static void __init bootmem_init(void)unsigned long reserved_end;unsigned long mapstart = ~0UL ;unsigned long bootmap_size; -phys_addr_t ramstart = (phys_addr_t )ULLONG_MAX ; +phys_addr_t ramstart =PHYS_ADDR_MAX ;bool bootmap_valid = false;int i;
arch/powerpc/mm/mem.c +1 -1
@@ -213,7 +213,7 @@ void __init mem_topology_setup(void)/* Place all memblock_regions in the same node and merge contiguous * memblock_regions */ -memblock_set_node (0 , (phys_addr_t )ULLONG_MAX , &memblock.memory,0 ); +memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 ); }void __init initmem_init (void )
arch/sparc/mm/init_64.c +1 -1
@@ -1620,7 +1620,7 @@ static void __init bootmem_init_nonnuma(void) (top_of_ram - total_ram) >> 20);init_node_masks_nonnuma (); -memblock_set_node (0 , (phys_addr_t )ULLONG_MAX , &memblock.memory,0 ); +memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 );allocate_node_data (0 );node_set_online (0 ); }
arch/x86/mm/init_32.c +1 -1
@@ -692,7 +692,7 @@ void __init initmem_init(void) high_memory = (void *)__va (max_low_pfn *PAGE_SIZE -1 ) +1 ;#endif -memblock_set_node (0 , (phys_addr_t )ULLONG_MAX , &memblock.memory,0 ); +memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 );sparse_memory_present_with_active_regions (0 );#ifdef CONFIG_FLATMEM
arch/x86/mm/init_64.c +1 -1
@@ -742,7 +742,7 @@ kernel_physical_mapping_init(unsigned long paddr_start,#ifndef CONFIG_NUMA void __init initmem_init (void ) { -memblock_set_node (0 , (phys_addr_t )ULLONG_MAX , &memblock.memory,0 ); +memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 ); }#endif
drivers/firmware/efi/arm-init.c +1 -1
@@ -193,7 +193,7 @@ static __init void reserve_regions(void)* uses its own memory map instead. */ memblock_dump_all (); -memblock_remove (0 , (phys_addr_t )ULLONG_MAX ); +memblock_remove (0 ,PHYS_ADDR_MAX );for_each_efi_memory_desc (md) { paddr = md->phys_addr;
drivers/remoteproc/qcom_q6v5_pil.c +1 -1
@@ -615,7 +615,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)struct elf32_hdr *ehdr;phys_addr_t mpss_reloc;phys_addr_t boot_addr; -phys_addr_t min_addr = (phys_addr_t )ULLONG_MAX ; +phys_addr_t min_addr =PHYS_ADDR_MAX ;phys_addr_t max_addr =0 ;bool relocate = false;char seg_name[10 ];
drivers/soc/qcom/mdt_loader.c +2 -2
@@ -50,7 +50,7 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)const struct elf32_phdr *phdrs;const struct elf32_phdr *phdr;const struct elf32_hdr *ehdr; -phys_addr_t min_addr = (phys_addr_t )ULLONG_MAX ; +phys_addr_t min_addr =PHYS_ADDR_MAX ;phys_addr_t max_addr =0 ;int i;
@@ -97,7 +97,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,const struct elf32_hdr *ehdr;const struct firmware *seg_fw;phys_addr_t mem_reloc; -phys_addr_t min_addr = (phys_addr_t )ULLONG_MAX ; +phys_addr_t min_addr =PHYS_ADDR_MAX ;phys_addr_t max_addr =0 ;size_t fw_name_len;ssize_t offset;
Signature · 1 line
2.17.0
Quoted 13 lines · Stefan Agner
With
PHYS_ADDR_MAXthere is now a type safe variant for all bits set. Make use of it.Patch created using a sematic patch as follows:
// <smpl>
@@
typedefphys_addr_t;
@@(quoted diff) +1
-1-(phys_addr_t)ULLONG_MAX +PHYS_ADDR_MAX// </smpl>
Quoted 1 line
Signed-off-by Stefan Agner <[email protected]>
Quoted 168 lines
--- arch/arm64/mm/init.c | 6 +++--- arch/mips/kernel/setup.c | 4 ++-- arch/powerpc/mm/mem.c | 2 +- arch/sparc/mm/init_64.c | 2 +- arch/x86/mm/init_32.c | 2 +- arch/x86/mm/init_64.c | 2 +- drivers/firmware/efi/arm-init.c | 2 +- drivers/remoteproc/qcom_q6v5_pil.c | 2 +- drivers/soc/qcom/mdt_loader.c | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-)arch/arm64/mm/init.c +3
-3@@ -310,7 +310,7 @@ static void __init arm64_memory_present(void) }#endif -static phys_addr_t memory_limit = (phys_addr_t )ULLONG_MAX ; +static phys_addr_t memory_limit =PHYS_ADDR_MAX ;/* * Limit the memory size that was specified via FDT. @@ -401,7 +401,7 @@ void __init arm64_memblock_init(void)* high up in memory, add back the kernel region that must be accessible * via the linear mapping. */ -if (memory_limit != (phys_addr_t )ULLONG_MAX ) { +if (memory_limit !=PHYS_ADDR_MAX ) {memblock_mem_limit_remove_map (memory_limit);memblock_add (__pa_symbol (_text), (u64)(_end - _text)); }@@ -664,7 +664,7 @@ __setup("keepinitrd", keepinitrd_setup);*/ static int dump_mem_limit (struct notifier_block *self,unsigned long v,void *p) { -if (memory_limit != (phys_addr_t )ULLONG_MAX ) { +if (memory_limit !=PHYS_ADDR_MAX ) {pr_emerg ("Memory Limit: %llu MB\n" , memory_limit >>20 ); }else {pr_emerg ("Memory Limit: none\n" );arch/mips/kernel/setup.c +2
-2@@ -93,7 +93,7 @@ void __init add_memory_region(phys_addr_t start, phys_addr_t size, long type)* If the region reaches the top of the physical address space, adjust * the size slightly so that (start + size) doesn't overflow */ -if (start + size -1 == (phys_addr_t )ULLONG_MAX ) +if (start + size -1 ==PHYS_ADDR_MAX ) --size;/* Sanity check */ @@ -376,7 +376,7 @@ static void __init bootmem_init(void)unsigned long reserved_end;unsigned long mapstart = ~0UL ;unsigned long bootmap_size; -phys_addr_t ramstart = (phys_addr_t )ULLONG_MAX ; +phys_addr_t ramstart =PHYS_ADDR_MAX ;bool bootmap_valid = false;int i;arch/powerpc/mm/mem.c +1
-1@@ -213,7 +213,7 @@ void __init mem_topology_setup(void)/* Place all memblock_regions in the same node and merge contiguous * memblock_regions */ -memblock_set_node (0 , (phys_addr_t )ULLONG_MAX , &memblock.memory,0 ); +memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 ); }void __init initmem_init (void )arch/sparc/mm/init_64.c +1
-1@@ -1620,7 +1620,7 @@ static void __init bootmem_init_nonnuma(void) (top_of_ram - total_ram) >> 20);init_node_masks_nonnuma (); -memblock_set_node (0 , (phys_addr_t )ULLONG_MAX , &memblock.memory,0 ); +memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 );allocate_node_data (0 );node_set_online (0 ); }arch/x86/mm/init_32.c +1
-1@@ -692,7 +692,7 @@ void __init initmem_init(void) high_memory = (void *)__va (max_low_pfn *PAGE_SIZE -1 ) +1 ;#endif -memblock_set_node (0 , (phys_addr_t )ULLONG_MAX , &memblock.memory,0 ); +memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 );sparse_memory_present_with_active_regions (0 );#ifdef CONFIG_FLATMEM arch/x86/mm/init_64.c +1
-1@@ -742,7 +742,7 @@ kernel_physical_mapping_init(unsigned long paddr_start,#ifndef CONFIG_NUMA void __init initmem_init (void ) { -memblock_set_node (0 , (phys_addr_t )ULLONG_MAX , &memblock.memory,0 ); +memblock_set_node (0 ,PHYS_ADDR_MAX , &memblock.memory,0 ); }#endif drivers/firmware/efi/arm-init.c +1
-1@@ -193,7 +193,7 @@ static __init void reserve_regions(void)* uses its own memory map instead. */ memblock_dump_all (); -memblock_remove (0 , (phys_addr_t )ULLONG_MAX ); +memblock_remove (0 ,PHYS_ADDR_MAX );for_each_efi_memory_desc (md) { paddr = md->phys_addr;drivers/remoteproc/qcom_q6v5_pil.c +1
-1@@ -615,7 +615,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)struct elf32_hdr *ehdr;phys_addr_t mpss_reloc;phys_addr_t boot_addr; -phys_addr_t min_addr = (phys_addr_t )ULLONG_MAX ; +phys_addr_t min_addr =PHYS_ADDR_MAX ;phys_addr_t max_addr =0 ;bool relocate = false;char seg_name[10 ];drivers/soc/qcom/mdt_loader.c +2
-3@@ -50,7 +50,7 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)const struct elf32_phdr *phdrs;const struct elf32_phdr *phdr;const struct elf32_hdr *ehdr; -phys_addr_t min_addr = (phys_addr_t )ULLONG_MAX ; +phys_addr_t min_addr =PHYS_ADDR_MAX ;phys_addr_t max_addr =0 ;int i;@@ -97,7 +97,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,const struct elf32_hdr *ehdr;const struct firmware *seg_fw;phys_addr_t mem_reloc; -phys_addr_t min_addr = (phys_addr_t )ULLONG_MAX ; +phys_addr_t min_addr =PHYS_ADDR_MAX ;phys_addr_t max_addr =0 ;size_t fw_name_len;ssize_t offset; --2.17.0
Quoted 13 lines · Stefan Agner
With
PHYS_ADDR_MAXthere is now a type safe variant for all bits set. Make use of it.Patch created using a sematic patch as follows:
// <smpl>
@@
typedefphys_addr_t;
@@(quoted diff) +1
-1-(phys_addr_t)ULLONG_MAX +PHYS_ADDR_MAX// </smpl>
Quoted 3 lines
Signed-off-by Stefan Agner <[email protected]>--- arch/arm64/mm/init.c | 6 +++---
For arm64:
Quoted 2 lines · Stefan Agner
With
PHYS_ADDR_MAXthere is now a type safe variant for all bits set. Make use of it.
There is? I don't see it in linux-next.
Quoted 5 lines · Matthew Wilcox
Quoted 2 lines · Stefan Agner
With
PHYS_ADDR_MAXthere is now a type safe variant for all bits set. Make use of it.There is? I don't see it in linux-next.
The patch "mm/memblock: introduce PHYS_ADDR_MAX" got merged earlier this week, should be in the -mm tree.
--
Stefan
Quoted 9 lines · Stefan Agner
Quoted 5 lines · Matthew Wilcox
Quoted 2 lines · Stefan Agner
With
PHYS_ADDR_MAXthere is now a type safe variant for all bits set. Make use of it.There is? I don't see it in linux-next.
The patch "mm/memblock: introduce
PHYS_ADDR_MAX" got merged earlier this week, should be in the -mm tree.
Andrew hasn't released his mmotm tree yet so this is not in linux-next yet as well.
Signature · 2 lines
Michal Hocko SUSE Labs