mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Frank Li" <Frank.li@nxp.com>
Cc: "Jason Gunthorpe" <jgg@ziepe.ca>,
	"Niklas Schnelle" <schnelle@linux.ibm.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Kent Overstreet" <kent.overstreet@linux.dev>,
	"open list" <linux-kernel@vger.kernel.org>,
	imx@lists.linux.dev
Subject: Re: [PATCH 1/1] linux/io.h: Add cleanup defination for iounmap() and memunmap()
Date: Fri, 02 Aug 2024 10:07:38 +0200	[thread overview]
Message-ID: <fea17390-f3de-470b-b252-e80f3ea2135f@app.fastmail.com> (raw)
In-Reply-To: <ZqumhgZ5heh0OYuA@lizhi-Precision-Tower-5810>

On Thu, Aug 1, 2024, at 17:15, Frank Li wrote:
> On Thu, Aug 01, 2024 at 09:27:40AM +0200, Arnd Bergmann wrote:
>> On Thu, Aug 1, 2024, at 01:31, Frank Li wrote:
>> > 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.
>
> Just !(_T) ? I just refer kfree()'s implementation.

Right, I think !(_T) is what we want here. I did see that kfree
has the same construct you are adding here, but did not read
up on how it got there.

>> 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.
>
>
> devm_* can help much especial in probe() function. but scope base cleanup
> also useful.

Yes, that's fine. My only point here is that you can't combine
the cleanup function you added with devm_ioremap(), as that needs
to be paired with either implicit cleanup or with devm_iounmap() but
not plain iounmap().

    Arnd

      reply	other threads:[~2024-08-02  8:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-31 23:31 Frank Li
2024-08-01  7:27 ` Arnd Bergmann
2024-08-01 15:15   ` Frank Li
2024-08-02  8:07     ` Arnd Bergmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fea17390-f3de-470b-b252-e80f3ea2135f@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=Frank.li@nxp.com \
    --cc=akpm@linux-foundation.org \
    --cc=ast@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schnelle@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®