From patchwork Sat Dec 1 15:41:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152632 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934366ljp; Sat, 1 Dec 2018 07:53:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/VPOu0rfki2kGo/KxiiljoBxnYq63SSz2rRAsgJgvoxSIFbI975OYcPKrrQ5nry3heHCr3Y X-Received: by 2002:a62:8145:: with SMTP id t66mr9742913pfd.55.1543679587509; Sat, 01 Dec 2018 07:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679587; cv=none; d=google.com; s=arc-20160816; b=GKuH+KHNg44S3N86UzpH+mKbidHSuh1L8MHDn3fRibpxotoAs+sZhgkEwUhIEFdclb Gh8o6MNDjvjTu9q9s1ZR0j6C4fklDw5j+kQCaXJ+QSoj8KeksxmfiAIUeN9nqCsTDuQa hnCRmOwXphuh/x3Aw8gkGBimgOt0KmBl9/osNRsnXJ9QGHorkYcd7r0LAj1xdJeYcSRy cyb6otcZzdetcYyW0HH6SW1QFaspFKL/d4PXdA9hNLEid1QRoZMWy9IxqxnDXmZAffJR 0xlM9YSE5VhkGQuWGDq6v5DxOE07/efQlKRvp+3oKiF4o8hD89nD+euzl5dIa+JJeseF jnsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KuQK+AP+PaPYL/ufObO2FE/V1xtOKXFXPeo5PNTs1lY=; b=suZ4ZG3hnwUPOQ3LRWvkw958bk9O6UoScshwdPrqNG6Iwa9fHqL3dbXWQ0cyIsgy8Q 4ETlsznpy5PGxSKm3vNZ/vOCKoSBUqWRijLCe3PgMo/xxlpU1i13Z6Av245c2vtqUaLT 3KjWLQctsJOhskAD2LIiSfftIsnnhdCUOUfweUTK2y+moBzbSXo30Gpcw5otzfpt6CBg 5LN1XdhzL0i0p3+NdGxTyERNVOkLbNrqCxmDlZ4drU86aggwQpVJWBRdyqk1THgu2s57 Ey2DiuIfy4t0YnX/hNUfam4WAhmUODHVOZWb6WKktWen1Wg9s1+R4QdQMqNvZBPvqQvl w43A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jy+uxs7e; 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 v10si8828780plg.82.2018.12.01.07.53.07; Sat, 01 Dec 2018 07:53:07 -0800 (PST) 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=jy+uxs7e; 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 S1727204AbeLBDFx (ORCPT + 32 others); Sat, 1 Dec 2018 22:05:53 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:47052 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbeLBDFx (ORCPT ); Sat, 1 Dec 2018 22:05:53 -0500 Received: by mail-lf1-f65.google.com with SMTP id f23so6180413lfc.13 for ; Sat, 01 Dec 2018 07:53:03 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=KuQK+AP+PaPYL/ufObO2FE/V1xtOKXFXPeo5PNTs1lY=; b=jy+uxs7eTVMvE8JiKgruxMZtERO9vRBBRI5luHO8adGQ3Vq8vqADvUuT3M7TjhaKqo Xh0qcfFvcs1SC7aAB1bWlZoz9mwboFr88O5lEw/HKWE9xli1n3TQ/kSOBGaCFsEPSZ4S Gm2eggOXmba7hf8GMldqEEYWkY+LKl50Vl6qY= 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:mime-version:content-transfer-encoding; bh=KuQK+AP+PaPYL/ufObO2FE/V1xtOKXFXPeo5PNTs1lY=; b=YuUZ//+8xOzgaN9H/9b6QNqNa5v5UdJRx2cOTbc7MVKqXZ0HO6r0j3YsFAiAamcsKT PbPjPHJLfgaytwza4B+50+Lo305zFhn2V49NuksUQ+/hOjpGCrU2l4wNv2HeENsjymSd XleB5OX3b7sdNtbYoASawYyatVvsP3lMFEJKBp3+OnJUS41LeHnWKeV8gF2qMAI+vfsL eP59FVeCipyvJbk1gC0No61OzW3RqtmarEtgcMM4Tgth44LDev9MKR/nkhBOQoBJZPL5 5nVUt1ChmFpl1d/2FlRJK0Kha9tcqVtuuhyDlWTHkz9gri4rhZiyXSWhrrUEjEyYzQP+ Blag== X-Gm-Message-State: AA+aEWZ7n1t6FCbtC8z+9Q1HR0BrJHvDiB5QzBSxL5nfM1/W2yE9rRPD FkffViOJvbnnKM4bSvTX9l5BqQ== X-Received: by 2002:a19:ca51:: with SMTP id h17mr5524716lfj.126.1543679582797; Sat, 01 Dec 2018 07:53:02 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:01 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 01/13 v2] regulator: core: Track dangling GPIO descriptors Date: Sat, 1 Dec 2018 16:41:39 +0100 Message-Id: <20181201154151.14890-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If a GPIO descriptor is passed to the regulator_register() function inside the config->ena_gpiod callers must be sure that once they call this API the regulator core owns that descriptor and will make sure to issue gpiod_put() on it, no matter whether the call is successful or not. For device tree regulators, the regulator core will automatically set up regulator init data from the device tree when registering a regulator by calling regulator_of_get_init_data() which in turn calls down to the regulator driver's .of_parse_cb() callback. This callback (in drivers such as for max77686) may also choose to fill in the config->ena_gpiod field with a GPIO descriptor. Harden the errorpath of regulator_register() to properly gpiod_put() any passed in cfg->ena_gpiod or any gpiod coming from the device tree on any type of error. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch, just numbering v2 to keep it in line with the patch set it came out of. --- drivers/regulator/core.c | 55 ++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 10 deletions(-) -- 2.19.1 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 757619878068..79cb090ff22f 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -4868,21 +4868,33 @@ regulator_register(const struct regulator_desc *regulator_desc, struct regulator_config *config = NULL; static atomic_t regulator_no = ATOMIC_INIT(-1); struct regulator_dev *rdev; + bool dangling_cfg_gpiod = false; + bool dangling_of_gpiod = false; struct device *dev; int ret, i; - if (regulator_desc == NULL || cfg == NULL) + if (cfg == NULL) return ERR_PTR(-EINVAL); + if (cfg->ena_gpiod) + dangling_cfg_gpiod = true; + if (regulator_desc == NULL) { + ret = -EINVAL; + goto rinse; + } dev = cfg->dev; WARN_ON(!dev); - if (regulator_desc->name == NULL || regulator_desc->ops == NULL) - return ERR_PTR(-EINVAL); + if (regulator_desc->name == NULL || regulator_desc->ops == NULL) { + ret = -EINVAL; + goto rinse; + } if (regulator_desc->type != REGULATOR_VOLTAGE && - regulator_desc->type != REGULATOR_CURRENT) - return ERR_PTR(-EINVAL); + regulator_desc->type != REGULATOR_CURRENT) { + ret = -EINVAL; + goto rinse; + } /* Only one of each should be implemented */ WARN_ON(regulator_desc->ops->get_voltage && @@ -4893,16 +4905,20 @@ regulator_register(const struct regulator_desc *regulator_desc, /* If we're using selectors we must implement list_voltage. */ if (regulator_desc->ops->get_voltage_sel && !regulator_desc->ops->list_voltage) { - return ERR_PTR(-EINVAL); + ret = -EINVAL; + goto rinse; } if (regulator_desc->ops->set_voltage_sel && !regulator_desc->ops->list_voltage) { - return ERR_PTR(-EINVAL); + ret = -EINVAL; + goto rinse; } rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL); - if (rdev == NULL) - return ERR_PTR(-ENOMEM); + if (rdev == NULL) { + ret = -ENOMEM; + goto rinse; + } /* * Duplicate the config so the driver could override it after @@ -4911,11 +4927,22 @@ regulator_register(const struct regulator_desc *regulator_desc, config = kmemdup(cfg, sizeof(*cfg), GFP_KERNEL); if (config == NULL) { kfree(rdev); - return ERR_PTR(-ENOMEM); + ret = -ENOMEM; + goto rinse; } init_data = regulator_of_get_init_data(dev, regulator_desc, config, &rdev->dev.of_node); + /* + * We need to keep track of any GPIO descriptor coming from the + * device tree until we have handled it over to the core. If the + * config that was passed in to this function DOES NOT contain + * a descriptor, and the config after this call DOES contain + * a descriptor, we definately got one from parsing the device + * tree. + */ + if (!cfg->ena_gpiod && config->ena_gpiod) + dangling_of_gpiod = true; if (!init_data) { init_data = config->init_data; rdev->dev.of_node = of_node_get(config->of_node); @@ -4954,6 +4981,9 @@ regulator_register(const struct regulator_desc *regulator_desc, config->ena_gpio, ret); goto clean; } + /* The regulator core took over the GPIO descriptor */ + dangling_cfg_gpiod = false; + dangling_of_gpiod = false; } /* register with sysfs */ @@ -5039,8 +5069,13 @@ regulator_register(const struct regulator_desc *regulator_desc, regulator_ena_gpio_free(rdev); mutex_unlock(®ulator_list_mutex); clean: + if (dangling_of_gpiod) + gpiod_put(config->ena_gpiod); kfree(rdev); kfree(config); +rinse: + if (dangling_cfg_gpiod) + gpiod_put(cfg->ena_gpiod); return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(regulator_register); From patchwork Sat Dec 1 15:41:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152633 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934415ljp; Sat, 1 Dec 2018 07:53:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/XdHMA/brANxTe2R6xe4oul2O5B2rf4DNM0LD5EDUhAJVgcvCCqYLAWkcvO03RTau7Bf2RU X-Received: by 2002:a62:6799:: with SMTP id t25mr9645747pfj.139.1543679591114; Sat, 01 Dec 2018 07:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679591; cv=none; d=google.com; s=arc-20160816; b=M7Y1A+bOPuRBN2kdNk3igvd+fRXkyhqg2kpOyV0s0E02UZNXcasON4JRiMCcoNGvN6 6+vOGIolvysQsmRdiUEqmYDkc77VAolwvb5ZmH/TKnikf+tSQs/jAweMVdl9UXklIW7C gEinyTDwPL9cgWpOO43B0fAtzk+ixXdv7rDhSk7vX+A6XtyLVPbwx3MlgFIA+9fwSr8v jBImL/CXSFW0N2fvJ9q5BJ7sTjHZXq55YsXToQaxWfN8TKPvU/rt/Jg413Ka2wIY6AAQ vIuYVo4VxFVF/KiA8y7SwBp0jp0gcQmaQaVnp0RhbJP4zRwibFCD3sdo0dDuqTJJ3VRJ BI+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3iUsZ/16+oDFR/k1SSqoY5Bn/jlRg+zr47SC2D/gEWM=; b=cLJ2ioKPzf6KWHGnAjM6ksmnzNvBo1MRRhbi7lyGK7hFUI3JHtTQ5xxPzxZNv3Fwr0 JJS0PLU595BLADUPCermTAPq0cmG5znECLdGwVJNwe5zl9rsCWcKe3UK8VPhgNYc9JYC necG4MzTQb0QFLYW/6Wi2xWgspSzO4e6EBknATs4TvcduKql6QL9PHveZh6nxcg08g67 UVXkGaetxAIEGDgFwK/+M0hbLw0+EzK42Ym5F0XkSWw6RR19emuZMaThRM4iFA65TW98 rDw4NUIeK71gqpP/lFLs/375zyoO1sAakchIueSrBtjNp+/TXNCB2g8YtoI5XM7iYbgP V7hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=j3DMkc9d; 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 p9si7596622pgc.448.2018.12.01.07.53.10; Sat, 01 Dec 2018 07:53:11 -0800 (PST) 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=j3DMkc9d; 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 S1727225AbeLBDF4 (ORCPT + 32 others); Sat, 1 Dec 2018 22:05:56 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:47056 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbeLBDFz (ORCPT ); Sat, 1 Dec 2018 22:05:55 -0500 Received: by mail-lf1-f68.google.com with SMTP id f23so6180451lfc.13 for ; Sat, 01 Dec 2018 07:53:06 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=3iUsZ/16+oDFR/k1SSqoY5Bn/jlRg+zr47SC2D/gEWM=; b=j3DMkc9ddwMjPqKCKbD7hXOMHd2rlLnPLk6WsLo2IASfy3MDmNSzo4yEfkwl6w9fDO e5H5wiTmvGwZfk634qy9KHznxDvTwiL/1184WnjfTe+o6Xt6e8XJHym+JM7K/6iQuLYk NgePIWkTJ7aV7V6YD0hGP37ah01Qd039ZIWJ8= 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:mime-version:content-transfer-encoding; bh=3iUsZ/16+oDFR/k1SSqoY5Bn/jlRg+zr47SC2D/gEWM=; b=hkgqPTpQQaPONfpgg/4T55p+knB5L/zKfHYd7mOArP2FkahIq0nFKeyX57Bcf2Yq5I HmE+chPeOJwHRFOU2QMweE/07EFtNRoRgA9ukofmk81lU47cjwcMrWsjw8/wHThSGOIT L0hkhsMeAy2RfMrNREHhMeNvepvrL/D+WcFEzMO5ykztYZq/ybTEvMvij8HE5uMRl2oW SBBCj9zH2YTHENkju0NPx17rFwCD6yX+xmbmAQmbLizYiOyM+zpcPYPInKbeuZU/1qny 9kSKFvEaD0me5wjFE1ktpue222oOVxyredFrCnxFxW39qHQfrSf94IKvG0zINVdO0Ibe 08VA== X-Gm-Message-State: AA+aEWZu7fr5BhWlq48W5l8a29qvddMD8axX+MbxtvT5OMTpz19YL85b W3NBT3ur4njdGVgIBytl3qv5eg== X-Received: by 2002:a19:9904:: with SMTP id b4mr5610949lfe.95.1543679585544; Sat, 01 Dec 2018 07:53:05 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:04 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 02/13 v2] regulator: fixed: Let core handle GPIO descriptor Date: Sat, 1 Dec 2018 16:41:40 +0100 Message-Id: <20181201154151.14890-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod_get() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fixes: efdfeb079cc3 ("regulator: fixed: Convert to use GPIO descriptor only") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the conditional gpiod_put() on the errorpath: the regulator core will take care of that once devm_regulator_register() gets called. - Put a comment in the code so maintainers knows not to use managed resources (devm*) --- drivers/regulator/fixed.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.19.1 diff --git a/drivers/regulator/fixed.c b/drivers/regulator/fixed.c index ccc29038f19a..9abdb9130766 100644 --- a/drivers/regulator/fixed.c +++ b/drivers/regulator/fixed.c @@ -183,7 +183,11 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev) */ gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE; - cfg.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, NULL, gflags); + /* + * Do not use devm* here: the regulator core takes over the + * lifecycle management of the GPIO descriptor. + */ + cfg.ena_gpiod = gpiod_get_optional(&pdev->dev, NULL, gflags); if (IS_ERR(cfg.ena_gpiod)) return PTR_ERR(cfg.ena_gpiod); From patchwork Sat Dec 1 15:41:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152634 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934437ljp; Sat, 1 Dec 2018 07:53:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/V1HElcUSk3ZmE2IK8hDft8o3MVqAlYO94BKeSwY7N6D8bhlVQZGjpXu5w9wZpOQiw08UI3 X-Received: by 2002:a63:a611:: with SMTP id t17mr8079832pge.338.1543679593800; Sat, 01 Dec 2018 07:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679593; cv=none; d=google.com; s=arc-20160816; b=apoj5/AuvuiKZBnlMHtBroqM5aLk8WGnKi+6Ex8RXZ4mN0H4xBLjg3Vtv7DQPj8Q6b GcXcJzsu2r/BCxvvV2drg4KbxSjSpryr0UhyOG1c5zyl/hzwojY1KHdM0/vmPIprDPu7 VNHvhxxuWaoKs9yGAf+l0rKY3oKg+gDkoC+LtQX9rEsrYbWnh/PETG1fbgm0tYn9NlIg Kv4agNb2BDn8X2cSABHq7qIca1tHqnTPHK39sWllcZHIAAaRqFc30vQ9XFqRH5FVxQEW 7GSnV8LaMAwoJxIaObeA2vhVv4kNIcRGE2M6k8JP2DTZlnLLIgEMOxZUtb1HWQDXz/FW 8ySg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kw5DmJYSpDmuJznmwAMRHQCtGgWe5nKFfzGdrXYI1X4=; b=re4RtGK5UMDgdaJU7fb8Va+SF86YsRdc608fAhuhxbEplpo+LvgZef4Od/Pd6iwI+g IF1Nx+VSMQk2maTNiT+Ydk8e8PN4OKtBXBTw1rUm8lR2b9JA5hQCt3P8gw8c+zkU/afO fOVb1bUvRgslvoxczkE6FEvJTdWyp99j06IDYbYiaseA/J7E6CUWcRUxgwbWbGd2I4he qFtWOr880zeKhjfT98e/LhuTb4zHRTdO5qNDi+LxlYSxT4EQCu8pRBqryyx1dnnJ21PB jJPHDqQ+AFMtme+h9Z/TX24/wC8B5KxLadamPsXx5Oo5it6FkP/U2w871yiMQmx5C2eT seqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KtUGzzrt; 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 j3si8249538plk.199.2018.12.01.07.53.13; Sat, 01 Dec 2018 07:53:13 -0800 (PST) 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=KtUGzzrt; 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 S1727248AbeLBDF7 (ORCPT + 32 others); Sat, 1 Dec 2018 22:05:59 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:33807 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727050AbeLBDF6 (ORCPT ); Sat, 1 Dec 2018 22:05:58 -0500 Received: by mail-lj1-f196.google.com with SMTP id u6-v6so7649671ljd.1 for ; Sat, 01 Dec 2018 07:53:08 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=kw5DmJYSpDmuJznmwAMRHQCtGgWe5nKFfzGdrXYI1X4=; b=KtUGzzrtlk2DxLtkU0GSvQOAnNzIWPXRRGKfQe2yVbwdXt7ofrw5D7dZ8ce12OaLCS unXZVIEy3vPQ16kqH5pI9yPTK5v/QOf7A0D/cUQQmPmHNSyWQnpzvMT+Mg6n5OHACWKu Mu+sU2Hzi82ZRIhvlvRDcvy6bW5MtXlNd00RA= 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:mime-version:content-transfer-encoding; bh=kw5DmJYSpDmuJznmwAMRHQCtGgWe5nKFfzGdrXYI1X4=; b=KHvq9rfhICsOYHnL1U75pI36oQ55/oxT07883cNxA7trj9/Am69nZCEfB1xz41YsCa CoxLXei9OOc4KoSBz4SrmNNE6nxDf2QTeVw40WKYtqZtNZ2kkMGYx+7HlAC8qgfMcVPY L7wYGF/wU2YAz/FyG9MLusSKz/t7Zq4tYxdH2Pg0Joqay7mzezF8fVpK+y/GY4NEHbv0 51d+E5ldFknBjwMVNvmHgrmEXpCPw1+L+GOa2L8DHOaytVek4Vzm3T9DPbZyW/MqkbBG PUCJ12XjgrnhASQZkxdHh9b5Qco0H1BRH8vor/KsPoh2xTxplWFYkBLIDOO6Eh7zMBAu klBg== X-Gm-Message-State: AA+aEWYa4CNTMs355+4jd8qrYVgWP/ZEqrFyT+9uYHJvu6zqUlDXuLmc y4OhKAKParS9acerRhnLSha1qw== X-Received: by 2002:a2e:6594:: with SMTP id e20-v6mr6836862ljf.123.1543679587802; Sat, 01 Dec 2018 07:53:07 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:06 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 03/13 v2] regulator: lm363x: Let core handle GPIO descriptor Date: Sat, 1 Dec 2018 16:41:41 +0100 Message-Id: <20181201154151.14890-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod_get() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fixes: b2d751b7f69b ("regulator: lm363x: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the gpiod_put() on the errorpath after devm_regulator_register() as this will be handled by the regulator core. - Put a comment in the code so maintainers knows not to use managed resources (devm*) --- drivers/regulator/lm363x-regulator.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.19.1 diff --git a/drivers/regulator/lm363x-regulator.c b/drivers/regulator/lm363x-regulator.c index bbedb08d257b..8c0e8419c43f 100644 --- a/drivers/regulator/lm363x-regulator.c +++ b/drivers/regulator/lm363x-regulator.c @@ -224,13 +224,15 @@ static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, /* * Check LCM_EN1/2_GPIO is configured. * Those pins are used for enabling VPOS/VNEG LDOs. + * Do not use devm* here: the regulator core takes over the + * lifecycle management of the GPIO descriptor. */ switch (id) { case LM3632_LDO_POS: - return devm_gpiod_get_index_optional(dev, "enable", 0, + return gpiod_get_index_optional(dev, "enable", 0, GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); case LM3632_LDO_NEG: - return devm_gpiod_get_index_optional(dev, "enable", 1, + return gpiod_get_index_optional(dev, "enable", 1, GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); default: return NULL; @@ -263,6 +265,8 @@ static int lm363x_regulator_probe(struct platform_device *pdev) LM3632_EXT_EN_MASK, LM3632_EXT_EN_MASK); if (ret) { + if (gpiod) + gpiod_put(gpiod); dev_err(dev, "External pin err: %d\n", ret); return ret; } From patchwork Sat Dec 1 15:41:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152635 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934464ljp; Sat, 1 Dec 2018 07:53:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/UOsHkW4HTQKGf/ZH63abSfKTVmx7EmVBo/Cwxw1yXFBSN5u4Zk+1+/Gc/Nc0shbRwffuxV X-Received: by 2002:a62:5716:: with SMTP id l22mr9962336pfb.16.1543679596053; Sat, 01 Dec 2018 07:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679596; cv=none; d=google.com; s=arc-20160816; b=zI9PIoaa4u9pxb+z+Bg0EmRrwi2lwRKCk84YDpUDTDMphHeiEQ7aNLz4cJDvvQWw6J HEgJLrliX17swzjMnF+AXInx6HnMdsBCUgE1IdC+NI4/6TbvD0/v4JJyLzMLSqXsRXv1 9hh9HuDfBaErcjSErmkuOvnASaHrFO6bJArpTMZOvXQ25OaL1oCOsEM0NFFJGjnsFU2r f04ppIalLCB3Fcvc8MSEUtG4xn0Q9QBhOt/algcHgyi1OZirCkFd/VHhDWXd6qchyNRW nFQT5MOza64NEildNwdWfnD7jBMB+/CVeJ9ENq1EhNiOW9Pkvm7vI1haApeHBcVA+PBE re7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kRRqVVwMz5ixbamRKAl9gUoe/zOElJopLPpSl/n7en4=; b=ce1+E4H7Vl+N+74liHKDX5X79s2wBoM0SDKIVXlPifiX6uibg7yt/26XMUFWY0U6iU M9BusZZvmHUC76mfBU6eXS9sTxdFdNDsaj5btC36kxlUSin6i12+FP3D9zwG9fnxCLgj lne4PchB0uzxkyO4cboxIxzDl+xFDOEDxOTcax7kZLhAVz1U/CAcIQMFHHkrPI3ieB0R P84Zgb1VNBxDzvidtsGuQiEaRaIZjOthg1cT41kupbPyieqn5hYUXQ2L8Nte3Op8T3s8 NJlqopZJlsNVxfZVrqmAKjLxYN/4TrrUAUP2McX8UZTRMRpETf0NG+E59G+ibFR74d1L 51yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JThfbg/l"; 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 w16si7927668pga.328.2018.12.01.07.53.15; Sat, 01 Dec 2018 07:53:16 -0800 (PST) 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="JThfbg/l"; 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 S1727266AbeLBDGB (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:01 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45217 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727226AbeLBDGA (ORCPT ); Sat, 1 Dec 2018 22:06:00 -0500 Received: by mail-lf1-f68.google.com with SMTP id b20so6179743lfa.12 for ; Sat, 01 Dec 2018 07:53:10 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=kRRqVVwMz5ixbamRKAl9gUoe/zOElJopLPpSl/n7en4=; b=JThfbg/lOMn+xzuNaXHGw5fxxc6JgwX3c8sTa9g9M1xQwp2EdSRPgWwBwkTv5fyiAG Q3e3FBWNCQNW7ilQSIPXLa4S5eNrDgiL1yYMZoxNu/gVHPnb4ljyOvTejUHcuP091y8Y VNgyfKsYQnhYGgaRvJ7otQBDfkt20Rl5yEbrg= 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:mime-version:content-transfer-encoding; bh=kRRqVVwMz5ixbamRKAl9gUoe/zOElJopLPpSl/n7en4=; b=kw3Wgz64FSedQb7Fnpx6FFROYB5GTjelVTjY0h922aCz1tbgpHCjQhjC6dfTa09Uas hNnJGF67iH9HwqoOHPd/bF9vYohBMNm88gWijxRr6N/avlE7glbCjaQWEz+pJC3AZILN Dhy7zPHJXVFqO6Ilve3GUwpK0z4HGWu+0pyk0jMogtZrqfyaHRZORjRWWOBhuWvhshRi 6cezyzIEgsnoJ6hbiyJl8yxtiuAiFHAlEZtkERyiIf6H3g0OMmHKiK/9jGmF0g/bKFwR 0Ga/yb6wv0AzQaKUaMFs+Me2PIJSMwz/7DBowPa0oDsN90zS4/+oB5qKdTo5Y8uR3igJ WhIw== X-Gm-Message-State: AA+aEWb6Mas2aylV2vKPMOQY2NVc/+Kuq8HGt61cmFNoYI2KOp2pQ+F+ CWBW4wZ1PTpOcGflJWA/GVVQ6g== X-Received: by 2002:a19:fc09:: with SMTP id a9mr6080583lfi.21.1543679590022; Sat, 01 Dec 2018 07:53:10 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:09 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 04/13 v2] regulator: lp8788-ldo: Let core handle GPIO descriptor Date: Sat, 1 Dec 2018 16:41:42 +0100 Message-Id: <20181201154151.14890-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod_get() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fixes: 2468f0d51548 ("regulator: lp8788-ldo: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the gpiod_put() on the errorpath after devm_regulator_register() as this will be handled by the regulator core. - Put a comment in the code so maintainers knows not to use managed resources (devm*) --- drivers/regulator/lp8788-ldo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.19.1 diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c index 553b4790050f..2ee22e7ea675 100644 --- a/drivers/regulator/lp8788-ldo.c +++ b/drivers/regulator/lp8788-ldo.c @@ -501,8 +501,12 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, return 0; } - /* FIXME: check default mode for GPIO here: high or low? */ - ldo->ena_gpiod = devm_gpiod_get_index_optional(&pdev->dev, + /* + * Do not use devm* here: the regulator core takes over the + * lifecycle management of the GPIO descriptor. + * FIXME: check default mode for GPIO here: high or low? + */ + ldo->ena_gpiod = gpiod_get_index_optional(&pdev->dev, "enable", enable_id, GPIOD_OUT_HIGH | From patchwork Sat Dec 1 15:41:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152636 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934499ljp; Sat, 1 Dec 2018 07:53:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/VEANWwTP+aBloyeIzKBBYoGMPWbvmWnwKpbRToVoJ555OGL41A4+yylFLVPCXW5YuLXT+r X-Received: by 2002:a62:e044:: with SMTP id f65mr9612669pfh.208.1543679599304; Sat, 01 Dec 2018 07:53:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679599; cv=none; d=google.com; s=arc-20160816; b=C3VW+STSYc1LZMCZE2Ldh1O7rYbVDu8jqay8APayduUycTcaF8WP3jBYaWOlLuLAFH JEUlPrSIpIZ6qH7E7Uzem4qQShPAX+eSuIuOMP0CNTIcgma5mUBPWS5hk3Dh4zIX8YRR Si6c6S4fU3Ie3jRra2POjx9YyDsIcHECE17MCImXl6CzLTs4H5NFUYeJS98Ez5xZo+ky mNNxfDuCXD9eq3tK8SE3GLQnFAel94MT5AUpXq6YaZoapNZu1nLeEjbVlrGqTz0fWl58 /mM7DK5W0FvBT2Ioyk41yCg858L0BoZd/PVf34Yy9RzB5e38sRzdLYRSLTWkMpK532df jeSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pq6EvrtcoHql5+ikFxa5KOOUuE702pUaeiFm45YZFag=; b=jYRDO43FYhZYpSc69ZeUm0vsifK+AQ4h4Y90mIwU4bh/ZGK8BLO3G4J8uI1MLsNbWd 8SKT2j8m6vtZ/zhxjMtwrmxV4fPuN4IrUMDOB5Kjhpf7rTFZVgtV2hlnnc0hC7iAZHp0 GHTVqt+4wpGxRecfdhVfASFpHkl0jiiP+zjEyWXl1kqLnR8EOR0TQKlcyGOgF1DWCG/F ZI1HLm173p0i6f44WdqLyLf5ajd2C5tZsskQ63Ju25c4Nz5NyTW8MzmjHLIpWu5HI+B8 n5vYJhdXMcxAMX/vFXuC1wdx2dIqt1jbxZt2/HlGat2w5DPDtnXAB6lCAhB1+/FJFlOO tDIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=huONIq9x; 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 v3si7791322pgh.305.2018.12.01.07.53.19; Sat, 01 Dec 2018 07:53:19 -0800 (PST) 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=huONIq9x; 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 S1727288AbeLBDGF (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:05 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39007 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727226AbeLBDGC (ORCPT ); Sat, 1 Dec 2018 22:06:02 -0500 Received: by mail-lj1-f193.google.com with SMTP id t9-v6so7622820ljh.6 for ; Sat, 01 Dec 2018 07:53:13 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=pq6EvrtcoHql5+ikFxa5KOOUuE702pUaeiFm45YZFag=; b=huONIq9xiOiCPKdaxpYnglZ90lOJ54IJVNZpMR2kMhewCKA0wlqAs1IgE0stbSmHBN bbqEDhA+k2i7sumjFv/YdI9+qx5pF0ZhVf7kwgpnTuKr3uhniUKF/8mCUHcbE3YHYAWr 9rcbabr9OvsfpJHKEqichuGOFEBPG7otpaZ3A= 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:mime-version:content-transfer-encoding; bh=pq6EvrtcoHql5+ikFxa5KOOUuE702pUaeiFm45YZFag=; b=tWtfhw5oHTsV4F2HJRx7oFT2PWMd4BPhQ7ihyXSdmD12Kphu8EJkq+cBBG5HA2zOzZ QrvFY9KKYA29+e3YfprYA9++0knCYj6A6XEZgRam+lopaMIkD28RZvsakKrec6gdR8Z2 gj1wx7joXY3hw3gNhjwE0cd75w7tRg18NSyTQfmUbC2k8Beryni3PBXyWXT0iTJn+ggV D+5uOHGbOzGvHiGyW7Dmm8gCQ2mIbXqk5wsdIRI7F4VuRRSr5GvfUo9EKnnr/X80japS ckO5oo3ge3RbTcJW4+I1g9HI5LWIQmoeT31pzWOSBXR2mE8TuLE8rRSk821syOX6ADJF iIFA== X-Gm-Message-State: AA+aEWYAC5mkkFLCXF97SllakuuZBvyNgoZBTKAoH6FUHvSvNhedQsoz 2iBjD22ZWy2sZwWhLfUTgGP7sQ== X-Received: by 2002:a2e:9f56:: with SMTP id v22-v6mr6173396ljk.114.1543679592216; Sat, 01 Dec 2018 07:53:12 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:11 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 05/13 v2] regulator: max8952: Let core handle GPIO descriptor Date: Sat, 1 Dec 2018 16:41:43 +0100 Message-Id: <20181201154151.14890-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod_get() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fixes: d7a261c2d1f2 ("regulator: max8952: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the gpiod_put() on the errorpath after devm_regulator_register() as this will be handled by the regulator core. - Put a comment in the code so maintainers knows not to use managed resources (devm*) --- drivers/regulator/max8952.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) -- 2.19.1 diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index 6c39fff73b8a..cf2a2912cb1b 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c @@ -231,9 +231,13 @@ static int max8952_pmic_probe(struct i2c_client *client, else gflags = GPIOD_OUT_LOW; gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE; - gpiod = devm_gpiod_get_optional(&client->dev, - "max8952,en", - gflags); + /* + * Do not use devm* here: the regulator core takes over the + * lifecycle management of the GPIO descriptor. + */ + gpiod = gpiod_get_optional(&client->dev, + "max8952,en", + gflags); if (IS_ERR(gpiod)) return PTR_ERR(gpiod); if (gpiod) From patchwork Sat Dec 1 15:41:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152638 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934539ljp; Sat, 1 Dec 2018 07:53:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wr21Iu7883N2mUhWXnFV59myEod763koov8e1j7t/fCaMSU2hU3csFvYrBryPfwzqAn2/1 X-Received: by 2002:a63:9a09:: with SMTP id o9mr7902463pge.94.1543679602096; Sat, 01 Dec 2018 07:53:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679602; cv=none; d=google.com; s=arc-20160816; b=QTkSXeDwOvPYFm5L1SLps/VajphhN/JrHz166Y2CH4wvoJKPR84rvLn2wy9ULHD+jO pM89/lGAHs1/j7y6pNJoXDL2EKTfShpZqHM74Ryq5jUEKemZkEVswGTb3L7NaoS/vjqY UL0866lQNVzWmxqDzrsGnsLyaC0yFEgaYSV08JqJNJVySEzOv4QoKy1kBL6pqU0PaZn5 dOJ3pVc9TXj+6OTE8Mdf3Yu5wGz9+PiSzE+dRvR3O/OmdSJBEyBd43tnrh+ITzIfCo8L QQ0YxrDNDOsBFw9jb9z0gt7ZuoScsTrSYJliCwj4CUiQzCHc2Vwq/cUJl5dS5xSjwPIN UPxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BjCRleG8di9Pc2Z7GsEkzTD2w0QLemG0losOcCHuzcc=; b=RYtKkElpc44wa3zN0wpnk+qi2Ssb5wBROB2i2iHXlrPHqssKcrMQ+Wj/4IZFqU9C8v +xbkK6Cj0DAFegKpo3gHjOO/OWp4Qkzik6wUJ9kZJZSda0mboYMmR6vHORD6CFD8fnQO pn98TXuuPGKvcJHAjLD/HFKCAunQURbJd1vngbW+0eMeyyHiEqMS7bqRzkOxWt9Ks2CY k43NnQnDSCwmZJNgQubZeqLz2i4t1CJ3W6Hc+yFvt8N/qROYGDhbuaI6yiih/AHXX8JC uV61iMBPmUrBpdp7MV8rZz+6W3A7Thev4DTQC40niAEoQ3kZB2nqAym2czUbCEhtUN07 s0Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="cgrekM/Q"; 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 g33si7806409pgm.426.2018.12.01.07.53.21; Sat, 01 Dec 2018 07:53:22 -0800 (PST) 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="cgrekM/Q"; 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 S1727323AbeLBDGI (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:08 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33815 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727267AbeLBDGF (ORCPT ); Sat, 1 Dec 2018 22:06:05 -0500 Received: by mail-lj1-f195.google.com with SMTP id u6-v6so7649839ljd.1 for ; Sat, 01 Dec 2018 07:53:15 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=BjCRleG8di9Pc2Z7GsEkzTD2w0QLemG0losOcCHuzcc=; b=cgrekM/QsorFtbcUaVHMmtDLtCS1sWSFypoqEELuUVtiCLgK3yXWHP2AACh+0+eaRN cY40+f0uc107IPDbonPK8eAXiTxQ7escPATii4qaLB5RXljzRmBI/xHKfhdnwxC1ROfV t1ipStUXE+8RupmAynDtcqzPzynWEiv9D6rfk= 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:mime-version:content-transfer-encoding; bh=BjCRleG8di9Pc2Z7GsEkzTD2w0QLemG0losOcCHuzcc=; b=e4PBqhqAAo+Fl8PSfebpMXqVKrHKAJ8PDyko1EDE/otEB34bQg2VRlz5IBNcHPoMA0 RneUXg8RGklO43g1JL8IVbYDbFld71eePlU5SriMt5jp7uMc5iO8ckAsXwLUgMXik9oM KAQFtxw7AlTu87h1sjeVkBCxGj3wRkCkbDLo4K0IMENoehnyvRo1zBAQFUCm+C+E4kwH +4RALzdOk+14K+L2zmjSTgfJ3d6eytzDMGOjjJv4bcMGomkLer9b79g2GPwh8kWki5hz a/LARQeZg13yiTgYWSFtHFLT3zFME5zTVA2i2ROrP84gFutYn00k0s0Tw6amPDcKULNO p54A== X-Gm-Message-State: AA+aEWYdMe+QriDdAM5VBccHWiqaYIAAO58vf7351DyIa85k38VTT7dP B5NHGPHnA9Wy1HhJbcxeXJBpYA== X-Received: by 2002:a2e:917:: with SMTP id 23-v6mr6038978ljj.1.1543679594169; Sat, 01 Dec 2018 07:53:14 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:13 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 06/13 v2] regulator: max8973: Let core handle GPIO descriptor Date: Sat, 1 Dec 2018 16:41:44 +0100 Message-Id: <20181201154151.14890-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod_get() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fixes: e7d2be696faa ("regulator: max8973: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Drop the gpiod_put() on the errorpath after devm_regulator_register() as this will be handled by the regulator core. - Fix the second case of devm_gpiod_get() - Put a comment in the code so maintainers knows not to use managed resources (devm*) --- drivers/regulator/max8973-regulator.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) -- 2.19.1 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index e7a58b509032..ef8f4789a517 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -632,7 +632,7 @@ static int max8973_probe(struct i2c_client *client, struct max8973_chip *max; bool pdata_from_dt = false; unsigned int chip_id; - struct gpio_desc *gpiod; + struct gpio_desc *gpiod = NULL; enum gpiod_flags gflags; int ret; @@ -759,9 +759,13 @@ static int max8973_probe(struct i2c_client *client, else gflags = GPIOD_OUT_LOW; gflags |= GPIOD_FLAGS_BIT_NONEXCLUSIVE; - gpiod = devm_gpiod_get_optional(&client->dev, - "maxim,enable", - gflags); + /* + * Do not use devm* here: the regulator core takes over the + * lifecycle management of the GPIO descriptor. + */ + gpiod = gpiod_get_optional(&client->dev, + "maxim,enable", + gflags); if (IS_ERR(gpiod)) return PTR_ERR(gpiod); if (gpiod) { @@ -775,10 +779,13 @@ static int max8973_probe(struct i2c_client *client, /* * We do not let the core switch this regulator on/off, * we just leave it on. + * + * Do not use devm* here: the regulator core takes over the + * lifecycle management of the GPIO descriptor. */ - gpiod = devm_gpiod_get_optional(&client->dev, - "maxim,enable", - GPIOD_OUT_HIGH); + gpiod = gpiod_get_optional(&client->dev, + "maxim,enable", + GPIOD_OUT_HIGH); if (IS_ERR(gpiod)) return PTR_ERR(gpiod); if (gpiod) @@ -798,6 +805,8 @@ static int max8973_probe(struct i2c_client *client, ret = max8973_init_dcdc(max, pdata); if (ret < 0) { + if (gpiod) + gpiod_put(gpiod); dev_err(max->dev, "Max8973 Init failed, err = %d\n", ret); return ret; } From patchwork Sat Dec 1 15:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152637 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934535ljp; Sat, 1 Dec 2018 07:53:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/WB+zGmka/0nB3mhze/+747XsXus+ZXsU5JtcqUIWay1O3JxEkbM6dANHEA1BmRuW4j3dz/ X-Received: by 2002:a17:902:7107:: with SMTP id a7mr9663010pll.290.1543679601735; Sat, 01 Dec 2018 07:53:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679601; cv=none; d=google.com; s=arc-20160816; b=Vrip+9B6yTwQv4Qd07iy8mme5GbUC3fkOIgnCKM0R0DsMS7/v5X/3kbqigOxxmZrXd YGrquXtT0W0KmmqqxWK/WIS4DXfvoso8M3+1vJAncVH1piC3Ux5ak8yD9msqvW0qNds6 auc/64T8BDN3S+7q9PpJRK2yDYywLsFLiKNqIz/gwxlJ/Xs5Z7Cb/f40cMSXKG/UaPCh gg/nFRsHV2D0Xe2CEIcJBXxF2Q44eBKBfynVYXY7/C6gf0FA07E0n5PxT3OotGPdn+DN bNMZWaFvObfHt2NPdQSmzgrlBae7vK9Hx47ObhgJYzum+N0XoO/XWP+HrKjtYaM+vpma NaGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BrPFi/hYRcSPeEznRnCiUx3rZp8u++LmCL/2uJqnCDA=; b=htnveRaLGbnYnomDiB4oEcUFhAj4ki4u1WActEYgbkL8GJ5SWzqWP0C2YR5XbX3Xp2 VNRT/DqW17WYDtrWnaGU9y5EvURGcF6RLDaEhP2lnAIzniIaj1HhnvyTooUbwp41l9Sk Rzl5wL0kyjnigNsM3zckYcX58S1w4+xFlYAQjkqVFJMh0rnRjFrwH59728gIj7yQKJa1 563lPqxXFEd1HXLPuF75MwxpQY7UWO+x1bPpYuruPoOBIQSfNgjGn81P64kqgoYFgEpv dD1BfMb5pJnfUCiDGVL0H6YmbqwChaxbmf7rNYMpKeB2xWJ1azwCJLHRVNIgTeS6qnmx wOpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KFpIXWvX; 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 g33si7806409pgm.426.2018.12.01.07.53.21; Sat, 01 Dec 2018 07:53:21 -0800 (PST) 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=KFpIXWvX; 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 S1727305AbeLBDGH (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:07 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45218 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727226AbeLBDGH (ORCPT ); Sat, 1 Dec 2018 22:06:07 -0500 Received: by mail-lf1-f65.google.com with SMTP id b20so6179823lfa.12 for ; Sat, 01 Dec 2018 07:53:17 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=BrPFi/hYRcSPeEznRnCiUx3rZp8u++LmCL/2uJqnCDA=; b=KFpIXWvX/c7KhKGC2JIPNiTBFev/AFC5/8JBt3xSiKj9q7RUbEK2RmjHLOAq7ZI/dH Pniq4IyCwgKEqkqknDyCXy6e6BB228uyedRfGLqAyQEVGBX0zyJnCP4yaD8Cghsje0dX gwwszSAHDIlrrako15Fn5N6CyByDXBsehnlCI= 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:mime-version:content-transfer-encoding; bh=BrPFi/hYRcSPeEznRnCiUx3rZp8u++LmCL/2uJqnCDA=; b=E+niyMj7s1WPV08sPqucLz+oJkMQdIQ88XiJTx6rwV/zJFWVZqCL++EMcISfaeYszH 6zvyLCHFmU7L6snZdm+NBfrWGbyr9QSO01xWhw/Ehi9sz2qCHTYC1J+WOU54Fn8Ivh/o p5x/rhdfX0i8KVZqO4ftMi98fMITVBNnv5US/r/VOfIH+It2t8Dzdzzl356WWyQM5PWu vA4hH8eaH4aM8QnoTRtvfvrGXtBGtkHH+JNXvG1nUAeCZvILywT9o0X0GKoHDuXCnpnZ 1uEz0mWCeTCGR6watKDMv+AIeiHrAfebQ7DmTuWPuUGgEoHrZq37H8MyNLri4mZFr2Cr JZpg== X-Gm-Message-State: AA+aEWaZZQYK/Dc2fTt6G36ZiGCo7Yu0NJTaYJ1EjoDTmtUX3VhcMVA9 fWBpSBV1XNO9dS+3pizZhVY0Fw== X-Received: by 2002:a19:2c92:: with SMTP id s140mr5654825lfs.42.1543679596440; Sat, 01 Dec 2018 07:53:16 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:15 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 07/13 v2] gpio: Export gpiod_get_from_of_node() Date: Sat, 1 Dec 2018 16:41:45 +0100 Message-Id: <20181201154151.14890-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function already exist inside gpiolib, we were just reluctant to make it available to the kernel at large as the devm_* seemed to be enough for anyone. However we found out that regulators need to do their own lifecycle/refcounting on GPIO descriptors and explicitly call gpiod_put() when done with a descriptor, so export this function so we can hand the refcounting over to the regulator core for these descriptors after retrieveal. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Resending --- drivers/gpio/gpiolib.h | 6 ------ include/linux/gpio/consumer.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) -- 2.19.1 diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 087d865286a0..bc57f0dc5953 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -201,12 +201,6 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, struct gpio_array *array_info, unsigned long *value_bitmap); -/* This is just passed between gpiolib and devres */ -struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, - const char *propname, int index, - enum gpiod_flags dflags, - const char *label); - extern struct spinlock gpio_lock; extern struct list_head gpio_devices; diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index f2f887795d43..348885f2f3d3 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -172,6 +172,10 @@ int desc_to_gpio(const struct gpio_desc *desc); struct device_node; struct fwnode_handle; +struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, + const char *propname, int index, + enum gpiod_flags dflags, + const char *label); struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, struct device_node *node, const char *propname, int index, @@ -517,6 +521,15 @@ static inline int desc_to_gpio(const struct gpio_desc *desc) struct device_node; struct fwnode_handle; +static inline +struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, + const char *propname, int index, + enum gpiod_flags dflags, + const char *label) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, struct device_node *node, From patchwork Sat Dec 1 15:41:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152639 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934563ljp; Sat, 1 Dec 2018 07:53:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wxq4/OJYrKB3wsqXiHqax9wtTL6ZJzZolGq1TWN1aC092AIq+C51wMXBcfPYqCyaybH3eD X-Received: by 2002:a63:2c0e:: with SMTP id s14mr8323897pgs.132.1543679603614; Sat, 01 Dec 2018 07:53:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679603; cv=none; d=google.com; s=arc-20160816; b=ZjBtTbrhlNeHah8j0waPPUFMeVvp1Rb0SVDoLbhBGLhIEhC9x733aGOw9bwtczWM3F TP1861DIxRyIq9NFLZcR+AgjV+Cb5GiXj5QGqZlQyz8ud29BQHDAfHCSZVicq7VUej6J oCpYGVLNswETqNe/sDKf2/COzCuQeGXsts3ImIMblELcaJ7CLFEkX0aNkkQs1uAxgQoZ JzznotEbhLHdaJOJTQZsPqApf2VIbFESe05hhEhzLZTfyj0TSMUN17wYxHoWGCzqcsam PBKGeqZoxqbQL+AI+QPT3xQq/0AUng13HF2zNHQeMI848krwQWKeVmTEAHa272nPrwjn WDdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WoT+Ndj5Ei0kF2uLiPdGvTf6lS/9r/F3o57+S1DbskE=; b=NtvAVZJU8Xfykglavp7I6vVEOyRsG+pDEXblt956btx0nD8+sqWm0kZ77VtaoENL+i 6wLmXVA1fejOJKMVraZWijHWy/TIOSKYAlPZiQ6JmsiHv8W7vKzUDNI5HgQXusv9DtPr YWVqoKQkHc4K16/1Kzxd0pAhR3I+L8MiB14WCP57pEMiW5Mq+UlJQRa/AzLgWm4KSXiG /X1cD8wetqIxnc7SOm+N9jS7e1R7HEnb+th2AoPa91yRjnsBX/HCseTniuqunuQNf1GX vH/XHn/tBThVRxFpOCdiBNInOWvbqmsA6PSV87+w5/zm8/z+ZkHEiLoMzNsqEGLiqvjh E54A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XgnOSiwj; 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 e8si8366903pfc.248.2018.12.01.07.53.23; Sat, 01 Dec 2018 07:53:23 -0800 (PST) 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=XgnOSiwj; 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 S1727342AbeLBDGJ (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:09 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35363 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727293AbeLBDGI (ORCPT ); Sat, 1 Dec 2018 22:06:08 -0500 Received: by mail-lf1-f66.google.com with SMTP id e26so6229085lfc.2 for ; Sat, 01 Dec 2018 07:53:19 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=WoT+Ndj5Ei0kF2uLiPdGvTf6lS/9r/F3o57+S1DbskE=; b=XgnOSiwjI4z9wgN+Zk3ZjjQlIhLlyC1NH653lGFo2zo2zTOJb1CuYW47Ex7XY1Ab/V r2cRc8S2nTecGtBUiwgmZJxpbH3QMYlTJhiFswmzR/RmtExPjcLKF+15fd0JI5xJKUx5 Dh6P3LP1mM7tBP85vFusmxS+LR60x+ZNJ0tm4= 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:mime-version:content-transfer-encoding; bh=WoT+Ndj5Ei0kF2uLiPdGvTf6lS/9r/F3o57+S1DbskE=; b=VKomQvHMmOb3Vigv1y4GFPNVl4PQ2DOv2t/bo64P7ipYNgRVolqCRdAipvrwolHuDW yClsru2f9M1EXeQNiUjeXV41WOJpjSxb6uKEDeUlKqfoa1XPaAIfdTjuXRDyHMPLCt5l sH2wvTvx2zMMGzjnuBCI6vvqzc7mOmnP4nE6fyotHRaMIfDv397cJC2Y6z8bC8w2MlUj Jqsu51ee8TOlmOPCCs+LI/bBQAlSjAF53+Lgha3GH25h9VWkuxSWIiyR0cGbgBWTdWe9 F4rOBgS5RGHtAHNYaX3uuCZoHoyK9+1SV+5Rbbn7Euqrv59siRLNwji0Vj1nTCxiqQCh YVeg== X-Gm-Message-State: AA+aEWabScmJnpHIyxYI/vsmWC2lKpmlvTH0+MbfQD1MINXsQ5+UTIsv A0dVkXxgf3NZ4bZFUs+gdKLPpg== X-Received: by 2002:ac2:4116:: with SMTP id b22mr6073306lfi.19.1543679598621; Sat, 01 Dec 2018 07:53:18 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:17 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 08/13 v2] regulator: max77686: Let core handle GPIO descriptor Date: Sat, 1 Dec 2018 16:41:46 +0100 Message-Id: <20181201154151.14890-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use the gpiod_get_from_of_node() rather than the devm_* version so that the regulator core can handle the lifecycle of these descriptors. Fix up the errorpath so that we free this descriptor if an error occurs in the callback. Rely on the regulator core to deal with it after this point: a previous patch fixed up the regulator core to properly dispose any GPIO descriptors once you call regulator_register(). Fixes: 96392c3d8ca4 ("regulator: max77686: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Handle the errorpath (hopefully) correct, back out of regulator registration by freeing the descriptors of all not yet registered regulators. --- drivers/regulator/max77686-regulator.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) -- 2.19.1 diff --git a/drivers/regulator/max77686-regulator.c b/drivers/regulator/max77686-regulator.c index f5cee1775905..8020eb57374a 100644 --- a/drivers/regulator/max77686-regulator.c +++ b/drivers/regulator/max77686-regulator.c @@ -250,13 +250,13 @@ static int max77686_of_parse_cb(struct device_node *np, struct regulator_config *config) { struct max77686_data *max77686 = config->driver_data; + int ret; switch (desc->id) { case MAX77686_BUCK8: case MAX77686_BUCK9: case MAX77686_LDO20 ... MAX77686_LDO22: - config->ena_gpiod = devm_gpiod_get_from_of_node(max77686->dev, - np, + config->ena_gpiod = gpiod_get_from_of_node(np, "maxim,ena", 0, GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, @@ -271,9 +271,13 @@ static int max77686_of_parse_cb(struct device_node *np, if (config->ena_gpiod) { set_bit(desc->id, max77686->gpio_enabled); - return regmap_update_bits(config->regmap, desc->enable_reg, - desc->enable_mask, - MAX77686_GPIO_CONTROL); + ret = regmap_update_bits(config->regmap, desc->enable_reg, + desc->enable_mask, + MAX77686_GPIO_CONTROL); + if (ret) { + gpiod_put(config->ena_gpiod); + config->ena_gpiod = NULL; + } } return 0; From patchwork Sat Dec 1 15:41:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152640 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934607ljp; Sat, 1 Dec 2018 07:53:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/XQ/UaPJlPCwBE6dihOF5XQBinec3Vsn7RkTm8E5K1YHOccFQ+R0kZg9Atd96fxDYRQopT3 X-Received: by 2002:a62:ab0d:: with SMTP id p13mr9655252pff.211.1543679606625; Sat, 01 Dec 2018 07:53:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679606; cv=none; d=google.com; s=arc-20160816; b=vWvFsU0/DapKBzs7gvr+9vwbUP7+4Dutls/+J6dOyWUEggJEDVxEyNCwiNPqGvgztv bY1bckESBfNuZxfSkBlIw/zFb2NysOx9pPfBcqCsQnpbaI05pI/Z6mifZwXFng768pPL tj5W73vD6T3qBEU7vNzOO/Ve2daGX7kLq3qAuB+LEzqGkgKYpU3PJ7DsO459yZf6s+1i +UpAwz5KjoPdEiDYIJy2XRuXlai+S1GBmhsGIYRTn7G6FW+FfaaVW87g3led4Jk6JXdM 4m3+6mUQ8hweDEPie1+2CwAg/xTVDI9bdcEiDfvWKmgj56Qa06PnBf1kL5DPiR+tKib0 Xz6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dKBvHfafiQ4kCpEJu7bit7Ossq558os4BIrgEwZdU7g=; b=AGe3+2UIUB2qYflxfI7Nqw7Imj0t3TrhvQqgAP8RlWXS+m0wzcOwuF0kMkVRmkCI5O ApJXeHsO8/rWbVxiWeA5LWWTElJmBsqBaUoBE29Qhm7cRLNEg/6v7+tECKd91d2bjdAB jloPV81TkFJVyNQgHSf0NAoQX1QelCZEihJwryE7CiKnyLONHCSJYHe6WhW5Jt3XEGFP BDJHVaateUZ4zUiZLVFCPCqYPg8zvPyhHOxlMCho6lnsCLLatE7iBNOk5V/0vA7oNUUN Are409ecrsD3WjH/FwPODyaw4Qfo4OwruFPV5tzqRQH5oU4MYjVxaeFEpxOqy8IG/e20 gZxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I2pzSeKI; 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 d90si8955723pld.148.2018.12.01.07.53.26; Sat, 01 Dec 2018 07:53:26 -0800 (PST) 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=I2pzSeKI; 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 S1727356AbeLBDGM (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:12 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:41976 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727293AbeLBDGL (ORCPT ); Sat, 1 Dec 2018 22:06:11 -0500 Received: by mail-lf1-f66.google.com with SMTP id c16so6199677lfj.8 for ; Sat, 01 Dec 2018 07:53:21 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=dKBvHfafiQ4kCpEJu7bit7Ossq558os4BIrgEwZdU7g=; b=I2pzSeKIFvN8gmFrIykZ6uJTglYZyR5CRTkfC6bB7qEWQ/YcmlGR9CFfgqi0Sz2Jon hje/27hhg52448csivuTpbC+pr5wBzOBVAj5B6Z7KSFKhnx7FW/OucIKyv0ByliW5LSy /PkkIJgF96tKcUsMm9AYCbnNMM7eRuzlfUUOs= 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:mime-version:content-transfer-encoding; bh=dKBvHfafiQ4kCpEJu7bit7Ossq558os4BIrgEwZdU7g=; b=FrfeH65nVUCfWQako3+HzfM8jqA3s6CvW0Nz4pXrnWL3n9X+LcIUj2DNkpC6wMYZ38 ybSEyRwC+jhllyAS3Lz7oeV6U9wuZbXcCx0a+NZjx8W1d/Q1FR4nYXeyk/ithNNQ17wZ Z68JxnkME+FvauOdsB8ESCcoinlW+/I2lXav8o9Lpl3Ov5NiEn5p4P2bJalflmwQrewm zWvvqr0NC/wouR1i0+ZistVZaK8AQ+l88MxB4hchsoxWkpWdgM3f2gADPnej9kBuJRwt YQ8sg9lTeCokRz5DLd9o6bqRgMfIPXDC5cr0HwZRYAZEtsdv8vl5oRqp938aR3t16PrU ClVA== X-Gm-Message-State: AA+aEWZeIkpQ+APG+8F+zOYC6KrG2D5+g/73ZlAGunIwwmY2mRHL/AWs jzbA1yyn7NAipTPz2andKSOVIg== X-Received: by 2002:a19:d70f:: with SMTP id o15mr6031149lfg.134.1543679600779; Sat, 01 Dec 2018 07:53:20 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:19 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 09/13 v2] gpio: Add devm_gpiod_unhinge() Date: Sat, 1 Dec 2018 16:41:47 +0100 Message-Id: <20181201154151.14890-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds a function named devm_gpiod_unhinge() that removes the resource management from a GPIO descriptor. I am not sure if this is the best anglosaxon name for the function, no other managed resources have an equivalent currently, but I chose "unhinge" as the closest intuitive thing I could imagine that fits Rusty Russell's API design criterions "the obvious use is the correct one" and "the name tells you how to use it". The idea came out of a remark from Mark Brown that it should be possible to handle over management of a resource from devres to the regulator core, and indeed we can do that. Cc: Bartosz Golaszewski Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch to be able to hand over GPIO descriptors to the regulator core. - Mark: feel free to apply this to the regulator tree with the regulator tree with the rest. --- Documentation/driver-model/devres.txt | 1 + drivers/gpio/gpiolib-devres.c | 17 +++++++++++++++++ include/linux/gpio/consumer.h | 10 ++++++++++ 3 files changed, 28 insertions(+) -- 2.19.1 Reviewed-by: Bartosz Golaszewski diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 43681ca0837f..fc4cc24dfb97 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt @@ -254,6 +254,7 @@ GPIO devm_gpiod_get_index_optional() devm_gpiod_get_optional() devm_gpiod_put() + devm_gpiod_unhinge() devm_gpiochip_add_data() devm_gpiochip_remove() devm_gpio_request() diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c index 01959369360b..5864e758d7f2 100644 --- a/drivers/gpio/gpiolib-devres.c +++ b/drivers/gpio/gpiolib-devres.c @@ -320,6 +320,23 @@ void devm_gpiod_put(struct device *dev, struct gpio_desc *desc) } EXPORT_SYMBOL(devm_gpiod_put); +/** + * devm_gpiod_unhinge - Remove resource management from a gpio descriptor + * @dev: GPIO consumer + * @desc: GPIO descriptor to remove resource management from + * + * Remove resource management from a GPIO descriptor. This is needed when + * you want to hand over lifecycle management of a descriptor to another + * mechanism. + */ + +void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc) +{ + WARN_ON(devres_destroy(dev, devm_gpiod_release, + devm_gpiod_match, desc)); +} +EXPORT_SYMBOL(devm_gpiod_unhinge); + /** * devm_gpiod_put_array - Resource-managed gpiod_put_array() * @dev: GPIO consumer diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 348885f2f3d3..8aebcf822082 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -104,6 +104,7 @@ struct gpio_descs *__must_check devm_gpiod_get_array_optional(struct device *dev, const char *con_id, enum gpiod_flags flags); void devm_gpiod_put(struct device *dev, struct gpio_desc *desc); +void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc); void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs); int gpiod_get_direction(struct gpio_desc *desc); @@ -249,6 +250,15 @@ static inline void gpiod_put(struct gpio_desc *desc) WARN_ON(1); } +static inline void devm_gpiod_unhinge(struct device *dev, + struct gpio_desc *desc) +{ + might_sleep(); + + /* GPIO can never have been requested */ + WARN_ON(1); +} + static inline void gpiod_put_array(struct gpio_descs *descs) { might_sleep(); From patchwork Sat Dec 1 15:41:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152641 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934630ljp; Sat, 1 Dec 2018 07:53:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQLLvUGHbXruAo21rG7Ta2FM3PYw8UynPaiPmSOUns9GmpcMK5TL8FaEiFLSw7uiFCtJdd X-Received: by 2002:a62:6f49:: with SMTP id k70mr9606846pfc.7.1543679608280; Sat, 01 Dec 2018 07:53:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679608; cv=none; d=google.com; s=arc-20160816; b=KSGBaqE7ckHySgmDCEXnTOXpWig6gO09xxXu3FUzKXWSi5TbEZU1ZDaTBDpEYl3v8y HLmal9K1weghRAUYRlgSZ0mSbt+nt2F3HUJx4EsJ/AQpH8ai71PlFEtHSErnLl5i/6M3 U6LZeUT1vy/3cXKqlIeHjky9coTxpBJqxxMCrF/gUph+4/m0jBfFEJqGNkapWVbeNZnd 75hWh5Md6fIHMQiXvgCZurGeAx1pBcFtikc1wHZftLBSsCfnawIRk2PuNLJaOzLjSd9/ s5WVMWCUIf6sVTHKQGrQc/paYMh/SuJy+3KkapzulqsXz9QksWwhxpyd2BWmfadbHNzP mcQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vSHgOcFCcORkAA/FyvR5Vyf7Y6Xs7jW379bIdSME4VA=; b=UtD8rJU8et3PXtguUWyVQ3jFAutPhiM5tDEBhb4TDfFf05tmgnh6yTF+nMMbUqvjtI HmDDySdzQCPigKVNP2BclU8TNUd98k6pniK5jxaXGtdarRzJzDSs3Ul0BFQJidAAzWo8 jl511bXVH/2X+Q63VLdHumGm9Odzl3hy3eXfCS5aJ7zrI2FQ/TZJjnv2IQ1fJF44vBbE PHNv2oDKLJ5Xnij0KfKXoksdrQf6m8Qs7IZdLxK/y6deLCqT2AOLerrMMN20kyfnQRH3 +CNdiWbZzMZEJCm1m/Dfa13Udg8r1jXI8+rXsFmY3rRhEVkMARXld8Fh4I43h7xCoOxL X9Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=awaJkCYR; 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 q5si8120204pgr.435.2018.12.01.07.53.27; Sat, 01 Dec 2018 07:53:28 -0800 (PST) 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=awaJkCYR; 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 S1727378AbeLBDGN (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:13 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44045 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbeLBDGN (ORCPT ); Sat, 1 Dec 2018 22:06:13 -0500 Received: by mail-lf1-f67.google.com with SMTP id z13so6189539lfe.11 for ; Sat, 01 Dec 2018 07:53:23 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=vSHgOcFCcORkAA/FyvR5Vyf7Y6Xs7jW379bIdSME4VA=; b=awaJkCYRZMHwI3+jvDJmJ/DvUoUFidnG+SAaLBjW16slimg8aAoDF0vH9xZQqT9Z3k qLgLlVi3ugAetbLrtWXMjvGv/oyg6aY5udlJgo5cjBdRgeu6SOQv0q7/w7toNYRsorHK 2u4SC4UDt3vTPKpq2ir/1B/oUihVXAUfNPmeU= 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:mime-version:content-transfer-encoding; bh=vSHgOcFCcORkAA/FyvR5Vyf7Y6Xs7jW379bIdSME4VA=; b=ezqQgNtwG++5AxcYhkG1opUI4FMwow9TPXWSrFFWWj6NOi3HTD5Y6knMWfIBLG0k6o 8XMix6KMaoLRgN7PF6L1v6Uum3BdI2vvRKQySiU4euC5v3G3xOjy03GXvvwC6sCJ7QGX BxRoFsxjgYRBy5lAwFrrSx1wm4KgkR0syrXfmlS34ajJJdPLAlRNHVXHPU1M36s/qxAO S7iOzkIEwitDgRbjVYAIBaodYMypQ7m1+v0/jJeUc+9+bWaeU+C7acU5ZH5mSrriNAuF Qj3boz044Hv4X0gvztkO5BASqM38kROCQr4zsEhMnt+q7iuswC55oh2FHwLWbO/L+0my oV/A== X-Gm-Message-State: AA+aEWa2JMi/LY4O1YGFotDbQORdv3n6NPh5jrAgwzPy4CNfo8Sgxqj/ K2VVDmoqlMetZ+imf2ek+QaCIw== X-Received: by 2002:a19:a84e:: with SMTP id r75mr6058120lfe.45.1543679602693; Sat, 01 Dec 2018 07:53:22 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:21 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 10/13 v2] regulator: da9211: Hand over GPIO to regulator core Date: Sat, 1 Dec 2018 16:41:48 +0100 Message-Id: <20181201154151.14890-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The GPIO descriptors used by the DA9211 driver are retrieved during probe() and it is really helpful to have those under devres management because of all the errorpaths in the intialization. Using the new dev_gpiod_unhinge() call we can remove the devres management of the descriptor right before handing it over to the regulators core. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch handling this drivers GPIO descriptors properly. --- drivers/regulator/da9211-regulator.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.19.1 diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c index 8f68c7a05d27..109ee12d4362 100644 --- a/drivers/regulator/da9211-regulator.c +++ b/drivers/regulator/da9211-regulator.c @@ -389,6 +389,12 @@ static int da9211_regulator_init(struct da9211 *chip) else config.ena_gpiod = NULL; + /* + * Hand the GPIO descriptor management over to the regulator + * core, remove it from GPIO devres management. + */ + if (config.ena_gpiod) + devm_gpiod_unhinge(chip->dev, config.ena_gpiod); chip->rdev[i] = devm_regulator_register(chip->dev, &da9211_regulators[i], &config); if (IS_ERR(chip->rdev[i])) { From patchwork Sat Dec 1 15:41:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152642 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934677ljp; Sat, 1 Dec 2018 07:53:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/WRS6n84LcH6ehHlZ2lae2BZrpDQmNnHslwRg8ZMLhW2f4n/G0tpS+uZf9S71vmFTW62+5B X-Received: by 2002:a63:193:: with SMTP id 141mr8226300pgb.136.1543679611192; Sat, 01 Dec 2018 07:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679611; cv=none; d=google.com; s=arc-20160816; b=a8K6j99WKRWGW1bSnwdrd7KX/Qu3KAF4Ap2u17volqNi8YrCKpDF6fdWWmzbFhRREe OKALGe/DENL24Gw3S1eA/VpuBIrOjksmSnAkSA2o74Bz+2HzogJk13xnFfii/OTBjN+f AjQenQncSU3iMABNKaS3SfKxN3XhR+BFHU2yGpBitlrsePtKlQ0YTbQo3VoL+KC4cqEN gxG3bzfSiYv8CSQLSOOa1CewUQsC74w2A8ZKGDiJEP6u0sXLWXOK1F2FosDksdWqBH9y /3dGCUfhYMq/rVQoANDf7ddrkFPcBAKtHxZ/p2HIez/szZgYcyTxDEQYRDavSo9ZlnqE l0cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=44SPP0BIPcyJprau3J/HnN7hoNM3OEVwqSrrtldr13E=; b=K7fMfaQLUD1z1wv7h8B60Qq4rbjZDIqlzNd8FFCZeHJs6Z11Pbq1XDqHAbBAK8ZBru BH5aBlT8DAgqJbgO0fknbqNh876+HQgbLkTYUa25Ia/d0AQ4EBntmsXYbXhwAg0w0mU+ zTwqqF1peOZysw6cip5Bq0QhGuYFVJcohH/iXr9ZixA+kUpWGIQa43fApM99ZUlA91hs /lQnYFLImEkpx8aqpGEqYKuf/eVcc2B3VjdNQQNlBD+xdBMK6SGQKQzmV5SrNq2h/HG7 BNidrOtNe0U5Gbcz/ioN1mjfk4Y85aXbWPL0ekYF33h+U8ExViYE6lVc+oCG3hgxbCHG kNSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LK6zz3sX; 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 i5si8204825pgn.243.2018.12.01.07.53.30; Sat, 01 Dec 2018 07:53:31 -0800 (PST) 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=LK6zz3sX; 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 S1727396AbeLBDGQ (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:16 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:36432 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727169AbeLBDGP (ORCPT ); Sat, 1 Dec 2018 22:06:15 -0500 Received: by mail-lj1-f196.google.com with SMTP id g11-v6so7641404ljk.3 for ; Sat, 01 Dec 2018 07:53:25 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=44SPP0BIPcyJprau3J/HnN7hoNM3OEVwqSrrtldr13E=; b=LK6zz3sXhQ6zMfd6xPVCcwV+AB03r2QF/4TreQ7SOnGwmct1GuZSJvvfH8UzvCEAu5 YyVU3YXxCGpbPzh5z82lpCiD0SBw/7fXw7ykD6zf2KNC6x4/5bm52PYIp38Ko+PzuDKw VYLVz8MrsciLV6eQc2WPKfwwagY0/gikp9GGI= 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:mime-version:content-transfer-encoding; bh=44SPP0BIPcyJprau3J/HnN7hoNM3OEVwqSrrtldr13E=; b=YPt766hz5wno4z1Z01Sob4Qsp+5jSPcfRhCtXTC8iwYJeA+f2fUgl7aekp11lkzS0s 22mBRBpTlKVSlqap/fbkQ4YjJlyy+JyxTsnXzIb+Z4nK0u4PfGp3X7xYVG9kjo4FHK0q xcK/HrAa7Ff4PAcBozK7N2oYx3m5KYZJyVwqOcAjmqPtUZy2RYrOm2ndr7TcYYk9+Ap1 +sO8/+G4ijqhgvIR3/b1akeSzDrq2eoOiMS/9WzsTR8wo91samyy2qe2ANM1z8jE+f6/ tmj6P8chKCPiGrUDuvRWjlWY7FzKiIiNaUyokv6aeXs7XcFsbBvqfYT0032yBeHzzBlw +5hQ== X-Gm-Message-State: AA+aEWYTLpIQj69rnQmcRHBEIh7JgSkOIUtXfyhaY7BRa2DsyeEbPMqv 3He40nUeZQ8rx8lI24cJpvzb4A== X-Received: by 2002:a2e:9a56:: with SMTP id k22-v6mr1977164ljj.17.1543679605045; Sat, 01 Dec 2018 07:53:25 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:24 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 11/13 v2] regulator: s5m8767: Hand over GPIO to regulator core Date: Sat, 1 Dec 2018 16:41:49 +0100 Message-Id: <20181201154151.14890-12-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The GPIO descriptors used by the S5M8767 driver are retrieved during probe() and it is really helpful to have those under devres management because of all the errorpaths in the intialization. Using the new dev_gpiod_unhinge() call we can remove the devres management of the descriptor right before handing it over to the regulators core. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch handling this drivers GPIO descriptors properly. --- drivers/regulator/s5m8767.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.19.1 diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 219b9afda0cb..d1edd8c2bcec 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -956,10 +956,17 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) config.regmap = iodev->regmap_pmic; config.of_node = pdata->regulators[i].reg_node; config.ena_gpiod = NULL; - if (pdata->regulators[i].ext_control_gpiod) + if (pdata->regulators[i].ext_control_gpiod) { + /* Assigns config.ena_gpiod */ s5m8767_regulator_config_ext_control(s5m8767, &pdata->regulators[i], &config); + /* + * Hand the GPIO descriptor management over to the + * regulator core, remove it from devres management. + */ + devm_gpiod_unhinge(s5m8767->dev, config.ena_gpiod); + } rdev = devm_regulator_register(&pdev->dev, ®ulators[id], &config); if (IS_ERR(rdev)) { From patchwork Sat Dec 1 15:41:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152643 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934685ljp; Sat, 1 Dec 2018 07:53:31 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXpBOvFtNF1rKwO9BiiANSEnGKpf9JXug9FzB+GBRjwdK2dPYZnxpN1wruQ0CtuAHScPii X-Received: by 2002:a62:e201:: with SMTP id a1mr9473239pfi.75.1543679611546; Sat, 01 Dec 2018 07:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679611; cv=none; d=google.com; s=arc-20160816; b=zGi/rWGDKjmoM8TJ/VTFe5EjRnmJEy4e6AyDUooD1F7L+rdyS4hapVRJCA35gnms0i +m07dg7u7dZiZUtsIjFFpa+5wnqGwAiPgwuhIkKBa9qHwjE2yz9AYtWbaOCtnx4wx+/p 62qNp5n2vAvhar0oS8Of5MzcD3A6uMvdr0yVAXqlhtYqeM0XUOkDd2QrNGuZRQvITzHv Z73V5bwvsomPY8x5NOEbiuTfVF16GGaiJii1HFe5MvZ9Z5J/tPDPpfdXI3mwyOcf7Ggx SLkI8l8gKDA9xyGEiTH8TtBaJIJSU0z6Dk/ConSmdr2SeX+J3C98guep30tqSRE2J19q B/tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ruvG321c2erSKd4WYuxWeHCQ5T1dUamVjuDaYGBmTnk=; b=QVL5yiVT5YamGQZDwWMeiKyHD03irEXatF2fY7YvNmCjcFajAZrkw7/kavyVO4JCLA vmp9VDGZ0qD8RQhCmdyCBWvZBj6eq+U3pw42QeukMFYrjB/ZjbvnZJIhmrUzGRkrhyxF 96ZVxmrVbHcPRTbxt9ojkBzXtNE/z1ZEfmFoDlpVfvhDNN4i+lqdeJU9AsTPpUMBsl17 MP8Hf4gvakagX5o6mQHkW7NmUM9qyO0iDia/OxTRo03gbVS5amBMs/q2EEdJeISUs+pz QcFJBhZi9m3XZH4vO1+7Mh+vg4qG10CoeS+PQHmF50OUsLdfO+4/BqN+uQPZhdqYfrEP On+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=St0vJBFM; 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 i5si8204825pgn.243.2018.12.01.07.53.31; Sat, 01 Dec 2018 07:53:31 -0800 (PST) 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=St0vJBFM; 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 S1727417AbeLBDGR (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:17 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37945 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727379AbeLBDGR (ORCPT ); Sat, 1 Dec 2018 22:06:17 -0500 Received: by mail-lj1-f193.google.com with SMTP id c19-v6so7638158lja.5 for ; Sat, 01 Dec 2018 07:53:27 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=ruvG321c2erSKd4WYuxWeHCQ5T1dUamVjuDaYGBmTnk=; b=St0vJBFMo1PEOsZeu5nQ1jcY2njdXe6Z9sgqA8e0yP5b9MZIoE8amrZwNPJfR02BZ0 33PhtotojcF3qCbbj8J4oyxDYszcJP2IeY6RjxkIh+NmY/Ko0yThJ2HSpiBL+JwI4Xe5 8XHZWoG5y60Hma2lanMhUPrr3PDd4JBWbPbSg= 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:mime-version:content-transfer-encoding; bh=ruvG321c2erSKd4WYuxWeHCQ5T1dUamVjuDaYGBmTnk=; b=nXRxEGOyj4/cLk0KBzwb46ROYC1RwNAS/PZoUNY0VLPbTJ2s/lBonRZpRhomHOpUch LTZyuY78T/o9lwhpXwQmkaHpjKIaedHyhNE+72JJ4c+Pw1/m2/cRUpTvC9pXAwU9szUn wYIRyh4RZLXLcCwrLN5gxXjHozRIBPpRPnJz3aAO8IsQVoEfL6QQsrOCYvRddiB24OtM io4AlWj1L/bnLXpeij4nnuApbY6W1+57J9nfiU/yvS1WpOJJfCtU5DVptmrP7UnN7BnN ncb8MG9U7t8yKcXue1qC8U69WS/CrxldquJUKQXxXAeJhVrnN9pG9tQzvAjSjcjvBjcB g+yw== X-Gm-Message-State: AA+aEWbBxlaHppPcGlWr452ebPgFvJXc8USrFWAT4yPmUnXSmUrs0inl 1HrPAlD6ogF55CauIePwAqX38A== X-Received: by 2002:a2e:5b1d:: with SMTP id p29-v6mr6224863ljb.176.1543679606971; Sat, 01 Dec 2018 07:53:26 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:26 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 12/13 v2] regulator: tps65090: Hand over GPIO to regulator core Date: Sat, 1 Dec 2018 16:41:50 +0100 Message-Id: <20181201154151.14890-13-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The GPIO descriptors used by the TPS65090 driver are retrieved during probe() and it is really helpful to have those under devres management because of all the errorpaths in the intialization. Using the new dev_gpiod_unhinge() call we can remove the devres management of the descriptor right before handing it over to the regulators core. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch handling this drivers GPIO descriptors properly. --- drivers/regulator/tps65090-regulator.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.19.1 diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index db714d5edafc..0614551796a1 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -480,6 +480,12 @@ static int tps65090_regulator_probe(struct platform_device *pdev) else config.of_node = NULL; + /* + * Hand the GPIO descriptor management over to the regulator + * core, remove it from devres management. + */ + if (config.ena_gpiod) + devm_gpiod_unhinge(&pdev->dev, config.ena_gpiod); rdev = devm_regulator_register(&pdev->dev, ri->desc, &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "failed to register regulator %s\n", From patchwork Sat Dec 1 15:41:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152644 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934708ljp; Sat, 1 Dec 2018 07:53:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/VdlJxPscL9etRfsCOmlt2ZvwBStFHlcBCX9FvhkKNQuudKp8ZJwRXvFsbRoP2dweoc9IAL X-Received: by 2002:a62:220d:: with SMTP id i13mr9629288pfi.162.1543679613882; Sat, 01 Dec 2018 07:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679613; cv=none; d=google.com; s=arc-20160816; b=p6TnqPtqEj02vDhIrIrwlBhwEb/emEv6/cIgsMqXPiDQ8nIeyVwYFdgQVwmkpexcGa djnojr1ikr012O/Eu+9ezQL3DC70SzChnyRrzo1y7YOxssYPy6l3zOgdj5ukAexeRdBe effsj3sJfA4w6u3ZT6aSlZ5rwRhLef65XJUXyzRJs0Ld5G5fwd1d67/hRxTMisuH/Xku 7/RJXgLdXFIkknGVxLOvtAOW1dcgWlbwDLk44beLLIBFBtgEx7cwa18SFLByTPqI4Wse IfcnshOGeUwrm51CJuR+IDzKEl5k3AawWAfUs7wb+Fu4NfLpp3oG6gAoFlBdBe8bbpTO iqoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6Lls7K5eWZynQmqU5NrZXBxowzW5loY4n6CUGHliIq8=; b=pRor1q8SRKaCmLnOVZNeSFcpb831gBUqpM/5SN5S8sTrLb6geGAcn96+S81ssFm+Gg ubk6xtcJwPGRlYrLaf5tnMdQk5wd8bertGA6mQlkbB1WXF03jCZJq27j9DUnLZBuV91v VHTuiC7yOSLUPJXHS+lsx0x1EOepS/IR/ri1Z0KaIymFeCAtGji5T1cvo//wfbETzbFc TDRLo3fYFu7RzCPuzrGxXc+8XHjcxmqpQfj1D57HVpCNJOVKPBnMG8msL+ByNa7+ehrK obx7hf45TdUeTYa+KhG1oUkGQFHQFh/MiwTlUPj68MDCJMDzPHxbFB+m1DxVH3AxPO+6 MGOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FeW6gnbR; 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 i5si8204825pgn.243.2018.12.01.07.53.33; Sat, 01 Dec 2018 07:53:33 -0800 (PST) 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=FeW6gnbR; 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 S1727440AbeLBDGU (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:20 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45469 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727379AbeLBDGT (ORCPT ); Sat, 1 Dec 2018 22:06:19 -0500 Received: by mail-lj1-f193.google.com with SMTP id s5-v6so7617268ljd.12 for ; Sat, 01 Dec 2018 07:53:29 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=6Lls7K5eWZynQmqU5NrZXBxowzW5loY4n6CUGHliIq8=; b=FeW6gnbRXbyaMhFsZRlumaUdm7FLVYSMd/t1qOlZIaTIy/2g1u5mGlgMnAdzWfabOY GIiDVg3frCCe80lRDrECMG3kgcvqoxIaMqax9RcJKTq2EOKR5uYt1zUWtUkhNcGmTvb0 XpHGcT7rsJo0bbfB0bQnOJLWQFY7FCGjH3hd0= 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:mime-version:content-transfer-encoding; bh=6Lls7K5eWZynQmqU5NrZXBxowzW5loY4n6CUGHliIq8=; b=FDyXupEqNZsFQ0Hi+6lqdqZ48iFhTlCkZDyX0WDaibR3c3Nfq6XX9CN6Q4eDHIXJAZ XR8O4wX6DmC0KTM/sLfBtQODFWPUu29j79IuvVVqZa9LAPN6B7U4nIJ2IlZ6F7a/3gip ecns/Dh3fK5h9RIo4vnhTlnmNh+LMJyQO/1qV/8Ee3t4sBI12xXdcBcQNczeYjH3Zp2f OhzsyDZFU7Tx8OvlxIORhgQYHZ6MO8yEnJEoQ+MUfi8jfun6ktcKRaKazWTymXXP8cJe 5SLr06ZVT1KcrHyhtH+j/M+a34/krCRjqQzkCdE5fixsrbbU+v26HJBtehAl4ToOXBDY uQOA== X-Gm-Message-State: AA+aEWa4kwKftchjCiDUnUZdUi8YrNRqfEGeqMr66Pa4fpIIjKGEy2g5 iNuhZztiXbXSbRaGIWBklmEsNKGdkID2mw== X-Received: by 2002:a2e:8546:: with SMTP id u6-v6mr6163700ljj.95.1543679609033; Sat, 01 Dec 2018 07:53:29 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:28 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 13/13 v2] regulator: s2mps11: Hand over GPIO to regulator core Date: Sat, 1 Dec 2018 16:41:51 +0100 Message-Id: <20181201154151.14890-14-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The GPIO descriptors used by the S2MPS11 driver are retrieved during probe() and it is really helpful to have those under devres management because of all the errorpaths in the intialization. Using the new dev_gpiod_unhinge() call we can remove the devres management of the descriptor right before handing it over to the regulators core. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - New patch handling this drivers GPIO descriptors properly. --- drivers/regulator/s2mps11.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 2.19.1 diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 63e66f485cc0..ee4a23ab0663 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -1178,7 +1178,12 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.of_node = rdata[i].of_node; } config.ena_gpiod = s2mps11->ext_control_gpiod[i]; - + /* + * Hand the GPIO descriptor management over to the regulator + * core, remove it from devres management. + */ + if (config.ena_gpiod) + devm_gpiod_unhinge(&pdev->dev, config.ena_gpiod); regulator = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(regulator)) {