[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VfFdf=ZxuURpVR6LRaDm+x4VQsPgR6FLrcZPhLMn8MOpw@mail.gmail.com>
Date: Thu, 9 Jul 2020 19:06:13 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Vadim Pasternak <vadimp@...lanox.com>
Cc: Andy Shevchenko <andy@...radead.org>,
Darren Hart <dvhart@...radead.org>,
Platform Driver <platform-driver-x86@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH platform-next v1 1/8] platform/mellanox: mlxreg-hotplug:
Use capability register for attribute creation
On Mon, Jun 1, 2020 at 12:19 PM Vadim Pasternak <vadimp@...lanox.com> wrote:
>
> Create the 'sysfs' attributes according to configuration provided
> through the capability register, which purpose is to indicate the
> actual number of the components within the particular group.
> Such components could be, for example the FAN or power supply units.
> The motivation is to avoid adding a new code in the future in order to
> distinct between the systems types supported different number of the
supported -> supporting a
> components like power supplies, FANs, ASICs, line cards.
...
> /* Go over all units within the item. */
> - for (j = 0; j < item->count; j++, data++, id++) {
> + for (j = 0, k = 0; j < item->count; j++, data++) {
> + /* Skip if bit in mask is not set. */
> + if (!(item->mask & BIT(j)))
> + continue;
Instead of splitted comments and this code, perhaps
/* Go over all unmasked units within item */
for_each_set_bit(j, &item->mask, item->count) {
...
}
It might require a mask defined as unsigned long, though. Or temporary
variables.
> }
> + num_attrs += k;
> }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists