Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4156786ybg; Mon, 21 Oct 2019 04:47:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjG5VWeiCmMJnxt8SOopWSATS4YJg4O3UTqueOrTUc1PDXFpgv1gRmy3IJKn5+eL2MSG4r X-Received: by 2002:a17:906:5007:: with SMTP id s7mr21817854ejj.181.1571658473681; Mon, 21 Oct 2019 04:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571658473; cv=none; d=google.com; s=arc-20160816; b=z/yHABKqzmljglgY4QOL9eVwFBG4YjYKGClNenDVjFkK/UwozXJ7RQJtd79NZ2meN9 CGbkxsDmpMKEPuznWVewtI1uHYqfaK8R+02dhGDeXpebIOa1p74VlXKF2jZ1J1ntjx/X zYYeUW+bDPKg/mNEaL/YgGcRrR/WbsWyfFSLjznZ3Pg8lU9BWJvkcGKD0B5jw+cJiy+F Lw86uOdKFcDluu/kI7LPmJ8Qh0dM1QRFsuDix/a06NYdlP6Y15yhCcRnVIDl7YoN4TVg IqmsWRHzbPDIQPHP4SqLFhvLoivBa9e3ZOLrDUttInxRYmbftirgViUnXFWurWb3Vg2d lojw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=r99SrmIAWCZFhQdc6QFpd7cI3BE/OyLzeiOHzb6k9dA=; b=L2Hy/C+vB9CIi7gbntx6hLrvbkfnA7JJ6DBVcl0zASor5D+8w8KLUSY6JryMRtkirh Lg2jAH9lcqmJILkeKbtU/rgPUsiz3LeUvsEouxATMZ0tVLSgxSCC85Wbtt0Uft00Jnqu wWnFbZbzTQ19bqlEfmrzvYRfV/cdXzinMBOzlQZ2wszvQeZhDzm98E4FpGqhgn2Q5b8u Um2yvkmE84yHOC5cGvvjoJQ8tZFsYgJrWuXsaDjs4DzM2wEKAUDlUNnsR8z/DDonrzfE 1+O5DpKnIBYNFgigYL3Scp7boPvtTZCrCcKzTNX9VuidfR2Rw/3aCumckRqmqyd/wvdY bIHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AMcWdO51; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay6si8905006edb.377.2019.10.21.04.47.30; Mon, 21 Oct 2019 04:47:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AMcWdO51; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728461AbfJULqc (ORCPT + 99 others); Mon, 21 Oct 2019 07:46:32 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45458 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbfJULqc (ORCPT ); Mon, 21 Oct 2019 07:46:32 -0400 Received: by mail-wr1-f65.google.com with SMTP id q13so8616879wrs.12 for ; Mon, 21 Oct 2019 04:46:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=r99SrmIAWCZFhQdc6QFpd7cI3BE/OyLzeiOHzb6k9dA=; b=AMcWdO51d/gm6zTYZOvF3fnk145odN8cyZWo76JC0ghHEXavyH8vzyGV/wfxZXgYVU 8XO0R/dE8lsMsAr6TglgjDyz9nMN8Rv53iwvQmDiBbuFFbYDR+bFA3CdxPki/htNdtJi QtRQdRNKibX7XrlX7Kwn4lBr3sSZS8Q+I2Tvj/DKaGAONzsjEY09lf0Ms8j/jAKmUqPg +WAhJE/Az06Wvtg/NyhKSkvQkniMvQHTVTwGAoWgwvCAsdavTxiHULlfspg416S324mc LI6mi/Apx61FqeJytQo2Qtjfmal0sQ8ujYiBBnVLvOimamhx1Sil//g2hH7ByN6Ib5UB 8hyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=r99SrmIAWCZFhQdc6QFpd7cI3BE/OyLzeiOHzb6k9dA=; b=e4tcYHETS18oDzr4CApXhUS0PyyWfQjb+NWCO9aXuJgOO+jl308BByM1+6OiTPp2xL B1R7VczpAgo9i1lPi0CH/TkgvcyAX7uThwErLKEU7KRvbvtIbEjRVjOuqmz1kRCqlANG R2kfSaA3l9LhaZRoXFRcuqIi0q4y0zbF2jGjRKp3CeFteGcwTjHv4aQ8kDvkD/qQEgNh ghC0wJC4wQQzF8rUdGOdoaxr4uVkeKna8EaMsvQ7kheFx6AuT+fmS/HT4O+WSPVZJhNo Wdi+6n/VsNdAMd6bbZJEE3E0QrELWHomfiIDltlqyvXo/0WeaiSA/9eLHlUbPb1uJWK3 eDiw== X-Gm-Message-State: APjAAAWgvRA7bCVuoc8X/SPgkQU+NyLI2H/ekXt6UbEMNST6GpxjJYZ1 /GmCj0MuLwZIB52dXKfdUksB7w== X-Received: by 2002:a5d:66c6:: with SMTP id k6mr12067264wrw.152.1571658389329; Mon, 21 Oct 2019 04:46:29 -0700 (PDT) Received: from dell ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q3sm14546759wru.33.2019.10.21.04.46.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Oct 2019 04:46:28 -0700 (PDT) Date: Mon, 21 Oct 2019 12:46:27 +0100 From: Lee Jones To: Daniel Thompson Cc: arnd@arndb.de, broonie@kernel.org, linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, baohua@kernel.org, stephan@gerhold.net Subject: Re: [PATCH v2 2/9] mfd: cs5535-mfd: Remove mfd_cell->id hack Message-ID: <20191021114627.GE4365@dell> References: <20191021105822.20271-1-lee.jones@linaro.org> <20191021105822.20271-3-lee.jones@linaro.org> <20191021111137.ey6cbrrb2af3wj5i@holly.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191021111137.ey6cbrrb2af3wj5i@holly.lan> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 21 Oct 2019, Daniel Thompson wrote: > On Mon, Oct 21, 2019 at 11:58:15AM +0100, Lee Jones wrote: > > The current implementation abuses the platform 'id' mfd_cell member > > to index into the correct resources entry. If we place all cells > > into their numbered slots, we can cycle through all the cell entries > > and only process the populated ones which avoids this behaviour. > > > > Signed-off-by: Lee Jones > > --- > > drivers/mfd/cs5535-mfd.c | 31 +++++++++++++------------------ > > 1 file changed, 13 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c > > index 2c47afc22d24..9ce6bbcdbda1 100644 > > --- a/drivers/mfd/cs5535-mfd.c > > +++ b/drivers/mfd/cs5535-mfd.c > > @@ -62,26 +62,22 @@ static int cs5535_mfd_res_disable(struct platform_device *pdev) > > static struct resource cs5535_mfd_resources[NR_BARS]; > > > > static struct mfd_cell cs5535_mfd_cells[] = { > > This array is sized from the initializer... > > > - { > > - .id = SMB_BAR, > > + [SMB_BAR] = { > > .name = "cs5535-smb", > > .num_resources = 1, > > .resources = &cs5535_mfd_resources[SMB_BAR], > > }, > > - { > > - .id = GPIO_BAR, > > + [GPIO_BAR] = { > > .name = "cs5535-gpio", > > .num_resources = 1, > > .resources = &cs5535_mfd_resources[GPIO_BAR], > > }, > > - { > > - .id = MFGPT_BAR, > > + [MFGPT_BAR] = { > > .name = "cs5535-mfgpt", > > .num_resources = 1, > > .resources = &cs5535_mfd_resources[MFGPT_BAR], > > }, > > - { > > - .id = PMS_BAR, > > + [PMS_BAR] = { > > .name = "cs5535-pms", > > .num_resources = 1, > > .resources = &cs5535_mfd_resources[PMS_BAR], > > @@ -89,8 +85,7 @@ static struct mfd_cell cs5535_mfd_cells[] = { > > .enable = cs5535_mfd_res_enable, > > .disable = cs5535_mfd_res_disable, > > }, > > - { > > - .id = ACPI_BAR, > > + [ACPI_BAR] = { > > .name = "cs5535-acpi", > > .num_resources = 1, > > .resources = &cs5535_mfd_resources[ACPI_BAR], > > @@ -115,16 +110,16 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, > > return err; > > > > /* fill in IO range for each cell; subdrivers handle the region */ > > - for (i = 0; i < ARRAY_SIZE(cs5535_mfd_cells); i++) { > > - int bar = cs5535_mfd_cells[i].id; > > - struct resource *r = &cs5535_mfd_resources[bar]; > > + for (i = 0; i < NR_BARS; i++) { > > ... which means this translation from ARRAY_SIZE() to NR_BARS > is rather odd. > > I don't care whether the array is sized using NR_BARS or the loop > uses ARRAY_SIZE() but IMHO the loop boundary condition must match > the array declaration. Sounds reasonable. > With that fixed free to throw the following onto the next rev: > Reviewed-by: Daniel Thompson Ta. -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog