[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YwspB8OP8/Phv+tO@li-4a3a4a4c-28e5-11b2-a85c-a8d192c6f089.ibm.com>
Date: Sun, 28 Aug 2022 10:36:23 +0200
From: Alexander Gordeev <agordeev@...ux.ibm.com>
To: Baoquan He <bhe@...hat.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
akpm@...ux-foundation.org, hch@...radead.org,
wangkefeng.wang@...wei.com, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 01/11] mm/ioremap: change the return value of
io[re|un]map_allowed and rename
On Sat, Aug 20, 2022 at 08:31:15AM +0800, Baoquan He wrote:
Hi Baoquan,
> arch_ioremap() return a bool,
> - IS_ERR means return an error
> - NULL means continue to remap
> - a non-NULL, non-IS_ERR pointer is returned directly
> arch_iounmap() return a bool,
> - 0 means continue to vunmap
> - error code means skip vunmap and return directly
It would make more sense if the return values were described
from the prospective of an architecture, not the caller.
I.e true - unmapped, false - not supported, etc.
> diff --git a/mm/ioremap.c b/mm/ioremap.c
> index 8652426282cc..99fde69becc7 100644
> --- a/mm/ioremap.c
> +++ b/mm/ioremap.c
> @@ -17,6 +17,13 @@ void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
> unsigned long offset, vaddr;
> phys_addr_t last_addr;
> struct vm_struct *area;
> + void __iomem *ioaddr;
> +
> + ioaddr = arch_ioremap(phys_addr, size, prot);
> + if (IS_ERR(ioaddr))
> + return NULL;
> + else if (ioaddr)
> + return ioaddr;
It seems to me arch_ioremap() could simply return an address
or an error. Then IOMEM_ERR_PTR(-ENOSYS) if the architecture
does not support it reads much better than the cryptic NULL.
Probably arch_iounmap() returning error would look better too,
though not sure about that.
Thanks!
Powered by blists - more mailing lists