From patchwork Thu Oct 24 16:38:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177541 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2399892ocf; Thu, 24 Oct 2019 09:38:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2zatgr7bQANhDuS+nNpv5apYdK3aPSUz3PQOxMmrAymGlwg29QJ7L41xr3j3cbmdfdcN8 X-Received: by 2002:a17:906:e243:: with SMTP id gq3mr21042723ejb.302.1571935123172; Thu, 24 Oct 2019 09:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935123; cv=none; d=google.com; s=arc-20160816; b=TRiILfHqfkEPDO0VfUMKUqmomFlhpew+ndn9VwM2j9OJ+NBVw5iMrIM8bZXuFoID5N z3jps3Ft+rIUCP10RanNlijFNlZ5cHVjEAYU7Sm9UpXRUw85W0zOWkeh8NVGFdr2UqBc uSEuRu8EZgF/nhnPsQWqAEnRbXc1FHwi6xafleIiVf2+HAVEmyKR+dr0Ic/0ivCuO2mL J9Oz3SpxD+AGU7YakcEPHMpjc2bRNAyAesWZHVJVUzN8RbA8pJvxcViOkIjBicENdgB/ uZF5if0yxsHNgir8UTjzaq/xAwNjXKEHiyHprbJSsL9QB8iA+MH2XZVyX+PsW/I/II3N Kn/w== 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=lO2slUDqP5dEH0jrdnu9kGklLHUR8+rQ0YUd8tB5kN1oxp4ZBHyAFD0n82hMWHtrIm Bp8lWLxmtYBhD07VY9AWYGTBFvCQd2dh6qOCWgOCDbbM7vqkt8GtZblA97jS595Qn/vy IjVCA5INkqKwi9fXXmEtJwEaKOYGFSYa1UF/Cqkwgv2JDO3OkFb7vfEUwKBu0lPkm5NG qUGJAyXN9l4QqjNJ1ED3xa4uc4lszmis1m1xuLFA+3fE4gSNWDNGW5C+GHad+dYnLfmc BnA9XvyKA5Me0NXriWk+fZRCOITa3aIsEgBEwFoD7VPWHz9zt8BocezM+tRACF5cEi3Q dz+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vPFphUo3; 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 g31si813582eda.325.2019.10.24.09.38.42; Thu, 24 Oct 2019 09:38: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=vPFphUo3; 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 S2503514AbfJXQik (ORCPT + 26 others); Thu, 24 Oct 2019 12:38:40 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:55657 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503426AbfJXQik (ORCPT ); Thu, 24 Oct 2019 12:38:40 -0400 Received: by mail-wm1-f65.google.com with SMTP id g24so3569651wmh.5 for ; Thu, 24 Oct 2019 09:38:38 -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=vPFphUo33Onh8HRK4E07pTzJ1f7NIAzAGVk483hJ9mrqwhKfpeM412ZrC+Mtnwzjp0 DT1qMsJ1/gCPq/F/1t4EqBTeVlCle5hjmdv+3EVPmZqvcSyOISZhN7XQp+GCXC6OBtuO J7eCaraw0d5fPtceFvVKfhirGWtc0Vpt1Y1gYBnNRe9ANPznLbQT7maKwMwOUxYQWAZu jexVQdSBRqBwtoNmWVaI816+ONrnsa1y6KWin9KEM0kUlFKJrjEtgNJlwaMBQKrnLylh M5tKLQIYz2aipnWQ9VGhgsLOmEfw2HuI9knyh2cHeVQy/RnXX32xk1Y8NUkbXHDcSPjL +b6A== 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=UEsruUxgwwP6yOpheaowsx0AuMcWrzdMEB8CADS+ieCiG5WeFxbUBJPMKmGjQm1+kJ /CSrqNb00fuRzbPRghIhrsXvZFgZnLEDFsyHiJx2STeXCiIiPPDtTiyjDSQAP/Zh6BHJ YR75KqeD4W6VLAfdsMlJS47/0JPdaUAdTn7iqf8ILcZVwj7f8ANhNEY9N91DCTVmQ0Xe xAoxZUP+oK4urRuj2Ofd7I0JxvNGgJIxZzrmqSItppOoe8Ok+X/crruXTngPgG4XaJCf 3YIkCsCu9CGG/WG7DoM8584FQaohkPuODniz8xKmpTTQSj2IlF5BkHknLiGZIMVhMPk/ /v6A== X-Gm-Message-State: APjAAAXsBP21BAzuTgpYEImFwnAyln/42GANnyooTBOQSuILq1oqxXfk fbY0HdLmyEWINBlST8S86NG48g== X-Received: by 2002:a7b:c959:: with SMTP id i25mr6065618wml.26.1571935117250; Thu, 24 Oct 2019 09:38:37 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:36 -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 v3 01/10] mfd: cs5535-mfd: Use PLATFORM_DEVID_* defines and tidy error message Date: Thu, 24 Oct 2019 17:38:23 +0100 Message-Id: <20191024163832.31326-2-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 Thu Oct 24 16:38:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177550 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2401088ocf; Thu, 24 Oct 2019 09:39:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqw8H3NZEQ+35VvYN/SPAM+zPSDIoQsx0bkcG2BUBp1i9pIaURfOjJL/1SES36zTb5E6SXcf X-Received: by 2002:a50:b685:: with SMTP id d5mr22651033ede.276.1571935177730; Thu, 24 Oct 2019 09:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935177; cv=none; d=google.com; s=arc-20160816; b=CtzGWzhjiRa86hqLRnqd994cdvw7ODrr75sVacAtYOeLvrZpNEpkoGO834Gw/00suK Vh2R6FXHRqaIFyT+jNAy1nMv1u7r5BHtrdvbQZEzRofAkYSORCFir7HGWqvUyf59ToLP AsB822KA/g9MkrQmMefgLc25zr7ClZzgeZ/zk/ZInqqBvXJc4umri2QK2vcIURCK0Gxj g0XMzXCHVC0j5boRoZe5PO2TeDHi+XDeDSMJiu70Tcac1qtAvJ8H6BWVoFTJmDGGKcol jwW7WiPwu+5/RHSpLPBB4jnnYJAvtt4N2HwtWGgs2e5RicEN/TDvsnJCPNf1OrJYBHeg p+og== 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=UL330JCxNCb1QfPA7XEdnee8d8sanDm58UEp+DpPD5E=; b=Qabyf71rQOZpJmvWGkfnlQOspxYWuKf+rMtH6shxsEKtHnLMBLkXBNt9+sjl1uiHfQ w+Q4oRcJcJRFeOS4BBl+OrDAbW30iaFGRFM9R+0L+NolwQ4tA/7gFBoeBPgClmIJak9p UzQ1KTtsdFSF/nu/ajwSI9BXPaXIoSnoKeQwlG1Mqo/OlPFDRGjplF8BVbYvHdwVAfCc wpe2D8w5akKvCKghqRJRjIb8MNJzUXBswbb787J4EFmFx0cxavLYini3bd/XYY4r8Kb2 YTVfNx5eZU9hIrsWB3NT0KitnC/mMWawoiXQXcdpYMn0VivSkXpuKS/5/rITUs+SwYn1 vtiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AO2viM8R; 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 t30si2333460edt.330.2019.10.24.09.39.37; Thu, 24 Oct 2019 09:39: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=AO2viM8R; 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 S2503696AbfJXQje (ORCPT + 26 others); Thu, 24 Oct 2019 12:39:34 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34270 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503504AbfJXQil (ORCPT ); Thu, 24 Oct 2019 12:38:41 -0400 Received: by mail-wr1-f65.google.com with SMTP id t16so21708960wrr.1 for ; Thu, 24 Oct 2019 09:38:39 -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=UL330JCxNCb1QfPA7XEdnee8d8sanDm58UEp+DpPD5E=; b=AO2viM8RfA1DxiniDHFsPnX7EJHu7id0/Nbauz4pHVAcEh/Vqn3h1cCsIRCAaGNIJr ZjlMabMeGfI++dacJ1ty4Ouq/jr7hOu1XAeoUkC1u+G903TpW9UwEjkRM1uCUUrcLVxI H/H643bgLQqGEWNJw5wEUgSR2bEqy2cfVXnngqm+AfFt0J2WpsMNXHexR2K3WYED4KND 5mSLuNIQ72aRBZgvd7e+0KcCpu5+ZxUSH+089gVL4hDpasT4MWDHRnUdhJFbpRUu6rim ZFOwtDQ0W393tuxnG/lfjtS+iV+0GJXV74Y3KSZgyVIRWQsZLwLeBhH/kvS3Dlr7XQ3g bKEA== 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=UL330JCxNCb1QfPA7XEdnee8d8sanDm58UEp+DpPD5E=; b=iFJHcPB1mFZe+tZNgQhDpnTfcDVPoamkbqL4OaUWphLpcT2HbqLtyUc0753//vD8rD w2jytXwdCw+x9zz2qUExJaofl8VfoOetQ4TRHLOG4Z+qxTHoARr9VlAhzH2GrsjjK9M1 hFPvqp08epsqtphHVl0mLqMvI5ZweuZ/ZLdWqeEydaqbW4nbnmBcAzTq777tSU8JAeFK FqGXmQporkrn4VCq+Vk4KgBUECXoE5Q1vgl9vT/INDPVprSxjmGepSU2zOgvPCr5q0Yx 9d/WNluXUO0crIQ0J0hruAU//cnYWr/8bnt6DVc5ohWth1uEjckoo8uadKpeiCT8X6YL uwaA== X-Gm-Message-State: APjAAAW6n8A4M7iTGbd7DjTKaeHbinbGzgesgYdILzMmSzY0XximMviu LNDIfuQoOYXrjBzutjZHpb05LA== X-Received: by 2002:adf:da42:: with SMTP id r2mr4493849wrl.383.1571935118290; Thu, 24 Oct 2019 09:38:38 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:37 -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 v3 02/10] mfd: cs5535-mfd: Remove mfd_cell->id hack Date: Thu, 24 Oct 2019 17:38:24 +0100 Message-Id: <20191024163832.31326-3-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 --- drivers/mfd/cs5535-mfd.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson 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 Thu Oct 24 16:38:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177542 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2399992ocf; Thu, 24 Oct 2019 09:38:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaK10GrBSYWljYCwss+hWs7L/xBcEujshQQDXaOVDSdeHEZlBIUbsaDhXa2P9E73LAVx66 X-Received: by 2002:a05:6402:3072:: with SMTP id bs18mr25958414edb.120.1571935128004; Thu, 24 Oct 2019 09:38:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935127; cv=none; d=google.com; s=arc-20160816; b=iLsbssxboQ3BYG/Y4Wkk8jxACJg/Y28BOSvaTeFOtbDmpsXxs8/66dcAQ3bxymhspF UXlhpKHHC8qoIezefztuidF2hXWtyg1IiiclFzFO3HJU7gkemWKXMRnuMykGsEYszGOD vomSNkWneDByBdddGz4vHgtYM440HyoI16iH9+KeWY+tEuzt5HbMW5ebqZOkf3L9q6im g/ke2xP8WknvCw85JD1Zp4J0A1vXXlQQzOtb4h8f7e3ppYiaU25W8ZLba+kSU85FjpWX TzTjOU+6cLK0k3uz5xX1FyidrZSqWT5JnfWbpw+Cj1vGP4vFVT94AWk8rIMk9VEnUgTP VDuQ== 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=QdHIheq0u1kbfETofjh9zy8pkEBm58YeSTndJs2NHac=; b=Tn+QUNpB/PaNteH8gnPKv47/uI2A1O7nNYWwfPJ8rJPpRaPYSW4jjzZ+f0mJn/oBcN Ua5ICy30K6tof3HvDwFi53NHlF60ndINg4a3mYH2Rhk+2n6kGFpnjPmV9WSlNUXJ3Cxv qdz2eryqLgmIh0DGgTfFZ9HrtnZar12uXZlrX70bAeTHyly3cXq/LuLD36y6cQaQpsgL lmE/0VjMaW0X/l/BqcBHq16Px0Cky8UT1VGbFoHLUt7QUCO3iBebA2tnMOAcJk2H4cDR Gf7hR9/t+lvYs8s2yPC5ZQoToa1pu0UYfLosUMhZJjfAnn4fCgqvPzBGoDq90IAAVXkw nvYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gPwrn6NP; 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 jo12si4186058ejb.176.2019.10.24.09.38.47; Thu, 24 Oct 2019 09:38:47 -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=gPwrn6NP; 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 S2503527AbfJXQin (ORCPT + 26 others); Thu, 24 Oct 2019 12:38:43 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44226 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503503AbfJXQil (ORCPT ); Thu, 24 Oct 2019 12:38:41 -0400 Received: by mail-wr1-f68.google.com with SMTP id z11so3461390wro.11 for ; Thu, 24 Oct 2019 09:38:40 -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=QdHIheq0u1kbfETofjh9zy8pkEBm58YeSTndJs2NHac=; b=gPwrn6NPz7e9qabl6w9R3rqJrhVP14D5VEoM/nG38JSXosj+EzFKlTPlVNYElFho00 +o+M2rHC0YjYffk6XVRDD8OSdWVwqxIOndJ67G98SIzgVGfeyu2GtRUJFmD/WG6dTihy 1TN9flRSC9i7K1ODhHNV5mHaS7EfS9ZS7dluqdJNoUNzUatqHVKaSg2272m4QJQv9ZET Yat6gdQYo4VoX02nxBEIbJBiFvNigZs/epeRYtuOw5uqzGc5QFRr639xcuDCcKg7YKDZ tEBy/uFvDYMKF2GfDzfZ17TxIKWKBh1DcbZBNXHAlzAEar7zo8EHVVFXUKDoS5K4oPzC ygHg== 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=QdHIheq0u1kbfETofjh9zy8pkEBm58YeSTndJs2NHac=; b=EfxIjxp9x8MmLYf6a/N4p0c4W+4WAYS0mTz0gVF5SAgXCChRgoKPNC+b3aTOoSaFZR Ye13m00iemnJ8pBq9Rg0b1HLMUFPxR6kJnLLCU0vHjjvr5MHbtXb3YTyQ3To8LoaHhDX m9Tnjr1Qgyi0JUYDbD85QKnFSv9qzSXOme4pZZNnTM5MoAs9nvQQJGrqP+N7Kc83KMsR 70xSbujgovuUbZgpWAcl2CQmX2dsGS4CSoWs2k+vHbU12lxRJK6srbtZjitlQxLBl5du +KTHpRVJN9g7+duIIiAIqrNoRbfeNLU/1b0lGwIye14YmRANf9z+AKrX6yHeeUgZ1DEC 1XRA== X-Gm-Message-State: APjAAAWQXjIZDrCZza1WdkhM/2WLDF/wejdlX/DqKQQ+pDkmH50av8Rh VFpksmrEJOS/bDDMfxh0u3VeJg== X-Received: by 2002:adf:f04e:: with SMTP id t14mr4491900wro.106.1571935119378; Thu, 24 Oct 2019 09:38:39 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:38 -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 v3 03/10] mfd: cs5535-mfd: Request shared IO regions centrally Date: Thu, 24 Oct 2019 17:38:25 +0100 Message-Id: <20191024163832.31326-4-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 | 71 +++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 41 deletions(-) -- 2.17.1 diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index b35f1efa01f6..27fa8fa1ec9b 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,8 @@ static int cs5535_mfd_probe(struct pci_dev *pdev, static void cs5535_mfd_remove(struct pci_dev *pdev) { mfd_remove_devices(&pdev->dev); + pci_release_region(pdev, ACPI_BAR); + pci_release_region(pdev, PMS_BAR); pci_disable_device(pdev); } From patchwork Thu Oct 24 16:38:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177548 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2400855ocf; Thu, 24 Oct 2019 09:39:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHJUBqBEcA+YApFT319RUj4bznUtbxyJFfo0aPBKqOOKQX8HLYb8Uhxo0ueUW5himkWsW8 X-Received: by 2002:aa7:cd68:: with SMTP id ca8mr22209229edb.58.1571935167001; Thu, 24 Oct 2019 09:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935166; cv=none; d=google.com; s=arc-20160816; b=jV0n2pmfKltpbv7BW2YCX3tOmDELg+rBcw+xM+cF9HQQBJFYSmyW/OBFMvPmjzAv6b Agodg47AL69/xbN1GkrVofl9rr2Xo9nt2+OtDQ3g1QsUqTwZgOF2gVqt8fs0i0kKSKbZ emrq+/kLeKXTy4VTbIkJz96DbtoqQirq71HvnMZpoqYJFqgtZQMfbCxOhYESEgS1Vnf8 9naq+4lK6AjtUPJVCisyCQ3I9w1frdsCTHcuReJG2xiz0O3ZyvceLmy0gmExi2DdfXGn Dh63X09W4QB089akGzW79+ItWURrIoTRu4WeUDmW06m8QrOUKVnBpWUHt2J6z35xK0yg Tbvg== 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=hp9auP1eDPhHh11Inl/NtM2csOEQVC7OB8vmkOBN3Yo=; b=P666JOX+sOsHK5MyM2GaKeE928iFodJd/IvmpYvTC9wvUCPQmjo0fj9DarssAot8tT QEXLxFu07el2wQxu2tbDyiNWYOaNrV62VEkBd7g3KvZHTuZbJfDU+3+B5EiAIM9Fi9b4 rAptZiT0Hagf2wxNlHJpI9JMlFYkmXAmY7dw6gdy4+L3nhpuLHtP6xZ//H6idiHmcrAG 1vu3PxmPVbo84907HqUqf8jNqi3iRLAGIGG71C3lZRGvEVY0PeV/ietdEIfRML8wF4/f ar5MwCBH92we+PTfkVC9+4npDM/xeydBxtbotzisZUgMaN0bbdD159JB2uKDPAE6s/AW jUWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dEYKAgP8; 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 p5si11155202eja.141.2019.10.24.09.39.26; Thu, 24 Oct 2019 09:39:26 -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=dEYKAgP8; 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 S2503554AbfJXQir (ORCPT + 26 others); Thu, 24 Oct 2019 12:38:47 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:43576 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503523AbfJXQio (ORCPT ); Thu, 24 Oct 2019 12:38:44 -0400 Received: by mail-wr1-f67.google.com with SMTP id c2so21606689wrr.10 for ; Thu, 24 Oct 2019 09:38:41 -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=hp9auP1eDPhHh11Inl/NtM2csOEQVC7OB8vmkOBN3Yo=; b=dEYKAgP8b62ELK3aQy8Sm5kXfcxSfxaAtjT6k+tEy2Fr1SkdaT8Z6Pmgbfx5CXzc14 jTsX9Jkng/DOgrAv0GelNisE3nHQ7yTupEmSIAw/5n4kSTtlYrgx/YLnF8DGyvAslB8P p0BbLyzg/LECSvrUWBrp0j7oW4JkIqArUMeHE28aaAMfMMnvRLn1MfFJ+8lVl8XlSmxk n/TCMCnjjEQPP1XiIBwM5a61rQX3N5AwYfykWqp0MbROF9g2ZoZQBdCr5CjtYKC5eVzL +Es6ogdDihTa1NzCLCbLUQ9BywpWX9XItmuPED0qWoroBUJsMwNdyk6pt70Y5qJYO4hx 31OA== 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=hp9auP1eDPhHh11Inl/NtM2csOEQVC7OB8vmkOBN3Yo=; b=HnT9HhS1+3TIKCbbm+ZZAONQ2wKyDOriG8NHJ+NA6yfYBmusY6Lsa9BmXBzCixT+wE peY2/BT/xmUrC+1om5PpA2jnGdGtvrXy2rIms7NyXcTWzeGc9hMJGsWiT35yJNbozIOE xwqWPEwZjuVRh4yXbrRVaXRD4qfajL3UX5/iBkhWndMUNSr58XLQ4ukX8QNZ9++QEo5p eDVjzOJOXxVI3CWquct+2wDxMeAYMOAWzDEgL3ZCLw3GahzgpxFT610oEg1y9I+VNUHO lJ4AXGlWSSGel6ijPwUrvg7uokuMOAfyClCvl2PQQrxNfxzNwFmpzaEdvT+4byA4yg2+ f1xQ== X-Gm-Message-State: APjAAAV4f/GlqAzy1os/dEKe5f7v2JJ+Ux3j1PwPjf3wHu0AOUWIvTGQ LUTeNtpuUz22RcO1IuesjXR5LQ== X-Received: by 2002:adf:f686:: with SMTP id v6mr5010878wrp.141.1571935120637; Thu, 24 Oct 2019 09:38:40 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:40 -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 v3 04/10] mfd: cs5535-mfd: Register clients using their own dedicated MFD cell entries Date: Thu, 24 Oct 2019 17:38:26 +0100 Message-Id: <20191024163832.31326-5-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index 27fa8fa1ec9b..4c034c9f2303 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 Thu Oct 24 16:38:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177549 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2400947ocf; Thu, 24 Oct 2019 09:39:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYny5Kdl9f88esOjVX9usJDjVuJZnyMqjlahMKQsJGjvJA3DxNFFdVYWa1pQ+qg0LsX1sX X-Received: by 2002:aa7:dcc2:: with SMTP id w2mr15640294edu.92.1571935171255; Thu, 24 Oct 2019 09:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935171; cv=none; d=google.com; s=arc-20160816; b=v6+m2RB+SsqNGp/pbnM6m3NCj+nMeJSH9taC6zROdtUrN43xMh6YGKaPWNONn5JTGM agdL5yYqcQNrtUsAdH7LVZt+MBrXy+jzmtUJMzBcpjpMS0N0ntvLsdDDRrTj524iyhHn K44pdfOYz4c64m7+t8pRGZdMquTJvoJ+Z+wkY7yD+TnmJ6cq0ldIR9eKgh9JhGPQipnf iylT8lpj+VBkTnjw4m/bav7S2Ley7PylG1gN1umzLnUKqj1U+SwYK1tcrkDCtmSFw7KF GeC7q/iRUsMG8yB7/1XRAb4+GA4+FH2ZXpOBx1Tg2o5kbFef+Wcqzra0awI8sLcw04Dk N0LA== 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=e4HNR/0VM5m4e7dMrNKrSD8efxMPd+5rZb481ikFf74=; b=UBl89UnEw0CbTJPYjcw6hmWXzxO3mZwI60bxCZaLB/ADFCKKoY7k1MlzU4DOZhyLcK vqRvXpygHYKhY5xrmTvDRsJvjsqWBztXmiFzcp+RWaohbNlVjX/t65bNaLM+uEz3rqj9 SGNF9g3+JxmwTkN1Pl7T5zdkiekNE9COoWukzZq6QScRcJf4VWUNZ/8P0rEv/8AzUFHx eayNc4c8H07iOH9x67RTM1eFKLzakLPK6hZSeQUr6qyB4Qc95jdfDVX0eE3SqssqqHRC Ph5pITaOppCNBAbep0N5v7W52jGoBD6QmChj2ptWn/1V4FENVFZ6/p/Ewxid6TEkod2s NSEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M7WkmfL0; 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 w21si10640654edd.204.2019.10.24.09.39.30; Thu, 24 Oct 2019 09:39:31 -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=M7WkmfL0; 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 S2503667AbfJXQj2 (ORCPT + 26 others); Thu, 24 Oct 2019 12:39:28 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51960 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503520AbfJXQin (ORCPT ); Thu, 24 Oct 2019 12:38:43 -0400 Received: by mail-wm1-f68.google.com with SMTP id q70so3589954wme.1 for ; Thu, 24 Oct 2019 09:38:42 -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=e4HNR/0VM5m4e7dMrNKrSD8efxMPd+5rZb481ikFf74=; b=M7WkmfL0zrA5DnctlcBxlGdxMtMvI7tb2Et+EcJD17XeKNEcanCAnSlnnFtfrQBuM3 sDhf5LBd626wET1CuSWyl/rNSMkVh7OT3aDCOds4shDrMV1BOqn/YQFAjcw5wHDP541P 1/KOQc4D2Q7cPOFKXNBlEJmLOHeUPfL218/n4FP/xi+GZncaONIbCHbY3wj8Ui4KD2w1 efGgPXWk+q/VIFUq9zoDrdj/MKBbzRWvdbAMOHU8q6g3mk2yO4zDLW0HKVtQslGanI6m yJaTeQurgB38QyJxOF/EQuEb5uHiE/GtD2I2MEEBn+DHfT1q9WyC8IMLjupNUcM8DF8w 2oAg== 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=e4HNR/0VM5m4e7dMrNKrSD8efxMPd+5rZb481ikFf74=; b=ZuHEpBUcryN4uCaO0e36tgjqH0Aew0Nv65WyUqvUggZgWyxOffiN+Gt2/Y1bOsEMMr UuqIHY26h+ytf/F+ncVarq+o+G1DdMlg3C22gKmt1d7mVdFRvIBZujuUeMBdKi9KsQWw IBJ8/14Ixy5Obc0B0c6nQhfA4nMEKUU1/b82ODxELFQtb4yML1GWe2BHBfQPniKl5+sM IMY2VBRr4WoAVv0FgX2yVKc1Rcs+BY8Nser60qD4+R2zXo7VMjv+gZaVklbAJm8IMBkM tZjbCMiDFdn2mgCZZu5tLMQ8JTnOC+8fCLHgVguSJ4QlTtFXWh5SbbmeaRL0pm3w3l+L LjiA== X-Gm-Message-State: APjAAAXACZ68wpe5hBE0UzQI3UWKTBQT09ueeE7/sSOIjUt9KAhtBW0P IVls2KxbMo4lqqE6QO3Gohh6PQ== X-Received: by 2002:a1c:2884:: with SMTP id o126mr6171815wmo.153.1571935121495; Thu, 24 Oct 2019 09:38:41 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:40 -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 v3 05/10] mfd: mfd-core: Remove mfd_clone_cell() Date: Thu, 24 Oct 2019 17:38:27 +0100 Message-Id: <20191024163832.31326-6-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 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 Thu Oct 24 16:38:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177543 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2400122ocf; Thu, 24 Oct 2019 09:38:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/HNBWSzYnS+RbXOejLNqO4gFpGZN5IssVfylxYAOG4Nnyqm6DQz3ET8uo2lJW93w3eRIa X-Received: by 2002:a17:906:49d8:: with SMTP id w24mr38628203ejv.264.1571935133529; Thu, 24 Oct 2019 09:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935133; cv=none; d=google.com; s=arc-20160816; b=iVkGOWv8VEv4g1hzXfnaw6nPDFRt3shGj1zS5apXPY5ddKPdsQy0lcA7d4Sd64Gpph cs5/YyD9VkvTuIhHwWPAmGf25TIBa/PgTZieXci6NtfvXD//tOxlnObd3hq9YIvMGnbZ 0rnvoWF8lXc/0+0rr7u8sJJAhAuJ0zcjxL8mJlof6Nx8UZiiTzBWZlxSyBuOE9x4UY9a fi4uv6Jh1aGfObHt1biP8x+G3dRrHytNbI+v4YV2koy2fkhmx894hH2YOK9EO/ex5cYh GgqpCBO/+Z+5p6vWUz4BvDRBhLtboXSikKWSx8n+MjonQyuYnQPVx5GMt/C6kzCV35tc Uchg== 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=J8DxW1d6v2NWJpBGtpmglXzzbNqCWfH+E3Y1OAoSPDQ=; b=QlWD7FJ24QjdsE9yuw1C48a/OAJoYsUDjI+npGpgJ1IEKZdO1v6mUDgcmKHbSdJgho XJcC5WgBUbmVsUbdtuj+zVwct8H2mJcsMyYOlibsLE2rGhdDFe0s4UYA3gReuqs9VdSr nrp+30JKHoDm9Wu/fayidJp8pGTeYzopxKl1ENYZfTMU3Gwm3jTPtkxxkg7luizXOMUb z/w/MhNShBA68r1590qw472288MvF3zgjDrhIQcFtCjoXJ11r86kD4m+pjBWVCxNh/gZ aE+7+nxNEjuduG7NV4gpub3nxAknyWmn6Cf4ny1xai0E4PhsLDGdtByn7aSt0gJ3eaB9 mtZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TocT4wWJ; 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 hk1si15321470ejb.408.2019.10.24.09.38.53; Thu, 24 Oct 2019 09:38: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=TocT4wWJ; 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 S2503565AbfJXQit (ORCPT + 26 others); Thu, 24 Oct 2019 12:38:49 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41382 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503532AbfJXQip (ORCPT ); Thu, 24 Oct 2019 12:38:45 -0400 Received: by mail-wr1-f66.google.com with SMTP id p4so26845255wrm.8 for ; Thu, 24 Oct 2019 09:38:43 -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=J8DxW1d6v2NWJpBGtpmglXzzbNqCWfH+E3Y1OAoSPDQ=; b=TocT4wWJl8/oyox28PzGdGFVTCR25Etd7BhP7Qc2cT5lzmEIZQi4tVOoNnf+I+jzVG jH7I9TaqB1wIT4XzmJhJOBEWcNaJ5ICg+n0N50/AVxig+aa7g/rFuKqHScLtkHqD1DAp eh/o1FgmMvGXskWwY+tBnjWvoGtX5TFg3g4wy3Nm/0yL0A2lDLBM7gWPHzm7PYmnZEeB e/QOnIvS51dRheVYG+4wU+2vpucvGzRotxn7/Ub5aur/FiB+/VYXGyqTEAV2Gql4ncro faX5qcVVEkPX+IqaJDgtdfJVRys2rkt+pKna51QOy+7bQEu5rfElCk68o3c1diDOkQen hv1g== 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=J8DxW1d6v2NWJpBGtpmglXzzbNqCWfH+E3Y1OAoSPDQ=; b=d4hbNYkApd7XQMRxEhFl5ES4gf23cMaKQSyQBdXyyUE9dbMgfBL4m2fRiXf5HgAJCC DfQkWW2umsSc4hN89RaCav9+SueFWb+g0fAeI+21s5R7efGooN38lSkvljSbDNoNwLPX u6Re5cZ07Nd8LnmwCKf2svHULoVYrdx/AQfcuSfZckic4o0HbLSotvhjUDHNS+dzaZBj jsuJrcrbX1NvSMEWebOKaeqI4kxFFz8UciQt8FhjR6ay6T0mYhAcC6TMXQUHXWAV0yup zOifkUNXz4uoxkbVaN98L7WG8v6RdqJazkTXSggu565jj2V65AIgbfWMWSPrg4nIAWD4 aDMg== X-Gm-Message-State: APjAAAU8vEl/kwrS6qlL/jPQ1ihQqG6WYGu9l+Va49le8a+Rsi80SaAa YHdCl+qON5MO2OBy5CNZDxgqxA== X-Received: by 2002:adf:8103:: with SMTP id 3mr5023528wrm.194.1571935122686; Thu, 24 Oct 2019 09:38:42 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:41 -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 v3 06/10] x86: olpc-xo1-pm: Remove invocation of MFD's .enable()/.disable() call-backs Date: Thu, 24 Oct 2019 17:38:28 +0100 Message-Id: <20191024163832.31326-7-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 | 8 -------- 1 file changed, 8 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson 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 Thu Oct 24 16:38:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177544 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2400138ocf; Thu, 24 Oct 2019 09:38:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxhFDwmNVHm9WuCFOb7CpUNU2c1ZgqEVLVTI9U/BgoIcrX/57DbUIL8ZlNfYdvvl9RmhRy X-Received: by 2002:a17:906:1f8b:: with SMTP id t11mr13895987ejr.191.1571935133974; Thu, 24 Oct 2019 09:38:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935133; cv=none; d=google.com; s=arc-20160816; b=a1GzpfEOhUDgZ76TUFO05IjKsytZjeZq2MDQ7VsxDfXwbNTbrgnZjz7xxPxIAwHslU MUeM9E4KRnCVusWfIhm6795ZU1wf5jvnGZSseswItQ1loC5FkkTHBUwmyiG59qTj7EMB AeTP8GFZMXO/xNl1j7p+Z3brq7TeMvSoI9NtoDUYC49HwE1S02DZeuyaCT3u7gsJNHbm GJUg/4tFfdqdmtGtSHr6+23Bfw8SltmkmQYpysfV9kCYsUINPnS5+w6VJTZ6Z26JX+n3 wpBZC3vztmEA7wVT11GKZee8VMbFD1AP1WZORaDJtQPjlDHvm0xPuBarkP2HgcxFR9VB SGUw== 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=Y4M/TuR9ElWDWsgab2CwXLXvo0XVpR3zUX6nx046dNY=; b=wXbs1O6hqUfhWGppi83gAgc5zwdGxqcqGyMN7Lnw5jLHqvztSdFj7Zj+wK0V56dSyY 0uypGb5p3y0BbtjgLGm9RLAPWXNYDsDlIYz/dV9Cyj9JpF4mEb+d+zZb7UahvdR7jYUn gQQZRUrs3b1tcplx9HqX2uYW11sYw0+wSjht6OLc6ov/kCglnB33pmjxw1vKEc8cyTk9 R7EvWbWssZts/9Wkqcl9kpSB9JzoFrSnc0DaGBAKIUMR+b07/VRvIYWuQwN3/2sIDlze B+xefacsWv3fKzhR7Ga1RkAWM6gntLKRVpuBmPFhi2eDh05r74tliD9TwyNZdLVqN9Nt F3Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iFgTncfo; 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 hk1si15321470ejb.408.2019.10.24.09.38.53; Thu, 24 Oct 2019 09:38: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=iFgTncfo; 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 S2503575AbfJXQiu (ORCPT + 26 others); Thu, 24 Oct 2019 12:38:50 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:33597 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503537AbfJXQip (ORCPT ); Thu, 24 Oct 2019 12:38:45 -0400 Received: by mail-wm1-f66.google.com with SMTP id 6so2385268wmf.0 for ; Thu, 24 Oct 2019 09:38:44 -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=Y4M/TuR9ElWDWsgab2CwXLXvo0XVpR3zUX6nx046dNY=; b=iFgTncfo27OyY3xOrjVf8k+LrQj/b3xCRYWuPYLMMo5ZBf6rQyO+w4OQN+tMw+qOb8 PU/JI8owfgoVR8WZdCHfhQykvjBV7dSBMopw/8M8qWvolQzu0JP/iCuPwpVmK4ZXMMNx 6rpHxMtmQGBEKg6By4WPJsLUgEwX95klixjUL2NWyK3JS17vlPYsCntul6yu4PvaKzVK 1Ea79lATIqchM99hH4HVvRPqSwRUVxm9CkiO+n2uYIGICjFuOxhL1T0nQ5WKqpgSlSDN 2i830iOga6S8ecjkM/isy9KN4zRSak1bEDGy/KVXxdytiyMJxx4SCpfrQyeXNDBDXg4j 5I8Q== 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=Y4M/TuR9ElWDWsgab2CwXLXvo0XVpR3zUX6nx046dNY=; b=imVtsc60cdZkdt9HyTSqxOXrKw6NfpwbCjuhbWxpk/81aKqk85P8nHy28ts85/ctFV 1ZRFlCX/4WLLx7sYslZWpTrC+/k7yoce5aV4NaoboZwSWplnDFLucjnltdGgXTRitnnS n4cEsUkOeg3uqBFKPrK3eDZ0fune7aticNpp32D1memcIQb6ODQN0img6PqISDD23cIl yKWqPw8a1a+4WnuvzuHRL/pFvmDfpQzEhdYzW6SVYl3yYmDM+aTekoRrL3n3JfxDdmYE Tmb3gzcWXAtvK8H8QPtPF59JGvyeqFS3VdNb8AKBrPrnkIhDPuoUOJvwVGEGnEKtfbs/ KkPw== X-Gm-Message-State: APjAAAUUvZDBlOtVjzmcloWKhIxo71S9XPkfQPzjafGEArDmGMwiIZ/0 YbZxyGdfaqnDDVhkzOjX5bg3qw== X-Received: by 2002:a7b:cc6a:: with SMTP id n10mr5998222wmj.94.1571935123733; Thu, 24 Oct 2019 09:38:43 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:43 -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 v3 07/10] x86: olpc-xo1-sci: Remove invocation of MFD's .enable()/.disable() call-backs Date: Thu, 24 Oct 2019 17:38:29 +0100 Message-Id: <20191024163832.31326-8-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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-sci.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.17.1 Reviewed-by: Daniel Thompson 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 Thu Oct 24 16:38:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177546 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2400292ocf; Thu, 24 Oct 2019 09:39:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjkD75X+uqlRn37Kga2XH0P1lqQjwJkL8QpSdatX0tvDdIoHezBkiFB080t7oZhbLh3Y+O X-Received: by 2002:aa7:cb5a:: with SMTP id w26mr44673578edt.188.1571935141178; Thu, 24 Oct 2019 09:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935141; cv=none; d=google.com; s=arc-20160816; b=aNkRy1yC71f2sWuYZ8QaTTzvsVnrQsR/WXYksRZQ/FQRCIvWc5IhNlL+Ut9AxGSRqP rmdmEtelW4hRWpeQcrw+Mgyz/TUYEi7jD0sNUc1VcJS3DZrxhnyLY82JuYxbDI+lPirl iH1Ir+ixK3gzazgsCoWExHxxzyuJFrTuYNQXqztwFfIK12AxLbRlfZB/26mv16NDQ20I 3n2a9Ge65BFE8YwdTO38GToRq+gfbZlJsoebHttJPqwARQ0kr/3A6RtWtpF76Qpgy+o8 MizpFOq08VfwAlx87jgHfiY2ikzSwQTXyxEjCVENjK4pwBjhoObXVP03Beg3+FbpnvOm 95fg== 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=+Uje5yZA2ldJsbsoiBPp+JyZjTmn5fr8PAwcjGY2GnI=; b=TbjO1o6BZfa8u27QaeqNa0CpG7qDeXllsup1Vl4OlbAlBhFB2OmynpYP+GVIKgTq0B 4grfJIqhcvnN+t5Ni64n/vLlizG7Cx9vwtDSpDniS10a3oARJCXjSQYmL8mjN+/rAQFq Nm0L3c6VzRlexS71Qfhz3GHbmU07gxLC4lwiI2cAas4ItrdLPSPGyk+qrcMUX7OCHYrs Ye0n7i608zrFsFJhxGMKi4+qYtvDzQYs0tZkvQCDWLuzjqgH5FikH0XwKoBjt62Mc345 6nDmmkiYKXzLk18uGKHsWzs5ePDThLtbuBfFmsgovNnXqqVePPxyJDf8hLL/GVXyoBT6 JwVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DQl9V900; 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 d36si5281599ede.44.2019.10.24.09.39.00; Thu, 24 Oct 2019 09:39:01 -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=DQl9V900; 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 S2503585AbfJXQiw (ORCPT + 26 others); Thu, 24 Oct 2019 12:38:52 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38680 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503545AbfJXQir (ORCPT ); Thu, 24 Oct 2019 12:38:47 -0400 Received: by mail-wm1-f65.google.com with SMTP id 3so3254029wmi.3 for ; Thu, 24 Oct 2019 09:38:45 -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=+Uje5yZA2ldJsbsoiBPp+JyZjTmn5fr8PAwcjGY2GnI=; b=DQl9V900fqGUpTL6GCaKfkeZ3gpfIHFqAKSX3ufvAjrIcUCC99G8QrABRgrFAHr84f zXLGkBQbvxYo558DCuJqQRDDXaj2qphtEatUBS+Lk2L/kgUEZOlNLKkQr/2VGOUirh4E 6jKdZxmOXPYIkjq+XUBdV+4Kw/ot1PyjPtVGHPHjzWvr5e5pNz9JmDdPSIPFVB09IPWO J99BmaTltlCpMUovCATgjqDRfUheM9tsvnCGce4Ysz+isq5zOjxTekh7k4kElKxW1h0I wSMBV1bRCLq9eaApiDlolzZZeA1p6It53pyezLs2vAm0LSkxnBL7yVJGV/ov+1Xf6Njw Chtw== 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=+Uje5yZA2ldJsbsoiBPp+JyZjTmn5fr8PAwcjGY2GnI=; b=gjkuulNg03UzZMx//iRvHYESdwVaMwsNbQZOPbY2gEnU0WbO8dsF4g8zxv68kCkTsk 8gSLOlpdXzRolJ0Ppt5YPyq4LTveev3IWBbQuwmmbIZmmf9XdB8BAkYWo1WZaqsVycn1 RZU9/vKUOVkNkjdhPcL9R2m4NTz3XJg7xQzC/zdNtgAOV2rHvSVMTaIgGKWNrZePtPYY LQ/hp055GVNLfM1XbkVpCeJWCR47RbA0F2sd4zcoaK4bCjPCYR5exIxpHJf6i5sSzJbJ II5pGn4xr4MkagZ3faum7aL+5CNwYmaIOcvrJBlbeQSZu6tdgUgxD+B0R7WtyCdeQkFu EeEg== X-Gm-Message-State: APjAAAXyJnJ7YNLBQ67SFlqydtQK3TeqKrFP6j3iqSyEhC96f60diIdb ufeD+u4XvL4l6IMLFZ3BiHTXUB3h8b8= X-Received: by 2002:a05:600c:143:: with SMTP id w3mr786098wmm.132.1571935124805; Thu, 24 Oct 2019 09:38:44 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:44 -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 v3 08/10] mfd: mfd-core: Protect against NULL call-back function pointer Date: Thu, 24 Oct 2019 17:38:30 +0100 Message-Id: <20191024163832.31326-9-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 --- 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 8126665bb2d8..e38e411ca775 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 Thu Oct 24 16:38:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177545 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2400222ocf; Thu, 24 Oct 2019 09:38:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzQOfGimUfk6qmOG2J2HqEw2bX+KmTuLhiUEHpJ9R2jzCbcb1sxl3GUGEp1hD4KPBOKN86F X-Received: by 2002:a50:eb42:: with SMTP id z2mr44234990edp.291.1571935138059; Thu, 24 Oct 2019 09:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935138; cv=none; d=google.com; s=arc-20160816; b=Y9VxfYVpMzyxZZhzr8TnyIAD07QLHphky7pd40AFlu639VYw05ixURTdoV9ki75YAJ RBFfhm11i54nxS7hVrq4qGQ4+tsDL+/3vDAQKw3qekcOP01Rl39+NRANBwzlMxuRWrXh t2eEVcGzjwnjdWZVO6ik5RK7dxumYFcEVitRW6hujlxayXALARPNNBJX7mgm4547gdli IoK/9OK9ocD/Hws/zq7dC3ZYS6++TMs3TwLWMk+gmU8y7nbmd0SSYcHjDs4ouaoquPJU EPkfILNsHpgQDrznhOkpu4/CNmOdU+TSrhfqsiBxRuw+n9A2B5mvWGx7MBn7yKe+eQwU dSbA== 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=upqfwlKhs7k/eSPsq9hKFEHUtdjIYjuhddMxgSfLZuw=; b=vf9A57kU0qJEm/k9vxK1wmBeaemH3NUvi8F8oKLMVVuHC/LmybCEZscL+Qc/HZ8V9Q o7AcImlqnVj5e6lomYxLjlTMDRlMEDmEnsFfoZUacwYJIknOIsjJ9NINNF/nNW7jfX1N 8jrxZwI43OcQCDW4KECqiBCv0D9IGTMe6jZ4qFbfRyBjGWYebpvRYc9C8dX4Bm1Ojjhv 1DU2VlGVEL5XyagQYzM7FnJZWLETINiQcv4iLjQPiShkU31onRUCUFuUOBlIfICW3t7G T1tIIs500MS1KDDxWsq/SKHkwMknI+63CnixFXlO050Yxp34UqO44ThcT1kActnJYKox ppog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YUG57ICb; 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 d36si5281599ede.44.2019.10.24.09.38.57; Thu, 24 Oct 2019 09:38: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=YUG57ICb; 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 S2503604AbfJXQiz (ORCPT + 26 others); Thu, 24 Oct 2019 12:38:55 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:38682 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503547AbfJXQit (ORCPT ); Thu, 24 Oct 2019 12:38:49 -0400 Received: by mail-wm1-f65.google.com with SMTP id 3so3254086wmi.3 for ; Thu, 24 Oct 2019 09:38:46 -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=upqfwlKhs7k/eSPsq9hKFEHUtdjIYjuhddMxgSfLZuw=; b=YUG57ICbMeCHTSax5yfo0FuXvnoLF8kGHiA/buq5WiRaaXKzhaT4hNG7BmqJ0OxYee 5fxtIZKRLVRQuRTdaycwaRVkENweVVq2bD/Uw4OOt6Yv2Ev/G00NWVHRW9Nupo9Ttsfa Q9FVU1MUwg2MjDoHNp+pQ8Xyir6M++uUg4hpoITozf1ll2uvsKKboKHTgDhkMZywcCpk UbtJI5SXHKkGVSOMKSh1cMpYWBBjDYH59Mima2mb4h+QTmaErOYG4L/PT9E2UnGDGacY wC9sjkF1RCfgHUIjGg4AvCeZR6ZG7hIOwoKWjzXGr1qy7rwDNlB2WTfKfVorBtexRT4a UTTw== 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=upqfwlKhs7k/eSPsq9hKFEHUtdjIYjuhddMxgSfLZuw=; b=PWKUkThKH6WJUJMtUY8AOxq0cYj38DbISWUI2pKa7XBrkt3Qkvb389ewEcTaXd+9wK c0vpOCHJH5g6pWhz3mB6F5TqQ2wYFYAjdY7Fl9mHEHmdDXB9gdLOuLGHA5cJl9MRK/in cNsUm80TOVPlawDebtQybc6Nnm1SWkN7HaTTEov95s0cXwG/Y78NLkm9vRkInPxyGtVe NOUu7mrgGo58co5f3kTQSV9fDwq9/fBqhHyxnXbkL81uF1IZGBfNzHXcQ2Bw97qnV3PR rmXSP20fFR73y+NaifkTBOoZ32F3lgIeYNb/ABSsA5/v9rhhOVbUsWJCneFRy3l5O3/k X+Sw== X-Gm-Message-State: APjAAAXJ7olAiSsJxR3nvG6OucrKzbxE06q1JW8zZxy+LCiVBtQlKePN MJHRl2DiVHTrg9i+ijCCl8njwQ== X-Received: by 2002:a05:600c:2295:: with SMTP id 21mr5459482wmf.106.1571935125915; Thu, 24 Oct 2019 09:38:45 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:45 -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 v3 09/10] mfd: mfd-core: Remove usage counting for .{en, dis}able() call-backs Date: Thu, 24 Oct 2019 17:38:31 +0100 Message-Id: <20191024163832.31326-10-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 --- drivers/mfd/mfd-core.c | 57 +++++++--------------------------------- include/linux/mfd/core.h | 2 -- 2 files changed, 9 insertions(+), 50 deletions(-) -- 2.17.1 Reviewed-by: Mark Brown 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 Thu Oct 24 16:38:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 177547 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp2400618ocf; Thu, 24 Oct 2019 09:39:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxs/VnyqqOlcjEXZFesNcOrtcqp1i0h6yqM2CiRvPAZw43bRJTXaPUFzk3AQsNp5LRs2sfP X-Received: by 2002:aa7:c502:: with SMTP id o2mr5533507edq.223.1571935155991; Thu, 24 Oct 2019 09:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571935155; cv=none; d=google.com; s=arc-20160816; b=xpMIedItad/SNW8Xww0NC1LnxWVnQu79Ok31Jv1AmuJG6UvZ+05OuePryr98G8Vc1t R0kmWbTim451T/yDwx2JIjBD+COTGzYiZn6ioLsurx1uKuhdrD+bCvsWB7mZ3FeGN5mV js0HldPRHlPMiDWRO79WAYglUNsqoO5k6XSINUJk/IlI0vCxth9Q8DrlcKhCk3jS0jX+ ALsuEVZM2UuExFTVeyhcdHtzn36hk4TX6RhSebPNBB+jmPxpaiqkbIGQ/SSycwtQHfc3 HQ/Fr/HGkC34/pMub/YYZoZBJiZkh6UqF7N7bhmHHKyreMBrKpNOrc/+rvIGpu/Qpf1a Ct8w== 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=LHOyXu4LqYDTcB2MwV67QciReuGA+gSIbqPrvF1Pvm4=; b=NhFf0xN9PmG0v4V1Vk34wNTi5RhW2JI7flmDdVbVN7CpI4aaH34DT4t00wMp3D4FWG I+HLPb22fEnnd2E2pfJjerA/p6hfNcZZNFleBPU0PlFpFgAte0LUzzaZN3RUL9Ma6TAo mpA1ZjwKCb0Z29ukejjs24rs4/VdFYhNicRy8Skdn/M2hkABRz70oFvXowokdSJVvWNj R74TDdSDOoijZO8K+A7VPgegvDfLeXqDUJ4KxuIl9UEdI6096m/gsTZFhoEBnhP74igO nOaFUqVEJsgO7GW9vY0zn2n06HIqf6G/mUKQHg9W6BDWveQyB9Z/u7tB+rqmV4Iom+bT A3RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=exAyRgPo; 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 cf22si6096432ejb.290.2019.10.24.09.39.15; Thu, 24 Oct 2019 09:39:15 -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=exAyRgPo; 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 S2503628AbfJXQjM (ORCPT + 26 others); Thu, 24 Oct 2019 12:39:12 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35244 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503551AbfJXQis (ORCPT ); Thu, 24 Oct 2019 12:38:48 -0400 Received: by mail-wr1-f66.google.com with SMTP id l10so26413214wrb.2 for ; Thu, 24 Oct 2019 09:38:47 -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=LHOyXu4LqYDTcB2MwV67QciReuGA+gSIbqPrvF1Pvm4=; b=exAyRgPo0tbJRTibAfJNkRf5NqiS7Ggg8h7mHvZ93UuWH2HxFLfuM+W2DRhuQ3qGGe 873Cwjby6hyu8499QtMvCUQtoiPQlnls1+CUQAl+qaV3cPMqI6WRcvL+uk/WNtrf1f3O V63sZiuElS1jIMoYNlFn6Qaif3JuuBTrukVtupm8yy0kK3BYvzaoaayGklWl7Nmj7bfQ MPKHe5ssUy6qZEWe0Lk2q1Zyo8YuhhrVyzXNbOU8foIv9fitdgPO/Cq580RJgByiKLik r4GpUfpfyrc3VEJqT5q86Px1YIobxXVM+oEi/sdSo1Q8HcJpmdMlS+V23XpuIu3ixY4x 9Ywg== 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=LHOyXu4LqYDTcB2MwV67QciReuGA+gSIbqPrvF1Pvm4=; b=Hcz7ZhJiQqGjsFwRwWwRycRx+okwZXcKPeP3biNidPs8iAXNyIPJZgOKQZ5aW4/0JS hFxa33CyTdNvv9Upkv4q0frCTAORlv74os8GHv7oiiMb0OBymnYl/EsBM4AZm7aonZQV RwWdzkneNxKgdZZFelXKgoiZ0NNHQsYE6/C5pPTbwMfXvOC34IfpptP2D8gw7/eqJQRW clQ8K52zBHkTDJ8/WZYsamWr2nABHQlLyXll7liP5TgP5NPU0q5tG8JS3LKloik/k/GG qr8A5BglgfosTMPu0x2lh/NVoRYJhnNGdHvIBnfc43ax9ncN8432J1JfCJDGYruugXYJ aGyw== X-Gm-Message-State: APjAAAVON11DEMHEIZ1LCfG15kInf/EAPzQmF5pm4noPO1yPbVF63H9e 2tdCCUlOxdR8xUwLMcYI+QGHJQ== X-Received: by 2002:adf:e50a:: with SMTP id j10mr4493921wrm.352.1571935126970; Thu, 24 Oct 2019 09:38:46 -0700 (PDT) Received: from localhost.localdomain ([95.149.164.99]) by smtp.gmail.com with ESMTPSA id 6sm3446175wmd.36.2019.10.24.09.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 09:38:46 -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 v3 10/10] mfd: mfd-core: Move pdev->mfd_cell creation back into mfd_add_device() Date: Thu, 24 Oct 2019 17:38:32 +0100 Message-Id: <20191024163832.31326-11-lee.jones@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191024163832.31326-1-lee.jones@linaro.org> References: <20191024163832.31326-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 Reviewed-by: Mark Brown 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;