From patchwork Mon Oct 21 10:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177067 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245717ill; Mon, 21 Oct 2019 03:59:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyuM8xCiqJrhbXnoVWJu2jdqHFGRpcUwUI0amtNAUuuj7LPIOCjMEXwPYF1tGblKvN3qg1O X-Received: by 2002:aa7:cd68:: with SMTP id ca8mr1479253edb.58.1571655542184; Mon, 21 Oct 2019 03:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655542; cv=none; d=google.com; s=arc-20160816; b=zZaG16FRYDuHJLQUwfNGEc4xRNnOLJwhAc/7gO1fEaI/Yy+XBhghyE+FDF5zquWI9B 1KFf78oDh26EYFaiQvz3s4LGQ7NElfZ8xBPABVVeUYdbVkpCSEbDU04MsX3CzonorsEo KQJodxCkuX/+Y2lGKFXdYzHqphjITiXBmpJ9vXUT111Y4zN/d5geQnilrtn5UhvzVt72 /2tf7RpoGF5hCVi2sa1SG7chwwowVN4sokMUCYML6q/VyOCoD/Ul+/4Y3ppnDOiHEMQU LB5Okcs34oVZdNlA7Le2LGkM+4KsXwufByverjAuB19MYV7JzJIEwZ7K2Vezkm8C7Dwu gwWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=/WGAQrvHY5TjDUNFg6EjqFOZngCTsCOrFFEohgL8HW8=; b=wQe6gWuTMdxKD2V2uyQsDaJJX5WH87e7dGyAuAoWIS8CR66y6aBtuz8zTZ2dWs1Aq7 i7IHmArXPMXM9s4FRM1vzg6+6h8gif61BngNKIkbshFIJ9PyJgOc0C6Cxiozo9o4Z8MH pVkdb8js+SC24dU0yrhtJMsWj+jd0jIOsnXIefHzU7S4Kk3uYENwKdZktIaagND56M2X K/+opMORH8BPHPl0hyN2a6ziJdJ+EoUnHk8U6PlCXqGsLGcbqikb0KN3mtlq5tf9A/Mg 4+hSToMkxPNl5wPKQwuxMzxXc1te/1qeCiQe9FuSQOi+/2NzRWhYuuaSMEzEFywcOseS R3wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B+XYPSq1; 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 d25si8760418edv.319.2019.10.21.03.59.01; Mon, 21 Oct 2019 03:59:02 -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=B+XYPSq1; 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 S1728251AbfJUK6b (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:31 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53318 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728184AbfJUK6a (ORCPT ); Mon, 21 Oct 2019 06:58:30 -0400 Received: by mail-wm1-f65.google.com with SMTP id i16so12785545wmd.3 for ; Mon, 21 Oct 2019 03:58:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/WGAQrvHY5TjDUNFg6EjqFOZngCTsCOrFFEohgL8HW8=; b=B+XYPSq1urYE2HkEcpY2835/NlXmGMnLkjGbIG1A67Ue4TIGWTiHwFP/CiCW2C5h+T h4Cy7j+aP+O4QHAnjFTRRYyVNuY9Dh6GepwO16DNbSg9ZunSaKm2KiwnxR/YZxkMwume NnjiEuKgmvF+Dq/UPGVy5kIEYzNAySo86swGeLrolI3Qz1viYRWzQ6KZRM0MNDTUYMpQ bmqIfZxg98ZWG+aJ29/Z2AsbhE+1Fzf6S+BVkSKStF9ShV4MWItJp7AHceymb1CxWUxI pWOdsLZqoiaxyXUNnc5tGbN18hG0es6wJGt6f1gYZoqqxUFOuAHs6KTLEVxNnmsmJaGp FkCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/WGAQrvHY5TjDUNFg6EjqFOZngCTsCOrFFEohgL8HW8=; b=OgwFFPaXGQUw0+0QQih5BrgYM1NQ7zuTw2FAM3+lSYj4jE9/Zf3Fq3Q5N86LkWRlSO P2fQrnyBrZ+rFNys8mg072sy4T4O5WU6IXaTyo+SzW4m6jZ5LZOJXqNLV0a4qYH5i11R A2M+0EKcl5HKQw/GJHp4LUR+lkXHLYaTARMme7vaudzHYUdcVoEhppoC9VQw8flrO4/G GAaDDG0wNWfr3k7NRZH9vUgvHP4s8lfJCAYWp7ZnNkA1KQz/caq9+IitE6HxzQ/f+M/W 5jqxTHASd5ks3pTzkTD8+LfUU5zcRZKdmedQ5qTijwtB3VbeaYpbQQHc6CvPyAtBYZiU wMzg== X-Gm-Message-State: APjAAAWmnoVNwCSCcrcJw8uA1/f/wBiNXq8zp0le/NBk3u45g3thag8r rieh8ekCjMgxFvTLJuS/ouFT5g== X-Received: by 2002:a05:600c:2948:: with SMTP id n8mr5822833wmd.128.1571655507269; Mon, 21 Oct 2019 03:58:27 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:26 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, arnd@arndb.de, broonie@kernel.org, linus.walleij@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v2 2/9] mfd: cs5535-mfd: Remove mfd_cell->id hack Date: Mon, 21 Oct 2019 11:58:15 +0100 Message-Id: <20191021105822.20271-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021105822.20271-1-lee.jones@linaro.org> References: <20191021105822.20271-1-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.17.1 Reviewed-by: Daniel Thompson 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[] = { - { - .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++) { + struct mfd_cell *cell = &cs5535_mfd_cells[i]; + struct resource *r = &cs5535_mfd_resources[i]; - r->flags = IORESOURCE_IO; - r->start = pci_resource_start(pdev, bar); - r->end = pci_resource_end(pdev, bar); + if (cell->num_resources <= 0) + continue; - /* id is used for temporarily storing BAR; unset it now */ - cs5535_mfd_cells[i].id = 0; + r->flags = IORESOURCE_IO; + r->start = pci_resource_start(pdev, i); + r->end = pci_resource_end(pdev, i); } err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, cs5535_mfd_cells,