All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: linux-acpi@vger.kernel.org, rafael@kernel.org
Subject: Re: [PATCH v2 6/8] ACPI: property: Unify integer value reading functions
Date: Sat, 21 May 2022 01:04:58 +0300	[thread overview]
Message-ID: <YogQijFxDHC8r+Wr@paasikivi.fi.intel.com> (raw)
In-Reply-To: <YoekxdtV9IA7OP7h@smile.fi.intel.com>

Hi Andy,

Thanks for the review.

On Fri, May 20, 2022 at 05:25:09PM +0300, Andy Shevchenko wrote:
> On Fri, May 20, 2022 at 09:11:46AM +0300, Sakari Ailus wrote:
> > Unify functions reading ACPI property integer values into a single macro,
> > and call that macro to generate the functions for each bit depth.
> > 
> > Also use size_t for the counter instead of int.
> 
> ...
> 
> > +#define DECLARE_ACPI_PROPERTY_COPY(bits)				\
> > +	static int							\
> > +	acpi_copy_property_array_u##bits(const union acpi_object *items, \
> 
> Personally I find much better if function templates in macros are not indented
> additionally.

I prefer it the way it is in this patch: indenting the macro has grounds as
it is part of the same pre-processor directive even if it's split on
multiple lines.

> 
> > +					 u##bits *val, size_t nval)	\
> > +	{								\
> > +		size_t i;						\
> > +									\
> > +		for (i = 0; i < nval; i++) {				\
> > +			if (items[i].type != ACPI_TYPE_INTEGER)		\
> > +				return -EPROTO;				\
> > +			if (items[i].integer.value > U##bits##_MAX)	\
> > +				return -EOVERFLOW;			\
> > +									\
> > +			val[i] = items[i].integer.value;		\
> > +		}							\
> > +		return 0;						\
> >  	}
> 
> On top of that, we use a minimum compiler that supports _Generic(). Why not to
> use it?

Good idea, I'll look into this. Perhaps we'll even get rid of having to
define multiple functions for this.

-- 
Kind regards,

Sakari Ailus

  reply	other threads:[~2022-05-20 22:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20  6:11 [PATCH v2 0/8] ACPI: Buffer property and reference as string support Sakari Ailus
2022-05-20  6:11 ` [PATCH v2 1/8] ACPI: property: Return type of acpi_add_nondev_subnodes() should be bool Sakari Ailus
2022-05-20  6:11 ` [PATCH v2 2/8] ACPI: property: Tie data nodes to acpi handles Sakari Ailus
2022-05-20  6:11 ` [PATCH v2 3/8] ACPI: property: Use acpi_object_type consistently in property ref parsing Sakari Ailus
2022-05-20  6:11 ` [PATCH v2 4/8] ACPI: property: Move property ref argument parsing into a new function Sakari Ailus
2022-05-20  6:11 ` [PATCH v2 5/8] ACPI: property: Switch node property referencing from ifs to a switch Sakari Ailus
2022-05-20  6:11 ` [PATCH v2 6/8] ACPI: property: Unify integer value reading functions Sakari Ailus
2022-05-20 14:25   ` Andy Shevchenko
2022-05-20 22:04     ` Sakari Ailus [this message]
2022-05-20  6:11 ` [PATCH v2 7/8] ACPI: property: Add support for parsing buffer property UUID Sakari Ailus
2022-05-20 14:28   ` Andy Shevchenko
2022-05-25  8:13     ` Sakari Ailus
2022-05-20  6:11 ` [PATCH v2 8/8] ACPI: property: Read buffer properties as integers Sakari Ailus

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=YogQijFxDHC8r+Wr@paasikivi.fi.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=rafael@kernel.org \
    /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.