public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Daniel Scally <djrscally@gmail.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: Re: [PATCH v3 1/3] device property: Get rid of __PROPERTY_ENTRY_ARRAY_EL*SIZE*()
Date: Tue, 22 Nov 2022 15:11:09 +0200	[thread overview]
Message-ID: <Y3zKbbMpcaHfqB2C@kuha.fi.intel.com> (raw)
In-Reply-To: <20221111154621.15941-1-andriy.shevchenko@linux.intel.com>

On Fri, Nov 11, 2022 at 05:46:19PM +0200, Andy Shevchenko wrote:
> First of all, _ELEMENT_SIZE() repeats existing sizeof_field() macro.
> Second, usage of _ARRAY_ELSIZE_LEN() adds unnecessary indirection
> to the data layout. It's more understandable when the data structure
> is placed explicitly. That said, get rid of those macros by replacing
> them with the existing helper and explicit data structure layout.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

For the series:

Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
> v3: fixed typo in PROPERTY_ENTRY_REF_ARRAY_LEN() impl (LKP)
> v2: rebased on latest Linux Next, fixed anon union assignment
>  include/linux/property.h | 34 ++++++++++++++--------------------
>  1 file changed, 14 insertions(+), 20 deletions(-)
> 
> diff --git a/include/linux/property.h b/include/linux/property.h
> index 5d840299146d..0eab13a5c7df 100644
> --- a/include/linux/property.h
> +++ b/include/linux/property.h
> @@ -12,6 +12,7 @@
>  
>  #include <linux/bits.h>
>  #include <linux/fwnode.h>
> +#include <linux/stddef.h>
>  #include <linux/types.h>
>  
>  struct device;
> @@ -311,24 +312,14 @@ struct property_entry {
>   * crafted to avoid gcc-4.4.4's problems with initialization of anon unions
>   * and structs.
>   */
> -
> -#define __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_)				\
> -	sizeof(((struct property_entry *)NULL)->value._elem_[0])
> -
> -#define __PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_, _elsize_, _Type_,	\
> -					  _val_, _len_)			\
> -(struct property_entry) {						\
> -	.name = _name_,							\
> -	.length = (_len_) * (_elsize_),					\
> -	.type = DEV_PROP_##_Type_,					\
> -	{ .pointer = _val_ },						\
> +#define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_)		\
> +(struct property_entry) {								\
> +	.name = _name_,									\
> +	.length = (_len_) * sizeof_field(struct property_entry, value._elem_[0]),	\
> +	.type = DEV_PROP_##_Type_,							\
> +	{ .pointer = _val_ },								\
>  }
>  
> -#define __PROPERTY_ENTRY_ARRAY_LEN(_name_, _elem_, _Type_, _val_, _len_)\
> -	__PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_,			\
> -				__PROPERTY_ENTRY_ELEMENT_SIZE(_elem_),	\
> -				_Type_, _val_, _len_)
> -
>  #define PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, _len_)		\
>  	__PROPERTY_ENTRY_ARRAY_LEN(_name_, u8_data, U8, _val_, _len_)
>  #define PROPERTY_ENTRY_U16_ARRAY_LEN(_name_, _val_, _len_)		\
> @@ -340,9 +331,12 @@ struct property_entry {
>  #define PROPERTY_ENTRY_STRING_ARRAY_LEN(_name_, _val_, _len_)		\
>  	__PROPERTY_ENTRY_ARRAY_LEN(_name_, str, STRING, _val_, _len_)
>  #define PROPERTY_ENTRY_REF_ARRAY_LEN(_name_, _val_, _len_)		\
> -	__PROPERTY_ENTRY_ARRAY_ELSIZE_LEN(_name_,			\
> -				sizeof(struct software_node_ref_args),	\
> -				REF, _val_, _len_)
> +(struct property_entry) {						\
> +	.name = _name_,							\
> +	.length = (_len_) * sizeof(struct software_node_ref_args),	\
> +	.type = DEV_PROP_REF,						\
> +	{ .pointer = _val_ },						\
> +}
>  
>  #define PROPERTY_ENTRY_U8_ARRAY(_name_, _val_)				\
>  	PROPERTY_ENTRY_U8_ARRAY_LEN(_name_, _val_, ARRAY_SIZE(_val_))
> @@ -360,7 +354,7 @@ struct property_entry {
>  #define __PROPERTY_ENTRY_ELEMENT(_name_, _elem_, _Type_, _val_)		\
>  (struct property_entry) {						\
>  	.name = _name_,							\
> -	.length = __PROPERTY_ENTRY_ELEMENT_SIZE(_elem_),		\
> +	.length = sizeof_field(struct property_entry, value._elem_[0]),	\
>  	.is_inline = true,						\
>  	.type = DEV_PROP_##_Type_,					\
>  	{ .value = { ._elem_[0] = _val_ } },				\
> -- 
> 2.35.1

-- 
heikki

      parent reply	other threads:[~2022-11-22 13:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-11 15:46 [PATCH v3 1/3] device property: Get rid of __PROPERTY_ENTRY_ARRAY_EL*SIZE*() Andy Shevchenko
2022-11-11 15:46 ` [PATCH v3 2/3] device property: Move PROPERTY_ENTRY_BOOL() a bit down Andy Shevchenko
2022-11-11 15:46 ` [PATCH v3 3/3] device property: Add a blank line in Kconfig of tests Andy Shevchenko
2022-11-22 13:11 ` Heikki Krogerus [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=Y3zKbbMpcaHfqB2C@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=djrscally@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox