Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp159068ybx; Fri, 1 Nov 2019 01:06:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeVJIOicyTOdWex+745Mzlmft/yJedb8P7ZwHeRLofuBIqBKrxCV74+B98dwX8hKRq9ja3 X-Received: by 2002:a17:906:3501:: with SMTP id r1mr8075633eja.301.1572595578928; Fri, 01 Nov 2019 01:06:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572595578; cv=none; d=google.com; s=arc-20160816; b=V40Pr/Mo7vEM4tJYa86XD2tVgZ5haDS8wwqqIg0x9XhQOUBByEWnBvZs2B3TKy7iGd 3UAoi9FpLIKtmR29EaugNivj6PD9l4TFsccYXogCmvAk5OkXsD7iP4sgqW29D+oN2v47 Ye6/tqElllhSeiupwFf7VY7BCdoU7vE0ZZi+dDOAUmRvOB42gsIgaSIEJ3uTZmdONN7W YMU2xJuv9I8ROMg2jFwlV3L/tj1i0xD+S9jFY/VoIL7sa8pvPYNKn2+fILLl5ydIz1qp s2Rvb6rh+QKD+hD32DWemhDRzmVhwo6T1mAFbHvQLCyye4F5Jb2pVckaQdL6CD/4fYDv S70A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WwG4RNOHvFkOsKEQAuSUlL4bFdysEsHDNGpaWR/Pat0=; b=tM3+hKeSxbZ/M/0zQnh+1U5IWkrf8v5YO0i8pYHzICgC6B2+wNsSpsR41R56o9/NnS 6WHeQhOPgtFRbV33dyNoolPfIyt/RQXii4QcSPECBfP9ph26azQInaq5w8y4YzYSt1rz 1sY1GRf+iWcUbG55WHFnYqQKUeI6F/2mqs6ZeMFQesRZu2pyJlczipHaeKhx3YBW2Bpq cdEX1b5l5qRidnBFWDH6Hu44ftBrfkQs48TEQ2FkbduuJJMOU8O97F3veIOWu6zvazSp 1zHz2tttsEZTH9509B37/4rtXdgBYDhb1D4EptBSY3Nbe4maRLzpQgJUjGN9T5V90pQz IPQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="S/symlXr"; 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 1si7314409edv.82.2019.11.01.01.05.54; Fri, 01 Nov 2019 01:06:18 -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="S/symlXr"; 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 S1730034AbfKAICE (ORCPT + 99 others); Fri, 1 Nov 2019 04:02:04 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:36822 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726921AbfKAICE (ORCPT ); Fri, 1 Nov 2019 04:02:04 -0400 Received: by mail-wm1-f65.google.com with SMTP id c22so8285109wmd.1 for ; Fri, 01 Nov 2019 01:02:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=WwG4RNOHvFkOsKEQAuSUlL4bFdysEsHDNGpaWR/Pat0=; b=S/symlXrnyXbV1Hv4N/GknnDwdxNxfdAmVeZAKQWJn34mc1nhmrnlQs85nwSBGvkwL YNMZGZ7N5SDuQkQb/7Y6V+470SFCP6zuBobyPpjFUYuHhi6PueWQaPseVM/0KJRYl4Ds OSRSiJZxTu0xp0XE3ITDXvUYdhd/G2eMC6OjgyLR5BgPenPusZfTZw9q7p1z6tjTiT17 2HTp89XVF1SlvEY0u+iMvSXmyFNTyjwRYxCs/Fw4r5pDG3aWT/nsxWIvsq3EhIap8PmK IjfT0GEo9rkv8elPYVLbO22e46RHYghbr0Frz7Zdlbxxh9YXvwIm5Zkd/QPQ/KWbo2u0 a18Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=WwG4RNOHvFkOsKEQAuSUlL4bFdysEsHDNGpaWR/Pat0=; b=ARQ8Ldh9NRmUUBG2l1Y1YfhFyAfEsZIsFhlVZoTy/g/4G4uCNu8StKZvpS+43JCAkF 70mA7wmsQmUa/0J1GouAzlqbb67nMAoA4tKwQe/xw84nOmwm2RpHSE1XsZwQijG/AK06 yZHhbT/yFg+MJLlLK804KDukAGXrfuuGHkwsdxfbqryYSsnoUjtxztnmqIagq62ki+5S ZvkMQ4bOsJ0vrpk/+us6ju1CdNcbQo1Ums4hSp/2AAfxSwf4kUTPMfrrHVNeAgWTSOYs t7xzi0/ZH3lZ0VVJIg1nKn21/eye+vMykYYAnzCR9b8tCwcjFvQXEuJhunV858y6k9mP bQKg== X-Gm-Message-State: APjAAAU7x4iQydiBxQJ9HVd01jkEuBwSMIiu+LaL5q9MTF5kkEv8c4jb HC4iEa2Fqx5ES7NNYNFLAKXuUg== X-Received: by 2002:a05:600c:22cf:: with SMTP id 15mr8235809wmg.148.1572595319436; Fri, 01 Nov 2019 01:01:59 -0700 (PDT) Received: from pine ([185.204.209.109]) by smtp.gmail.com with ESMTPSA id u1sm4977950wrp.56.2019.11.01.01.01.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Nov 2019 01:01:58 -0700 (PDT) Date: Fri, 1 Nov 2019 09:01:53 +0100 From: Daniel Thompson To: Lee Jones Cc: broonie@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, arnd@arndb.de, linus.walleij@linaro.org, baohua@kernel.org, stephan@gerhold.net Subject: Re: [PATCH v4 03/10] mfd: cs5535-mfd: Request shared IO regions centrally Message-ID: <20191101080153.bvws43z2n6gsjnym@pine> References: <20191101074518.26228-1-lee.jones@linaro.org> <20191101074518.26228-4-lee.jones@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191101074518.26228-4-lee.jones@linaro.org> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 01, 2019 at 07:45:11AM +0000, Lee Jones wrote: > 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 Reviewed-by: Daniel Thompson > --- > drivers/mfd/cs5535-mfd.c | 74 ++++++++++++++++++---------------------- > 1 file changed, 33 insertions(+), 41 deletions(-) > > 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); > } > > -- > 2.17.1 >