From patchwork Mon Oct 21 10:58:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177060 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245372ill; Mon, 21 Oct 2019 03:58:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqweTNO+i0QyRFAwIrD5/E+REkNwI1fsQFMsnH6gSQo5Xi0Qw2IIkVThLZtJIqT/jm2V68Ue X-Received: by 2002:a17:906:35cb:: with SMTP id p11mr21784121ejb.128.1571655518280; Mon, 21 Oct 2019 03:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655518; cv=none; d=google.com; s=arc-20160816; b=GVjdaDutOLLLYkCHc57/UDvhOWlqJIvhZXP2epITwkz4Gt1HAqJQlZPRJcCfubH9rT jQBWRASSPUTgGow77r8uX16TCLzIB10sp9HxAaNm/i19P11tX4mgI7IOQSfONvcwI3sH qfyz675Sls8U48j752l0UvMHtu6TiQD4Q865deMRNZ0zdUfnS3/Vuh560qC+k4/iUIFi 2cnPUBEBYbpnz7jwOpeM84NcUh5Qb17DRvDzXNjzXloXzkrIMLKQDyPNXAEViniyqmRg 0HITZHuZHGIszb1d0Hr4atjIdyG2ySYFfdTBkyYraNcinji47BYYeoLghIy5A0I/ATFS mn3g== 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=TJ3e2otpMWVdhjzztz3QDOTYAmPJU5Qr6nYPafBRUGw=; b=voPW/JOt/QAyGG2O1z/gRWJQ3k4pxlPPsEsVuJWMmJLI1bX8UNDNVwUxZkhWjIAUGh axT2/zcyzxMczk9qJH3TMFplc3C2HzbhpwaFS9o2VOtnwNyl8ZogClxEVcI5uvg8fu9o AxSNpawtKcKrtNq9wZB8Jr/ALZTV1GGwx7Spx2CDGXPW8vr+fULoOdWH1h3j0qQmVRFn JYuDBSBiG6utF6G5mRjEKG3dj9IKNsN7UqB0D5MdhYMW+pDSF6HE4RU41lgKgl2nK6MS 7qRHjeQcxUlDTRoouTzk5ZAz6b4Nckr67RLHFCoLpfpHYSUUIsbqh4h7HYs0VhvB25bJ +Cgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uPg/RYjg"; 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 f57si10064009edb.165.2019.10.21.03.58.38; Mon, 21 Oct 2019 03:58:38 -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="uPg/RYjg"; 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 S1728328AbfJUK6d (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:33 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38017 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727032AbfJUK62 (ORCPT ); Mon, 21 Oct 2019 06:58:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id v9so2160828wrq.5 for ; Mon, 21 Oct 2019 03:58:27 -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=TJ3e2otpMWVdhjzztz3QDOTYAmPJU5Qr6nYPafBRUGw=; b=uPg/RYjg86DcbqDDwpLKJLDizvEJdEwdu7r8c2St5KAPIaUBtJ2NW+5df+E/vgXtRN 5KCsxEpSpB+ox0II7sWLU3yx5zbb3bufQ9EdHuMQsm9cxEgwwa95Xn//m2vJuZg1aSk9 DkAsQh224TNp+EtORwR5LqBWH6mauTV2SPhSUPH0izHHkNJMgCZD9j+g92xNaSILVH+L dWEP0ZxA4RqmAgcPuMTW71oZN0nM2oFbvTD0Txz+qhIi7ft29z9G8DkYPqbjA/HDsHeg hkHAUiGTBRPTl4v9JqDXpcwLen9YMKYs8bWi1bhKchCeIVDVmZgUmQ8L0Prx/dEq9IXG oK7A== 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=TJ3e2otpMWVdhjzztz3QDOTYAmPJU5Qr6nYPafBRUGw=; b=DtOrN1LmB6ud5KhAH0zgnJQLoZFvPgt0HRoQyqilKIiH2PBc5VSl219+vw8X3JrQRj OKzodgz2o14vwYPy/hgHqQHpEZIea3JvXbANOYqDW/zoUQuoNgkGv4kPGONyx3/ZWxc3 U3HWh9mzi9aBm1ocx/t0IqO5F2OcJhU6rEN+TBmORzNkrwLIgKShvEQlNtf2085HgBn9 3G3hXf+OdFEWg1B6SsAm/xqIupLrNA13G2PODXXfMtntr3Cc2a9LJQE6wY2Ft0yAFzDT 5M6oWTnn3RfDkCOKpGgnIKF0D+6fvYgDU6syD8GEVNU7NKlUnuKVRU6/a8hlW8LDAJ98 QzXA== X-Gm-Message-State: APjAAAXyjq+lVNLQiBoHMPNeNuMUZ9hpLuSSQgfbujwLLxXCqTtkwaOt UE2IsC8y/XURJHBehfZ5licxxA== X-Received: by 2002:a5d:4047:: with SMTP id w7mr19242902wrp.270.1571655506394; Mon, 21 Oct 2019 03:58:26 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:25 -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 1/9] mfd: cs5535-mfd: Use PLATFORM_DEVID_* defines and tidy error message Date: Mon, 21 Oct 2019 11:58:14 +0100 Message-Id: <20191021105822.20271-2-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 In most contexts '-1' doesn't really mean much to the casual observer. In almost all cases, it's better to use a human readable define. In this case PLATFORM_DEVID_* defines have already been provided for this purpose. While we're here, let's be specific about the 'MFD devices' which failed. It will help when trying to distinguish which of the 2 sets of sub-devices we actually failed to register. Signed-off-by: Lee Jones --- drivers/mfd/cs5535-mfd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index f1825c0ccbd0..2c47afc22d24 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c @@ -127,10 +127,11 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, cs5535_mfd_cells[i].id = 0; } - err = mfd_add_devices(&pdev->dev, -1, cs5535_mfd_cells, + err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, cs5535_mfd_cells, ARRAY_SIZE(cs5535_mfd_cells), NULL, 0, NULL); if (err) { - dev_err(&pdev->dev, "MFD add devices failed: %d\n", err); + dev_err(&pdev->dev, + "Failed to add CS5532 sub-devices: %d\n", err); goto err_disable; } 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, From patchwork Mon Oct 21 10:58:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177059 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245299ill; Mon, 21 Oct 2019 03:58:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5By43EcRh85ric2e5mFSgqyQXriibjGMV/lXTQlXQMj3ECUFn2QEeo7ZLiuDJuY/Vv/wc X-Received: by 2002:a17:906:351b:: with SMTP id r27mr1036499eja.83.1571655513751; Mon, 21 Oct 2019 03:58:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655513; cv=none; d=google.com; s=arc-20160816; b=lTd/6R3ZcKZi2mqykVn8ndziVU9Yb7Z/0l4tEsMsfn6QsjwyB/J53y+tDF9c443Jiq DXXPeYzkOjX04uS6wcZNm05Ux0FMnzHnzNmTGMgI1zlIShxBxDBKFxo9Eygo0JIq9dsE QAkgv00RdxNXeazuzmMPCr2cylsbDjbOdOBVK6u91tyHVHR8g4bpOoS1UJ2fGn/uZmIU rQOmVOHt62gDnD121eIyTCWPWnDdyOqx5qi7hOzn8v6tvn1Bh6wLQKD69/yP7+Jd4U/G jTp/1F8Oil2zuQUyBLMpn8eJzUnhmqtQh/BRGgX8XCTNT6neLbwmkP3hys/+5TvIEUza ENpA== 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=45AT36kNkG6TuZTs0Da4Zkgj9k+BoulBorMLvGdJTSQ=; b=BR7kewetjpAsELzwRR0NZ6FUVmpLzssf6z9rG4ilvuvX8lM99w7sOFq3finacRXiGT 8FEcofL/AMuBEUFIdACLAETsDKoSBwn9SLEbKfMggmB7ttrGsDCumVay8hbTzO333zRF XGcsAAed+iQZswbZz5+Wqb90w8Z94OM5GGH0n2//uO9qjE6t7CJMqO9h8Nv3W0ap4451 jx+HPeF3UdbxbQCBpp0ZO3r/dpKsSvZicibhxVJH8GbMvnPVE77ulgv0phFAX2N6K3AI rQrGKj3AGGFX8w+qwyCwf9fohfWB4I0l3fbBr6TWqQTWHfPDbWfsnSvVeMPCK6UVXsk0 WkHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FFP1C61B; 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 rn4si8809325ejb.251.2019.10.21.03.58.33; Mon, 21 Oct 2019 03:58:33 -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=FFP1C61B; 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 S1728314AbfJUK6c (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:32 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38022 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727058AbfJUK6a (ORCPT ); Mon, 21 Oct 2019 06:58:30 -0400 Received: by mail-wr1-f67.google.com with SMTP id v9so2160948wrq.5 for ; Mon, 21 Oct 2019 03:58:29 -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=45AT36kNkG6TuZTs0Da4Zkgj9k+BoulBorMLvGdJTSQ=; b=FFP1C61B/LvUJEmQ2mYw/K2hW8FBRzhLSkQ9m4i27lqiPrqi/dCTKUbwP/XUTjLdNO 7q1nDyGJp4p3+IJgrl9OJ/C9HrbG5yFg5V6+hu8LVzjyWNxQhH3sa1zXaBa+cWjIj+sV CRoqgJ3JWtWrKBIHWK+WlEZDrlOHLkmyepoWU+YaTtoSmw9FmgsARPv8h+/iuaBJ79Bk kmAdJRqiSPJwczawk0wtx0PSK6k83mj0MiC1FfKB3ZYgGTRMrEXa9+iGeCQJtT48m7uv 1yg75JMBbBoIwGBtIUwPus87jWSfu+OfzaeVCLEPZ0dM4ZBS2/0CqAOMHILGica8DXUU dbag== 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=45AT36kNkG6TuZTs0Da4Zkgj9k+BoulBorMLvGdJTSQ=; b=fmEqtOekAnaW0lLUbJlVDG7njw8wvyVCziFgd+dfTxzGwtBgqx2jva/TyE7C8oeXNJ h8j5eG0g4AWj5yevyuFadshIbYQ3m0LMAS3PsDJhtLiqhHS9OwtdarpL1k6zG52fC9kN yD+2WUyt/HRY6prhDXNobTW2FtSBfQEQR2gF5YVjX1kBw9u1LfUxNhebbtaFWdYroTIM ptoaWjctwXZoluRw8G0xmRUxBNP8fM1pOJ6cuOnjakyrY02I8WBMQDArzBT6YjgIhSKF cI2feoBKWUDh8Vu04Z8ANsCaPt062sNnlBeQ2MA7JhLW1BFeOSDGAHjF26jWuCjkA3wU tzuQ== X-Gm-Message-State: APjAAAVdxPZV81Q8F9YXbyGgPVVrlGazC4mhgGZu3bVV4iV9DpUdYs6s i1jcVuiaku10mjijQOhVsvar0A== X-Received: by 2002:adf:e28f:: with SMTP id v15mr18585655wri.130.1571655508272; Mon, 21 Oct 2019 03:58:28 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:27 -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 3/9] mfd: cs5535-mfd: Request shared IO regions centrally Date: Mon, 21 Oct 2019 11:58:16 +0100 Message-Id: <20191021105822.20271-4-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 Prior to this patch, IO regions were requested via an MFD subsytem-level .enable() call-back and similarly released by a .disable() call-back. Double requests/releases were avoided by a centrally handled usage count mechanism. This complexity can all be avoided by handling IO regions only once during .probe() and .remove() of the parent device. Since this is the only legitimate user of the aforementioned usage count mechanism, this patch will allow it to be removed from MFD core in subsequent steps. Suggested-by: Daniel Thompson Signed-off-by: Lee Jones --- drivers/mfd/cs5535-mfd.c | 72 +++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 42 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index 9ce6bbcdbda1..053e33447808 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c @@ -27,38 +27,6 @@ enum cs5535_mfd_bars { NR_BARS, }; -static int cs5535_mfd_res_enable(struct platform_device *pdev) -{ - struct resource *res; - - res = platform_get_resource(pdev, IORESOURCE_IO, 0); - if (!res) { - dev_err(&pdev->dev, "can't fetch device resource info\n"); - return -EIO; - } - - if (!request_region(res->start, resource_size(res), DRV_NAME)) { - dev_err(&pdev->dev, "can't request region\n"); - return -EIO; - } - - return 0; -} - -static int cs5535_mfd_res_disable(struct platform_device *pdev) -{ - struct resource *res; - - res = platform_get_resource(pdev, IORESOURCE_IO, 0); - if (!res) { - dev_err(&pdev->dev, "can't fetch device resource info\n"); - return -EIO; - } - - release_region(res->start, resource_size(res)); - return 0; -} - static struct resource cs5535_mfd_resources[NR_BARS]; static struct mfd_cell cs5535_mfd_cells[] = { @@ -81,17 +49,11 @@ static struct mfd_cell cs5535_mfd_cells[] = { .name = "cs5535-pms", .num_resources = 1, .resources = &cs5535_mfd_resources[PMS_BAR], - - .enable = cs5535_mfd_res_enable, - .disable = cs5535_mfd_res_disable, }, [ACPI_BAR] = { .name = "cs5535-acpi", .num_resources = 1, .resources = &cs5535_mfd_resources[ACPI_BAR], - - .enable = cs5535_mfd_res_enable, - .disable = cs5535_mfd_res_disable, }, }; @@ -109,7 +71,6 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, if (err) return err; - /* fill in IO range for each cell; subdrivers handle the region */ for (i = 0; i < NR_BARS; i++) { struct mfd_cell *cell = &cs5535_mfd_cells[i]; struct resource *r = &cs5535_mfd_resources[i]; @@ -122,22 +83,47 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, r->end = pci_resource_end(pdev, i); } + err = pci_request_region(pdev, PMS_BAR, DRV_NAME); + if (err) { + dev_err(&pdev->dev, "Failed to request PMS_BAR's IO region\n"); + goto err_disable; + } + err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, cs5535_mfd_cells, ARRAY_SIZE(cs5535_mfd_cells), NULL, 0, NULL); if (err) { dev_err(&pdev->dev, "Failed to add CS5532 sub-devices: %d\n", err); - goto err_disable; + goto err_release_pms; } - if (machine_is_olpc()) - mfd_clone_cell("cs5535-acpi", olpc_acpi_clones, ARRAY_SIZE(olpc_acpi_clones)); + if (machine_is_olpc()) { + err = pci_request_region(pdev, ACPI_BAR, DRV_NAME); + if (err) { + dev_err(&pdev->dev, + "Failed to request ACPI_BAR's IO region\n"); + goto err_remove_devices; + } + + err = mfd_clone_cell("cs5535-acpi", olpc_acpi_clones, + ARRAY_SIZE(olpc_acpi_clones)); + if (err) { + dev_err(&pdev->dev, "Failed to clone MFD cell\n"); + goto err_release_acpi; + } + } dev_info(&pdev->dev, "%zu devices registered.\n", ARRAY_SIZE(cs5535_mfd_cells)); return 0; +err_release_acpi: + pci_release_region(pdev, ACPI_BAR); +err_remove_devices: + mfd_remove_devices(&pdev->dev); +err_release_pms: + pci_release_region(pdev, PMS_BAR); err_disable: pci_disable_device(pdev); return err; @@ -145,6 +131,8 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, static void cs5535_mfd_remove(struct pci_dev *pdev) { + pci_release_region(pdev, PMS_BAR); + pci_release_region(pdev, ACPI_BAR); mfd_remove_devices(&pdev->dev); pci_disable_device(pdev); } From patchwork Mon Oct 21 10:58:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177061 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245378ill; Mon, 21 Oct 2019 03:58:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKDNDCwfdi565KJ1WfWJ0hHzsRdMPlo6dtb720GMHnk9ImxX4LTj6Km4XRB8mkWsKJMP44 X-Received: by 2002:a50:e606:: with SMTP id y6mr24148734edm.261.1571655518743; Mon, 21 Oct 2019 03:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655518; cv=none; d=google.com; s=arc-20160816; b=jVvjz5X9+X0+bZRXexgeqiW99WLrmXFb7Cf8B9BPmzF5F94//9Hi8dVzHrR11lXkmc Q7oqR39eZdMl/JTj3dGt/x5LwjbyNm+Enq4Ki60GA2BlxQu5qKEydBT8D1bcXxc//4mU W4wq3t62SragVViXrfpQxKEkjP9WE+WCmgY81y6jQmC9gFW/6kXhElsTAqvTwGyO6ERd QV2bt2lPUCyXgiEBPGJTr+0+TZ9yBJEanDixzfKzplvi6cCApPwru6lkNOTdVHtUNq4G LKbbj5nrua1YRrAVZbhsW6mnp1Rwf1vVf+kF9hTgD1nGksLf4ezQB4ddRLpsVP+k2uIf JlhQ== 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=skmII0RjDFD6SFbyT8IGszhWT77ReZDZIQ2EcDM2hGg=; b=u/luk9WMisIrlTVFXHHinV9tNpLyFVaYzjQr/Nutldasw2SU+GdHy3eiQT0DL+hVml Bt6JRasB14AyhGCp4jFbiIU+leiac/UWx4C4+Bto/8+2yMNDwSmG85Thim2h01zpajfj rVzYJNbxgercTHmPXMgvYaovPLLQIMFgucEu+arT2LmnkD/67ozmMvHq4Al4h86S7ZbV 86nA5jJz7gX3VeUXacMz+gMcE84OWfjRUpQGzfeNXcCU99AS1bcWkbN8sQsB04l2ZvDF qOavHJFSnxGzZK93q18xVhvukX1fEvAG2IY/AO9dMR7YhO253YvYqIRVI+jGd743JZ3o dHQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O2gJBDIt; 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 f57si10064009edb.165.2019.10.21.03.58.38; Mon, 21 Oct 2019 03:58:38 -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=O2gJBDIt; 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 S1728350AbfJUK6f (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:35 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:51177 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728250AbfJUK6d (ORCPT ); Mon, 21 Oct 2019 06:58:33 -0400 Received: by mail-wm1-f66.google.com with SMTP id q13so2740389wmj.0 for ; Mon, 21 Oct 2019 03:58:30 -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=skmII0RjDFD6SFbyT8IGszhWT77ReZDZIQ2EcDM2hGg=; b=O2gJBDIt/uu3D3HrGWT7bdvLhDBGsgkK+oKb1wgbr874atEZbtzgTb8tFMtu8f/0R6 DqH9iU2QQIsK7OyqVEb3An+lKaclKzQvZwQ/cjdA3GiRoKszuxJb5p9srbdXf89RCJmo qpwCM28UgKws0pbdkgaxpwhS8W9n+q0Yn0uGsj+fB5S2t2AA9m8Mx8LifNoureM40/ss CQPAx86Vv5QabLz+CB7Y/c4SgIwxO1/6zKvo5bnGXcSYEYTp6iLO+gK4sWphMt/NfFor NR/+JYtiap6aqa7V0py2HEeSMWxcnmxz//1mXU17TOnqGHkOvcjvGRD5mVzQfPt6aqlY ufEQ== 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=skmII0RjDFD6SFbyT8IGszhWT77ReZDZIQ2EcDM2hGg=; b=rljpBIIkBrKGt1SNShNEqTI5gfrQVLiBLGopdyY6/jwwNwtfLlqo3vuA0OR0dK0q7m lZWLq7nR/8usRlNjXAEHU0+fG0uNMExl0ACH5P0ubfo6zCrmoMvyezSJANplJ82DabDt HKAPP3BpofJJGsL+NW+xx25GdQDS+Rra+enGvIL9lBq3O5UiGhYLMcJWjfH6lJpd7tEg lReKIRDLU4jbmiMeyQr8H6jQyDEgN6wEkyH6tlngkFyXorNyfVa8LpwkqiMOsfByxsBw iuCTRO+PA2WMamrppQ3DTvnjasrMgi5XpZxWAedcs+PyxTBMOe7JFDZmaw9VDQ6RZ9ON iGQw== X-Gm-Message-State: APjAAAXzDXKDawsyI6hyfHEFE6cCqc9SLRi8bBMPS3XD+f+Be+mClRYF Jm9jElP1QOxWNobwuR3i4k4y0Q== X-Received: by 2002:a1c:a9cb:: with SMTP id s194mr2818850wme.92.1571655509326; Mon, 21 Oct 2019 03:58:29 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:28 -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 4/9] mfd: cs5535-mfd: Register clients using their own dedicated MFD cell entries Date: Mon, 21 Oct 2019 11:58:17 +0100 Message-Id: <20191021105822.20271-5-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 CS5535 is the only user of mfd_clone_cell(). It makes more sense to register child devices in the traditional way and remove the quite bespoke mfd_clone_cell() call from the MFD API. Signed-off-by: Lee Jones --- drivers/mfd/cs5535-mfd.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index 053e33447808..96a99ac13384 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c @@ -57,9 +57,17 @@ static struct mfd_cell cs5535_mfd_cells[] = { }, }; -static const char *olpc_acpi_clones[] = { - "olpc-xo1-pm-acpi", - "olpc-xo1-sci-acpi" +static struct mfd_cell cs5535_olpc_mfd_cells[] = { + { + .name = "olpc-xo1-pm-acpi", + .num_resources = 1, + .resources = &cs5535_mfd_resources[ACPI_BAR], + }, + { + .name = "olpc-xo1-sci-acpi", + .num_resources = 1, + .resources = &cs5535_mfd_resources[ACPI_BAR], + }, }; static int cs5535_mfd_probe(struct pci_dev *pdev, @@ -105,10 +113,14 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, goto err_remove_devices; } - err = mfd_clone_cell("cs5535-acpi", olpc_acpi_clones, - ARRAY_SIZE(olpc_acpi_clones)); + err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, + cs5535_olpc_mfd_cells, + ARRAY_SIZE(cs5535_olpc_mfd_cells), + NULL, 0, NULL); if (err) { - dev_err(&pdev->dev, "Failed to clone MFD cell\n"); + dev_err(&pdev->dev, + "Failed to add CS5532 OLPC sub-devices: %d\n", + err); goto err_release_acpi; } } From patchwork Mon Oct 21 10:58:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177066 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245674ill; Mon, 21 Oct 2019 03:58:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3eQO9FIA96uxW0XuwHrAOQifI1Iw1LtSoA4U4ioS80rYScaivPqEbAwUompXkw3AgpCEU X-Received: by 2002:a17:906:af8e:: with SMTP id mj14mr21855560ejb.45.1571655538474; Mon, 21 Oct 2019 03:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655538; cv=none; d=google.com; s=arc-20160816; b=BDK6eFh5LIlNQxi7hXOq9ncKJLXeFbK2buUV/NbhMZfFcqB/uLFjtfvQA9QzbUX64M AU1MZZpFhxtrhYaXdvtC1puT5WlDxsA/c6syRAFSftgY5Kup8W9LhQgs/FauUORwcVkl DVx2AoTYQj69oO8gMEL0uaTzda8AXDMfMtgLRTeH6oREJKjPU4p1rnjkQ1FT5l/Tj9A5 a/Z82DYFqIa/59LuWlW5ExEiQNc7G4UjiMyokMwxM/bXn8rKYHtBSEtkKBwXVX7jSWUF j9joounI5AI2Yaqf55B9q5VXruQeUBVN0wKiwVMar6NYYIzkagCxWZEav7Nin1VSbTEA aasQ== 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=AcYtOZZC3SDgF/F2fzm0VNHT2ydT5TrPWwuuSdTpFkI=; b=o0Pu4ZiY00WhU8SsXxP6MB+8vIsqmI5vsgIi5HPzGIB9o7mbEHbcblfddd9k1Uf86i eKlVW0hyguBXU5I5Y0inI7SdL3wjK/6Py/17b4CAZR+IBxs6KP1wSRO+EqVHYg0Pggg4 CI6Tu2zl1cpFioBkJ6CRNOjQapd/jQAKRfqD7z6O9jqvWLGr5Lt0TG5FwHUkIBu6m12f n58I3ek/2eKj9YA109TfbSkDI43gmxXf87qDoIg8XQQ6BkVRI+FyUO9xPD4KFJVaBr2S AaZdHxcPmCuSkElCvPe8Q6jwwQhNOST2pJPRDw6ypflk1pLFq8KGwd3phKQXb1HLVgHi +dmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=p6Ft5Tcx; 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 b28si1042025edn.230.2019.10.21.03.58.58; Mon, 21 Oct 2019 03:58:58 -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=p6Ft5Tcx; 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 S1728425AbfJUK6y (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:54 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45239 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728213AbfJUK6c (ORCPT ); Mon, 21 Oct 2019 06:58:32 -0400 Received: by mail-wr1-f65.google.com with SMTP id q13so8439395wrs.12 for ; Mon, 21 Oct 2019 03:58:31 -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=AcYtOZZC3SDgF/F2fzm0VNHT2ydT5TrPWwuuSdTpFkI=; b=p6Ft5TcxLv+E+Nqn4V5r3Z58b7aTm2FHSTanPxT+z0HEeTqd5XVYhGwVw9rXy2e2Pv ShO6+JNNqzwtdzkUSZiwdqdw35pIai0tvvC89yyO7e0z33vfpn27aB5zrgvTbiJOiRnY uzXXeUp/RXxKV5IqixhMIyoZxdNHMxd9kQ77EHBg4FyapVI6c1s0E+zXjEUmpxjwgz8L Goj349p6YjkM2EEa0vcVX9qZs2QI3b1HtnDHAfVXhiZBjkqr1sOeH3B+NC6PYqymug+G aoB1UFpaD/iWX2tPqvGUEG/QH8U+ZFubBV6eZv5XR8d7mnmFru2cJfx2bXkEMkAbnJL7 exCQ== 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=AcYtOZZC3SDgF/F2fzm0VNHT2ydT5TrPWwuuSdTpFkI=; b=dWkpk3TABbg/dXks2J/oBodeSnes2iH18e531GRWZ6IVGY1l7VYkdk1cnM0mKWxfFG X/OsUBIsI7DhN+g0qQrEsEMK4rwpeD0b5KsiS3a0V6422GK9qpQWNJP2NexWzoWSOp7z c3fzRjqqqWJWMGm0yaUV+sAnbW1SM5a59HCfDAM6pz1u8hEkQE/KSx34nezxCxuPaGlp SAPxrK00QjeikgvLJLzZdgddexEkLcaBDuPdtKVIDHsKy8rOe7czI/7dX9euCwmNmuwX Te+G3xe2tN7mAK/M0ruy2Dl3JyGAv8c1pboA8jfIyQZp28/q+YMrPCrQvaZVV4QU/BQO OnTw== X-Gm-Message-State: APjAAAXEwgXCTK1iPl6f8TrDoLLsYyk14Y8xan8PLXMEm9UBVd+xSRpj fvDO8fn8CZDu9s94XHWxiVv78g== X-Received: by 2002:a5d:5101:: with SMTP id s1mr3913120wrt.339.1571655510311; Mon, 21 Oct 2019 03:58:30 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:29 -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 5/9] mfd: mfd-core: Remove mfd_clone_cell() Date: Mon, 21 Oct 2019 11:58:18 +0100 Message-Id: <20191021105822.20271-6-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 Providing a subsystem-level API helper seems over-kill just to save a few lines of C-code. Previous commits saw us convert mfd_clone_cell()'s only user over to use a more traditional style of MFD child-device registration. Now we can remove the superfluous helper from the MFD API. Signed-off-by: Lee Jones --- drivers/mfd/mfd-core.c | 33 --------------------------------- include/linux/mfd/core.h | 18 ------------------ 2 files changed, 51 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 23276a80e3b4..8126665bb2d8 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -382,38 +382,5 @@ int devm_mfd_add_devices(struct device *dev, int id, } EXPORT_SYMBOL(devm_mfd_add_devices); -int mfd_clone_cell(const char *cell, const char **clones, size_t n_clones) -{ - struct mfd_cell cell_entry; - struct device *dev; - struct platform_device *pdev; - int i; - - /* fetch the parent cell's device (should already be registered!) */ - dev = bus_find_device_by_name(&platform_bus_type, NULL, cell); - if (!dev) { - printk(KERN_ERR "failed to find device for cell %s\n", cell); - return -ENODEV; - } - pdev = to_platform_device(dev); - memcpy(&cell_entry, mfd_get_cell(pdev), sizeof(cell_entry)); - - WARN_ON(!cell_entry.enable); - - for (i = 0; i < n_clones; i++) { - cell_entry.name = clones[i]; - /* don't give up if a single call fails; just report error */ - if (mfd_add_device(pdev->dev.parent, -1, &cell_entry, - cell_entry.usage_count, NULL, 0, NULL)) - dev_err(dev, "failed to create platform device '%s'\n", - clones[i]); - } - - put_device(dev); - - return 0; -} -EXPORT_SYMBOL(mfd_clone_cell); - MODULE_LICENSE("GPL"); MODULE_AUTHOR("Ian Molton, Dmitry Baryshkov"); diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index b43fc5773ad7..bd8c0e089164 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -86,24 +86,6 @@ struct mfd_cell { extern int mfd_cell_enable(struct platform_device *pdev); extern int mfd_cell_disable(struct platform_device *pdev); -/* - * "Clone" multiple platform devices for a single cell. This is to be used - * for devices that have multiple users of a cell. For example, if an mfd - * driver wants the cell "foo" to be used by a GPIO driver, an MTD driver, - * and a platform driver, the following bit of code would be use after first - * calling mfd_add_devices(): - * - * const char *fclones[] = { "foo-gpio", "foo-mtd" }; - * err = mfd_clone_cells("foo", fclones, ARRAY_SIZE(fclones)); - * - * Each driver (MTD, GPIO, and platform driver) would then register - * platform_drivers for "foo-mtd", "foo-gpio", and "foo", respectively. - * The cell's .enable/.disable hooks should be used to deal with hardware - * resource contention. - */ -extern int mfd_clone_cell(const char *cell, const char **clones, - size_t n_clones); - /* * Given a platform device that's been created by mfd_add_devices(), fetch * the mfd_cell that created it. From patchwork Mon Oct 21 10:58:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177065 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245601ill; Mon, 21 Oct 2019 03:58:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMIZmul7OWOJMlN3BLj7G2Vy/NuDXGOjInBD4akzWOEEs50N3oEKfyG6bKVbiP+EdlOfr2 X-Received: by 2002:a17:906:6882:: with SMTP id n2mr21802317ejr.48.1571655533251; Mon, 21 Oct 2019 03:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655533; cv=none; d=google.com; s=arc-20160816; b=kqHUiDFCJMIoOh9vLOZ2nov5Z4fGDotCYmTEL75BNwg7WtkcVk6MfzbeMS/Vc8vsmD WJ95FKPQ4WFPNrgOInTJIjTfhIzxS4BeU7+oINjxQqLJbaN0sNfnTarQ0OFnt1UKRfRi TeUppL3daxJPMNUK8zYDjYTiXiwBREc0JwmO/rnJVI3Hl+STV5+XfPmU/INIZkzPEp9a Ko48EjlxR+/etnLaW0DaRRIjZNaKnM6XZ2yiz9Uv5TwGUSI/x6IkvaJw41BMOZeX2Ftx 0WL9aRfptAtuu5d3tBo3DcLcJopMtAN+7FfjK9p7DqG9Vi56ASes3GV+4Oles2xCDCjy p0WQ== 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=N1QWSWmQ9Z196IzSFBZAn5l+uyQZbYxA5PcE8j0aOpM=; b=ywsPIGnMb1ut341JrHqyTZq8SC/z0ZOFDUiw9SDOWeLUsRA8+KyMRdybhyRZHU2CAw 404XhPudnHiie57LsrBFbQkZ0xiGaiQiDsJs0Eov4Ro39jtpSiNvJ5n6j3y6m7oROEdS tizw3vZW+PVJ/NGnXrRa4Eza2BN+4BpnsxZMTuF7h2n6t5QZfSZAg4PsFU1Mp9Dc61Sx DMc+kndXKvBZ/yPBA2XpGR7LKeYGfyOaFnDLuU8rCV5RaWLJZnXQwkrQ0q7q+sRnZeFE HbUJFx5U3wzv6hZ6zw+smo3pVkNGNiJ43P/AXMs1BvnABAF6svyoHfF5y0sQYjDvSuYD uIwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iVJ355dx; 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 nj7si8643743ejb.262.2019.10.21.03.58.52; Mon, 21 Oct 2019 03:58: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=iVJ355dx; 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 S1728412AbfJUK6s (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:48 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41164 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728313AbfJUK6d (ORCPT ); Mon, 21 Oct 2019 06:58:33 -0400 Received: by mail-wr1-f65.google.com with SMTP id p4so13409450wrm.8 for ; Mon, 21 Oct 2019 03:58:32 -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=N1QWSWmQ9Z196IzSFBZAn5l+uyQZbYxA5PcE8j0aOpM=; b=iVJ355dx/uAdqxNtz28IemMGbVKdAZvYRt4leY2T4v9S/sVKuTNbBWEXGYb7MZQCCX bEMWit0rElAZ3UzowGiYzAR4vfkkAmBx3y8kVbey82j9a06PIQ6GTbSiUzbDTjIsE+Bv 2ZMWAnxzQUrV7IilCxBkdlNYVRT+P5Ws2aMb8Zu935IT1F4HYuuIDnRI4O7xVZ+L2d57 ff6UR1t6nLVlBSenVOD5qWq2MDiCJuJvhJEZSVaCHLRxc7WD/mjIKPB2RloQse8mdFef WDnRAh1VS5BhGhAG1h3QykJIzwhm38VrNRNRsL76fsaSmdR/HU5o619gIDhf5FzS5WaF kkvQ== 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=N1QWSWmQ9Z196IzSFBZAn5l+uyQZbYxA5PcE8j0aOpM=; b=HRngjDSW7y80ut7Arq9/XExDp52GELQgNuKLoli5ugXfpnAO01GSRZFz+xvZItXGuX D9eSbQnf2QBVPNJ9XyPVuxtFuTv5VKdU0E7M2TDAAw9AHO1Fm+MI91uZr47k5aQ22EIX +4Jt5/VnTqYDclDgN/mrGEjQ/kHsULzmBCKVPrwptNGe6YU/Onc5aS+3F60tB4H7zQez UPoNXWBrNnryorS3GY0T0cN/w5JCx/g+0LQBS4j4YRIbUig83cZwA3+dQh0/w75KXb5f dopOzY6BjCjm4rbL0O7S1mqC1o12KyGjtFNrUbJl3AYS0DphtQd11DwPSRGOsI7fW8Xp M99w== X-Gm-Message-State: APjAAAU2THP7Jbr3/2lH1iswY8fJoRstjBdMS6KrJmoO6sMt7WZo3ji5 bEcm5LxJiJjrca5pqfnFLuKflCJBj54= X-Received: by 2002:adf:f343:: with SMTP id e3mr19104359wrp.315.1571655511574; Mon, 21 Oct 2019 03:58:31 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:31 -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 6/9] x86: olpc: Remove invocation of MFD's .enable()/.disable() call-backs Date: Mon, 21 Oct 2019 11:58:19 +0100 Message-Id: <20191021105822.20271-7-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 IO regions are now requested and released by this device's parent. Signed-off-by: Lee Jones --- arch/x86/platform/olpc/olpc-xo1-pm.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.17.1 diff --git a/arch/x86/platform/olpc/olpc-xo1-pm.c b/arch/x86/platform/olpc/olpc-xo1-pm.c index e1a32062a375..0fc57b59743c 100644 --- a/arch/x86/platform/olpc/olpc-xo1-pm.c +++ b/arch/x86/platform/olpc/olpc-xo1-pm.c @@ -126,10 +126,6 @@ static int xo1_pm_probe(struct platform_device *pdev) if (!machine_is_olpc()) return -ENODEV; - err = mfd_cell_enable(pdev); - if (err) - return err; - res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res) { dev_err(&pdev->dev, "can't fetch device resource info\n"); @@ -152,8 +148,6 @@ static int xo1_pm_probe(struct platform_device *pdev) static int xo1_pm_remove(struct platform_device *pdev) { - mfd_cell_disable(pdev); - if (strcmp(pdev->name, "cs5535-pms") == 0) pms_base = 0; else if (strcmp(pdev->name, "olpc-xo1-pm-acpi") == 0) From patchwork Mon Oct 21 10:58:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177063 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245445ill; Mon, 21 Oct 2019 03:58:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHcI0JEjxhVp/rtaK2QH5Hvt7pV1KCZo0Js1sqYdq5zhekMmcUlL2Kf/KiEMA7rVGrHL6i X-Received: by 2002:aa7:d582:: with SMTP id r2mr24679323edq.196.1571655523292; Mon, 21 Oct 2019 03:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655523; cv=none; d=google.com; s=arc-20160816; b=OQqo3r25XsVsbJKI27P9OBTu/6JtSoRWWDa6V6voTCel2xmx6axqQdpZOGGPqj/4yY aaScvM1APej8nmSCr3wgasJmiljXbBh0U/CHaCo1geuo/TuExHFg6+pv9KIXOCZaKr30 8rjfU7K3h5Lob61RqIzqDCqNgaHr8lIANqq7bHYCsplKoU496ixBR5W7KDmp6+N67RSa wIRMBR5R38koQ75+2y/ZBaSLHF1FVPFVdbp6N51BAD0uwK7rll0zlT4Vo5ZpltmGjNrP h3cmD15hbQ9c1wNGg4PYOH46wmRLfM3s86z7M51/m7L+PjUf3ShChAcpmu7gAivlSlNh W9OA== 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=OylZk9s0mis8tzuGBIwAaa88loW1Yq19LfmLj+u4mfs=; b=k5HC6/NyXG/0XE7/3q9iBfQQX5/qilbx62cFGd9KWNIgRHc1v/A9ElLe8j7rHlKttu xMtO3vy+FWDIx3MET4VTw/GKfakqbOZn80hh0aMzCQD8hbpPEhIF1SSSbfcZVWCDv+T/ dY1bMNWxtMyLzis3z9mozLMqzK4sys4prNTuSm99hRBC6qe0woKuuQAkvyJqisWDesxC KrYmjXQ5/pVsrW2GqlHh03GqNVSt+K1iWk/AmtFWMLNvpdRqNtPrp8TQX4Pnw38G0Kdo 2d70kUPDQF2dZvl4+9XBfiq/B8Wrhq0qSYnK21szio39SJOh+rn5j9Xrosy+X/i1tcKG V8Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hjbd4jzP; 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 o21si852687eja.318.2019.10.21.03.58.42; Mon, 21 Oct 2019 03:58:43 -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=hjbd4jzP; 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 S1728378AbfJUK6k (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:40 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33898 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728334AbfJUK6e (ORCPT ); Mon, 21 Oct 2019 06:58:34 -0400 Received: by mail-wr1-f68.google.com with SMTP id t16so8283216wrr.1 for ; Mon, 21 Oct 2019 03:58:33 -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=OylZk9s0mis8tzuGBIwAaa88loW1Yq19LfmLj+u4mfs=; b=hjbd4jzPeI1PUWLlYV4B8LpdZp+xJ8qe9umoadGdA9E9h5uyWAn+m4H6FUYmLJdd4J 0HxB57wjYo23ive7bR5mSTDVnyms+GgEFeZECTnwOrZlvN7jbloHloiEiUlKkISk4LIO osY7YZU9gXM6dy41N1p5yl3bu2LkA2fiuxLqwBQqjQD4IFUBxfKuXasoBn2UcVT37Z79 8s9spHNbvhlSqirIuhbUceepbMrutWVFNZ4PGKN1ypMAPZ1sC2zc2EueBqoiG1YbJP2t UcbZenefQ1KTENMJJ52x5nF8UKFG8jUBzrieioNMqQE8qMh8wV6zhiXRAdpnG+PSa4ml fbQA== 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=OylZk9s0mis8tzuGBIwAaa88loW1Yq19LfmLj+u4mfs=; b=VHe8f6/IZeHwcqOA+wdxiDAfbfwOxMNetZ4OoeHqYK7/MILfehHRM1MBlpiJejQOB1 Uw75UgWCd1DKTO6bYrXo962Eb4C5fZcXKQGdu42+MSitBM5ZgunXUQyBdaXfDChPiWm2 d4PjG16G2Ves0IkEowkpkogJngzKmLpnjf/RTp1F2/Dg6Sv0BLbnxnu1hXVT2NtHFgHB JBw2BeotJLtIzTNOx6L5Fwan3tyliBYzlVoAIDC6OvvWueE0HwIs44px/XcxR1Ut6A8G tVrwfmNjWpe6SZ/M6GDRJtsYMVEiR19QBzLDIIeK5JxcQOyCeD0XfDG/rsuEvWO3bwas b3fw== X-Gm-Message-State: APjAAAUQt8Yxi98EqjDt+Rp+ovTtjuEp7LVK+CieUoMl1k1DvclsXfcK Z0Lay6cYnVnIDTyrwoEcbh2s8w== X-Received: by 2002:adf:f004:: with SMTP id j4mr20804975wro.68.1571655512433; Mon, 21 Oct 2019 03:58:32 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:32 -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 7/9] mfd: mfd-core: Protect against NULL call-back function pointer Date: Mon, 21 Oct 2019 11:58:20 +0100 Message-Id: <20191021105822.20271-8-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 If a child device calls mfd_cell_{en,dis}able() without an appropriate call-back being set, we are likely to encounter a panic. Avoid this by adding suitable checking. Signed-off-by: Lee Jones --- drivers/mfd/mfd-core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.1 Reviewed-by: Daniel Thompson diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 8126665bb2d8..90b43b44a15a 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -28,6 +28,11 @@ int mfd_cell_enable(struct platform_device *pdev) const struct mfd_cell *cell = mfd_get_cell(pdev); int err = 0; + if (!cell->enable) { + dev_dbg(&pdev->dev, "No .enable() call-back registered\n"); + return 0; + } + /* only call enable hook if the cell wasn't previously enabled */ if (atomic_inc_return(cell->usage_count) == 1) err = cell->enable(pdev); @@ -45,6 +50,11 @@ int mfd_cell_disable(struct platform_device *pdev) const struct mfd_cell *cell = mfd_get_cell(pdev); int err = 0; + if (!cell->enable) { + dev_dbg(&pdev->dev, "No .disable() call-back registered\n"); + return 0; + } + /* only disable if no other clients are using it */ if (atomic_dec_return(cell->usage_count) == 0) err = cell->disable(pdev); From patchwork Mon Oct 21 10:58:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177064 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245485ill; Mon, 21 Oct 2019 03:58:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTNldQv8ZBvhscW2tPsC4kgJ7wQWzKCJO7+JV75M1fXXNC03E4Ncybur9yJG9U8R/d2MYP X-Received: by 2002:a17:906:3053:: with SMTP id d19mr21851089ejd.109.1571655525979; Mon, 21 Oct 2019 03:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655525; cv=none; d=google.com; s=arc-20160816; b=B5G+sfsavQpiMh9XfE476/2v6dQAo2fL8pMoOIbpdux7nOw/vhMYvI6NHfomPnCE8D JmHo9M68W3Z2urh/72PR78CcgRglZzJ+vZK+bzqUdY2N0b5d4xti/atK1tJhYasIZU8E bKDNyuCjCdfWy7BH0gWLVDLUEh7jgWqhfVXWBw27Ap3x3lTi4Swfkf7ZJfWAioLge+XQ 7DKQDUvzMmxmI6sbQCOUhwZ3tad7GACITLNmyjq383cDiUGbsO3s82GfTNwDWQovFVdS 9sJfB6JHY3IXgRnCTdL0tabyxQDtUEgLNMyYg93UssDBNQIA9jA8+RvgpV1X1Gbr4/Rl gqdw== 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=IbXKOY/JOfOJZSRWAViTfLDMweZJVT8cxQjaKThEJUs=; b=HZXEijfX4rpaoBk619HvR+KY6rArJkU4SrlGK5n60ewvBY4lR/7lHvEi2wRR8l8lnY qri4Bsnxhlv2nsuMNRkBB3C8qJYruKxwg29KIFF48Tfme6xgWju4SSfmP3UtDSp7oNhj P/AT+TwEFOwlGS/PlbiPnMpgtclMqcsIPh/epTHGlfrYpvpL4sMVzOsW6B1+qIdQd52h J3gj6rHx3BnMYPY6R/jHDLZBjyQklpQtgcN7KYGxR9pmUNq7YLDQjWR7JvJU8VnXqY0B munzJiRL7U3whDH6PC4Ow2uHW81YDXkdPk9UKyDjyplMlSG2jRQUV3i/8uD5j7I48qR+ fcOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="g2YD/r70"; 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 o21si852687eja.318.2019.10.21.03.58.45; Mon, 21 Oct 2019 03:58:45 -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="g2YD/r70"; 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 S1728391AbfJUK6o (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:44 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36934 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728348AbfJUK6g (ORCPT ); Mon, 21 Oct 2019 06:58:36 -0400 Received: by mail-wr1-f68.google.com with SMTP id e11so4701289wrv.4 for ; Mon, 21 Oct 2019 03:58:34 -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=IbXKOY/JOfOJZSRWAViTfLDMweZJVT8cxQjaKThEJUs=; b=g2YD/r70AWQyO+VHPtEGhGPosKYW86edskEOwPZfS49Q++wZv6N1rnQKxBatV5B7xd 0tigIl5sw+dR7G0KTeD1okgY6m2eNO1BfQtAPbZw4m/PLaNZkNEX6VJBCxzrzdufBgrQ KC9GA121S5U9QeZlCEDMD1eoEewRJk/MGmRUmVwaFV15KX/KHkJo0g9OAP4d0zqg1pXz PFWtICDTNfEC6sKpBZ/k7V5lxnH8DLwG7hV78bsnGqX1+kd2vpdvjil2uYr3vMH6HTpX 0L0lD0UFh3vgDiGSKDEfDZlRsIt0r1JaB+w+wLd4bZztkTCSb5RfwHoOCWDneAE4+GK5 PSCw== 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=IbXKOY/JOfOJZSRWAViTfLDMweZJVT8cxQjaKThEJUs=; b=Li5MEeribnIGOmSt0WH90cTu4Y7b1ut7eqE1Lex66iapzmmH0gbAcSZtts2fEJg0Il QFLfXEFbRsKH07ODlQVOcJbGdK0ugPVoIJdX2zvdbWXuit6VKhWJH9FqCXu3KOjWPOaR o2nc+2My2nzXmu4i+xnrW1avENkYvsw6baEopspsBKKc9bTcquAd810S9QkbdMjUa4pU rBspsEdhhHzkxrO/oRqx9m8p/ZY8c9mGICzfhXwOm5ZYImCToxtXV+KKK07BfNoEhjy/ p5kxJhYCaDOwtZBBBED7MWt/NwvekRk0YSprgutB0ejmq35Enb4Hqql4/xeZ7V+au8Ds YVww== X-Gm-Message-State: APjAAAWKLz2x1uSbLZ4GwTK01lobSrDvQBp+BfAkHiWBA6m+aHjKqNcK xb7ZVAmYiiPHgEvpCJjtaNYCvw== X-Received: by 2002:a5d:6a8b:: with SMTP id s11mr12752681wru.394.1571655513309; Mon, 21 Oct 2019 03:58:33 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:32 -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 8/9] mfd: mfd-core: Remove usage counting for .{en, dis}able() call-backs Date: Mon, 21 Oct 2019 11:58:21 +0100 Message-Id: <20191021105822.20271-9-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 MFD implementation for reference counting was complex and unnecessary. There was only one bona fide user which has now been converted to handle the process in a different way. Any future resource protection, shared enablement functions should be handed by the parent device, rather than through the MFD subsystem API. Signed-off-by: Lee Jones --- drivers/mfd/mfd-core.c | 57 +++++++--------------------------------- include/linux/mfd/core.h | 2 -- 2 files changed, 9 insertions(+), 50 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 90b43b44a15a..5d56015baeeb 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -26,53 +26,31 @@ static struct device_type mfd_dev_type = { int mfd_cell_enable(struct platform_device *pdev) { const struct mfd_cell *cell = mfd_get_cell(pdev); - int err = 0; if (!cell->enable) { dev_dbg(&pdev->dev, "No .enable() call-back registered\n"); return 0; } - /* only call enable hook if the cell wasn't previously enabled */ - if (atomic_inc_return(cell->usage_count) == 1) - err = cell->enable(pdev); - - /* if the enable hook failed, decrement counter to allow retries */ - if (err) - atomic_dec(cell->usage_count); - - return err; + return cell->enable(pdev); } EXPORT_SYMBOL(mfd_cell_enable); int mfd_cell_disable(struct platform_device *pdev) { const struct mfd_cell *cell = mfd_get_cell(pdev); - int err = 0; if (!cell->enable) { dev_dbg(&pdev->dev, "No .disable() call-back registered\n"); return 0; } - /* only disable if no other clients are using it */ - if (atomic_dec_return(cell->usage_count) == 0) - err = cell->disable(pdev); - - /* if the disable hook failed, increment to allow retries */ - if (err) - atomic_inc(cell->usage_count); - - /* sanity check; did someone call disable too many times? */ - WARN_ON(atomic_read(cell->usage_count) < 0); - - return err; + return cell->disable(pdev); } EXPORT_SYMBOL(mfd_cell_disable); static int mfd_platform_add_cell(struct platform_device *pdev, - const struct mfd_cell *cell, - atomic_t *usage_count) + const struct mfd_cell *cell) { if (!cell) return 0; @@ -81,7 +59,6 @@ static int mfd_platform_add_cell(struct platform_device *pdev, if (!pdev->mfd_cell) return -ENOMEM; - pdev->mfd_cell->usage_count = usage_count; return 0; } @@ -144,7 +121,7 @@ static inline void mfd_acpi_add_device(const struct mfd_cell *cell, #endif static int mfd_add_device(struct device *parent, int id, - const struct mfd_cell *cell, atomic_t *usage_count, + const struct mfd_cell *cell, struct resource *mem_base, int irq_base, struct irq_domain *domain) { @@ -206,7 +183,7 @@ static int mfd_add_device(struct device *parent, int id, goto fail_alias; } - ret = mfd_platform_add_cell(pdev, cell, usage_count); + ret = mfd_platform_add_cell(pdev, cell); if (ret) goto fail_alias; @@ -296,16 +273,9 @@ int mfd_add_devices(struct device *parent, int id, { int i; int ret; - atomic_t *cnts; - - /* initialize reference counting for all cells */ - cnts = kcalloc(n_devs, sizeof(*cnts), GFP_KERNEL); - if (!cnts) - return -ENOMEM; for (i = 0; i < n_devs; i++) { - atomic_set(&cnts[i], 0); - ret = mfd_add_device(parent, id, cells + i, cnts + i, mem_base, + ret = mfd_add_device(parent, id, cells + i, mem_base, irq_base, domain); if (ret) goto fail; @@ -316,17 +286,15 @@ int mfd_add_devices(struct device *parent, int id, fail: if (i) mfd_remove_devices(parent); - else - kfree(cnts); + return ret; } EXPORT_SYMBOL(mfd_add_devices); -static int mfd_remove_devices_fn(struct device *dev, void *c) +static int mfd_remove_devices_fn(struct device *dev, void *data) { struct platform_device *pdev; const struct mfd_cell *cell; - atomic_t **usage_count = c; if (dev->type != &mfd_dev_type) return 0; @@ -337,20 +305,13 @@ static int mfd_remove_devices_fn(struct device *dev, void *c) regulator_bulk_unregister_supply_alias(dev, cell->parent_supplies, cell->num_parent_supplies); - /* find the base address of usage_count pointers (for freeing) */ - if (!*usage_count || (cell->usage_count < *usage_count)) - *usage_count = cell->usage_count; - platform_device_unregister(pdev); return 0; } void mfd_remove_devices(struct device *parent) { - atomic_t *cnts = NULL; - - device_for_each_child_reverse(parent, &cnts, mfd_remove_devices_fn); - kfree(cnts); + device_for_each_child_reverse(parent, NULL, mfd_remove_devices_fn); } EXPORT_SYMBOL(mfd_remove_devices); diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h index bd8c0e089164..919f09fb07b7 100644 --- a/include/linux/mfd/core.h +++ b/include/linux/mfd/core.h @@ -30,8 +30,6 @@ struct mfd_cell { const char *name; int id; - /* refcounting for multiple drivers to use a single cell */ - atomic_t *usage_count; int (*enable)(struct platform_device *dev); int (*disable)(struct platform_device *dev); From patchwork Mon Oct 21 10:58:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177062 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3245436ill; Mon, 21 Oct 2019 03:58:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUkqGhfI4jGZWeBz/fvdPPP2vflI0oGFMrMcSMpk7KFjkW+7sdlE5sHVy9KCG0qMMgz7S/ X-Received: by 2002:a17:906:b7d0:: with SMTP id fy16mr21627614ejb.207.1571655522718; Mon, 21 Oct 2019 03:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571655522; cv=none; d=google.com; s=arc-20160816; b=A9ukwTi84LCuSOannrkgXSYl0hV9UvirOCPFPjINJYKIR1s4DeOamMD0EpFTk1y5EE ep2PFNXdauO6+SN+6PdKcrs3r7STYnE23UCQUULncSlU8uZhOga7VslEGhrhYqPfRhFH 2rf62K/HZgIDAQpABmMN9JSZWaKDh6QcJG5PV8LctfU+j+gxN5Dqln50uDuPiTMclhM6 h++JhAix0tx8HkBdntyoZNM26qk4+480ihsQ+ZWq0HKF0xz/yUBW4Hb9Hu7rUl5T5zKx jKoLmZU8BbkficPvxKPJnHwpIbUzZ5/nHB/6OPLFC1VGTacu+z8M3tcGGORlyd8nPvO7 xcLw== 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=aRIsIrxJRG4WGhOzej9X0cMyz5OqcLFYkbUiKyLomGE=; b=vBKisRaOOQbsGPHE2pM1Yz4C4LsRC2tPDjY0WEpTlu9xXNojn7wnTc1XzYdcm8NCUO hoDB+PkhSunQ/4xVH/PB951BR0GnlKz4PSh4r8kCZk3dAjcVwAD2Zv5VzzUB/rrJZWNT r0oKypo6PbacPg0QYWV2v9BbOQ50GXc9UdCi4RQIxJCXFS42Ty+t8zCDz3IS1mv51oPW 9lr/LKgDch2Auf2siiTwVz8QOAbrVY49fkQZNj2F2u4g2hYsojRc9iv2hs2hkptJOlDm gy5gmVF6Nm8XH194yqEPXYd4Y/PDrIoUKga/ghKTdQFvtAZulOB9BQ/NhJS2XLBL9Iri qxTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cTeiB4Qc; 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 o21si852687eja.318.2019.10.21.03.58.42; Mon, 21 Oct 2019 03:58:42 -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=cTeiB4Qc; 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 S1728364AbfJUK6h (ORCPT + 26 others); Mon, 21 Oct 2019 06:58:37 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:35561 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728287AbfJUK6g (ORCPT ); Mon, 21 Oct 2019 06:58:36 -0400 Received: by mail-wr1-f65.google.com with SMTP id l10so12992728wrb.2 for ; Mon, 21 Oct 2019 03:58:34 -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=aRIsIrxJRG4WGhOzej9X0cMyz5OqcLFYkbUiKyLomGE=; b=cTeiB4QcI/9D1UCeh1hzV+1od3PVVBhQlL72xj03bVUzMnwFnJarkT3Uqedx1NfBAs VYsdVW/U+jL6mmMApxUm7s8EdbLDQ34lDiQMVyO9e5xbSkHQ92Y3/3wKHbOlES7D+Q9a AKRv2JAi+ZPKpEzpS6yO7Nf7cRoCEXJebv27MfESjaxI9K2IO1OZJRf3ShNdo2GSHebK 6VZoPHGPCibQycGVei+Ls5x1pYadk/6OK3pre7jjZbewtrAt0cEbQ59GI1uCS7ri9dRb foXS/X1MFU+gZDuV21M+EN9A04hTB6AvIaaOWnpSGeDfWgQNuXi0Xg3Ned6IUGuMXaRC bjtw== 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=aRIsIrxJRG4WGhOzej9X0cMyz5OqcLFYkbUiKyLomGE=; b=AMuVirigt5A/YFoo5PMrccNLVMNrrKg9Z/W/mv1pgYtssT182/1pBbjyk0qvEJChmz 0AHgrwtjKX1zWaPYMyT1SLGWa2nTkIQ/3hO+Ig0U/OYoyYeZ9jzWKYHhUFDxCDppPZIe E3FTwHPqefATqrIg8xq5s1Yx5In8OtAj/SOMCSE40n6yAySof7QkEeHrY1+DTuVDpp+i e9e1MVVFhlQCnxZesrTu/AoVPFtdu9/cOhhzKC/mowp3wuZe6Efl6ejeXFG3PHBKEz8k JgAe1J/ItL6J/d0zNDTvyVIEIJq1p9TZJMpYevtYdAZ9LrukkgA2wDX0doKJ4CNxINix BXFw== X-Gm-Message-State: APjAAAX2Ze1+/4xACW3+7swcm8SjUXoYRK5Pwz5BX7Y5flb8bhzlcSKT EPXYIGzfPnMY9BpBH6sPhvD2lg== X-Received: by 2002:a5d:5401:: with SMTP id g1mr9448965wrv.54.1571655514185; Mon, 21 Oct 2019 03:58:34 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id q22sm12544289wmj.31.2019.10.21.03.58.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:58:33 -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 9/9] mfd: mfd-core: Move pdev->mfd_cell creation back into mfd_add_device() Date: Mon, 21 Oct 2019 11:58:22 +0100 Message-Id: <20191021105822.20271-10-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 Most of the complexity of mfd_platform_add_cell() has been removed. The only functionality left duplicates cell memory into the child's platform device. Since it's only a few lines, moving it to the main thread and removing the superfluous function makes sense. Signed-off-by: Lee Jones --- drivers/mfd/mfd-core.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 5d56015baeeb..849dbe3798b0 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -49,19 +49,6 @@ int mfd_cell_disable(struct platform_device *pdev) } EXPORT_SYMBOL(mfd_cell_disable); -static int mfd_platform_add_cell(struct platform_device *pdev, - const struct mfd_cell *cell) -{ - if (!cell) - return 0; - - pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL); - if (!pdev->mfd_cell) - return -ENOMEM; - - return 0; -} - #if IS_ENABLED(CONFIG_ACPI) static void mfd_acpi_add_device(const struct mfd_cell *cell, struct platform_device *pdev) @@ -141,6 +128,10 @@ static int mfd_add_device(struct device *parent, int id, if (!pdev) goto fail_alloc; + pdev->mfd_cell = kmemdup(cell, sizeof(*cell), GFP_KERNEL); + if (!pdev->mfd_cell) + goto fail_device; + res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL); if (!res) goto fail_device; @@ -183,10 +174,6 @@ static int mfd_add_device(struct device *parent, int id, goto fail_alias; } - ret = mfd_platform_add_cell(pdev, cell); - if (ret) - goto fail_alias; - for (r = 0; r < cell->num_resources; r++) { res[r].name = cell->resources[r].name; res[r].flags = cell->resources[r].flags;