public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Lucas Segarra Fernandez <lucas.segarra.fernandez@intel.com>,
	linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
	qat-linux@intel.com, alx.manpages@gmail.com,
	Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Subject: Re: [PATCH 4/4] crypto: qat - add pm_status debugfs file
Date: Fri, 18 Aug 2023 11:46:55 +0300	[thread overview]
Message-ID: <ZN8v/2McQboR3dIu@smile.fi.intel.com> (raw)
In-Reply-To: <ZN8BipaGe6DOwiVS@gondor.apana.org.au>

On Fri, Aug 18, 2023 at 01:28:42PM +0800, Herbert Xu wrote:
> On Thu, Aug 17, 2023 at 04:33:17PM +0200, Lucas Segarra Fernandez wrote:
> >
> > +static struct pm_status_row pm_event_rows[] = {
> > +	PM_INFO_REGSET_ENTRY32(event_log[0], EVENT0),
> > +	PM_INFO_REGSET_ENTRY32(event_log[1], EVENT1),
> > +	PM_INFO_REGSET_ENTRY32(event_log[2], EVENT2),
> > +	PM_INFO_REGSET_ENTRY32(event_log[3], EVENT3),
> > +	PM_INFO_REGSET_ENTRY32(event_log[4], EVENT4),
> > +	PM_INFO_REGSET_ENTRY32(event_log[5], EVENT5),
> > +	PM_INFO_REGSET_ENTRY32(event_log[6], EVENT6),
> > +	PM_INFO_REGSET_ENTRY32(event_log[7], EVENT7),
> > +};
> > +
> > +static_assert(ARRAY_SIZE_OF_FIELD(struct icp_qat_fw_init_admin_pm_info, event_log) ==
> > +	      ARRAY_SIZE(pm_event_rows));
> 
> Was all of that churn just for this one line?
> 
> How about simply declaring a macro
> 
> 	#define QAT_NUMBER_OF_PM_EVENTS 8
> 
> and then use it for the two arrays:
> 
> 	static struct pm_status_row pm_event_rows[QAT_NUMBER_OF_PM_EVENTS] = {
> 
> 	__u32 event_log[QAT_NUMBER_OF_PM_EVENTS];
> 
> What am I missing?

Splitting ARRAY_SIZE() is very beneficial on its own.
The static assert is slightly more robust for the big code then defining
something that at some point can be missed or miscalculated. Yet we can
survive with a macro if you thinks it's better.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2023-08-18  8:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 14:33 [PATCH 0/4] Add debugfs pm_status for qat driver Lucas Segarra Fernandez
2023-08-17 14:33 ` [PATCH 1/4] linux/array_size.h: Move ARRAY_SIZE(arr) to a separate header Lucas Segarra Fernandez
2023-08-17 20:24   ` Alejandro Colomar
2023-08-17 14:33 ` [PATCH 2/4] linux/array_size.h: Add ARRAY_SIZE_OF_FIELD() Lucas Segarra Fernandez
2023-08-17 20:34   ` Alejandro Colomar
2023-08-17 21:30     ` Andy Shevchenko
2023-08-17 22:03       ` Alejandro Colomar
2023-08-17 14:33 ` [PATCH 3/4] crypto: qat - refactor included headers Lucas Segarra Fernandez
2023-08-17 14:33 ` [PATCH 4/4] crypto: qat - add pm_status debugfs file Lucas Segarra Fernandez
2023-08-18  5:28   ` Herbert Xu
2023-08-18  8:46     ` Andy Shevchenko [this message]
2023-08-18  8:51       ` Herbert Xu
2023-08-20 19:52       ` [PATCH] linux/container_of.h: Add memberof() Alejandro Colomar
2023-08-21 11:18         ` Andy Shevchenko
2023-08-21 11:23           ` Alejandro Colomar

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=ZN8v/2McQboR3dIu@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=alx.manpages@gmail.com \
    --cc=giovanni.cabiddu@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.segarra.fernandez@intel.com \
    --cc=qat-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