From patchwork Fri Nov 1 07:45:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 178250 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp116787ill; Fri, 1 Nov 2019 00:45:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuBARd7w3wbwY6ChpSwsaEcb2buAvoC8pMACFFToKsuS25WnVuqwy+il5nbzloQLWrwiQ0 X-Received: by 2002:a05:6402:120d:: with SMTP id c13mr11047852edw.264.1572594336930; Fri, 01 Nov 2019 00:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594336; cv=none; d=google.com; s=arc-20160816; b=XzqvVAUqvN3LqpxqYkINuH42ao2dlnaM8IcjzEIrLIr4qzky4Y15l2fjehEaNGe5KN xkpJ1G+kirPlB+zznpDae5wbDrTtlx7oFQXWtDutsY7CMfZEaNKTimCDr9BsA0lkWNLI FpgzqLMqb2rBdyUhEJiu7IvrNHhTTJSq+WGwQPizXRXKCV0fs+hYwp0ZiT8SJD84/44q ruRqnWjcmfk+jaJYkkDqGtb5FTcBfvSew4eon9nqDBwXWQvbbQpYEFv4+ChHYYBfZz2b wJHRPdmbEnWu6kI01vNMGD45/1h2RCH3nxvBzb77HflayiP/hxswK26eztw7SPokSPDF 2pIQ== 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=YZmXO5ePw27XXjmw9aqXqaRd2VOTfPGeZBWp3iFdesM=; b=i5n5D27NAwDm8IcR9pxaunsiCd6+ou2mEyzux784liW4Yfw2p3qtxs37f6G7YKR4dU eiqC0loteHrVslj5N8KSbwXzSEVdCg/BUrLev6DMPDZIHcud6aU3IugRC1nP/6AvHJJ/ FDJRAnMOZg0VgPbSQlAK4jpj89QQfc9caAAKHDVwWWoxvn8gmzVOyXTGBMThJzSJc4ej ouJjwKtUwOql5Q+f2VmFjXGFOp0ArG+AYp5y2KHejzGdu/9PYHbfAHN7VnYHOOSpEQkj F2aeiC3APsakxSfydNYZi5mXr7YBdbdsAO2pSysoO2feamidZspqsRGrrz3iwVxm1Xgc KVWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tbCJuYLo; 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 d10si5362544ejb.54.2019.11.01.00.45.36; Fri, 01 Nov 2019 00:45:36 -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=tbCJuYLo; 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 S1730079AbfKAHpZ (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:25 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41446 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726921AbfKAHpY (ORCPT ); Fri, 1 Nov 2019 03:45:24 -0400 Received: by mail-wr1-f67.google.com with SMTP id p4so8787952wrm.8 for ; Fri, 01 Nov 2019 00:45:23 -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=YZmXO5ePw27XXjmw9aqXqaRd2VOTfPGeZBWp3iFdesM=; b=tbCJuYLob+0SWNE/H/aeNZaYlGi3cJ/mzfR3bgtLr1RoF0bzCFs3kcYakZXCwCnEnd MnLJgV1VtNOLom7eF3xRGzmxN00x8pt3aNMSyx8IlHnxSN+vGoNCz8lnWXF/E2LeLRvn XuvG3bchUwfbZm8phPQsjEYu6akLSU2CDD+qS4olY3VNarH3zFRwoe+XEwYQbqJlBfzq tQ9kT8oAkB6fwztc9zSR4if6OpgunzPPqsW0tCdlEdG5uSZMnTh0Nv5cpGDx/fojiR1p 1zIVuPoGmrTObZd6uVv0z7p0Xg2J9lR6gL1Fj/BLXh7mzPJPAim6tOvqoSDnWlzZRh8C /1uQ== 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=YZmXO5ePw27XXjmw9aqXqaRd2VOTfPGeZBWp3iFdesM=; b=GhEYHeggpjnGdYamNXaIPjH00a00NKe4Ks1EvIzTo6BWXerh2qdil2hqVpQnXJFMWD AEALMUP57a9pJUNh2ej9pWtyPHcBjOWniR2K4+I/TP71m0or3rTg7c/mBF6YUGiH1JK4 8hVVecDCgtVC+UV6LYBsMt/WSw6yELlShkmd8glL/KMcOpdDlgQjUvREYzgCLkG67q+I NyZNcJ2fFCLOiJh+VtAGg0dtYKz+U8OdOYEqKsKxAfcZn8yWruCJ9XkwP0ANMpcSe0AL cRnNM2j7WmLh8DGv1hoee7fYX8v9BJt6e3bqSe37XR2Ehslk2ujBfjlkB6MIcShRQvEM 6zEw== X-Gm-Message-State: APjAAAU4i/zPlTRxSU15HKVOwR1qRBEXFZkq9v3di1p9ySo8bPUTzylS y5ek5exMGxYvFQHXNNQDkZUJJQ== X-Received: by 2002:adf:eb48:: with SMTP id u8mr5175902wrn.225.1572594322417; Fri, 01 Nov 2019 00:45:22 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:21 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 01/10] mfd: cs5535-mfd: Use PLATFORM_DEVID_* defines and tidy error message Date: Fri, 1 Nov 2019 07:45:09 +0000 Message-Id: <20191101074518.26228-2-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 Reviewed-by: Daniel Thompson --- drivers/mfd/cs5535-mfd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index f1825c0ccbd0..cda7f5b942e7 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 CS5535 sub-devices: %d\n", err); goto err_disable; } From patchwork Fri Nov 1 07:45:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 178259 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp117154ill; Fri, 1 Nov 2019 00:46:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0xQM/Dhr/j2Ht1YxG4qQNfun6eujnO13yFO3+/C8ul+KRo8sUBqEUSESOPvDrKt4qTQhp X-Received: by 2002:aa7:cb09:: with SMTP id s9mr9017948edt.148.1572594360096; Fri, 01 Nov 2019 00:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594360; cv=none; d=google.com; s=arc-20160816; b=hqcp6aamasdignKQKp+y9W2E9695XzGey/dn8DgrxVbirqiO3UbA8mymu9I56nZ2VZ I0t2Nk3xSEhlXnjoMapR9AI9jbVubk6nxnu/mTo4iO9klL9XsO/+o+3ZsOQlqlMBDt7B oJe1msXMqTpWH8xDMGHmGA+fu8xCreTBd95ClCOyRRZguKKxO0EvgE8V8RTITgBgX2WL 73j3cqpN2hcvoFG4boNDtifuua6nS0aH9H3hXHB67TU81tITYkS5ekWqGpqrkGD6Rgy0 wpGzcp+Ak4G2lz2ouCknL0wZ09BhcqbNTSmlqIqFNxf+SMKd7Vn5/i0YUyippfW+NHd0 uT/Q== 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=C/fpce4zj8Symqro3B0UUT4uQWdn48veRLNE2xUiEm4=; b=QYKsBq6D2g2ahflA9pfQtVPDGvefQXKMEo/4BryRh2w921B2E8PYKCYq0F/y5NpAW8 Dahs3qI3sVS66jyh8Y5PCS9HGl6NcV7g7GJbDUerJlAz/4Tw/hsk1zzhRHknXA/YttAn Qmtnkwnosobq8nbuinEZS26R5Zvv1qzFQ7pLPnd7GuCKyNZh1L52H2JURUvNM5Zw4nuC hdv54bFrNFYy/Azcq6br0CVGatokzQTPrOigy3SvecIfCqqxZJY2pHsn1p17J8Vj1ybB rrRd0QnflEhBUJEqAuiugxhekgbGpEdWIZskuBYJ0b2IRx5TdBflNu244Oq2HW/vNOPT qIOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vdGFsAjy; 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 v10si6363904edc.62.2019.11.01.00.45.59; Fri, 01 Nov 2019 00:46:00 -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=vdGFsAjy; 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 S1730205AbfKAHp4 (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:56 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33753 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730082AbfKAHp0 (ORCPT ); Fri, 1 Nov 2019 03:45:26 -0400 Received: by mail-wr1-f66.google.com with SMTP id s1so8831462wro.0 for ; Fri, 01 Nov 2019 00:45:24 -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=C/fpce4zj8Symqro3B0UUT4uQWdn48veRLNE2xUiEm4=; b=vdGFsAjypI0mSjBgOqNUooAp4m4MfQ3YHrTg00PdnnA9cGN40by+eWJugaNkshf/ZB KR3IFrZ6ysfOE0+XKewaL50A4TNjCAL7tv0Fsi0pIY1f86g/5nZkEKP085Tux1fMEM3Y kUDK9XDy5ceVyg+QvbSqg6AuLfDPqtWroZrgdR0WAx0L91cOQrcqgWdjIHErHpt4VXCS 4yHGTUCPWjz6TvOinw8pjau6F783yazcdNr+vFEpgamEysT4OqJ8ZL3O0y2usDFtAtww M34m9y7C+zIIeHrIkOF4qbE9xNou0Z3cBPGq/bUeLDmImLlg6fiOV/IofRdBOY0vepuW YXTA== 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=C/fpce4zj8Symqro3B0UUT4uQWdn48veRLNE2xUiEm4=; b=tEqAjAgBaBbk0tobWG99PL/8myN/FXj5fSffHguRZ8cIxwaAII9ZN0DlFyCql4DXbS glv8AIGFwbOvOAxNKK2vmxslWHQXxGbD1ZNaynwtioD1In5xPoYlEXa1KjJks2PjVM73 r7pd6Llk60OSSA20GKuOPhz3CymszgHkGkWQ4sG9IHB1CbfbJjiqPSuMzUMtHjweX0f3 vTJ0KMkiy55Gn0eFRxPWw6r5zLFH0XAxvxn0+hw2XySA7EVZDbY23aGJuDtU97Qc/CG+ g6VMk/E4R4hWp8vAHnvNRZUB4seaZiILnbKLfoD8dYIdeWGS4qdQA2jLOOGIVNmE3Dqh dYgQ== X-Gm-Message-State: APjAAAV/++AaH3gx8RCP2qF0lXi6WSd2UPFX/6NWMB1ORC9a2QVyb5ZI D3j5kTz6Ak2WFtDwpp8g6p101w== X-Received: by 2002:a5d:6944:: with SMTP id r4mr1938621wrw.238.1572594323745; Fri, 01 Nov 2019 00:45:23 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:23 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 02/10] mfd: cs5535-mfd: Remove mfd_cell->id hack Date: Fri, 1 Nov 2019 07:45:10 +0000 Message-Id: <20191101074518.26228-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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. Seeing as enough resource slots are already available, let's just loop through all available bars and allocate them to their appropriate slot, even if they happen to be zero. Signed-off-by: Lee Jones Reviewed-by: Daniel Thompson --- drivers/mfd/cs5535-mfd.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index cda7f5b942e7..b35f1efa01f6 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c @@ -63,25 +63,21 @@ static struct resource cs5535_mfd_resources[NR_BARS]; static struct mfd_cell cs5535_mfd_cells[] = { { - .id = SMB_BAR, .name = "cs5535-smb", .num_resources = 1, .resources = &cs5535_mfd_resources[SMB_BAR], }, { - .id = GPIO_BAR, .name = "cs5535-gpio", .num_resources = 1, .resources = &cs5535_mfd_resources[GPIO_BAR], }, { - .id = MFGPT_BAR, .name = "cs5535-mfgpt", .num_resources = 1, .resources = &cs5535_mfd_resources[MFGPT_BAR], }, { - .id = PMS_BAR, .name = "cs5535-pms", .num_resources = 1, .resources = &cs5535_mfd_resources[PMS_BAR], @@ -90,7 +86,6 @@ static struct mfd_cell cs5535_mfd_cells[] = { .disable = cs5535_mfd_res_disable, }, { - .id = ACPI_BAR, .name = "cs5535-acpi", .num_resources = 1, .resources = &cs5535_mfd_resources[ACPI_BAR], @@ -108,23 +103,18 @@ static const char *olpc_acpi_clones[] = { static int cs5535_mfd_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - int err, i; + int err, bar; err = pci_enable_device(pdev); if (err) 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; + for (bar = 0; bar < NR_BARS; bar++) { struct resource *r = &cs5535_mfd_resources[bar]; r->flags = IORESOURCE_IO; r->start = pci_resource_start(pdev, bar); r->end = pci_resource_end(pdev, bar); - - /* id is used for temporarily storing BAR; unset it now */ - cs5535_mfd_cells[i].id = 0; } err = mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, cs5535_mfd_cells, From patchwork Fri Nov 1 07:45:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 178251 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp116792ill; Fri, 1 Nov 2019 00:45:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqytGGBiij9aLMHTXmM0hvMDmHE6JuQ9oLM4bHOEqlRW/WUMUrzrqL1LXp6CAbuiE2FN1GDR X-Received: by 2002:a17:906:70d2:: with SMTP id g18mr8649083ejk.18.1572594337308; Fri, 01 Nov 2019 00:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594337; cv=none; d=google.com; s=arc-20160816; b=EUzIPMX/4ptxZKheBICLzmhgNV/WXBa9C+b9CvLC77pG8rcphOwje0mbX+xk4EWxQQ IEg0Pa0bxA+IndcjEwgXoaeM13uDCA2x9Vz++d+TUqjiziJ+4vSRaPX9M65lDmWDkmMn j1j1fydMMczrwwQ7rIarVr/YmSe3Jq+7o+GbBeoUEb3N5GvO3FdVcejnhl1k26+JLc2N 2VqhdGRJ+emZwis5fzWbdO2hHNTHMkZlaGpOSQ3b7hnkWkh2vICL81GI1uJJw5We548a inyS4bSIFTYtfdYyg67VG3AHDyGQKc+uvVWgDSUukO3U8nqiKNZ0iEzF3RqdHl0iU+Zr 1jVQ== 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=YwP+Ou3x0Xq501y6yZMGhDxJBzedJFnXI45wlydnDjg=; b=wZ62xpST6TBeiSlBjK31qfWBfNMeaFJLqhCwMT4gRCxRfbNbjlzl+E6dvAymkaq8M5 ATHcvnL3s2TrcIZLG06brN+6HGaUVca+lIV2A2+Ue9DdQX+N/hvvs5fQbors2lNR8ybe muQyyjCdzFCWm2niSM+S2+db+CDzuA6GFlFukCjPBTsLFXrfh8lCAXpEpR2r2meDMjbW 08/v4oJ5Zt4UTE6dwOCy9KvdkgWE+7eXf0xFq1pjZo5qxqHcHku3lPlZDJINyv+LG9uA gRPEEov2/KFWCfbLs+bcphXAf6f9Lz/eUzJZw580PqyoQEryU1lIt6McykrAUN/HUUuG 7fgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=At9PfBtn; 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 d10si5362544ejb.54.2019.11.01.00.45.37; Fri, 01 Nov 2019 00:45:37 -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=At9PfBtn; 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 S1730112AbfKAHp1 (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:27 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51194 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726921AbfKAHp0 (ORCPT ); Fri, 1 Nov 2019 03:45:26 -0400 Received: by mail-wm1-f68.google.com with SMTP id 11so8467355wmk.0 for ; Fri, 01 Nov 2019 00:45:25 -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=YwP+Ou3x0Xq501y6yZMGhDxJBzedJFnXI45wlydnDjg=; b=At9PfBtnr200Qg5yCgwaj6cV7dJ1Xi6kY3lokTY5Um/mHszQ9tQ+oE0Fjdi27WE2t9 rhbGMrbX/WTBMw5kFNO9WoiX86d+KsjMX31m+b3OI4FhvnOqTDs1pzpNL8aH6R0lHkxW rIBOf0w6MlhnutR0f9HYYnStgyMhE5bsGFxKe5/b/SI+/PH5FXzb8DrcKt6+JlOYYBiA w7dk4wFw2cJGqmwTAuFVYf2F+WoOKbafPV8vZDGik639QE64nAb/ABYNof59zIsL8KNy +jmYlSanPX1wsWSZv1VeBm3REATgSbK1eJkuULXZAHIXHgTR5YEAHrOJjGoZm07HAkXw aWeA== 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=YwP+Ou3x0Xq501y6yZMGhDxJBzedJFnXI45wlydnDjg=; b=tL2y0reGmqhIEJSHPTqT0zHjJopoU37NyCt9Xhi+sA63wIBZjvGJCDsGFn+haBukKi 9cUDpuXPAzbg9wfWd33C3Z33rIDBX4IWcKNFIMUDgeXF/XkP+hYftWR8GOPW9MfL5Iup gTYF7NONIQYm1hwnyqR7bicmLTPrV50TPg5nbsQicvK4tsYK0It/L4Jh7Ni7/9Wjklrr tvDJb4WxjW6YVSS4rkFvZe71jzpnifGH2dcvHA4sTYkTPnbVjEig0YSYjTKZDhS3FtIX I6YbjCjkvGRIvdzjNZWqikE46VgdwwILCWZSos4E+nFCH+9HYXAFR+ltgZ6QUDE845fV Kr5w== X-Gm-Message-State: APjAAAUuQiuIRnTxqGnvVW1u8oRh6ma5ElyWuYE0g5SRWBpOXGIwnEcz TRG4ftciuiZZ2/qzZqzoJ7A06A== X-Received: by 2002:a7b:cb43:: with SMTP id v3mr8689669wmj.137.1572594324646; Fri, 01 Nov 2019 00:45:24 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:24 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 03/10] mfd: cs5535-mfd: Request shared IO regions centrally Date: Fri, 1 Nov 2019 07:45:11 +0000 Message-Id: <20191101074518.26228-4-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 | 74 ++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 41 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index b35f1efa01f6..3b569b231510 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, }, { .name = "cs5535-acpi", .num_resources = 1, .resources = &cs5535_mfd_resources[ACPI_BAR], - - .enable = cs5535_mfd_res_enable, - .disable = cs5535_mfd_res_disable, }, }; @@ -117,22 +79,47 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, r->end = pci_resource_end(pdev, bar); } + 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 CS5535 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; @@ -141,6 +128,11 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, static void cs5535_mfd_remove(struct pci_dev *pdev) { mfd_remove_devices(&pdev->dev); + + if (machine_is_olpc()) + pci_release_region(pdev, ACPI_BAR); + + pci_release_region(pdev, PMS_BAR); pci_disable_device(pdev); } From patchwork Fri Nov 1 07:45:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 178252 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp116799ill; Fri, 1 Nov 2019 00:45:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwi65SG0dRuU8FOm4j6odv0QdN6cqrizKlIpqFRqGv2iMolgQ9MH2qL1NY0LhA2uhr3gdva X-Received: by 2002:a17:906:557:: with SMTP id k23mr8126820eja.165.1572594337734; Fri, 01 Nov 2019 00:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594337; cv=none; d=google.com; s=arc-20160816; b=N7R3hzWRL/YQMsadn1tfK24nALxhaNukHdALIyHSHvAkyIPgXjyoP4zI1QsJXj0ZM1 I5JpsL/mo76aZ32iiSPwDb8K/CPT1HlHwhDaS8e3DyYkUZb+kr+33FZ3DQ5qLlF16kYS RwFu3ClHi6TGEcO6syymyuxeE+sOzdyeXb5ibBD+SbKXbTme7ik+BHzAs9LPyVnFKFAK kAYhzBPR5qu2D8Q4ot9UP7mrs4SWA+7G4mdLa6df5rbwbUgY2KlwnRCjUu56tfZfd4EB a5qwh9y8AAPsd2TpXNjBuvbsxHy8EC3p+zY8JxGeAphNd2EEiwK14WTM3ZGqVpwdEp9X TzZg== 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=o/WXNJ1LA673vdJ8sFOa/ninCgRnpi26dheEONfyqB0=; b=e9MMRGK4IXvItIvuVkJytPgQpDIDt5t/VHI0rJo1knZqryKbIwi0HPcHtHDA63RyL7 Zx3UejPdkk1xFKsNeE1iN74qCAyGAqRgjc68LHSRjrZzifXvCTJkDYZLZqtWpH3fBIgJ KDpV39lQZtm3WN0dYCKeOM0vNtcN8QYSMNaRiwP3GD+39d8QJPiE6xvJ2Hfrr9VzJ2il sWS5aqMdgeAvJkNk2ZDiOQ0AjPLywsDT9FO8cAby3juFKphmRzOTNILyxGG1u4SZySxh GSF9R+MnMh1jI/10jWdeLJMpt+56UevsFkZmSpzTFMJRPEEhOJ6zcoyAtoeF4G26Xl0z U0dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NLpmXnv7; 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 d10si5362544ejb.54.2019.11.01.00.45.37; Fri, 01 Nov 2019 00:45:37 -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=NLpmXnv7; 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 S1730126AbfKAHpa (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:30 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55660 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730095AbfKAHp1 (ORCPT ); Fri, 1 Nov 2019 03:45:27 -0400 Received: by mail-wm1-f65.google.com with SMTP id g24so8446741wmh.5 for ; Fri, 01 Nov 2019 00:45:26 -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=o/WXNJ1LA673vdJ8sFOa/ninCgRnpi26dheEONfyqB0=; b=NLpmXnv7R42LKiqA47VpSnkRY8XSxT2H2FVSayMw/zkOdsQZzOkqdbPIQ/zqzCB0db y1kbqWP6t1ZUqf2oG8daRFBPtTfdlI0EhlkJjDINFp0R+3vik28XAfGFzUi/YcMLwbZ4 q5YudIUt0fOEXyeHJzEPJKZHIEheIL/Vl2oW2w92Bksv+d5sT+DP9vkVugFdl/uXBG0Z DTkzSlSAWby6oCttAgyuuRZpASHljJq6nuGd0k9KJ8HyDyz4Gad2Ni90RK5h/+fk+tfK Xxp5P3XYMA0CjrWLUpV8mIegqZNVrZgpJRxOU5z/h2T25UfZimy0TX/BlswzJX++KXp4 KvyQ== 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=o/WXNJ1LA673vdJ8sFOa/ninCgRnpi26dheEONfyqB0=; b=eVGzx4P+POqAKGQKsZIVuDpl+0V+8aLjhoTH157vEJmiTu4II17RKATrYvNsG6XVGW 237CDOJAuc5P/AnEdokjz7/P2MvJx8EpoKkLTvcAKC8yGoFB9DoXAxq9urcazWs8KnRX S0ReY9357K3A5nVs0EJ2thbmWW3UkYVldpHwBzUtZtD6vWffmgP6YW9ruCqkmW8skU+Q D1PoCwwLwLkezgWKqGzrtmQO3KvKMMcZYHFPaVXz0qv8y+JNEMyJ1VAXjwz17worc+t6 u1m//ASGZkGVBf9n1Z52sQi2d7zgbs7npft9spuneV/0LVq/5vstqnR1Iah0c05aVTyC sMKQ== X-Gm-Message-State: APjAAAU/kqYO7nFU/nnW58jdr+QXSOC6BYse3/2LONyc3gyJfeIvbesq ygu5ETW2pX5HSm9XiGj/cJfjVQ== X-Received: by 2002:a1c:5f04:: with SMTP id t4mr8374156wmb.23.1572594326248; Fri, 01 Nov 2019 00:45:26 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:25 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 04/10] mfd: cs5535-mfd: Register clients using their own dedicated MFD cell entries Date: Fri, 1 Nov 2019 07:45:12 +0000 Message-Id: <20191101074518.26228-5-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 Reviewed-by: Daniel Thompson --- drivers/mfd/cs5535-mfd.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index 3b569b231510..d0fb2e52ee76 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c @@ -50,16 +50,19 @@ static struct mfd_cell cs5535_mfd_cells[] = { .num_resources = 1, .resources = &cs5535_mfd_resources[PMS_BAR], }, +}; + +static struct mfd_cell cs5535_olpc_mfd_cells[] = { { - .name = "cs5535-acpi", + .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 const char *olpc_acpi_clones[] = { - "olpc-xo1-pm-acpi", - "olpc-xo1-sci-acpi" }; static int cs5535_mfd_probe(struct pci_dev *pdev, @@ -101,10 +104,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 CS5535 OLPC sub-devices: %d\n", + err); goto err_release_acpi; } } From patchwork Fri Nov 1 07:45:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 178256 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp116978ill; Fri, 1 Nov 2019 00:45:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVXbF4KYlBgJI5K8F2p0574pVYHGvfgoH9mD3i9dgPIWTL6lRfByLgOc/EngUp06tPj6qo X-Received: by 2002:a50:fd1a:: with SMTP id i26mr10904380eds.272.1572594349504; Fri, 01 Nov 2019 00:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594349; cv=none; d=google.com; s=arc-20160816; b=A5inWwoz53tHPwrQ7xR18zTAiFtgsFOqsthSErWNVJ2j4ezlzjW3cEEg2nIgQGN8Z8 dgEcUVhoWDcOYAczngcj4rW/B8P62stFMtIvOVZliHlXjnY/ZtVDxKHWgTMrzxeYflcM nqxXkHurSQ/bx6tA/1XTDT0HqiY1zi3DrKX2PsN7tDNaBKZi3HRFEUjMhyIN75a5Kzke eeG7pET+95dd+xQpZEXGAcUODNrl5f5+RJZ0ESWKjWKf7Pk9Hq/E2aiqTCV6DqkigjXR cXlii+WYXSlDjV5PZL789LlCj2glsgGeZzv2JfhBNVVTbVA0QdbG+3KbN3kI9tiSqsnn YmwQ== 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=GReEFG2GWwJjsYxj+qnWr2ZeJ1W345Xh+fZqhg0GuOc=; b=sWcyrCzakgKwpSvsYIekdml8b09zlvuVVDLN5+DzbL0mXJH+iwHLN1873CDlIG7uw+ MPMSotkKm4WN6dWO+Qw5gOIo/6UE7BELaCSTJwXqz9v7qjSYvPB6RrvDZQMLI6FGJnj9 7RwwnyNYN0e1U68EC/vaLS9iV697eyPF94LrseDDFGzdSnPdjSRl5MQ1sNW5Ibupq97f bzfWM0yZsLw7mhyz35R/DCH6mcguIU79g9Mxbftjal9qzakjCD5+4bFno9Q3M51kAbga uVlLglnOWN0FL6PEtcFquX0M+iuGTHzM4JqueMwaQqMwas1ykws1JMvjt8joCydqYqjo C2tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aPAUMhk6; 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 w18si5188280ejv.378.2019.11.01.00.45.49; Fri, 01 Nov 2019 00:45:49 -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=aPAUMhk6; 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 S1730139AbfKAHpf (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:35 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39639 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730121AbfKAHpb (ORCPT ); Fri, 1 Nov 2019 03:45:31 -0400 Received: by mail-wm1-f65.google.com with SMTP id t26so4168759wmi.4 for ; Fri, 01 Nov 2019 00:45: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=GReEFG2GWwJjsYxj+qnWr2ZeJ1W345Xh+fZqhg0GuOc=; b=aPAUMhk6ayoWZyrvs0fsQnUU17xXjJv6voGdabNYsT7kPSp8UW342XBwFG/EeCKz0M 9HsX/Ldh/pDdk8lDjcmMli0SNg0TYdag8vMTj25aA78BvXaLqt9Cip7XMGccXX3djbMt f5T+xevpesx2ybGhZaHvyv/4lfHjcQ8WKL17xX0pbqQCYyF5U7q2oaX4MLyl5liN0hHz CQpfRklQ5z2fEf9l34Dg4zNLAGIIvGG8s0970wnbzNziW5bYYqeUboSChFg21DExUJgn MmSriuu9eSFRucviBK0WmT8DoZUToeM4JmB7oRR+ek1UV/IoV6ueW0DXiGuiCb9GxbAb /5uQ== 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=GReEFG2GWwJjsYxj+qnWr2ZeJ1W345Xh+fZqhg0GuOc=; b=Yh63qrvRItgZ2YnhCxzKxdz3j2YEId6maq+eC4hwGY3JPw+ZhI9wzJEDcroPii1pwh FAxki0T9J2Tcq9poeKm/ZT6Q3GjcvwFOsWTD+fwo52sVwysr1clg172d/SxNwZCLe+XH AkDkKDxp6icJecGBXgTQVkxwgv+MMH0xwEUmgP2rigEjsInPYSVsc9qej+KKz10Q389P s5ZLpfSZQoEMsmVuDkZLUbrco8sP8mul4itBH6eat8nkUQzw/Q8PnXJ12Am2GYLdWHvC dLBezwxaAzYhBv4bK+4BqVJlArkG+vQePCx1ALQTof7VsX7ftsngMObpvDoJAshW82z6 YYmw== X-Gm-Message-State: APjAAAWmZvAAYo+jGoSYsSuiw3WWFQq1/yj7iynw/iGpFCAJ20R9Htvp gb9Q8KoNnXe5kQFW+cbRzCzRPg== X-Received: by 2002:a1c:808d:: with SMTP id b135mr8624500wmd.175.1572594327746; Fri, 01 Nov 2019 00:45:27 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:27 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 05/10] mfd: mfd-core: Protect against NULL call-back function pointer Date: Fri, 1 Nov 2019 07:45:13 +0000 Message-Id: <20191101074518.26228-6-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 Reviewed-by: Daniel Thompson Reviewed-by: Mark Brown --- drivers/mfd/mfd-core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- 2.17.1 diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 23276a80e3b4..96d02b6f06fd 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->disable) { + 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 Fri Nov 1 07:45: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: 178258 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp117072ill; Fri, 1 Nov 2019 00:45:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV1Kzwc3qlxHvwzkCaeZhKuyOpu9ThPmiSgNHWAEdYC3f3MXlDRrHBwIvT7loZWf49CxWJ X-Received: by 2002:a17:907:429e:: with SMTP id ny22mr7981633ejb.174.1572594354905; Fri, 01 Nov 2019 00:45:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594354; cv=none; d=google.com; s=arc-20160816; b=TdQgyh304UWJk10tQUKg/nV75ATG29aoELngjh4G+k0FoNvqnJw2giqIDRzTM9FlTi FV1hw+gx+ztsJLJqdPdgqUMjR2C4RZr5+msoiyyvXsR13zVlZZoCZCU24Z4thtV3vXRO DGgN+75LsXThY7dPBadI8z/nmNRHwq0sixQYArVl2NZA0mGLWA9JxNa2csLdK0s2VN1h oIAinrvdJMW8eC8s+OOT7y/jjUc3t3nM5mX3xaE7eriMMdu8AXLvfL8gS97dfAaaYh3n U9s1wo8BRLhys04PwXUmIHZOFhjeKxVLRIhVzn+husIIlDl70bQbKY+G4BhehEcuWUE3 Eitw== 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=n8Ucez02iItku1JzTTgA4X0TOQF7g37QZ5FK6iQhubQ=; b=LkB78m6Y6DVTaoq7DMuWLYNry5F8LHy84dlpk45XTTUnnFr1KiX+wj6ux0YbC3zvpj VfpwrU7M60vNMsxHbSVyVCLf/Pfw8D3kvdR3DhOACz4zm2QUi3v1vK/Bp5Xh2S6RZ4GQ pwyJcp8+i1XQa0eWqpxzmcl/yDnu6T7MRYKxEuFYXAmzh5ZeWCyTvUK7zCSiiB0MOsQB hgDjsue1fky58enC0YkQfJF/8mULzgIyHbzucUe9dAXKhQM0nH2YSFz2RCvfVkvWGYOs QHeEf2ulrF7TJdHyz7ODoe5uLXwpioxiJtu/i29lWEfOFv5KLYxEd9UxMRRGzUaE9Off U3UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B6R+1JCS; 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 bq21si5134942ejb.432.2019.11.01.00.45.54; Fri, 01 Nov 2019 00:45:54 -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=B6R+1JCS; 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 S1730194AbfKAHpv (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:51 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39673 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730119AbfKAHpa (ORCPT ); Fri, 1 Nov 2019 03:45:30 -0400 Received: by mail-wr1-f68.google.com with SMTP id a11so8795387wra.6 for ; Fri, 01 Nov 2019 00:45: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=n8Ucez02iItku1JzTTgA4X0TOQF7g37QZ5FK6iQhubQ=; b=B6R+1JCSAwgKyR+aoys7iRUcEXhF3L/eli9PKppCN67iGTa5dHpuJBYW8X2vtxWRJe V7wTxydHk4Ct8YvnSw2UcLuTwXtjjbLQ666IT3NUpkXd5O1k08xxXtaEZwTcY64P7ngp +dpgTwiVaWNesy6RsktWd0EzF2wbkDF/rHJsF9tCQRKmKZi/3eYjzK4erdj7rbfyICJC jk6Jvl6IzMdWBLl8ebqJodEwDq8zVW63CGjUcX+SY0YJCfTuHzcxc4gMLkgx1Cf8ZrAa mUjSsKuDsvrttJrGmFIvqY8i6iPQPLpTQtCbWumn6yv6GTf5KqGthZt2jhVOdnHk/oRz G50Q== 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=n8Ucez02iItku1JzTTgA4X0TOQF7g37QZ5FK6iQhubQ=; b=Vh/aVsMfDUHBcnUePb/fyeqpmi+n6AiBKGnnrPsIpyeOBY8Pm29x4vmw26mLGyoGvl ZjyiFwl8G4fB5BcJMUJLBMD9ty0QumydwvX/Qpxuy7vBi4e7OU0h91aGa279NoWW2x/E ODBbg7LoUJl40/OoI4GonveEbaTSFHMeLFfCcY6Md14n/yqs4kPePiUJ62mWRx6JHmmC KNDDnbTa27gYMRHE0kmSeTyuB8GKOQWuC1H+TEL5OXexpbQeFkLvlw6oKAqzwvqIzmLK wjIzYn0fsPAlnd5+qGqqZrzmCVSwvYrwFtvWMLsqg8KJun7MFYA7Q3QEHb4WcG280HqI a2wQ== X-Gm-Message-State: APjAAAU06WzBaJsQjvnqRIX+QdzUcuOhVnxAqc9hnI+6Gj155Fb84RDb rJlPalPk/M380rcj2/a2bd5Kog== X-Received: by 2002:adf:fe90:: with SMTP id l16mr9255966wrr.81.1572594328646; Fri, 01 Nov 2019 00:45:28 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:28 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 06/10] mfd: mfd-core: Remove mfd_clone_cell() Date: Fri, 1 Nov 2019 07:45:14 +0000 Message-Id: <20191101074518.26228-7-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 Reviewed-by: Daniel Thompson --- drivers/mfd/mfd-core.c | 33 --------------------------------- include/linux/mfd/core.h | 18 ------------------ 2 files changed, 51 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 96d02b6f06fd..e38e411ca775 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c @@ -392,38 +392,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 Fri Nov 1 07:45: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: 178253 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp116803ill; Fri, 1 Nov 2019 00:45:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwD+k8gdx0rq8FNhxVCt8LdEhk8DoFIv37ltoUvUcpByFYRfiqHwxXImOHXKj8Mj56QySrW X-Received: by 2002:a17:906:858d:: with SMTP id v13mr8135518ejx.61.1572594338119; Fri, 01 Nov 2019 00:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594338; cv=none; d=google.com; s=arc-20160816; b=iopITETT//1Nui5e9MXZdWbCXXTBAGwTbd2qbUXnb3wKk7r1bilKHyo9MJrc6J+V0/ gktgUy3kH1CbeJaCZAjt3TwyR5ZezAIBRwvZmEc2Q6jPDGWtq7i9hCEnHrY/mawEy3ML 4EFiA3cw02A71Kb8eR2nWGvqrVlBfjgNIHYAbpjGO0zH+Frv8Xe5lx8mYJMnU5fv26Dr 2mi7/OKbv+MfezJNGFjJMQ6ssjXtk2dHshIVfTVPFfAhLqsZg3fwd//+mnOEwGNaP12U H1j6mwrki1CKkLJ1Hn7b69yfkc9VD+N3CW22DuziMGC/2WqKHjOm1RttuekrI4fCNX36 D1lQ== 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=I+jRYJ+sv8PSuO5nB4vni872MPFD94JrjqUMD7lrsKg=; b=Lc6lkbFfMUUB0W8oa12M7fvu64Ax+JfKMgcu4nu2ZPZ26eYk0Nl3BgorWChA6Mtavs B1cab26+kpJja0RWLhzfqxxVJaYBxSurN14u5rT9W5Xb0uvX11ujl7QVsPe8EcPEt4a7 Diy4ikw2gNnk3Tvw/y5G2LHuP5Pu14c51aGSk3//ujed/xwBn1FfaYdbGsa3UVKiCEkT D26TeieRgDS1VJIeTVKzOB719cWglTf9GKwXCgf6ot6SoUAtyQuuXWSeazHrkXkD3S8D 6R8XqjmlqE7yI9f3xO95xHbURlOAOUQQsGg3Bk0uDXmk4Z/EwnXXYgNEWTSwbMVEqjCJ CHTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SWoRZn1T; 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 d10si5362544ejb.54.2019.11.01.00.45.37; Fri, 01 Nov 2019 00:45: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=SWoRZn1T; 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 S1730150AbfKAHph (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:37 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38732 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730124AbfKAHpb (ORCPT ); Fri, 1 Nov 2019 03:45:31 -0400 Received: by mail-wr1-f65.google.com with SMTP id v9so8814090wrq.5 for ; Fri, 01 Nov 2019 00:45: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=I+jRYJ+sv8PSuO5nB4vni872MPFD94JrjqUMD7lrsKg=; b=SWoRZn1TJzuIfLyY1vbC2tQKk7pxk2GocVuGBSqprOkpeT/3QhldJootnOYUFiUoCW gffwSB1PUQOvQUhc2IycslRcwMVtl0OGCyKY0JVj/7TY2tCwLsJ7NLKuo6qX/6e99LH+ EpUyQKZrmnfU0fxcYD5J8438Ap+OkYn1pfEIt4AwNc+nu+Q+JDNuETpOqdH/IO3Frftf AX0sEGoxCggCDq9ru0P8HsrzgbWjCYKktoN/oIUKG9DUzGDxeiSFH565yAseyidSK+s4 MdmyH8jZckm8ulA1RFijtPeSaxbpDU+Kk56RJq5tAF/riUxZchUB1MBrz1uJdPhjr6wh e+cg== 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=I+jRYJ+sv8PSuO5nB4vni872MPFD94JrjqUMD7lrsKg=; b=Rm2eU2wifrgp5mQd6MnY9c7P9I6V/Sr3jw4HbKwIMTJct9jDRlDwCcusb5EpamsgBN 6g8SiNJIL+HOMD3ixKlWqCXhZnnIaG1gBARtWRh5NHJiiSNL4NwAF2Nbfn2zGpyshJS6 sAzIxt9LUY3lpgwcl0LJOiIwLyEGesTpoGMRy/8QBq8JN207XV5/gqN1ZOdywprK28B9 OdJvcKna7St45a8jgIFlfrfw6Y2dzj/V+uZ7I68WN1PkytxidF4ugf/Jattpl34N+3mX 52OxH9jiNwLihfIi9TB8PvFkh7bt1AKhh4L+zd5o6mNgojMD1asceQM2GvwkC7bxIbPg PZ+g== X-Gm-Message-State: APjAAAVccwQghCDWcSHeZoPNOeLSw31+SFTIOLlYfWVlJXHj0/fGQJqi bB7dtM+ALXQx7fNWmsKRBoAV3Q== X-Received: by 2002:adf:9dca:: with SMTP id q10mr9394442wre.183.1572594329634; Fri, 01 Nov 2019 00:45:29 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:29 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 07/10] x86: olpc-xo1-pm: Remove invocation of MFD's .enable()/.disable() call-backs Date: Fri, 1 Nov 2019 07:45:15 +0000 Message-Id: <20191101074518.26228-8-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 Reviewed-by: Daniel Thompson --- arch/x86/platform/olpc/olpc-xo1-pm.c | 8 -------- 1 file changed, 8 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..f067ac780ba7 100644 --- a/arch/x86/platform/olpc/olpc-xo1-pm.c +++ b/arch/x86/platform/olpc/olpc-xo1-pm.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include @@ -120,16 +119,11 @@ static const struct platform_suspend_ops xo1_suspend_ops = { static int xo1_pm_probe(struct platform_device *pdev) { struct resource *res; - int err; /* don't run on non-XOs */ 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 +146,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 Fri Nov 1 07:45: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: 178254 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp116900ill; Fri, 1 Nov 2019 00:45:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzzN1CMUz8TKoukiKONrhxmBHNELpoLd5VHVgE2Ud98bsfJWcOGhaOb04z+cp8xTAAOR04+ X-Received: by 2002:a17:907:213c:: with SMTP id qo28mr8631412ejb.43.1572594344070; Fri, 01 Nov 2019 00:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594344; cv=none; d=google.com; s=arc-20160816; b=M8WEieENRpJkCLJuRGpF8ln8nGHfxdMXyRcQEckVMendVKR5ljYxxIIY8tLA0SaoJY 6wZBB9q0h7Q51+QWIegJxKywIIhXf66EYFpg11xs4Hb+1DRNB/cbYWLYwALOiCRWJ6OA ox/WCuhitB8wsrL3Jm7PGcj+Xyanh1VgvgbVlmrH717rFukuTmMvxaS6BZN2bMoobM3C OSFVv2gJD/AwsklpkkonX2zBtTMs3GopIrOBFK17sqOnPvgowzHU8O5l5mIM9YCXAO97 wM87NKG+ZZlA4ci9iVLu6jlfmld/3S6z2ln4G+Nvnu8YD1LJYrue3DlPNeBE0PhYy01t V1WQ== 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=BF4ZzyUEGnGEiyqA1v3l5l4pjBuYXhzsNNXXOYP8w+o=; b=YBg1CnaEtdhs8B7mgox7CM8af91eZjU6C8TEQ6/yNuPQPvXn9VpffiQbfGxcjwKlfp DWYy6fzOv/N3StcyUCsMDiQcqNoSVFBUAKwvdXCY6I2JbYROvoOIwZ/aWRMIlabfmNjm A3jbmqwuIc6+fSiD+n1mXUCz7p6PqnmdiylgUIqFYt6YFLoTOBECg6Oc/c+AUM7QQZX4 NFLtJgUUBQZN/9jzqUvgBZqItNmyx28pfjtKfCFCNS8WwNgF4+MFLgbbBWBVt4Bq8u7L ZpJmqg8f7aBiAzaj2AJl9I2hLFOG14Z9ng10Kh0f3YtxXHqOeUMqJOjIePzsXIpWXNrG el4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qbHXVYhy; 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 bi3si6878051edb.331.2019.11.01.00.45.43; Fri, 01 Nov 2019 00:45:44 -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=qbHXVYhy; 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 S1730161AbfKAHpi (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:38 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35652 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730130AbfKAHpd (ORCPT ); Fri, 1 Nov 2019 03:45:33 -0400 Received: by mail-wr1-f68.google.com with SMTP id l10so8821307wrb.2 for ; Fri, 01 Nov 2019 00:45: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=BF4ZzyUEGnGEiyqA1v3l5l4pjBuYXhzsNNXXOYP8w+o=; b=qbHXVYhy5UqqBLj8qTiPohKa/wHistzi1bos518nV9bTNsteO8GyV6wzqHtSV3HuDM L2SOVq0KsobRYwXQzm6Dhi9BtAveaD3ISRF3m6M/ZDS1J3WuAV64hWlBbBsnoNjOkCUK Nbr2QDhq21lEZDWQWAPGh8ymfd/spSRc11zEeIX+Rd5tJknLhiLYpw156XiJc7n9nob1 UX1ZwMymHYKPyB61tOF9yGHL4CSezawT6ynfWSJpnXp2HLYjFprBeL49Q/4snQusirgI akUFjZspQxQTHfoDAbT/W+7pHIOCA9CqSmwWBDFOAxYLMeuANTYzqIQkUvKDJjjyGIvP e+EA== 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=BF4ZzyUEGnGEiyqA1v3l5l4pjBuYXhzsNNXXOYP8w+o=; b=L/mOkL9zrcBARZPaETyunc9D8sAPCwsl1Wg6bEzAh1v+Qy9AdGqzZ+ND/kpzykw7Yl W98qWv2rjlH6YbDTpgHjOr+J+y4z9/LZ3UThqow4Y0RCBTr4+3KS/9xoswL2M7BQaur6 6jU7qStCi6bLjH2RzKunYxrqn8l5scWuPu/AdMi+pv2El/UyCfrVycsIwT1M3uBlppOf H+tJng6nRXtOOVlyzAb/IZCIennE2kHH8b/iytcaay8IpWUJA9OdEUOxn5Z1bdDUg1ZU Zck4n0GXhPHgq45Ez4Un6U0bMaw+JWvzxjnR1Dq7Y4aM/jR95MUDKnNBAVSbf8aajtjC sCFQ== X-Gm-Message-State: APjAAAUYemy5GB1rxqDf+SXcD7JecErHhidZUS87Fs9wxNNonCpZxGIO bZwiEW8HGwjOCHtPiZRPOZMwxg== X-Received: by 2002:a05:6000:1601:: with SMTP id u1mr9321793wrb.214.1572594330472; Fri, 01 Nov 2019 00:45:30 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:29 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 08/10] x86: olpc-xo1-sci: Remove invocation of MFD's .enable()/.disable() call-backs Date: Fri, 1 Nov 2019 07:45:16 +0000 Message-Id: <20191101074518.26228-9-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 Reviewed-by: Daniel Thompson --- arch/x86/platform/olpc/olpc-xo1-sci.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.17.1 diff --git a/arch/x86/platform/olpc/olpc-xo1-sci.c b/arch/x86/platform/olpc/olpc-xo1-sci.c index 99a28ce2244c..933dd4fe3a97 100644 --- a/arch/x86/platform/olpc/olpc-xo1-sci.c +++ b/arch/x86/platform/olpc/olpc-xo1-sci.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -537,10 +536,6 @@ static int xo1_sci_probe(struct platform_device *pdev) if (!machine_is_olpc()) return -ENODEV; - r = mfd_cell_enable(pdev); - if (r) - return r; - res = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res) { dev_err(&pdev->dev, "can't fetch device resource info\n"); @@ -605,7 +600,6 @@ static int xo1_sci_probe(struct platform_device *pdev) static int xo1_sci_remove(struct platform_device *pdev) { - mfd_cell_disable(pdev); free_irq(sci_irq, pdev); cancel_work_sync(&sci_work); free_ec_sci(); From patchwork Fri Nov 1 07:45: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: 178255 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp116912ill; Fri, 1 Nov 2019 00:45:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrixjpdZ8Oy25hoszj+DcaQKe/AkwT9sGKq4qMgFni+0wIXlfRx+RUBD5inaY7YbDnjZRE X-Received: by 2002:a50:ec8d:: with SMTP id e13mr11271317edr.54.1572594344463; Fri, 01 Nov 2019 00:45:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594344; cv=none; d=google.com; s=arc-20160816; b=U9VUIuHOkQK0e/qz8VuW0mihBVwPBvBGwO92hcIKXVaJRCYIHn7MQbPYwO+9io0Qpb mklGe5ei9OI0z9l5TOTMiPp5SW+YjegfFWsudmdK4DKmcw9WryFoI5pOdJ92ixJnYe0U yv5VeTj7FcvGzvnGdb/bMTv1iGGWOeIJtAYz4P9JwzyBKh+z1LNF9ZRCCfOge7TlPplj +/lTiIYlwDax9Uzi4yA/HMnf5Vo7Gis73emjdKfOOMeT/RXnwteky92ahtrvDo9ffKky CviAilnFYmmmS7JE8y6y+Y8arxN3S3FITzdl01R5e1JGaL1uf/rJOsyOibm8k8+d2F81 Ei0w== 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=G66DJ8x191Pz9QU5XLq/zdiIBtE2uKywn/4cMYv/RBg=; b=rFyyxM/ZvbdEm+F5+o6af6bOrx895UUxUsvpCP02ryY2HJm6TeTL5wYGFxDrdtV2NU 7IcESzuRo57zV+kAjsXmvYEU6S7Mg58FIbis+pa1FDUv/rxr6rkOLiBGS6WD0ReZwMLC xWaLe/G+WKEvWeJ90AbPtphPCz+Qr63vznXxBEHjZC/SwNoHq55REmlK8xJjQPAIwc+q ncPanwjyYY4/chlzoJyZiM4Cx0BEf/wnWywQPXN0CU0gkTsnY6oOrullnu62kozVBN1L SdvchEZIca/WBeOobDnffnGWtmPhBceAp25cBbHEvOMGZziK55obm7xgezKfKcVdQ0hr R1bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LKOGWnyZ; 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 bi3si6878051edb.331.2019.11.01.00.45.44; Fri, 01 Nov 2019 00:45:44 -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=LKOGWnyZ; 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 S1730172AbfKAHpj (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:39 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36588 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730129AbfKAHpc (ORCPT ); Fri, 1 Nov 2019 03:45:32 -0400 Received: by mail-wr1-f65.google.com with SMTP id w18so8826424wrt.3 for ; Fri, 01 Nov 2019 00:45: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=G66DJ8x191Pz9QU5XLq/zdiIBtE2uKywn/4cMYv/RBg=; b=LKOGWnyZ+ssOprnTgp43gChOt34A7AW4ibBfDtuBIW1V9+TM+2J+xFUre8GLvyPFik PvpW26uL6ZwlNoNueYi+wocJOmRhRlgnj5JXrog3pPTIQJE4FbgdALfMKZ6vCdPAXwk/ 98gUmHW7r/gDma0V9jhqm2VN4gCns7G+l/8CXDbef88Iy0GnbO0ZxAQZDQXQYE90NoEx IfJ9zoyKTTuoyZ4MfXGiv0Yg9dUflza1bwxv/0/l0aYQzomi/SV9fRKVsZNy9uFOcnnd QuUiqiESOAOif6zPTLb4/ZmMHIIM5Udx/vPKTJpIRjwE4wD/EDIZCXEXZyXxnbPbb8p0 CKew== 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=G66DJ8x191Pz9QU5XLq/zdiIBtE2uKywn/4cMYv/RBg=; b=ntrlflu9VUYrbfc7UFywweqdliJJpDR0FZ7yX0YJBgwyHvSdrhz4dsELhBtDQk9tWJ 1IRjDOQkTGN6z35CRtIviJbPdXKlKl1RGGQFs4c4luUjZSSwrhE2jDCAi4KHmDcPnwC3 8tUpzcTaCPkrHgd4ttASpFWFLijEtkk7TGIc3WQySt+sziGq98lV4B0dBT5lzRNlywEO Z2VhC6JxPfBvYbUeiHS9ea3/m1FcwObYCLR3+XLGJ18TUEZZO0FU7GHIOCaBz3x2gUy8 3RAYMVqpbenVF0jIBLxcG7wfaOOcGQKM8xe7WzLPRXGmE/yDnQdz2M24dBeXxD+zhqX4 Go6g== X-Gm-Message-State: APjAAAUIdODQsRRZb2NnWJe/uY3aTwIeiNzZhsBP+IYg4dKIDvn7c22N 3TectjiAb0w7CuOXXwW1WM+Y0Q== X-Received: by 2002:a5d:694d:: with SMTP id r13mr8929386wrw.395.1572594331448; Fri, 01 Nov 2019 00:45:31 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:30 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 09/10] mfd: mfd-core: Remove usage counting for .{en, dis}able() call-backs Date: Fri, 1 Nov 2019 07:45:17 +0000 Message-Id: <20191101074518.26228-10-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 Reviewed-by: Daniel Thompson Reviewed-by: Mark Brown --- drivers/mfd/mfd-core.c | 57 +++++++--------------------------------- include/linux/mfd/core.h | 2 -- 2 files changed, 9 insertions(+), 50 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index e38e411ca775..2535dd3605c0 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->disable) { 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 Fri Nov 1 07:45: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: 178257 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp116984ill; Fri, 1 Nov 2019 00:45:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1P88Apg+QnW3OU0Rzmehn+7OuRcDcYPZWgxtAOFUT5fFikP+OhAMVIWbUSCiT0Sv7abwU X-Received: by 2002:a17:906:e88:: with SMTP id p8mr115291ejf.15.1572594349913; Fri, 01 Nov 2019 00:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572594349; cv=none; d=google.com; s=arc-20160816; b=w1QNuB2L2u8pJDIrtNxvjk+X/u8cshJMnQsmzwnNSHgYDtpxZq865C1Lh3soBHJ12L a4+JCfk+z9bv7/G01t/b82e5ryHFo2V5J5VYtLbT9c8sT7cYY/r4bC7GG1e7623ORvZV J7eEjZXmK5aSqS0Weh/cDVN5WsS2HmkZ5gUo+6IbO/Nz2S7BLvRaTXIYOPcagtT4fiM/ 8fWiTfXEj36Tv0m+PAtThNLGLuJdPE62DhF5HYZIoHs8IParzJGoCO7rDsyirEY4dQui oGE2HGlDWUG4qGxiIQmW5p2yWwvPe9/lac4mzVXsnStoEUk+t0RtjbmqzYid3sXhO/pU 0ENw== 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=L3ntFqp0Br65sFjkR6CV5W+v78yDN2My2Y/1a4PurZc=; b=D/1o0ylq3U8eGrndGE2Sf3WVuEc6x14tlwv3Q0327zmWNmn6/vtdXMz5JpCwf+yOT3 it+AkKb1Y8svONpw+GxBPU76FuoW04gz/8XB1pIfslK/p3kCGGrFHwnDFlHonXJQvdsB HPvIT2Kg5KYEfo7U3dMkLnWM9zqzqWNtC46b9Yr8hXokznC+v6vl3DZ4M4o3H1DJLnNn QgOrBLyzNwaZLcxpq+9SnuQIDJHlDEwPEDNr3veBVFFzKwNKefLtYFClVy3luiAqk/7Y 2YQGwFUMl4tJoJ9e+NgCdZe6w4mi1zGC8E1jJLUmg30SdTKs0PW6kpbTkVD/gW5n3smh D4FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dnSa6iYh; 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 w18si5188280ejv.378.2019.11.01.00.45.49; Fri, 01 Nov 2019 00:45:49 -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=dnSa6iYh; 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 S1730183AbfKAHps (ORCPT + 26 others); Fri, 1 Nov 2019 03:45:48 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38737 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730135AbfKAHpf (ORCPT ); Fri, 1 Nov 2019 03:45:35 -0400 Received: by mail-wr1-f66.google.com with SMTP id v9so8814194wrq.5 for ; Fri, 01 Nov 2019 00:45: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=L3ntFqp0Br65sFjkR6CV5W+v78yDN2My2Y/1a4PurZc=; b=dnSa6iYhiNbdnjJmZ64ci22Ch8sTiVytWPZwp/hjW4bZZj9bX8HlNOYpLoAJtK5QAW Mjqohe0lpiN6BwInpgNQwBaMm48MYcx6CmBAjKRAXH7Ehq5xE64nuEyjgqn6s/vuwoo3 6vTfUBcQyK5pt++HyFRgz/y4lBQg0/NNs+GOae3rK+gMX+/aEsXaOOuk5NyQs2YoEchD flDohJEiKxDyuUWk6L+KAxXWJNP/GlaHVI+5rw7gBmd8ms7/mvM0CdudoEcElp7d6Lu+ 9C0eNZNkHRPYs0IIF5MtPX0dISfIH/38IYa/Ffo67/O4qa1tko1zJQn9o7W9W4rlmvFw VKSw== 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=L3ntFqp0Br65sFjkR6CV5W+v78yDN2My2Y/1a4PurZc=; b=gxqSvkF/fBs+54mUODH33nUl7cavm/KASqTW0tUhhjX38mAT8MuCjkHjmPPC9maMjf TPLFwUZzcLpXS7CilIre2ZiCUVYlJ3zzUL5EkqcTUhd8K/sf3w1LHGIxksVb/9BdNHOP SJNcycO1LmMjT7u7L9zeGEgeIOnPjVgvpKKU4wRTWtb8W/HTRg2jxlN7Hb8DkUw0+Ao4 ke0yIw14wNMPiu5LWxBCShl67JhGF6E+1SYKLBT1izEXm4qfg98hSNDpdsfT26o6UfBH a/v5ii77xUUfj6GEmtBUSLWNsb/ntFKOtRQZv6rQ9XfTzQ746+TXvj5xZqUmjzE+xvtw 1snw== X-Gm-Message-State: APjAAAUcQWApc/TPAV401DUoETsp6Cyhylm5tXZZ5K9HAvv4fKdb39Ny xHvR2eK68aLMqgN/jDKJgz+pyA== X-Received: by 2002:adf:9799:: with SMTP id s25mr9477755wrb.390.1572594332397; Fri, 01 Nov 2019 00:45:32 -0700 (PDT) Received: from localhost.localdomain ([2.31.163.64]) by smtp.gmail.com with ESMTPSA id b1sm576215wrw.77.2019.11.01.00.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Nov 2019 00:45:31 -0700 (PDT) From: Lee Jones To: daniel.thompson@linaro.org, broonie@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net, Lee Jones Subject: [PATCH v4 10/10] mfd: mfd-core: Move pdev->mfd_cell creation back into mfd_add_device() Date: Fri, 1 Nov 2019 07:45:18 +0000 Message-Id: <20191101074518.26228-11-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191101074518.26228-1-lee.jones@linaro.org> References: <20191101074518.26228-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 Reviewed-by: Daniel Thompson Reviewed-by: Mark Brown --- drivers/mfd/mfd-core.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index 2535dd3605c0..cb3e0a14bbdd 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;