Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1531123ybt; Thu, 9 Jul 2020 09:09:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLh3iE8rpFkJk3rX7cwTAwrFvGDc+a3pSxPPAH6lJyhslhzuaEtw7WJcfA39d5BC/WgX1e X-Received: by 2002:a17:906:1a54:: with SMTP id j20mr56268946ejf.455.1594310984846; Thu, 09 Jul 2020 09:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594310984; cv=none; d=google.com; s=arc-20160816; b=BDynPcTUxiRVWLcuRfvUiktTkO4f/Tr/ca6q+BnebV8L08zbidkbYZlHpDZkR0wC5z S4qg4xcuBvNr9/Wpx/QRw3JICtk+iFlQ0lIJwOpQAEf3un6vlrXn9XGFWG+uSjqx1BMG drY7+DJqE56e4jWqdFQr7ss12bRAlT5uniCEOYGo45/kIffNEbxmwDjcsxX9UEUWVXtl 7LyJ+cxCPii7w5hSuJLwl+36knRv48K1hKrDWJFQ7IjxIk40pXUq3URFqe/6fkG0mAB8 IFwYyKxsmwJmNfpdXDOuUYUuLjKtOwUJIMXdOWuy2Pb629PUmHPuvXT6VmmbmI8E8Sj2 xanQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=a9l+tYk/85riUuxTuUt4kuJT2J7SexvNZ2Qs7Rkx7Yo=; b=stCEXwV2dKxQKRkAgqOlS0CW3b1ev57g0bN78zPYrm2oOe2rbCoNn/YlHKO0loRA7c ZDJZuKEgRfXjfmVt4+iuxYfnRudXFYTmdz5AOgB21/1XoPTINLVbNJ/3oemFfGDb6xp2 PUCw6gxGOx+1Uie9ysTaqYh6JdOmwavitE9LqBRFIRkZTEoCRv2kkemdwK5IXSkeMB6k +DyTBMfmRBiNxvHVPqz+vJgxIjRlzWaLv6J18DJppWCHiHbdZ2KZ5UadV2yqrDrPKLFJ qRpNeq7JLuR1bqGfsANkZQ+Zd3hsJBiBtQn7SluZesMm+vwweWcc9SDetsYFOvoMRG28 af2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UIMYWZNG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f11si2133811ejq.283.2020.07.09.09.09.19; Thu, 09 Jul 2020 09:09:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=UIMYWZNG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728133AbgGIQGa (ORCPT + 99 others); Thu, 9 Jul 2020 12:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726357AbgGIQG3 (ORCPT ); Thu, 9 Jul 2020 12:06:29 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82558C08C5CE; Thu, 9 Jul 2020 09:06:29 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id z5so1168505pgb.6; Thu, 09 Jul 2020 09:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=a9l+tYk/85riUuxTuUt4kuJT2J7SexvNZ2Qs7Rkx7Yo=; b=UIMYWZNGO9j/+zxVwaG/pEaMhgQBDOz4sVQUc96onnh3Km64D+wPEh6h63Qz4TWSP2 XsRY+ISPSZbxWrsDHzOqVd3DwO+jn13q7r7UYZokOo3s1FiG2nwMwWwZmqd5bFtKwxQ+ 7min4joP/kLnjFue26kvH4McDc7c5GblSG7uorFlGZ1P99NsSe0V1sqwQJZB4X76mdCu i6xYF2pb+ijEansklByBwX3lMG37FMLYsZDj5qGeE1VcWDp4k58yGsiDHg61qtsqLdZf yX2vc1mZYM0hIQBguHbDQseqkSVx1Y72XZwWvUrLszIzAplDVdOmRTluucejQGA4GE03 8YdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=a9l+tYk/85riUuxTuUt4kuJT2J7SexvNZ2Qs7Rkx7Yo=; b=GtX/uKXrSAitsAhJEefctt6eFVW8OGo/Dqc4bwKTr6vqnw37IBlSaeso6gF4AeuEV7 fB9kwjhBLwgH/Ym/kdzoAZjuwj5rI/HT94aFhHJ3Y0v9fqDU6hlyONVWSt4aWZcHjgLy sXmUSdM1Qt6NQEczZpaJmYdD8ow8BIwjdncRSWRjgiyawBG93FAXdFvplGhYhtnefRwf MJE0dtXAuLkJjBQ4kw2DznBr38BDBCrg17cKcGJ4XBZEaXiKHP2wHquSCgxuZL8Yk3oW QYbre/xONnt4SP7xWbI1ug0wvHgOc7ry+SdRXn9i9nJLLreuuc59awri9NFfuIAV6za0 Pf/Q== X-Gm-Message-State: AOAM533AkOdLiMd3mF504GE6mRL2L7YnOXzD0Rr6zPDUg0bLhsc1bfm7 QVKUTJLplXbdJ4Y5VrclU7loj58sqccTrMNq3YIiWdw/ X-Received: by 2002:a62:7657:: with SMTP id r84mr56878331pfc.130.1594310789004; Thu, 09 Jul 2020 09:06:29 -0700 (PDT) MIME-Version: 1.0 References: <20200601091851.5491-1-vadimp@mellanox.com> <20200601091851.5491-2-vadimp@mellanox.com> In-Reply-To: <20200601091851.5491-2-vadimp@mellanox.com> From: Andy Shevchenko Date: Thu, 9 Jul 2020 19:06:13 +0300 Message-ID: Subject: Re: [PATCH platform-next v1 1/8] platform/mellanox: mlxreg-hotplug: Use capability register for attribute creation To: Vadim Pasternak Cc: Andy Shevchenko , Darren Hart , Platform Driver , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 1, 2020 at 12:19 PM Vadim Pasternak 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