* [PATCH] m68k: Pass a pointer to virt_to_pfn() virt_to_page()
@ 2023-03-23 13:36 Linus Walleij
2023-03-23 13:42 ` Andreas Schwab
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2023-03-23 13:36 UTC (permalink / raw)
To: Geert Uytterhoeven, linux-m68k; +Cc: linux-gpio, Linus Walleij
Functions that work on a pointer to virtual memory such as
virt_to_pfn() and users of that function such as
virt_to_page() are supposed to pass a pointer to virtual
memory, ideally a (void *) or other pointer. However since
many architectures implement virt_to_pfn() as a macro,
this function becomes polymorphic and accepts both a
(unsigned long) and a (void *).
Fix up the offending calls in arch/m68k with explicit casts.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
arch/m68k/mm/motorola.c | 4 ++--
arch/m68k/mm/sun3mmu.c | 2 +-
arch/m68k/sun3/dvma.c | 2 +-
arch/m68k/sun3x/dvma.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 911301224078..0a9bc8292f78 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -102,7 +102,7 @@ static struct list_head ptable_list[2] = {
LIST_HEAD_INIT(ptable_list[1]),
};
-#define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page(page)->lru))
+#define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page((void *)page)->lru))
#define PD_PAGE(ptable) (list_entry(ptable, struct page, lru))
#define PD_MARKBITS(dp) (*(unsigned int *)&PD_PAGE(dp)->index)
@@ -201,7 +201,7 @@ int free_pointer_table(void *table, int type)
list_del(dp);
mmu_page_dtor((void *)page);
if (type == TABLE_PTE)
- pgtable_pte_page_dtor(virt_to_page(page));
+ pgtable_pte_page_dtor(virt_to_page((void *)page));
free_page (page);
return 1;
} else if (ptable_list[type].next != dp) {
diff --git a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c
index b619d0d4319c..c5e6a23e0262 100644
--- a/arch/m68k/mm/sun3mmu.c
+++ b/arch/m68k/mm/sun3mmu.c
@@ -75,7 +75,7 @@ void __init paging_init(void)
/* now change pg_table to kernel virtual addresses */
pg_table = (pte_t *) __va ((unsigned long) pg_table);
for (i=0; i<PTRS_PER_PTE; ++i, ++pg_table) {
- pte_t pte = pfn_pte(virt_to_pfn(address), PAGE_INIT);
+ pte_t pte = pfn_pte(virt_to_pfn((void *)address), PAGE_INIT);
if (address >= (unsigned long)high_memory)
pte_val (pte) = 0;
set_pte (pg_table, pte);
diff --git a/arch/m68k/sun3/dvma.c b/arch/m68k/sun3/dvma.c
index f15ff16b9997..83fcae6a0e79 100644
--- a/arch/m68k/sun3/dvma.c
+++ b/arch/m68k/sun3/dvma.c
@@ -29,7 +29,7 @@ static unsigned long dvma_page(unsigned long kaddr, unsigned long vaddr)
j = *(volatile unsigned long *)kaddr;
*(volatile unsigned long *)kaddr = j;
- ptep = pfn_pte(virt_to_pfn(kaddr), PAGE_KERNEL);
+ ptep = pfn_pte(virt_to_pfn((void *)kaddr), PAGE_KERNEL);
pte = pte_val(ptep);
// pr_info("dvma_remap: addr %lx -> %lx pte %08lx\n", kaddr, vaddr, pte);
if(ptelist[(vaddr & 0xff000) >> PAGE_SHIFT] != pte) {
diff --git a/arch/m68k/sun3x/dvma.c b/arch/m68k/sun3x/dvma.c
index 08bb92113026..a6034ba05845 100644
--- a/arch/m68k/sun3x/dvma.c
+++ b/arch/m68k/sun3x/dvma.c
@@ -125,7 +125,7 @@ inline int dvma_map_cpu(unsigned long kaddr,
do {
pr_debug("mapping %08lx phys to %08lx\n",
__pa(kaddr), vaddr);
- set_pte(pte, pfn_pte(virt_to_pfn(kaddr),
+ set_pte(pte, pfn_pte(virt_to_pfn((void *)kaddr),
PAGE_KERNEL));
pte++;
kaddr += PAGE_SIZE;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] m68k: Pass a pointer to virt_to_pfn() virt_to_page()
2023-03-23 13:36 [PATCH] m68k: Pass a pointer to virt_to_pfn() virt_to_page() Linus Walleij
@ 2023-03-23 13:42 ` Andreas Schwab
2023-03-23 15:09 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2023-03-23 13:42 UTC (permalink / raw)
To: Linus Walleij; +Cc: Geert Uytterhoeven, linux-m68k, linux-gpio
On Mär 23 2023, Linus Walleij wrote:
> diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
> index 911301224078..0a9bc8292f78 100644
> --- a/arch/m68k/mm/motorola.c
> +++ b/arch/m68k/mm/motorola.c
> @@ -102,7 +102,7 @@ static struct list_head ptable_list[2] = {
> LIST_HEAD_INIT(ptable_list[1]),
> };
>
> -#define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page(page)->lru))
> +#define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page((void *)page)->lru))
That should probably get a pair of parens around the macro argument.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] m68k: Pass a pointer to virt_to_pfn() virt_to_page()
2023-03-23 13:42 ` Andreas Schwab
@ 2023-03-23 15:09 ` Linus Walleij
0 siblings, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2023-03-23 15:09 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Geert Uytterhoeven, linux-m68k, linux-gpio
On Thu, Mar 23, 2023 at 2:42 PM Andreas Schwab <schwab@linux-m68k.org> wrote:
> On Mär 23 2023, Linus Walleij wrote:
>
> > diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
> > index 911301224078..0a9bc8292f78 100644
> > --- a/arch/m68k/mm/motorola.c
> > +++ b/arch/m68k/mm/motorola.c
> > @@ -102,7 +102,7 @@ static struct list_head ptable_list[2] = {
> > LIST_HEAD_INIT(ptable_list[1]),
> > };
> >
> > -#define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page(page)->lru))
> > +#define PD_PTABLE(page) ((ptable_desc *)&(virt_to_page((void *)page)->lru))
>
> That should probably get a pair of parens around the macro argument.
Ooops that's right. I'll fix.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-23 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-23 13:36 [PATCH] m68k: Pass a pointer to virt_to_pfn() virt_to_page() Linus Walleij
2023-03-23 13:42 ` Andreas Schwab
2023-03-23 15:09 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).