Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4120782ybg; Mon, 21 Oct 2019 04:12:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqynieZ9OYgPsOVFGowsfJzkD88qAF9BUv8laJm7yQrdliRx/CmaHljfbuEUvTht2OqnQhlH X-Received: by 2002:a17:906:6a09:: with SMTP id o9mr21168332ejr.289.1571656350487; Mon, 21 Oct 2019 04:12:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571656350; cv=none; d=google.com; s=arc-20160816; b=NWxrAnWvSuAEK/bEWR1GIB8tCJL/6JIZxxVi6gC3L1VZHA/MlfiKYgpFFsq+/gtWp+ 1T2m3e3MpuDlWmbNLZNpOwMmLA12y/ANsZIv6TuZL7r6Zh90v5KWmZxGfnNFaK+eUm6m v5JM8l0xNc2gykFum/tGC7eVtXkd87HivUVjzYtyK/f0l47pP+3/oVyryzrautX+2ozn tEjmmlT2USbwJ9+0oww7S+tEj655iTn6X1MLNrXpczsp6K8+nB5BDa2zTDteETcetOQM qRnfbNxcx5FMnTMp/gN9k9Njpd4POMAQc+wBPHtf1WrkClueUdYMqp6zG88ldzY8Xq7o CIUQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qsofjz6mshTaTSConAGSTps6s034Gbt4rNbvJmgPEqI=; b=KwpnTicoIRGaRI0kxYrqIMNlpfGATg8HIvowzeadDtpEC/f/IqsiNUx8QPK5FcW76j G53L7cP1oqVZWTLHYeilkiSjSFQb3o6OzSBhPr8rpNpbMS1g/wYHaosUmNPhL3i8sgC3 g88kuOUOLmff+CSrinfLbfC5QPKU2tsSBTml1QX7R/X0E4JzJim7a8win9xuJOUJAFvp C9U0oo7Gi0NMd7NHRd+/TQFaJDRKMh5okl9DYYbWILR5Cmv5Y/dcQuZCdV5v7mSXeqIC Rq9epfEy2EG+8izK1uC7kizcumqzF1Zdo3F1SmtqteUlxLut+UZe0SwoEzA4fardmtmW 8GwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Qw/aS0HG"; 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 y47si9742099edd.236.2019.10.21.04.12.06; Mon, 21 Oct 2019 04:12:30 -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="Qw/aS0HG"; 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 S1728416AbfJULLn (ORCPT + 99 others); Mon, 21 Oct 2019 07:11:43 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41174 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728360AbfJULLm (ORCPT ); Mon, 21 Oct 2019 07:11:42 -0400 Received: by mail-wr1-f67.google.com with SMTP id p4so13460372wrm.8 for ; Mon, 21 Oct 2019 04:11:41 -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:in-reply-to:user-agent; bh=qsofjz6mshTaTSConAGSTps6s034Gbt4rNbvJmgPEqI=; b=Qw/aS0HGq3uA01t/yK2JtENn3tenwrVO/oinZ+LDdFPK4K7lSstYeFd09mmDdBc6jA 3BktjSCm9JK61WZrxMyUBtJz729Va8PGXWcVkr9koxvT3rnLTo5fjjcPgUMRhtwZ+3bA sENUFHX9WqL6LaQkdYyAwMeUmEJtYE0uPFHMxp+ONNs5OD7z2cnfd0FAvZEtHHWaU3PO T/bLU0Q43Xa0jrWmnJKSEC0CnvkvdEfZhjLnoiW/kNYB+TzxTiyUc6sJUIcKkUGyRJ63 8RbLCwZ4mqIdbyYVvo6/AX+k1Y4rpIlq82KgLKKsNJ/9L/UOMU3VYVlR5FwLDxHqxlmx Lk2g== 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:in-reply-to:user-agent; bh=qsofjz6mshTaTSConAGSTps6s034Gbt4rNbvJmgPEqI=; b=NJjee8guTaQwkq6sWc+Wx+ajxBVkvzIx2ilISuYuk+SyTy5NlTAguc/L5uQI0SAkBK UwtjMtRghAbe7jyYTuVt0LGLeL01Hrre1AvkyLuEn9ei6pRhm4BPkn55KpiMugK441HD fN/IdRWxl4YFalZK2kkftmGkv8DoVQOT+78Tnox4abMrfSyG2G0iE1LfKJGol+s44Gtx hIJPiNUWjv1tutoKlvODk5R1gGxII4/FnBJPLQ/nkwLTNAWI+7AacidWP38MffXOs+fK o60VVK0tZ0EMtctReOKlKctahbFHraUMBKTzgBz6tM66U4GxAovUNYDK+Q1xEk+xiz+o /gmw== X-Gm-Message-State: APjAAAXstg/BQgAhYQZ+YopOMsUBuSZKZPob90hj0LsSkq4/I/Bs8Ryz N522TaBQvdVr2rMPBPZH/su0fn3OXevLzw== X-Received: by 2002:a05:6000:149:: with SMTP id r9mr14617479wrx.90.1571656300623; Mon, 21 Oct 2019 04:11:40 -0700 (PDT) Received: from holly.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id r81sm7985522wme.16.2019.10.21.04.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 04:11:39 -0700 (PDT) Date: Mon, 21 Oct 2019 12:11:37 +0100 From: Daniel Thompson To: Lee Jones 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: <20191021111137.ey6cbrrb2af3wj5i@holly.lan> References: <20191021105822.20271-1-lee.jones@linaro.org> <20191021105822.20271-3-lee.jones@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191021105822.20271-3-lee.jones@linaro.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. With that fixed free to throw the following onto the next rev: Reviewed-by: Daniel Thompson Daniel.