All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Rob Herring <robh@kernel.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	Daniel Scally <djrscally@gmail.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Len Brown <lenb@kernel.org>
Subject: Re: [PATCH v6 4/5] device property: Constify fwnode_handle_get()
Date: Wed, 13 Apr 2022 20:21:41 +0200	[thread overview]
Message-ID: <CAJZ5v0jcDztpR4rn0JqksCDwbFzq8VD8nZG-9QypQo63y-h1Sg@mail.gmail.com> (raw)
In-Reply-To: <YlcAYpZ0yB6wh1uA@smile.fi.intel.com>

On Wed, Apr 13, 2022 at 6:58 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Wed, Apr 13, 2022 at 05:35:46PM +0300, Sakari Ailus wrote:
> > On Sun, Apr 10, 2022 at 05:10:23PM +0300, Andy Shevchenko wrote:
> > > On Sat, Apr 9, 2022 at 2:35 AM Sakari Ailus
> > > <sakari.ailus@linux.intel.com> wrote:
> > > > On Fri, Apr 08, 2022 at 09:48:43PM +0300, Andy Shevchenko wrote:
> > > > > As to_of_node() suggests and the way the code in the OF and software node
> > > > > back ends actually uses the fwnode handle, it may be constified. Do this
> > > > > for good.
> > > >
> > > > How?
> > > >
> > > > If the fwnode is const, then the struct it contains must be presumed to be
> > > > const, too.
> > >
> > > Why? The idea is that we are not updating the fwnode, but the container.
> > > The container may or may not be const. It's orthogonal, no?
> >
> > As you wrote: may or may not. The stricter requirement, i.e. const, must be
> > thus followed. I think it would be fine (after adding a comment on what is
> > being done) if you *know* the container struct is not const. But that is
> > not the case here.
>
> But even with the original code one may not guarantee that. How the original
> code works or prevents of using a const container against non-const fwnode
> pointer?

I don't think that this is the point here.

If const struct fwnode_handle *fwnode is passed to the ->get()
callback, the callback itself (and any function called by it)
shouldn't attempt to update the memory pointed to by fwnode.  It need
not be the memory starting at the fwnode address IIUC, so that would
cover the whole object the fwnode is embedded in.

This way the caller of ->get() can assume the immutability of the
memory passed to it for read access.

The question is whether or not ->get() needs to update the memory in
question.  If it doesn't, making fwnode const is correct.

  reply	other threads:[~2022-04-13 18:21 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 18:48 [PATCH v6 1/5] device property: Allow error pointer to be passed to fwnode APIs Andy Shevchenko
2022-04-08 18:48 ` [PATCH v6 2/5] device property: Introduce fwnode_for_each_parent_node() Andy Shevchenko
2022-04-29 23:45   ` Doug Anderson
2022-04-08 18:48 ` [PATCH v6 3/5] device property: Drop 'test' prefix in parameters of fwnode_is_ancestor_of() Andy Shevchenko
2022-04-08 18:48 ` [PATCH v6 4/5] device property: Constify fwnode_handle_get() Andy Shevchenko
2022-04-08 21:36   ` Sakari Ailus
2022-04-10 14:10     ` Andy Shevchenko
2022-04-13 14:35       ` Sakari Ailus
2022-04-13 16:54         ` Andy Shevchenko
2022-04-13 18:21           ` Rafael J. Wysocki [this message]
2022-04-09  2:38   ` kernel test robot
2022-04-09  3:39   ` kernel test robot
2022-04-13 18:10   ` Rafael J. Wysocki
2022-04-13 18:19     ` Andy Shevchenko
2022-04-13 18:23       ` Andy Shevchenko
2022-04-13 21:47         ` Sakari Ailus
2022-04-14 13:09           ` Andy Shevchenko
2022-04-15 15:40             ` Rafael J. Wysocki
2022-04-08 18:48 ` [PATCH v6 5/5] device property: Constify fwnode APIs that uses fwnode_get_next_parent() Andy Shevchenko
2022-04-11 13:50 ` [PATCH v6 1/5] device property: Allow error pointer to be passed to fwnode APIs Andy Shevchenko
2022-04-11 14:28   ` Greg Kroah-Hartman
2022-04-11 15:46     ` Andy Shevchenko
2022-04-13 18:06       ` Rafael J. Wysocki
2022-04-13 18:20         ` Andy Shevchenko

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=CAJZ5v0jcDztpR4rn0JqksCDwbFzq8VD8nZG-9QypQo63y-h1Sg@mail.gmail.com \
    --to=rafael@kernel.org \
    --cc=andy.shevchenko@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=djrscally@gmail.com \
    --cc=frowand.list@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=sakari.ailus@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.