arch/loongarch/include/asm/pgtable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
From: WangYuli <wangyl5933@chinaunicom.cn>
The __pmd() and __pte() helper macros provide the correct initialization
syntax and abstraction for the pmd_t and pte_t types.
Fix follow warning on gcc-15 under specific configs [1] :
In file included from ./include/linux/pgtable.h:6,
from ./include/linux/mm.h:31,
from ./include/linux/pagemap.h:8,
from arch/loongarch/mm/init.c:14:
./include/linux/swapops.h: In function ‘swp_entry_to_pmd’:
./arch/loongarch/include/asm/pgtable.h:302:34: error: missing braces around initializer [-Werror=missing-braces]
302 | #define __swp_entry_to_pmd(x) ((pmd_t) { (x).val | _PAGE_HUGE })
| ^
./include/linux/swapops.h:559:16: note: in expansion of macro ‘__swp_entry_to_pmd’
559 | return __swp_entry_to_pmd(arch_entry);
| ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Also update __swp_entry_to_pte() to use __pte() for consistency.
[1]. https://download.01.org/0day-ci/archive/20251119/202511190316.luI90kAo-lkp@intel.com/config
Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Signed-off-by: WangYuli <wangyuli@aosc.io>
---
Changelog:
*v1 -> v2: Update __swp_entry_to_pte() to use __pte() for consistency.
---
arch/loongarch/include/asm/pgtable.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index 03fb60432fde..9a7029285fd5 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -297,9 +297,9 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
#define __swp_offset(x) ((x).val >> 24)
#define __swp_entry(type, offset) ((swp_entry_t) { pte_val(mk_swap_pte((type), (offset))) })
#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
-#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
+#define __swp_entry_to_pte(x) __pte((x).val)
#define __pmd_to_swp_entry(pmd) ((swp_entry_t) { pmd_val(pmd) })
-#define __swp_entry_to_pmd(x) ((pmd_t) { (x).val | _PAGE_HUGE })
+#define __swp_entry_to_pmd(x) __pmd((x).val | _PAGE_HUGE)
static inline bool pte_swp_exclusive(pte_t pte)
{
--
2.51.0
Applied, thanks.
Huacai
On Thu, Dec 4, 2025 at 10:45 AM WangYuli <wangyuli@aosc.io> wrote:
>
> From: WangYuli <wangyl5933@chinaunicom.cn>
>
> The __pmd() and __pte() helper macros provide the correct initialization
> syntax and abstraction for the pmd_t and pte_t types.
>
> Fix follow warning on gcc-15 under specific configs [1] :
>
> In file included from ./include/linux/pgtable.h:6,
> from ./include/linux/mm.h:31,
> from ./include/linux/pagemap.h:8,
> from arch/loongarch/mm/init.c:14:
> ./include/linux/swapops.h: In function ‘swp_entry_to_pmd’:
> ./arch/loongarch/include/asm/pgtable.h:302:34: error: missing braces around initializer [-Werror=missing-braces]
> 302 | #define __swp_entry_to_pmd(x) ((pmd_t) { (x).val | _PAGE_HUGE })
> | ^
> ./include/linux/swapops.h:559:16: note: in expansion of macro ‘__swp_entry_to_pmd’
> 559 | return __swp_entry_to_pmd(arch_entry);
> | ^~~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> Also update __swp_entry_to_pte() to use __pte() for consistency.
>
> [1]. https://download.01.org/0day-ci/archive/20251119/202511190316.luI90kAo-lkp@intel.com/config
>
> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
> Signed-off-by: WangYuli <wangyuli@aosc.io>
> ---
> Changelog:
> *v1 -> v2: Update __swp_entry_to_pte() to use __pte() for consistency.
> ---
> arch/loongarch/include/asm/pgtable.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
> index 03fb60432fde..9a7029285fd5 100644
> --- a/arch/loongarch/include/asm/pgtable.h
> +++ b/arch/loongarch/include/asm/pgtable.h
> @@ -297,9 +297,9 @@ static inline pte_t mk_swap_pte(unsigned long type, unsigned long offset)
> #define __swp_offset(x) ((x).val >> 24)
> #define __swp_entry(type, offset) ((swp_entry_t) { pte_val(mk_swap_pte((type), (offset))) })
> #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
> -#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
> +#define __swp_entry_to_pte(x) __pte((x).val)
> #define __pmd_to_swp_entry(pmd) ((swp_entry_t) { pmd_val(pmd) })
> -#define __swp_entry_to_pmd(x) ((pmd_t) { (x).val | _PAGE_HUGE })
> +#define __swp_entry_to_pmd(x) __pmd((x).val | _PAGE_HUGE)
>
> static inline bool pte_swp_exclusive(pte_t pte)
> {
> --
> 2.51.0
>
© 2016 - 2025 Red Hat, Inc.