[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <969fb014-682e-4984-ad1b-7ab4f068ed85@app.fastmail.com>
Date: Thu, 01 Aug 2024 09:27:40 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Frank Li" <Frank.Li@....com>, "Jason Gunthorpe" <jgg@...pe.ca>,
"Niklas Schnelle" <schnelle@...ux.ibm.com>,
"Andrew Morton" <akpm@...ux-foundation.org>,
"Alexei Starovoitov" <ast@...nel.org>,
"Kent Overstreet" <kent.overstreet@...ux.dev>,
"open list" <linux-kernel@...r.kernel.org>
Cc: imx@...ts.linux.dev
Subject: Re: [PATCH 1/1] linux/io.h: Add cleanup defination for iounmap() and
memunmap()
On Thu, Aug 1, 2024, at 01:31, Frank Li wrote:
> Add DEFINE_FREE for iounmap() and memunmap() to support scope based
> cleanup.
>
> Signed-off-by: Frank Li <Frank.Li@....com>
> ---
> include/linux/io.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/linux/io.h b/include/linux/io.h
> index 59ec5eea696c4..7695d7973c8ff 100644
> --- a/include/linux/io.h
> +++ b/include/linux/io.h
> @@ -163,6 +163,9 @@ enum {
> void *memremap(resource_size_t offset, size_t size, unsigned long flags);
> void memunmap(void *addr);
>
> +DEFINE_FREE(iounmap, void __iomem *, if (!IS_ERR_OR_NULL(_T)) iounmap(_T))
> +DEFINE_FREE(memunmap, void *, if (!IS_ERR_OR_NULL(_T)) memunmap(_T))
I don't like the use of IS_ERR_OR_NULL(), which tends
to indicate a problem in the interface design.
In which cases do you expect to need scope based cleanup
on an error pointer here? The only interfaces I see that
returns an __iomem error pointer are the devm_* ones, but
those have their own cleanup method.
Arnd
Powered by blists - more mailing lists