public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bard Liao <yung-chuan.liao@linux.intel.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-acpi@vger.kernel.org, heikki.krogerus@linux.intel.com,
	rafael@kernel.org, bard.liao@intel.com
Subject: Re: [PATCH 2/2] device property: add description of fwnode cases
Date: Tue, 5 Jan 2021 16:44:43 +0200	[thread overview]
Message-ID: <20210105144443.GN4077@smile.fi.intel.com> (raw)
In-Reply-To: <20210105091146.25422-3-yung-chuan.liao@linux.intel.com>

On Tue, Jan 05, 2021 at 05:11:46PM +0800, Bard Liao wrote:
> There are only four valid fwnode cases which are
> - primary --> secondary --> -ENODEV
> - primary --> NULL
> - secondary --> -ENODEV
> - NULL
> 
> dev->fwnode should be converted between the 4 cases above no matter
> how/when set_primary_fwnode() and set_secondary_fwnode() are called.
> Describe it in the code so people will keep it in mind.

Thanks! It will help in the future to understand better this code.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
> ---
>  drivers/base/core.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 51b9545a050b..17eb14607074 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -4414,6 +4414,12 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode)
>   *
>   * Set the device's firmware node pointer to @fwnode, but if a secondary
>   * firmware node of the device is present, preserve it.
> + *
> + * Valid fwnode cases are:
> + *  - primary --> secondary --> -ENODEV
> + *  - primary --> NULL
> + *  - secondary --> -ENODEV
> + *  - NULL
>   */
>  void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>  {
> @@ -4432,6 +4438,7 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode)
>  	} else {
>  		if (fwnode_is_primary(fn)) {
>  			dev->fwnode = fn->secondary;
> +			/* Set fn->secondary = NULL to keep fn as a primary fwnode */
>  			if (!(parent && fn == parent->fwnode))
>  				fn->secondary = NULL;
>  		} else {
> -- 
> 2.17.1
> 

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2021-01-05 14:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05  9:11 [PATCH 0/2] Revert "device property: Keep secondary firmware node secondary by type" Bard Liao
2021-01-05  9:11 ` [PATCH 1/2] " Bard Liao
2021-01-05 14:44   ` Andy Shevchenko
2021-01-07 14:10   ` Heikki Krogerus
2021-01-05  9:11 ` [PATCH 2/2] device property: add description of fwnode cases Bard Liao
2021-01-05 14:44   ` Andy Shevchenko [this message]
2021-01-07 14:11   ` Heikki Krogerus
2021-01-07 16:58     ` Rafael J. Wysocki

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=20210105144443.GN4077@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bard.liao@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=yung-chuan.liao@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox