Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
From: Daniel Scally <djrscally@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	linux-acpi@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Yong Zhi <yong.zhi@intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Bingbu Cao <bingbu.cao@intel.com>,
	Tianshu Qiu <tian.shu.qiu@intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>
Subject: Re: [PATCH v2 5/6] software node: Introduce SOFTWARE_NODE_REFERENCE() helper macro
Date: Mon, 29 Mar 2021 23:45:29 +0100
Message-ID: <5e76c3b8-d154-e5ca-25d8-290376469e5a@gmail.com> (raw)
In-Reply-To: <20210329151207.36619-5-andriy.shevchenko@linux.intel.com>

Hi Andy

On 29/03/2021 16:12, Andy Shevchenko wrote:
> This is useful to assign software node reference with arguments
> in a common way. Moreover, we have already couple of users that
> may be converted. And by the fact, one of them is moved right here
> to use the helper.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> v2: no changes
>  drivers/base/test/property-entry-test.c | 11 ++---------
>  include/linux/property.h                | 13 ++++++++-----
>  2 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/base/test/property-entry-test.c b/drivers/base/test/property-entry-test.c
> index abe03315180f..c2e455d46ffd 100644
> --- a/drivers/base/test/property-entry-test.c
> +++ b/drivers/base/test/property-entry-test.c
> @@ -370,15 +370,8 @@ static void pe_test_reference(struct kunit *test)
>  	};
>  
>  	static const struct software_node_ref_args refs[] = {
> -		{
> -			.node = &nodes[0],
> -			.nargs = 0,
> -		},
> -		{
> -			.node = &nodes[1],
> -			.nargs = 2,
> -			.args = { 3, 4 },
> -		},
> +		SOFTWARE_NODE_REFERENCE(&nodes[0]),
> +		SOFTWARE_NODE_REFERENCE(&nodes[1], 3, 4),
>  	};
>  
>  	const struct property_entry entries[] = {
> diff --git a/include/linux/property.h b/include/linux/property.h
> index dd4687b56239..0d876316e61d 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -254,6 +254,13 @@ struct software_node_ref_args {
>  	u64 args[NR_FWNODE_REFERENCE_ARGS];
>  };
>  
> +#define SOFTWARE_NODE_REFERENCE(_ref_, ...)			\
> +(const struct software_node_ref_args) {				\
> +	.node = _ref_,						\
> +	.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1,	\
> +	.args = { __VA_ARGS__ },				\
> +}
> +
>  /**
>   * struct property_entry - "Built-in" device property representation.
>   * @name: Name of the property.
> @@ -362,11 +369,7 @@ struct property_entry {
>  	.name = _name_,							\
>  	.length = sizeof(struct software_node_ref_args),		\
>  	.type = DEV_PROP_REF,						\
> -	{ .pointer = &(const struct software_node_ref_args) {		\
> -		.node = _ref_,						\
> -		.nargs = ARRAY_SIZE(((u64[]){ 0, ##__VA_ARGS__ })) - 1,	\
> -		.args = { __VA_ARGS__ },				\
> -	} },								\
> +	{ .pointer = &SOFTWARE_NODE_REFERENCE(_ref_, ##__VA_ARGS__), },	\
>  }


What are the .args intended to be used for? I actually had it in mind to
replace this with a simple pointer to a struct software_node, because I
can't see any users of them and the fact that it's actually storing a
pointer to a new variable is something that confused me for a good long
time when I wrote the cio2-bridge (though that's mostly due to my
relative inexperience of course, but still)

>  
>  struct property_entry *

  reply index

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 15:12 [PATCH v2 1/6] software node: Free resources explicitly when swnode_register() fails Andy Shevchenko
2021-03-29 15:12 ` [PATCH v2 2/6] software node: Introduce software_node_alloc()/software_node_free() Andy Shevchenko
2021-03-29 15:12 ` [PATCH v2 3/6] software node: Deduplicate code in fwnode_create_software_node() Andy Shevchenko
2021-03-29 21:06   ` Daniel Scally
2021-03-29 15:12 ` [PATCH v2 4/6] software node: Imply kobj_to_swnode() to be no-op Andy Shevchenko
2021-03-29 15:12 ` [PATCH v2 5/6] software node: Introduce SOFTWARE_NODE_REFERENCE() helper macro Andy Shevchenko
2021-03-29 22:45   ` Daniel Scally [this message]
2021-03-30  9:26     ` Andy Shevchenko
2021-03-31 11:25       ` Daniel Scally
2021-03-29 15:12 ` [PATCH v2 6/6] media: ipu3-cio2: Switch to use SOFTWARE_NODE_REFERENCE() Andy Shevchenko
2021-03-29 22:45 ` [PATCH v2 1/6] software node: Free resources explicitly when swnode_register() fails Daniel Scally
2021-03-31 11:06 ` Heikki Krogerus
2021-04-08 14:15   ` Rafael J. Wysocki
2021-04-08 14:50     ` Andy Shevchenko
2021-04-08 15:04       ` Rafael J. Wysocki
2021-04-08 15:18         ` Andy Shevchenko
2021-04-08 15:19           ` 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=5e76c3b8-d154-e5ca-25d8-290376469e5a@gmail.com \
    --to=djrscally@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bingbu.cao@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=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=rafael@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tian.shu.qiu@intel.com \
    --cc=yong.zhi@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

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git