From patchwork Wed Dec 5 12:47:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152890 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255591ljp; Wed, 5 Dec 2018 04:47:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/V3c86rmGwQiOoSGPc7yijKwP+3YiL/7u9C5J78Fv2ArIhu825nBHht5RjBqW2PXIvjPBb0 X-Received: by 2002:a17:902:d806:: with SMTP id a6mr23139308plz.172.1544014057445; Wed, 05 Dec 2018 04:47:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014057; cv=none; d=google.com; s=arc-20160816; b=D4Gxx8FSLzY5t5yRqmcTm1z03gz2lWZgEIEhpesnFH5LUvwcAGvhpzWZCAOC3aMI8x bu+WPgcROQKmm4zScTZizK1ISYGl/O9NiVqs1IyqsfAdNsNXlsCuNWDnV44GyyQ/R+7u Vam7CWtV+jVojZkY72iUfTve6NPOB9GKtZmfFHA7s20oZ9Mkv9T3DqFS6tBVZr5u+zqM 3SJCC225OcoJq9KdmsrwJmRrl2h/h0fmfdTUiKeXv/QNfcHQwyH5B6wZ2Y54dmX+n41g ES1xfMhZRZk3DHjLNiXWR02vtz4cIy8rIdygFYXJg2EaxqzNvjAVD6fbThAbN7JcxGlP C2eg== 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=A4nDgU+7Qud5q5NA5TQ6/b4Bwy+ewSh5xeh7X5HZgf0=; b=s0KK2mJ66vg2J6/TMbru9UHC+lqDEXN9oMVKXfhIIGaFl21LmS7AUY+U+s63uldPvf WsZA2fbqSlDZYliOrjG8EvI/3M+/ju5yGrjAeAqhFismEsg0EpCoaeIB0xGcBTU8fCh0 D25wnQ6lhQRpqsg/bQRdR3nh//bAicNFobfKaRaXHhIDR8R2yrr72EFjXkM63vJh019n xQ1PYL9YON+WY+MTwuYDC4x93e94tmLmawMKOu9XLRnwpG0hNOQWwuTBvDPl5d+momGI Xu7WhJtUh+Dofq7GHQ6cj9SYmm7gvrPUeKIVn/ChQcPKtUMgDGdu6tsiQSBycChFK2sQ Q5wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NahVgoXu; 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 o3si17730638pgi.388.2018.12.05.04.47.37; Wed, 05 Dec 2018 04:47:37 -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=NahVgoXu; 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 S1727828AbeLEMrg (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:36 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39748 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbeLEMre (ORCPT ); Wed, 5 Dec 2018 07:47:34 -0500 Received: by mail-lj1-f195.google.com with SMTP id t9-v6so18186652ljh.6 for ; Wed, 05 Dec 2018 04:47:32 -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=A4nDgU+7Qud5q5NA5TQ6/b4Bwy+ewSh5xeh7X5HZgf0=; b=NahVgoXu8syEOm7l2/ydfZxU8zJa+ZkG+qgq5mXGJdihaYumr+04Y/ptkVAzrCsGyA BIo4dWjegzgiMXJGC4i7zz7t5KmKRRU6T1sJRc4gGukbdy7+fRW/d6wBrM5PaIX5t3+F Erdne9uWUVQnh24nyFmPvumM0ezY2GmDCQ6HI= 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=A4nDgU+7Qud5q5NA5TQ6/b4Bwy+ewSh5xeh7X5HZgf0=; b=lNKKA8j2oPdRNpPqQjJK9EKbC4AmYzN3jBKHLn1D4+Qdw+8wN5vA9IJWszgs39YZeD r3lx/I2KnNYwzhmkl8208VfGmIAoZ9kIMwVGa9SF2xGxRzyflucgxrnJcnwlKDIgIMgd 2/YpRYdzAvPPKdGfEBrbfM7IYKUCDIY9sRbPrYDOIahi9RfSd5s39jBCRzXZ+Zrj64U3 ijAsXkQ2i5XW8X26OgV0euG4ZLNx2vbjwA7YUOloovdd0DdrSgbg2mzQlP1VigZ/tMzc elfJmcqghZ1moGagHLXH/YNywwnwyQibBoEyhPaDYB8qKpACFBI7RUyZxRQ7ScKMMh4m GiTA== X-Gm-Message-State: AA+aEWZGM7zI2MCjKQWLMwp5VJYJ4SC0jZZxm4IYVMrSwdGMaaKnSINb 8+PwBgwTR/WuZy/IMEAMtiJlCg== X-Received: by 2002:a2e:5d12:: with SMTP id r18-v6mr17136640ljb.89.1544014051150; Wed, 05 Dec 2018 04:47:31 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:29 -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/15 v3] regulator: core: Track dangling GPIO descriptors Date: Wed, 5 Dec 2018 13:47:07 +0100 Message-Id: <20181205124721.26624-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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->v3: - Resending. 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.2 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 Wed Dec 5 12:47:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152904 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9256684ljp; Wed, 5 Dec 2018 04:48:51 -0800 (PST) X-Google-Smtp-Source: AFSGD/V2i5qwvf8Q2HIiiN0ldw6mX+AIRqZEPkyaUgI7w16zobg3fBOQ3fyp7xvmM7DP25rBMtKy X-Received: by 2002:a63:1e56:: with SMTP id p22mr10443684pgm.126.1544014131277; Wed, 05 Dec 2018 04:48:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014131; cv=none; d=google.com; s=arc-20160816; b=QqWed14PL8w7ekql9Nsndaj5AzIRb4kHCo6WUM2LC7+5X9gnUAPx9nAq1kYKtVWxod YJ8733h4zeIWFeI9JGfPAnbZQtPJd/Fc18/qJ5bBUeRS3EH8lgqhbuWPahcJzk/6skZT 989+UdCfiTQLw5dMTflOedCgN+omIUpPsgxiSxB3m/6ioa3NIdLK+IT2DnBeXNlN8ihx jPi3oZdt7aHSPJtR+GWEeWs8eQ0luq/7VX+kisuwB+TffbrbtRUhIgP0mTI1N6Q2rvWp UtXGlaudCTNRFO0+TOl7A4Gqo1sFwoGVIIg77DoPNQmBq8ROfFYCBgrvjZ78cmDgoEsa QvGA== 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=O/tSaH5O7cNIBaIVmHZFPw2uq5T69lxPBmIyOOIA2ik=; b=xm2zqH9Jb6FBid2TdR2AmILtCPmRmh1B9Hk+pHI6jy0DHy4DXhM9aewWF4tg5NiCFq 9ju7E68rl8GNpWExZeOsU021rUFZDI9j9z2tlpm/dlmaC39aQHJZ8eQTYHZuQNOHXKt+ Ior7+z8ssU0rZY6sCvRM/56RlHMUXFgh/binrCouKa/es1IfyidNdj8miv/Tn7R+EMYF cNXbMnkpqqLkcrUF2XFo/CikXuSujwQ/bQTU4TKcWFs4t3T5Sw2mObPlWWKFDM5UuF7f Lx13o2I25QY+46GlE3u+A3zpxlRgstTdl2TLBXh8ooeDdbtGksxalzXki1cdBvzpfCUx w3+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WBImvxxn; 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 b124si20109893pfg.47.2018.12.05.04.48.50; Wed, 05 Dec 2018 04:48:51 -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=WBImvxxn; 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 S1728070AbeLEMst (ORCPT + 31 others); Wed, 5 Dec 2018 07:48:49 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39944 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbeLEMrf (ORCPT ); Wed, 5 Dec 2018 07:47:35 -0500 Received: by mail-lj1-f195.google.com with SMTP id n18-v6so18208205lji.7 for ; Wed, 05 Dec 2018 04:47:34 -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=O/tSaH5O7cNIBaIVmHZFPw2uq5T69lxPBmIyOOIA2ik=; b=WBImvxxnrLj10G/y4YEWYG2puvBbKj7GH0JoF5G/lDv2wynU9DgaAsouFmDQ5jSwC7 ExweG2i/py0nlbYJTr+ghEqr8MTKmYpk0uufPqZ9Jh06P+ZCYa1nnETFOWRXLtir2D/U mxV0o9VssUFLZp6jmcSuDh34XAml0OnIfp9tE= 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=O/tSaH5O7cNIBaIVmHZFPw2uq5T69lxPBmIyOOIA2ik=; b=M+fPUpaqW4qkz1Sq2Np5K5dxqCbVywKEKNbnLe8hxRUT0cu3I+fhLdGC+V6DpO4QSw SK28SUtFPinh3//vD2uPtSTghyKJVUfbc+K4tmBanVU1MOrlPfK81S6ZQFudv8zF5iZm g3CmsW+ySdwk2JqnU0KfIzC1wlImAefhMrEvD8wHAJYR2i5QIJphnIJNs0Pf2hUhTXMg wNP2i0qbJI6JCEApOZE6IEiNCrS8IaZuJ++ggQq91B+FERB1W6ihWa5hX7ID1gyZ/hvV Vr8GTlq/0Pe8utkGdbvii/KYqIqqo68whfvG563MBAPyY+fAjVT8mJbESLkctjDl1dtS Np+g== X-Gm-Message-State: AA+aEWbwtDXz/qDVnRiBZum+bcgj9+YvlWOz1h+IzRuAoOfgjsUmdAx4 EYcaPHuNXyX/mbiIWoog0vJEYA== X-Received: by 2002:a2e:449c:: with SMTP id b28-v6mr15208124ljf.47.1544014053364; Wed, 05 Dec 2018 04:47:33 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:32 -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/15 v3] regulator: fixed: Let core handle GPIO descriptor Date: Wed, 5 Dec 2018 13:47:08 +0100 Message-Id: <20181205124721.26624-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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 Wed Dec 5 12:47:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152891 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255671ljp; Wed, 5 Dec 2018 04:47:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/U4gYK+j3YhP7/WAIoSizixVLbtpk3OgGinrR54/irQfJmXXddDtGWOqekXnFqQyCZUJULS X-Received: by 2002:a63:374e:: with SMTP id g14mr20747102pgn.59.1544014063085; Wed, 05 Dec 2018 04:47:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014063; cv=none; d=google.com; s=arc-20160816; b=SpXGlF6OJ5VmL4sjeuCuV3A0aV02E0UIN7VkHoT+SJ95WLK8Rqkn52U13VyxLZeMK5 VHSKndRbK0tXW6GBCT9RJDtK2dqk4xUrUYG5N/+7s0iYVgtQKnbcibQmeM3i1LoGZltP bvjGsalGtQ+MoFbiakAkHl3JOhy+FpLF9cTmz4F4Xsi8zEwQqfzcMau5t14QYzGG8qtG MIB0zu4JrcVnBvZ81ZfUqvstzLEhi1h1gggWGo9Uh8Tp5JqX55Apb4EddBXtiqxrxUrU YPM3axdI591hnXRT1kXm4Q1eD6TJGn697gw89OJXdK47H01vPxLMGaRrsPVYVfxdWqp5 ik0g== 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=yYp3S/IRQJmcBgWx8RZhYl171BsROIDwACkCZb3Iuv8=; b=hStDl5QD1QLAyRGIUiYylQGi1KistuUzd2YIuf2nr0ZxH3cnl4Bya2utUadut8sQ+f 7ms3jTa+nogObanlSbuzbZJpuua1B0Q2cA0JXZEZ4uzoE+Am+u8F84v47IA6vNY77TH8 NI+11ne81MqJxaRH51lsPtsM43NWKUdUqtbE8GI+5BtPUHM46zNVUpKfVwL/jKIEzkSt DgnJuxO2pQIMa1YWj85MHFBEptxR4KaIiGmuy+ds/9fqDmVL9LrRfS/dMiGSZ6hvd/lF dtFVoA9gqfd9iEHJ+H8T5qwKVXWNDQJi2YdxrcmvwYAZFtk4KB1kPZWKGEuh75t21Zjq qFlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ma63Pt9B; 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 m19si18583185pls.437.2018.12.05.04.47.42; Wed, 05 Dec 2018 04:47:43 -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=Ma63Pt9B; 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 S1726149AbeLEMrk (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:40 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46134 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbeLEMrh (ORCPT ); Wed, 5 Dec 2018 07:47:37 -0500 Received: by mail-lj1-f195.google.com with SMTP id v15-v6so18174964ljh.13 for ; Wed, 05 Dec 2018 04:47:36 -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=yYp3S/IRQJmcBgWx8RZhYl171BsROIDwACkCZb3Iuv8=; b=Ma63Pt9BEM9ip4CwNsk4DDecTc7sh8LyWBa5bjzjs/mLmRXXUlgqSkEp97IEyzAot5 XZyC0cwZol6hziuA6SHd3eElxXMpxsmT7qrt9YedFlkuFLx04PXkR/N79jCbDrnwF/wJ uCybcGNUAI4X7Asurbz/OLrTaIFKHkiHhFxLo= 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=yYp3S/IRQJmcBgWx8RZhYl171BsROIDwACkCZb3Iuv8=; b=M+7Bn+vVKrHqjGTRsHqWkk2l2BvmgnJCeNQ2PK1DWvf1EwAJl9k198a0Mvul52ZB6j EAqOhzjlagt0HVepkL6jKpsoOyxSney+NfB/jJ+QB9ax4YXytJV7pWXPJCAD3Y+7pgH3 2ydDSHOh+ZNVpj/F9RsxtsqBsARQderdUDfkDB78Namx6nKXXoChYtivCA6ayRwC0wCz k+Okf9FFQuGi+5Sx4KqpHXKyGWLk2LyX6ikz6+oZX9t/6zvzzZdCNFUWSy7bc9WRuBu2 dLyyRHjfHYKvPaq6SReAInl55+GpI8NyxQLWLUK9Kz6eTRaQAop3h8BxqL69HRDEP7rm iVbA== X-Gm-Message-State: AA+aEWbTx9YSh3eZj8ayD5EhPWVFKQS4m5U0UqG6aTV1S3FwYtXXPGyM WzgYwE8mAXy8pdQkKUaOMU44Kg== X-Received: by 2002:a2e:5109:: with SMTP id f9-v6mr4227555ljb.52.1544014055704; Wed, 05 Dec 2018 04:47:35 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:34 -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/15 v3] regulator: lm363x: Let core handle GPIO descriptor Date: Wed, 5 Dec 2018 13:47:09 +0100 Message-Id: <20181205124721.26624-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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 Wed Dec 5 12:47:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152892 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255716ljp; Wed, 5 Dec 2018 04:47:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/XOB66WV7uViU8umTzXi3vSKAKckcjkkHPjxhBTk0sUCGNR+l9zOB9ClE9Bh5MOVrNdrJig X-Received: by 2002:a63:9c1a:: with SMTP id f26mr1787791pge.381.1544014066346; Wed, 05 Dec 2018 04:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014066; cv=none; d=google.com; s=arc-20160816; b=fqCw5A8uUpzAdyp8IVKXYpyOkL9/TTQY0qvBwsRESmX9ittFprFVRsX/RFGx95AHQk qbVRAVEZHrj7BHU1Q2deh08jas4gr7O+bctTA6b8vUV0EDtiuQlmYT8+fMAE/+VSesbf daSO9oAdy5lvgy7sM/MUGg4hYpxtmYZ6hMSvVa8rqg6zCYI2//xYdh2BD8kPixrD2msU tP/88fYPZTD5L7SYhZLRXbiTrY4ABO20zZIABb79VeZxqu5BfOFqs9I9LP1eXM2vUJJw v4QhKWoUoG+UVspNS89GIGMnK5NnrgGKMm3DtCDqN2o1JO76bwmtp4sFq882g4q/OHC2 ZvKQ== 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=mRudiYan1+9SGUqT2YYA3x44wsGQ0MYaQO8d+oaHrpo=; b=FXbLFOeF+k5orx/BgHIBoWxCUDs8GqnEIuc8UwEr7VJArH7++2++h9lf50VBOTtDvb gWv6SmcvoEzMu+i+8wDKHAJPwkpU7ZqR07zOu1EBO6+uwar/0FPl/APCeNcOVvEoE19T npA+ihAWMKXaWXkzHnbNWAC6CQXu52KqwEoO5Ij8w8dylKMlIV7yhExnZw+OVg0Ad7pV CmfEuJZ3unL3M4TJsEm8OM587L4M8qXQtFeLMtb2bnKpQeo0wlhFjsV09LkMv/WJ5Eud UnrbRC3g7QE2uakoBj5X15di6hsdJv+obO6fXb4J9S1iVtOIj+NCdBj258iVR13bSYPC nmyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bk5IIEKI; 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 n5si18372865pgh.422.2018.12.05.04.47.46; Wed, 05 Dec 2018 04:47:46 -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=bk5IIEKI; 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 S1727877AbeLEMro (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:44 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35139 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727838AbeLEMrk (ORCPT ); Wed, 5 Dec 2018 07:47:40 -0500 Received: by mail-lj1-f193.google.com with SMTP id x85-v6so18213188ljb.2 for ; Wed, 05 Dec 2018 04:47:38 -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=mRudiYan1+9SGUqT2YYA3x44wsGQ0MYaQO8d+oaHrpo=; b=bk5IIEKIAvyo3fv7E8AC9gwr+k7nsDv+5+bAtfzoX4iPntU0cCnQrlpAYzyFCdL1lJ s+7IgNHQHSVnlOVS7SRuV2IPPrnBrKOdOlXsKUMbAqE8TwKbaZfvnduHP4b3FFZuuBq4 XK6onBb/yZ9pXTcrQ5zudiHRqqnCNuerc+0KQ= 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=mRudiYan1+9SGUqT2YYA3x44wsGQ0MYaQO8d+oaHrpo=; b=t9enMZ12BZg7ws1wI7DS+tJIj4Zr/ovzL6KwXBIly5FYJqGwFeoImwXWibQpo137Vj i50jgkbhEj8laiDbQA7lWJeAj523AkMCMKbwdhD36K/19MqtVwhhEXe66UCPpHm5CKZj 76Arkt8h/pqnARb6JY0/6wzus+EO1rxRJ8qh9Ug/6PkzehRuJ53QdrvIaTg3NAai+c54 ASyGBdCVscUGGbO+2mW28r73P7rE6D+Ve0V+WLCRM3kcDZvx0ZPILqrK3uMMNvvX/SDr HeBYpmBjxX4WQWSSABxqLtij++3XTbmDZcdwtCNf1sRtYwnMphi6F77B/MJzfxEeY0sB VoPA== X-Gm-Message-State: AA+aEWaGZ5rU8Ts7tm7MoUzTdTqI+5sa++oi0RE3Gq4GOMMV0nSWvIgi xH9zLnAfbJkMCZTdceQCSRrDHg== X-Received: by 2002:a2e:97d7:: with SMTP id m23-v6mr3516884ljj.18.1544014058007; Wed, 05 Dec 2018 04:47:38 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:36 -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/15 v3] regulator: lp8788-ldo: Let core handle GPIO descriptor Date: Wed, 5 Dec 2018 13:47:10 +0100 Message-Id: <20181205124721.26624-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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 Wed Dec 5 12:47:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152893 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255768ljp; Wed, 5 Dec 2018 04:47:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/U15ffG+OsPXXz4QF+xcQjDn9doI2eNQnR/5DZA8nhHW4tF39P2EZV0tqak1kU9wQ0JqRzi X-Received: by 2002:a63:a112:: with SMTP id b18mr20519600pgf.440.1544014069394; Wed, 05 Dec 2018 04:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014069; cv=none; d=google.com; s=arc-20160816; b=O8SpRXmjK+IPyfgg6QX5alO8hJGqrgR8iKyFmAJ0x5miXHJvFCQNXsJI1B2MOWxWIV FImr5PvtzPy5jih1pCvY6G1x2QYfqqMsDwFgAHVO/Zl/LOooP46MsTrahx0TdT7+64hM JBTPJ9NoZD9pitrSJYYg6egGd4qzc5A2P3dOuM9ednFIm+kleK2rj93bJvW3YAzzmA1S dut5EFWVUjF3z2xs0jvAVbu2bofMQxLrZid/3CKVNVYLnQ4DuwtqIbBCbMc2tkWDzXVI hrg6U7ekNoW+enRj0Wh7rjvsbRMMDXt3AkPP9vj6iAm1kBZy52hLGCX0g3EZ/MIEZSno 3wFw== 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=43XiVVGq7hH0pR2NpZT+COnrkFVHv9hG501qWIv0FBk=; b=PyXiU1D0bCCTTpUOmvQb6t9rNQHN9+Faz3dgy4/tmufTacfGb9a7MWAluTtZFndg1s Mpp28AA7iAqcozFJ8cJWb5Yc7yO+F6cUcTTlTWMcujwL51K7fiqDw7JrxZwWDnBrlhvW QGLqcfyEyB2GJsRVcE/1eKuDgAawrq+z1v+sF/bfQfkKWnJw1jQfIh+BUvuwrzsO2Rg1 qW7fJ2rD29clHKlR40h+DVEcquqe76OlbXvQmxfr1l5CtOSofL0fEB+OPghxIw/y2AOv XLop48RCpa4o7jinEQHKw2O6VNFvW/QOTFxlT4jSGAQtKRNolP9bsNv/zc1R4GjebDDy oCIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="cX+K3/4T"; 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 f189si20077559pfg.123.2018.12.05.04.47.49; Wed, 05 Dec 2018 04:47:49 -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="cX+K3/4T"; 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 S1727900AbeLEMrr (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:47 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35142 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbeLEMrm (ORCPT ); Wed, 5 Dec 2018 07:47:42 -0500 Received: by mail-lj1-f194.google.com with SMTP id x85-v6so18213272ljb.2 for ; Wed, 05 Dec 2018 04:47:40 -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=43XiVVGq7hH0pR2NpZT+COnrkFVHv9hG501qWIv0FBk=; b=cX+K3/4THGL5LL0BH8gNtw1VVzI0md6/Rf7zvQ0RAs9iIWIUsKKMFJwGGO84b/jS1i wPTr5cq2UpZWvpN3BYacjvb1/ed/Ds4rVGQcwb0ws7o90U2Rin+AKHtspv9FcvV81vpu JxJhOW5TNBVZe2kpzhaQ9g/ZZkS8EgE2KHXVs= 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=43XiVVGq7hH0pR2NpZT+COnrkFVHv9hG501qWIv0FBk=; b=d+oyEgKC7idklR17mW2RXAPbZyix0NqAOV9NFPxi1+ojDQc3zOxvrcVnxlZ8c0UHfg NxOWvyXdoDQcbkltYwWFHw45WkKG5p9H2MFsBhqqaHFq3eIMxmKV57Mi6CIYhz5Ogufp PCPn49M9gQNR8LqG34wvdYbfIzZxxMW08ZneCqRVetR521gXpUHfElYXhwk60Rvl+9MO UoE9Uz4GbI3bo+oeaA6F0bsXOQw2IuSGrxw63NaAAnFEKqJim0n4AKDHm/22YmQBoezm yavNGWhrqo9IBejJRT7TsSu5WsEqw20R0Jlju7wCKwvkNmclQ5slNi7dXy0zsdY59b+w GF1g== X-Gm-Message-State: AA+aEWZCFS/NPUa7J4kS80JWGXVakYbAXuTAB0kHpD+p35pcm/EDkLna 2m4RdQmnmvwYsiiHOIrCEVJXkw== X-Received: by 2002:a2e:5c86:: with SMTP id q128-v6mr4269476ljb.119.1544014059957; Wed, 05 Dec 2018 04:47:39 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:38 -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/15 v3] regulator: max8952: Let core handle GPIO descriptor Date: Wed, 5 Dec 2018 13:47:11 +0100 Message-Id: <20181205124721.26624-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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 Wed Dec 5 12:47:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152903 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9256545ljp; Wed, 5 Dec 2018 04:48:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/WYz4q/WRgoVJ5jMpWXTKfsSmZ92+x+vVpST7543TFDG8Pm3JnI+VSuvf5gfuhUxr6VTb49 X-Received: by 2002:a17:902:850c:: with SMTP id bj12mr23657751plb.46.1544014120510; Wed, 05 Dec 2018 04:48:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014120; cv=none; d=google.com; s=arc-20160816; b=yoygF3rKD6uMfEvZpissMwbl0h9rfMKX04uZ+Hi3omWpWpshvSvnICquso7hULEuZg fSX9a72fduX/XwCwa4mlWWA6N2wAPxZVmk0xCp8M7tnZW74CnJsb+IwMA5qWp3zZD41t 3sa1oc3OB20vNz7OjlFE/yOHdmYAhYSPAEJ9DMKVzwss+JJUV5ow//egT0nmne9qDhIO qkJSUaYZAJZVkBrdIFfMR0AAYb05/roMfXiB2K2WHTO72Z8VaNxBFDm6pB54zbTOrQaF HPgYYAqstTRRKEGM5RMaZg0MY7ZQ7UO3O4B0M5wJEKMLT3b/iojU1KqJ1w/jyBokPXrv /+3Q== 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=0XQGPplmAxsoD4Fqk/HW1LiiDkGUJY5wCq//IJHDs0c=; b=tyV8YPmGkD4oGW909je6I2zMOnnmEI0q1PBiIhZhXOrxTe8plfMAp+0chhgIpkThIk dA62YpFGsF4+w+vm+GZQ2i6gDmxL2EhFWlH1hEvqtocZvrR/xy+y6f/M18TufmraeWk1 IVHQ4lFugMBiVVDem/ix4rt04DuJ/nG/cUXV2VtTcPZIo7sDb4Ps2PUJ1IqwKzhxMKts 8tTSPK5zwf2bz+PgBiQgfDYvuzFre/2BWClbXigblRRkuP/GQSsIACjJ9YAdISYZ8PZe 5KIooZ3JzWbsamivga4BaSEld3w6dP6sIKq7dAzfG8mPYmBGtgxUNKySYYgrP3WnuJxT B37A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kfmHo1KO; 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 b4si16345958pgk.350.2018.12.05.04.48.40; Wed, 05 Dec 2018 04:48:40 -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=kfmHo1KO; 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 S1728059AbeLEMsj (ORCPT + 31 others); Wed, 5 Dec 2018 07:48:39 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34801 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbeLEMro (ORCPT ); Wed, 5 Dec 2018 07:47:44 -0500 Received: by mail-lj1-f195.google.com with SMTP id u6-v6so18207050ljd.1 for ; Wed, 05 Dec 2018 04:47:42 -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=0XQGPplmAxsoD4Fqk/HW1LiiDkGUJY5wCq//IJHDs0c=; b=kfmHo1KOzEnmzFEOh7qMnVB3y5geh2cSYRas9Pmgq/F00yi299pjmRKr4F0hBms4JA UJmId8NqwaV9zdbaPckLglKvZwfumXUP79dA6WfrmpXkWJS0Xks06+//Y8aEzDdeouRP d9UkzZdjHGQ7YyuLSc0EMKcEussauxs+s1YmQ= 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=0XQGPplmAxsoD4Fqk/HW1LiiDkGUJY5wCq//IJHDs0c=; b=qVQrgwIeEjyCbnuzBZJA5BvybJy8kWKzINwB9boAN3zGNxf1DM+mkhma1T8rjvOyba DkUdLmWfIpYRp2AS8Yl1SFKkdQ7EFecPnhEOkzCRB8aWS8xPdV1E8sVbKQNMQoSn0bg8 xORbKhliQBO6kIiUnZhP1XaNvxn+jh7EI8GAMjOYsJY0lUrTyn2sT2aMevasjchnS6Kp MAFp/C970cuOHjm8KFEs1kcGHRNB2tuPaFle60GA9Rk7uAsVXWBFR+MsPSAGL5MgCBT/ l4GEPHpeqf2YTFNWWtyU9qE1TgRjZJ/B+tPO4raZZL9TmiGbLEjwmHApgliqM0QFLqMM P5qA== X-Gm-Message-State: AA+aEWaa64lHxLs0fAu+3GVFBsSChlZl/pjjAzuWOLNjfl5zAXpcEVkf 3HWlfT5dkNdc2/UsoOcBo6ADmw== X-Received: by 2002:a2e:9d86:: with SMTP id c6-v6mr15235740ljj.146.1544014062231; Wed, 05 Dec 2018 04:47:42 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:41 -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/15 v3] regulator: max8973: Let core handle GPIO descriptor Date: Wed, 5 Dec 2018 13:47:12 +0100 Message-Id: <20181205124721.26624-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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 Wed Dec 5 12:47:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152902 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9256469ljp; Wed, 5 Dec 2018 04:48:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/VH5ilW5dWtM3CXi0jFLaE19rds83fDAo/KVFCnL4CytnUV/sDscIBEKhoYIua+spmRQIT5 X-Received: by 2002:a63:77ce:: with SMTP id s197mr20244732pgc.89.1544014115553; Wed, 05 Dec 2018 04:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014115; cv=none; d=google.com; s=arc-20160816; b=LhGQkN84VA5tiXC/0N2PiQMVHk3Hd7AdpYLrdRCltMyMye+w9orZK1YOJI8z78+dsV tmwaAnKainF71awsaArpnFiqQX7+vsqcUr33MTsFKhtZSDt/iOTYpOWxW0qSQRRsKgTa nMYisGL5pm/F7kFFBbAibDYTck5hkrb/i1tBFwawrBsShI/V0zbhWw/NletuBnfvF91a sOLWjwAw4WCC83WWUXxQfdIGNGUFgWG5pbedWn51EorgcDzlxtDcULE4iy7Sp4oUDf1a meo+tYdu7eOmwOBx8FDy2jbs4L77GB87XIAvoPfTJga2eoEApcjdNqnMMhFrdM2tvmIX 8A2w== 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=wc1j/0Qq8o4SJIOdzJVRjBHOW+PSsZdnGaM6qp9lzlo=; b=ZxhVAT4+B4KF/c9VjxqttGCljb7Z22ULabuaIC75MhWb1P2Z0ID1AB9d8LzlGdHUzQ yv2dxs6+LVOK7BCGBF8UmLP8ife6IJvRpGrw/GklGm/2Uy1iphqAPBcJN6yjPhuPyRDx GTOPLAS58auV+hjvjs/2Ye3XjWDTd5vhisksqBRXPyYqF9QjuJc1xK+E/c4hziDWlxBE duhfEZIFwqjwyM0QoyMaqRUXtk30PtrxysRe9U4vk+QQZLOCv3vQFIDJBkQ8qf22pzu9 FzlA40qNHU/JPyve3Vx1J8lmewQGqsVvphaFRxrfBIaRCaXox3MKnx/NI0Rwc+lKSlx2 62yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HK7+AjO8; 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 b4si16345958pgk.350.2018.12.05.04.48.35; Wed, 05 Dec 2018 04:48:35 -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=HK7+AjO8; 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 S1728044AbeLEMsd (ORCPT + 31 others); Wed, 5 Dec 2018 07:48:33 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42162 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727884AbeLEMrq (ORCPT ); Wed, 5 Dec 2018 07:47:46 -0500 Received: by mail-lj1-f195.google.com with SMTP id l15-v6so18197207lja.9 for ; Wed, 05 Dec 2018 04:47:44 -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=wc1j/0Qq8o4SJIOdzJVRjBHOW+PSsZdnGaM6qp9lzlo=; b=HK7+AjO8+Q+QJM1J2np4NUI70PHgLQmmlqMs/rhoNn7mW6teTjDBtS92DmX3SyNjJ+ eUSK3tUSLMVH8f/K3SNllbphg0r7+rwhP921052TwI+xUvJBMF4EBcjiQU6uaSUG59mu kRc+MHSiYcVys8DWVOCD9rg14vbp/L7Fz7o6Q= 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=wc1j/0Qq8o4SJIOdzJVRjBHOW+PSsZdnGaM6qp9lzlo=; b=q9RrgBzK3u/PptOgpbw8YQ+LbyyT6JSb3jPwbufqqrFklVZsRWSqNg9mZD3ksTLvPK YiQmw/6/syJjzeGu64sJaW04BZiIYt7i4u/Knsh3pbRt3HM3BC6WYlo/s2HGeVCnAt8N kUlEsnTkvvBQxLD96zyLZ/jmsEcoucsfbczOuMRkO5S5fRBgy1Hv5o3MKQX8KhHkyhWj /YeZiYvbU82N00bSXF8Yppqg019BW0hy47kTFfwOKv93A/Zg8DzRowfTj70NVvolgF2X wfMhgznHzqnpgeU84anuCGjOKq59/gMpSAyG6gTjtlctPccakHjR9iolheuQVVri+Abt qCdw== X-Gm-Message-State: AA+aEWbKq20YJapFxWrGCtMNe7il2BnqhjBWN2vl5s1kLTtGmffyzX2V ZlSpKKRqOPIDy33pMHLv7mWYHA== X-Received: by 2002:a2e:5054:: with SMTP id v20-v6mr15366401ljd.45.1544014064091; Wed, 05 Dec 2018 04:47:44 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:43 -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/15 v3] gpio: Export gpiod_get_from_of_node() Date: Wed, 5 Dec 2018 13:47:13 +0100 Message-Id: <20181205124721.26624-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. ChangeLog v1->v2: - Resending --- drivers/gpio/gpiolib.h | 6 ------ include/linux/gpio/consumer.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) -- 2.19.2 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 Wed Dec 5 12:47:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152894 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255810ljp; Wed, 5 Dec 2018 04:47:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/UtT7oTY4DYBarxizamRdZb7c+r0F8WCLfY6S0Or3I9KYIMsK4x8ngB2Z3kad5CB4Z3A1wN X-Received: by 2002:a63:e5c:: with SMTP id 28mr7756323pgo.369.1544014073111; Wed, 05 Dec 2018 04:47:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014073; cv=none; d=google.com; s=arc-20160816; b=v1YTbrvL5DlGYJdQyKPjx/2HC5FpSYNTjQmAa2KgLf79RxQvf2dQVu/eh2/4U5mESh Ov+2DPp6Amh2zeUOQ0dYdLG/VyY+yBtbv7PntCXCJ3eDOtrZLNJXUbbfMeqL4Xs1/9HR IY19RK1fUfVfmnkDWdf4NFNamHDUbpraM1fmOrCz1dNzSpb53DclLEy115TU6R/sX00o o6YZMir6q/4nXgk+MtBQ8TtlWDDzlwCL3ZiIK51tghjleEWOt0xJEnu3Hwhsfy8VA/8m cnxlQd+5gHgbiphyJmYG8DBfWBcRC1pBE61A2IpYbpze48F07zkuRfwUdi9y9k+PUcI0 noyw== 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=qTwEgaJuHML2/WugrEbTAW9s/jIgwlSTFOzt/GYbDJk=; b=y4XXbw/JRQHZh75sqsxcJWpiB85mo7EftY1ZZEfRRT8N3sQLv+3DL13NLoDljYtsRI ImGhbQPwmUfj1gVnIu9LZ2onNwR32JeRUAo0oX/8FedriIX6APk//Ch/SFElVu801Q/N oYjQOLZiyG9f/OZotnDsn32HlxE4+hJLzMlsGFJ07MKGTaPbHt4AtO09zdj9qBcUilFL HnL2qTgiSR+M1quxkHGyq9Y3gspiHCpwRuEW3iP099uRPejN4xlqtQpAQHSBcA/YfKy3 hI3JowiSZYnp7aC9s9dqZHWJOTi42H82/RxWfQCYoePb+Yy1v2jZisWviejRY/p9FcqT Q+lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ScvXDerd; 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 184si18679578pgj.329.2018.12.05.04.47.52; Wed, 05 Dec 2018 04:47:53 -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=ScvXDerd; 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 S1727921AbeLEMrv (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:51 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35150 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727898AbeLEMrs (ORCPT ); Wed, 5 Dec 2018 07:47:48 -0500 Received: by mail-lj1-f195.google.com with SMTP id x85-v6so18213586ljb.2 for ; Wed, 05 Dec 2018 04:47:47 -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=qTwEgaJuHML2/WugrEbTAW9s/jIgwlSTFOzt/GYbDJk=; b=ScvXDerd9AjqpSTtybMjmLDBmrN/dJTK4LZtUTVLDI8K/hsBSik/8My7fIAhAB0JpM CY2z6RfbQsonquJTdfMp7uO+zPewcW1EaZrYBjm4XvcdIkurSp1KKLQrZ9iAcQmP6KJi H7xa3mbRBhl1eCYurlEPEGzjRcBl00fKqTI4Y= 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=qTwEgaJuHML2/WugrEbTAW9s/jIgwlSTFOzt/GYbDJk=; b=BGBhNdJ82CbohbNfizrYni/Tcn0qPdpDOoiz2B5+7wItiWRTMK+jWgPeW2VM4PK5mf y0MiS+9Qkkq0dn+BL0Di9R518W+8Zj6iMVNdnkCqg9Bg72Aqxglx+16F5TpqCcurhD3A 5yYzWORyhbxOFsxeua5IZGVXt0gfuVOLqXSDwHYDliFMWUllI44bCLYVEzyaXfY0sDjC NiIUZmHGctk4O1CGITQjxQbFY+fP7EiznJWvd/31dfmjZ4NIDbsFufNj7S6dJoKYGerv JtusmuaXV5eU9nbRoVW7TF8qzmyynp/LUDjMIfZeqhDKwQbTKerh/9jU9DA9NMVW1ht4 mpLw== X-Gm-Message-State: AA+aEWbXVFqZsAsUoPbwmiR74QpFKOCJxl6UxabWP6BVtEyWhF6Qrc0L mCQ8aWTERxO43NsO8U4apTciJg== X-Received: by 2002:a2e:9dcb:: with SMTP id x11-v6mr17299442ljj.158.1544014066335; Wed, 05 Dec 2018 04:47:46 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:45 -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/15 v3] regulator: max77686: Let core handle GPIO descriptor Date: Wed, 5 Dec 2018 13:47:14 +0100 Message-Id: <20181205124721.26624-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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 Wed Dec 5 12:47:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152896 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255924ljp; Wed, 5 Dec 2018 04:47:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/W69/Ft5YHqObU6N/NMasn1mwtYivxLYbNCO/OSFONZYaWNTTXxlibKdfGwJbpldglu3c4s X-Received: by 2002:a63:561b:: with SMTP id k27mr20354277pgb.271.1544014079041; Wed, 05 Dec 2018 04:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014079; cv=none; d=google.com; s=arc-20160816; b=Qkkay6u0BGOYQrP8H8QBNY+SJDe7tF5jBMdXleT8l+WbdSJofsHT7P5vLs9f32aRHg WaNfYMVedDRNt4ACRHsvKnCI/aVhl3oy3rGQyc55GwnY3kauVg4Fs/+swg0trIGBf+gq BHuQB5E5O9KlwIp+L1+TEqAbQts+QMefV6D9gf7ebxStaHozuT7L/kuoqaVBuijNblC1 c0pBgX+OHc2Rz9anbladXq0WPqyopuS8L1aEMae0qR04crggH2epV9+xR9Z6BehTbgbD nbrbkmItQZ1LJ0g+c3UVAyuLxDvWvuYS41mOq7fWZgU3Rg0/h9KlXc6PABUZH1IfrFbe 4uug== 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=1OGUaW4HLWctMtQHrwOTqPJRU9A2u+9w8AwyRoL6A9Q=; b=xX5ixId4eNOccBE2k4FV7iPlmalD77A681IpFSttWXXnPvs9gipwSrw/8UbYq1tCn7 PW+04tweEbeAg5ygzg1sN4BVHr39/sgom+oWnK70y+qqMwACaYQTcqkHKqLm13yg3qf2 9cTNBVYiYwekjXayzKxKdmJN4MkSEfORvFFKV0HwvLtiyJyuhNzVPCgv78/4k9qX9dmi QWgEwDztG15xT1tAUivw3DI728ypPC9atdJ8O9ILDxMMdN4K5ykYfjAVYqv5+LQctwSR 8a2L/CFXOiVnIIh0Q59jRA+5nXycfGdrjlcBRGR6P6VeG3Wpg4qf+JoExolQV3EbLO55 wBaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kk2RKmpx; 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 n4si18996509pgd.10.2018.12.05.04.47.58; Wed, 05 Dec 2018 04:47:59 -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=kk2RKmpx; 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 S1727956AbeLEMr4 (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:56 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:36129 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbeLEMru (ORCPT ); Wed, 5 Dec 2018 07:47:50 -0500 Received: by mail-lj1-f196.google.com with SMTP id g11-v6so18205769ljk.3 for ; Wed, 05 Dec 2018 04:47:48 -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=1OGUaW4HLWctMtQHrwOTqPJRU9A2u+9w8AwyRoL6A9Q=; b=kk2RKmpxsDFy9cCP5k5caiGO9Qhtr1lHPXPRw8dCeOcUUm62UcM3SP3Bl6qtbvzZKP cVwO+w7JMLMh+HJSUznc+UBCbw6P+TIF5x4K52zB/XmvK2mbok1Xq+lGWlXx4/fc/j1a Z/Z0W8QfRHJx0H7XnqxEH8BAsRA/QF3+OuBLM= 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=1OGUaW4HLWctMtQHrwOTqPJRU9A2u+9w8AwyRoL6A9Q=; b=eKusSEeU1i2K04/IgyRD1s/BhUKd4f2PtuwnFSCDdcIrpsrDiw9MtGpaZCBuEdOImJ SmbzEZ92GkvAY6LCfxiXK9zJ/b1ijf+H3+eG1NWoH1vXmFNhEzBfF08+bkRKacAC70ru 9r5y0nKCn/70C8wCXSSQ9E1PxB37fd31suW2YG6y/1DcyF1jCyYqF3P7eGmKWa6SbAUf rdJt7xAjW26oFAf0P2Guku2dPZwR2g5Xy7fronxopZLSqjrxhb9jRY5YaCNj01GLx4IO U8lYSMHHLmTHjHDWFb7haCJF+7o90HP7E+y4FUyfb6Okh2PwgHgjAl7DRhtMPTMfppv4 UgSQ== X-Gm-Message-State: AA+aEWaz/pNGs+U08quwUUVXO3NcLC2809qGnsoj/5+TlXvtcS7GX5if 2e6VIPd6OPk/qe8wI23+ygri8+KgpQNs1w== X-Received: by 2002:a2e:914b:: with SMTP id q11-v6mr15122517ljg.164.1544014068137; Wed, 05 Dec 2018 04:47:48 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:47 -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/15 v3] gpio: Enable nonexclusive gpiods from DT nodes Date: Wed, 5 Dec 2018 13:47:15 +0100 Message-Id: <20181205124721.26624-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 makes gpiod_get_from_of_node() respect the GPIOD_FLAGS_BIT_NONEXCLUSIVE flag which is especially nice when getting regulator GPIOs right out of device tree nodes. Cc: Mark Brown Cc: Bartosz Golaszewski Cc: Marek Szyprowski Suggested-by: Marek Szyprowski Fixes: b0ce7b29bfcd ("regulator/gpio: Allow nonexclusive GPIO access") Signed-off-by: Linus Walleij --- ChangeLog v1->v3: - New patch after Marek's review. --- drivers/gpio/gpiolib.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.19.2 diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 230e41562462..a7e3fd512e2d 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -4204,6 +4204,8 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, transitory = flags & OF_GPIO_TRANSITORY; ret = gpiod_request(desc, label); + if (ret == -EBUSY && (flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE)) + return desc; if (ret) return ERR_PTR(ret); From patchwork Wed Dec 5 12:47:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152895 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255867ljp; Wed, 5 Dec 2018 04:47:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQP9/EckzwQmboX72RCslMF8Q8ITA3FK9pUEyjKN7p4CCBx7/2n7qNJAb6QVq/x5hYcdW+ X-Received: by 2002:a17:902:3f81:: with SMTP id a1mr15420324pld.258.1544014076438; Wed, 05 Dec 2018 04:47:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014076; cv=none; d=google.com; s=arc-20160816; b=K3rhRI0H6O2u+ECAZmg7z0RQ5h/DINjcnTVQ9hJGZipUFHNnpoY+Nv/H5RI4XyoqCe NOg1REuEvMjovk0VxRmj2d2VhbAPT4ktxG5PLECTKsqvrlBON6P2hmEU6/iJU/8SgZiu JuJMWfVc7YknTgyCFdjKtcZMn/JRBzvdHum2DY19ZKAZ5MpSTb2lx8BK8MZsk478Une1 3OUIGtRa7XbnHGSl+K8puSHukhBu38/VPyHGhbUt1AtAOlYMmUAzayy0UN2GolNhIs6q odlg656nbpPt/vqaKmJlmDJ3W0Bhg49a2UqaVBofSjX4Uj4tf3NGJfBo7OVXa4xxwYvO T3bQ== 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=Aih5LvsfvsMhYdIrSkgjVM1Zlxek03AkpQ3jJn8pr8c=; b=Rc5uJpgr+pWwRSalBKjURe1TN+th37G6rKw3E8Di/S5N2UIGsUbqkWUze+czd8fpq8 gh6uXRp/L99/Lo24Y5yLSP8WbG2JiqOYU8LjN6/jz455U+D5wDJJPqsVOLtKa6uLDdoU 4rPWQcf3l1N9+i+tvRa6V6fefiin/uKIK4PLIUxBysvG/BHtJ+3i7MPhWAF5zNqfq/rm blfG8d9R7nkTHrHMfj5tK0BBd0n+CLKZtd2yDBqEr67/6ZmNkiQIHvJQWD2H5d2EdpVL KsBOFapdYClw189KTh/D8CEzNT/c1fO0y4CgvvDcL8zjkqSsnLVovXK57+NTlnSSNNvH McbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BD1AsJ0i; 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 184si18679578pgj.329.2018.12.05.04.47.56; Wed, 05 Dec 2018 04:47:56 -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=BD1AsJ0i; 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 S1727935AbeLEMrz (ORCPT + 31 others); Wed, 5 Dec 2018 07:47:55 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:41422 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727919AbeLEMrw (ORCPT ); Wed, 5 Dec 2018 07:47:52 -0500 Received: by mail-lj1-f195.google.com with SMTP id k15-v6so733478ljc.8 for ; Wed, 05 Dec 2018 04:47:50 -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=Aih5LvsfvsMhYdIrSkgjVM1Zlxek03AkpQ3jJn8pr8c=; b=BD1AsJ0i9yE4A7wpFRIL3wjXaEUe0g6haVUi2mrHm3Z55B8q8ppckHHyG69pIT05sB UUgh3hFhqMBxyfLLkYe+Mk/i6ZIg2aPH7MHJYreSuLnT5puXl1xJXPuRNoQJ5EbP6UVc X6Q1zj2gJDY/lyp7B2rPrpSYhU40meZ69fnmI= 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=Aih5LvsfvsMhYdIrSkgjVM1Zlxek03AkpQ3jJn8pr8c=; b=aA9Gr/0VdEEj7by9v4+KJCRNAH4H1h7LxhAiD3/lssDFhildVlnecAVfyrsVvuzXq2 622yC/u7oLc3ViNmEzyaZRNB8QLXW9oFptVnSP7p4y2gYUdEuidFP6C8fZUDrzK3FMOa qBQSOvEejjoUHFSM7ZVhIiYBqjEFZMtSvR40tZRl3tJ8HDMjWftM7zRTdS6sIPqWJ9Ww AyXezxxvXKOWI8r+dhjJQFqH1wpViUyNHW7ZOu19dvSlxfM1XM2eBrw2UggupZHT49An 1hN1dRHwVsILADSx9IT1iFJB6odt9FZ0LldRvNIO3AxakLQG3qOovlhbIIoU9jFaycdr x5NQ== X-Gm-Message-State: AA+aEWbjQlTt3YvYQ8iLkAVNR1Ig2PwhIKY8T5Tfx/kIq11e8d72h51B wFfS0HQFDaJiwHQc6IDbJgO4Sg== X-Received: by 2002:a2e:5703:: with SMTP id l3-v6mr129644ljb.106.1544014070213; Wed, 05 Dec 2018 04:47:50 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:49 -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/15 v3] gpio: devres: Handle nonexclusive GPIOs Date: Wed, 5 Dec 2018 13:47:16 +0100 Message-Id: <20181205124721.26624-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 When we get a nonexeclusive GPIO descriptor using managed resources, we should only add it to the list of managed resources once: on the first user. Augment the devm_gpiod_get_index() and devm_gpiod_get_from_of_node() calls to account for this by checking if the descriptor is already resource managed before we proceed to allocate a new resource management struct. Cc: Mark Brown Cc: Bartosz Golaszewski Cc: Marek Szyprowski Fixes: b0ce7b29bfcd ("regulator/gpio: Allow nonexclusive GPIO access") Reported-by: Marek Szyprowski Signed-off-by: Linus Walleij --- ChangeLog v1->v3: - New patch. - This fix is in response to an issue Marek saw in the fixups for resource-managed GPIO descriptors used with ena_gpiod in the regulator subsystem. - I first thought to apply it to the GPIO tree directly, but since it is not a regression it is better to put it into the regulator tree with the rest of the patches. --- drivers/gpio/gpiolib-devres.c | 50 ++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 12 deletions(-) -- 2.19.2 diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.c index 01959369360b..a57e968025a8 100644 --- a/drivers/gpio/gpiolib-devres.c +++ b/drivers/gpio/gpiolib-devres.c @@ -98,15 +98,28 @@ struct gpio_desc *__must_check devm_gpiod_get_index(struct device *dev, struct gpio_desc **dr; struct gpio_desc *desc; + desc = gpiod_get_index(dev, con_id, idx, flags); + if (IS_ERR(desc)) + return desc; + + /* + * For non-exclusive GPIO descriptors, check if this descriptor is + * already under resource management by this device. + */ + if (flags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) { + struct devres *dres; + + dres = devres_find(dev, devm_gpiod_release, + devm_gpiod_match, desc); + if (dres) + return desc; + } + dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *), GFP_KERNEL); - if (!dr) + if (!dr) { + gpiod_put(desc); return ERR_PTR(-ENOMEM); - - desc = gpiod_get_index(dev, con_id, idx, flags); - if (IS_ERR(desc)) { - devres_free(dr); - return desc; } *dr = desc; @@ -140,15 +153,28 @@ struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, struct gpio_desc **dr; struct gpio_desc *desc; + desc = gpiod_get_from_of_node(node, propname, index, dflags, label); + if (IS_ERR(desc)) + return desc; + + /* + * For non-exclusive GPIO descriptors, check if this descriptor is + * already under resource management by this device. + */ + if (dflags & GPIOD_FLAGS_BIT_NONEXCLUSIVE) { + struct devres *dres; + + dres = devres_find(dev, devm_gpiod_release, + devm_gpiod_match, desc); + if (dres) + return desc; + } + dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *), GFP_KERNEL); - if (!dr) + if (!dr) { + gpiod_put(desc); return ERR_PTR(-ENOMEM); - - desc = gpiod_get_from_of_node(node, propname, index, dflags, label); - if (IS_ERR(desc)) { - devres_free(dr); - return desc; } *dr = desc; From patchwork Wed Dec 5 12:47:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152901 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9256317ljp; Wed, 5 Dec 2018 04:48:24 -0800 (PST) X-Google-Smtp-Source: AFSGD/WpvTse4YSeCRSUBoCyBRUtCvJadSxzAgJMOHEBmS7ancpOXVU0ln3DhbQ33cI2ldb0Qitg X-Received: by 2002:a62:18ce:: with SMTP id 197mr25206926pfy.88.1544014104212; Wed, 05 Dec 2018 04:48:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014104; cv=none; d=google.com; s=arc-20160816; b=vMoSVjZpiPQbf34+/2l6AFS2GRS9zJNXcCy49FF0jcmOzv0T91b4BUwETIXWYoaoGq jGt2i1USne8nT8ce/fklOy47mBRt2pbzTTN3nlhQYuipBPS+PyaXzEmpM19taLv6glBV yXvB+BJG/OZ/XyJQCeJNWX53b2l2B0DGNS1qtyA9EIlLvY2fudG4ndmWYbEY7ylK4oaz DxBpt0/GGk6v0S8X+QqNESpn5CvQlJfyPhuvY17iWDUQR3PVitANO3LUOvGAi1Fy3Gw8 5x8qQk0/etMBLImMb5ZkO3DNf19m1Uc4O0VKCi2YAsMGa+0KmZ3dpJvupW7F9o3hx0Sk WemQ== 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=2AByHMOP3S01NinyElG6HmeuOLN4IWUXl2HPqQubasw=; b=XEqa4hyYiUVz9WaT/M4vHx1hZlUUUpg6I7IlKDTPPdsHZR8XKY6yd6qASjWA4d0+Gj hNCrYz8EqJbFhpilVhRhCVLTIoCREcVXq06HE37AjzrFyWJsiAJhQIai5PSji/O8Uh9X F6B/diazYMGelLLVU2WqD9h0TKY4zzn5jDZg297/wW82Goq9VE9M1Pcv0P7d+RDrkr4N bwkYq8vyuq95Qn0sUGhvU26OCGUx+Dldf7XNqJAuK3sdp8NomrFDL2vj7rnCEJ/c6Ght EUl+mP38bOHXccSozfh57iOnvdm5urt1vDq6bvo9ZKtguuVFiIK17gFEXFDxTBwTlaDL PoIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KHwdU6US; 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 w12si18042427pgs.182.2018.12.05.04.48.23; Wed, 05 Dec 2018 04:48:24 -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=KHwdU6US; 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 S1728029AbeLEMsW (ORCPT + 31 others); Wed, 5 Dec 2018 07:48:22 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:41427 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727700AbeLEMrz (ORCPT ); Wed, 5 Dec 2018 07:47:55 -0500 Received: by mail-lj1-f196.google.com with SMTP id k15-v6so733589ljc.8 for ; Wed, 05 Dec 2018 04:47:53 -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=2AByHMOP3S01NinyElG6HmeuOLN4IWUXl2HPqQubasw=; b=KHwdU6USscCF/4a1LQxFqOmSbcfva5RfFEiVtKCJ57nfdTXetVjAPKMnfaTs2mLp1e HeC+6+QT6Q0OZcCRSyZ+yFTmMx7A7FHwFNOC2k2ymgTM+U47gMDDj/4C2Pv6iUufa3m8 lGbwGevATPK87shLl0vP1HQt1mAVxJsTTKByI= 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=2AByHMOP3S01NinyElG6HmeuOLN4IWUXl2HPqQubasw=; b=P+CI0rjPGmNOxTeVfnyot4utmpyrISxL8mft7+8nG+CrjEmlUMQ/URLs3pSQp8ACzJ ccYU2N43VZKzK0/DuB8tVFnNCXIfI9P2H1i293e8X02X2fJSVhC3bZoZ1ShWke5Gnkm4 8Hh/DGjRV1cIxALdseTPgJ38BCDyD4Z9sLlBcaSuPkZNoWftxbQtF/Alyf2zJQDo0lIV tNpf/TNYRAQu55iwLa4aHmfGFXkg9kGSpL60xIF39twAtuuvhbQN9PqmjvSsfPGD0jM6 Wq7AfKUeXl1ARFnJK7c/rL/zOQf16utWo+L+OkdgcuCPdCkIvi02N6ZX/V7GVnntFEJ5 hpTA== X-Gm-Message-State: AA+aEWY/DMrudoD/2aqXIlFDym6WMXMWas5IhUymLtr7yvQTWUoiBOZs ywIRc8aauJge868AU0QPMeFghQ== X-Received: by 2002:a2e:990e:: with SMTP id v14-v6mr17428594lji.60.1544014072481; Wed, 05 Dec 2018 04:47:52 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:51 -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/15 v3] gpio: Add devm_gpiod_unhinge() Date: Wed, 5 Dec 2018 13:47:17 +0100 Message-Id: <20181205124721.26624-12-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Make sure to bail out of gpiod_unhinge() if the descritor passed in is NULL or an error pointer. - Accept of devres_destroy() returns -ENOENT: if we have nonexclusive GPIOs, we may attempt to remove resource management from the same descriptor multiple times. 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 | 30 +++++++++++++++++++++++++++ include/linux/gpio/consumer.h | 10 +++++++++ 3 files changed, 41 insertions(+) -- 2.19.2 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 a57e968025a8..e9a17ec4de02 100644 --- a/drivers/gpio/gpiolib-devres.c +++ b/drivers/gpio/gpiolib-devres.c @@ -346,6 +346,36 @@ 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) +{ + int ret; + + if (IS_ERR_OR_NULL(desc)) + return; + ret = devres_destroy(dev, devm_gpiod_release, + devm_gpiod_match, desc); + /* + * If the GPIO descriptor is requested as nonexclusive, we + * may call this function several times on the same descriptor + * so it is OK if devres_destroy() returns -ENOENT. + */ + if (ret == -ENOENT) + return; + /* Anything else we should warn about */ + WARN_ON(ret); +} +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 Wed Dec 5 12:47:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152897 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9255979ljp; Wed, 5 Dec 2018 04:48:03 -0800 (PST) X-Google-Smtp-Source: AFSGD/Vr3Vk7Lpi+xJWqtfJ/Ej18rIYRNMXrVznbObHMhGjPbHfCFvQiwIJHBOpnt5P4ky5uywAK X-Received: by 2002:a62:7796:: with SMTP id s144mr24141159pfc.26.1544014083017; Wed, 05 Dec 2018 04:48:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014083; cv=none; d=google.com; s=arc-20160816; b=BUS0ABygJnF7kC2GgsC/j+a1tulilwBx1/WjjGG44CzlnbEbp/irr0jy7WUvittknK LHFbw/hM8k6iNIeF4SGtL/L/m4GYDgjykb7N7/trun0SQYrWI9F6pthrOaUUqBY0xsoK W/lkapwkiBcn6BHwEPYkox4FG+e4q1Nm/Rs1S8nC7RCoI/mEy+pPlq5sdW5EgLBsHu9Y 6y1UBKR39jyI7n/mvMQYKqLXPIMqO0+pl3pkjJTGIYQmqEIKuWJfScKgx3JL43yYxR2f VQ+znW0kjj7ST4ZrBgEXS55Rmj7FS2PwFyzWVX16sgWm0+S+/+tmmMXjbpkG3pBD+ul3 LO0Q== 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=7kaSioRZMdN3SegrcZ9FLbUcYPNWPye8wQmfXmSzf3g=; b=tvdFQZ8VMZLWRGvYGGp0Wet3BYuOu4lYLjaDiAPOmELvZQ0WrBpI6WpGCswyOXR09h F8jat9HmGeWJLdFLG8PJZ6yOU/663Z/0iRcurB3OHiOZxl5mNwcRzG+n0ZvRt/dYjj7k AfcaiXhYvixNUUvLgOObAfEFpXlQknmj2owYjIsZQvQKCxuroTCrJ2Sl40plTfSOiUfR Dlm7vNNxp1TUz04snpSThrgLWQAddYzpue/2ePugX/h5yWhCkVJsIicwaLuXY59CvUBg vRj0PbR92ai4IjnCIn9/aS68PQ2VB0ZYrvEa7RqBDCG6QOsvmaLwfDje0P3+OYFjQ95T Z0jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B7K27khP; 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 3si20107812plq.138.2018.12.05.04.48.02; Wed, 05 Dec 2018 04:48:03 -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=B7K27khP; 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 S1727980AbeLEMsA (ORCPT + 31 others); Wed, 5 Dec 2018 07:48:00 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34068 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727936AbeLEMr4 (ORCPT ); Wed, 5 Dec 2018 07:47:56 -0500 Received: by mail-lf1-f67.google.com with SMTP id p6so14619947lfc.1 for ; Wed, 05 Dec 2018 04:47:55 -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=7kaSioRZMdN3SegrcZ9FLbUcYPNWPye8wQmfXmSzf3g=; b=B7K27khPwEWSmKMr04bv9k4h3qpmIbyBbsn16ZRdZtsUWsIvKWNLq85f4OgSdCPa7K n5MF/4HYh+d9uY6MykHFLPGoL00CDbtGig+TNkPL7+vDiI8RDG4G8w/9sHfWhe1hrhI2 PWtZbdR4U6gz9aJHxJ9/IORImw1dYcXrJipCw= 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=7kaSioRZMdN3SegrcZ9FLbUcYPNWPye8wQmfXmSzf3g=; b=UVx3YJzcXqiyAAKiBspexun57yLNIgbE0IqvVNLvHLenGBNDyd0/QPBNNDJuTgH2oF kb7g5d8vu6Ns7mFJOOliNo1p9VMtiqyCYgapSKHEVoUIKaPcZY4dgmINECAyzg2kBxC9 +gLOLhfQd0Y2/t6cB9BCV4snqY1T/QlfE2RRVb5JQU4TqVi2G/NspkPxP8V6tSSPwade jKqXm6sUSwo/AWSG2MyMFHj4J8efhHv8XtjVojSl+w0+aE4hB8g5yiKEKiKdqDGzNkgF Ssy/TyJgMJ8tiqjd1kJFejL+VP6ERo6TQAwiwraO8CMirzwoZJVq293nxJ+sUzpPF+dt P3yw== X-Gm-Message-State: AA+aEWaVnmgjgs/vr+qQf7nNCXqQp4Keujj0+yrkXhdauZhsL/NG5cui W5j/6oGv7z4HjBJOLMsWau0a/A== X-Received: by 2002:a19:2906:: with SMTP id p6mr13910692lfp.17.1544014074729; Wed, 05 Dec 2018 04:47:54 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:53 -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/15 v3] regulator: da9211: Hand over GPIO to regulator core Date: Wed, 5 Dec 2018 13:47:18 +0100 Message-Id: <20181205124721.26624-13-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. ChangeLog v1->v2: - New patch handling this drivers GPIO descriptors properly. --- drivers/regulator/da9211-regulator.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.19.2 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 Wed Dec 5 12:47:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152900 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9256186ljp; Wed, 5 Dec 2018 04:48:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/XFgkOP11qenEwXNuRDdih8+/m75CUxGcEFhKWs89P1C8Qy3CTk9hC6q93pS71nD0LR8prT X-Received: by 2002:a65:66ce:: with SMTP id c14mr19022862pgw.450.1544014095258; Wed, 05 Dec 2018 04:48:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014095; cv=none; d=google.com; s=arc-20160816; b=m5TwJ55wyHvRjoaG4gx9lx9qKcfTz0J3dp4o5hJqJ0EoNErbSiA+MeegAuuRCNIDQf shFIVJL3iZtyZt97k7PrI362u5fzSZLdJhPDG4y5bPTR2auu5M93+5l093ayjBGMwZrG PCEYvb30ggy4KWbA+GxbEakVJfJVPhJwHa47c/ksvzL3B9SuYoewwpK2N09olTPium7w ShKOu7offK4Lv+Tfp4sw9VKXIRsDm6QCea/29nRTdZBcpASTCEM/xTgAnAJH/a2xyImJ 3et4EqzdujdIup6EknyyFxizW3Ya4ruKE+kpCozjtHtZ74rtWteemPmxEtGjnOPquWpn bxXw== 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=nDXJn4r2s+zy7VrlG4cSBIGqxAHZiQ7TczOaY5V2Rm8=; b=Bg0LVFOSEk5n+KoKk1e7ZKSy+8V8LR9mTilt/yUAeTYR6DslcCRcJfDUPr/vybRRoi I5uTAd8AF0V+gjSJe4naiftc+dA1LGd4laQOZaQBEqKx/NfAepr4pYnFms9Tg2fEQxcy rUEPCBUA7VZIydpX6T9eNWJ76wTUXo0noFMFB4LCBxgJv/JzZjjWJWND/1Sqr+wYKeVI 1ad7LF9D+Q+b1LoqLvyi5QDmPW6MbbTreVyRN4y5OVmbVaTLipAao9bHDlETgyqHzDG+ IfDqODA1VXUl0SVY8o1fT1gB6ZwZnCrQkZLHz55k5+TsZPVsuuifQtIRySnnF3RK5rOT KwrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="XVl/6G5S"; 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 w12si18042427pgs.182.2018.12.05.04.48.14; Wed, 05 Dec 2018 04:48:15 -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="XVl/6G5S"; 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 S1728020AbeLEMsN (ORCPT + 31 others); Wed, 5 Dec 2018 07:48:13 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:41430 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbeLEMr7 (ORCPT ); Wed, 5 Dec 2018 07:47:59 -0500 Received: by mail-lj1-f195.google.com with SMTP id k15-v6so733769ljc.8 for ; Wed, 05 Dec 2018 04:47:57 -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=nDXJn4r2s+zy7VrlG4cSBIGqxAHZiQ7TczOaY5V2Rm8=; b=XVl/6G5S49/iWZPpOwxE5k94KUzcEZDoQVae5FXyOYLmyvWIpfcP98MVEKl3BWCwcr 7J28orekYDmunAVYBsEVT/Xcfvb6EnC+oOB9pwRY7e6/CfSfJORwhdpW6tu42e3cQukr tyPNQR9r80hmaaor9rRmUMXRISMJt6UAgZqHI= 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=nDXJn4r2s+zy7VrlG4cSBIGqxAHZiQ7TczOaY5V2Rm8=; b=jT5o51TkB1S7uFrCV90c+xTTrJMAf6/4d8cJZW0RbBicePfYD7PSyXIbf+yl5B+mdI oSpTGpaamnRscIliS3hFmZ/dcZr6MlC1w224U+SnLEn7bL9I571aNsb9OOeWs+A9xJe6 CT/07pAbWXyRemr3OwOe595DnPEQOU/ACyeLpNgGp4Z6tCliArJ0AyjIE5MwnCCBvOQD eRECqMBoPiuvtkeIWdZkNKPYHsAo+7Kr0hPNOAB+E2djvwK64SbWN6fI5Kyhm4S5NO8V Ig6Nzrtcyj/xSHVgEaYfFGEV2SEmW/h8nwxJMTr9QhzPAFVwPFfULzRca8ivfG0ohWeg L99g== X-Gm-Message-State: AA+aEWa2Ggwv2XDZ79NhGvu6tFv7sV8YCB7VjKI/1+iD4AKcXpkuAlpJ QxvPfOdr6e8h2V+379GBLPYg/A== X-Received: by 2002:a2e:5418:: with SMTP id i24-v6mr16955090ljb.51.1544014076783; Wed, 05 Dec 2018 04:47:56 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:55 -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/15 v3] regulator: s5m8767: Hand over GPIO to regulator core Date: Wed, 5 Dec 2018 13:47:19 +0100 Message-Id: <20181205124721.26624-14-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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 Wed Dec 5 12:47:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152898 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9256028ljp; Wed, 5 Dec 2018 04:48:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/WVt3aU0HYfvfmh5K+bRPS/XfUncqXLljYToOIqRtWeZ/8n0zR60WpbD7HVfJtipGDJhsvD X-Received: by 2002:a63:77ce:: with SMTP id s197mr20243567pgc.89.1544014086053; Wed, 05 Dec 2018 04:48:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014086; cv=none; d=google.com; s=arc-20160816; b=sLXKd+Fqy1NBcvoyanChhinbVCgsekbJ212zPc8sCqfdQ2eX/tPBno6IH5vovpwEj7 EVGDCdrK5PpnF8cna/R3fqLNzWTq9xvJXBdur4BCuo56uRSAi+LXH+FrU3Ky96BO5kwL RyW0UFW0GnMNRI5sZvQ0pjfR1FrjQhZz0DpeHROYAdkMY2toODqV67+AIxMQZfECefkL p9VbWfUUBK8kYOU5f9a/EfErqOn5Ywq/d0+WNNX0AnUBsWNKHesR0TRntAtOCF76JdPW XkBhYvZI9mDgk/WRyQhDr5HkPVCf8U9kD6TqJyiQ2UECbB/BqAGiZ10c3FYMpF/Pq1gs FMgQ== 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=0D3WorUOEulyLATldQc2enEjdRGG/LFQCVQP8Gk/E1A=; b=D3j7WTl2qS09Z5gdOg/sVVnOcH6BIxxxs6gCFdn+eYq5M3wsiup6WTaUB3VuGSz6j4 ZdHsAAmru1M4DZOkzFlE4+sA1RGgebup+nmfdJDnhiRbEn9c15+9rAKCQN+OhOiPbx/x UYKqrHIove0YByAhflZVxu6kCEOC7Dy8MVaQ1tDe4nOqfghSFj/wiL4IY2nrmOFLpzkJ joZEZVBg/wW0/esDKF8EWWfh6Sbz5YLqkpkWkOShCJ1XDHKztH6hDoHq6XB7x4YVphg/ XJ5uct22bBXKFac9vYw7PPNYCnSdrU7dhM8JNRp69l1REGIk6o2/Z2M2Ek/G8I9UX2fX Rl7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="AsZ1o/yt"; 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 u7si20831947pfu.270.2018.12.05.04.48.05; Wed, 05 Dec 2018 04:48:06 -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="AsZ1o/yt"; 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 S1727997AbeLEMsE (ORCPT + 31 others); Wed, 5 Dec 2018 07:48:04 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35164 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbeLEMsB (ORCPT ); Wed, 5 Dec 2018 07:48:01 -0500 Received: by mail-lj1-f193.google.com with SMTP id x85-v6so18214209ljb.2 for ; Wed, 05 Dec 2018 04:47:59 -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=0D3WorUOEulyLATldQc2enEjdRGG/LFQCVQP8Gk/E1A=; b=AsZ1o/yt0g+Jl+5sVVA+5jLbXIhFIOHs+/E0m5QBdzSqKk3H2HQVQBnPaQ7m1kDg0m E4lyBOdtrIWEZZhS042uW6mxIPbj59PtHMPHCG4hJGBzVmVqzOLoeojWXRbdjuTWHQug YkAnbaXJL9QUgOwNJ66pXJ3/9RrYCTaWIUyyk= 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=0D3WorUOEulyLATldQc2enEjdRGG/LFQCVQP8Gk/E1A=; b=bYWvtLo5lmfJZyyBK2AMJFZRgWhRQLfd5ch5Pv6+KxtVH8h7MSlRAO/Ri0UW0RZhcr rtqd613xeoOxuZMuhkzZG9FtJJiebnf3jOM6Q5spLuOYSBiQAkhzGvcZI7HY1YI20XoO FojljBmHrU/gHeVHSAEie0YKGmMmhjCjyB2d0vqSthsvlLdq9Yu1xfHWRd6ojXmW+NrI AlQBjsSpzt/3RHq9tmqcCgGfPujr3JexY7gtGdM8Jrm4eZ75jrMfUaio8M9mE+ajskTx ap+ckOa61T3EZdSrxf0BIYRbgEfHjiN9XusQ53MK99zLQMPHcChGGl9LgziJjMCXays2 HW3w== X-Gm-Message-State: AA+aEWb5DQdM6m2drWaPCknkMiXBq5T1qClHQx4LDKiba/UJXD4djm7I 2RH2DwP7vhTBgSyWGg8Unyy07Q== X-Received: by 2002:a2e:5747:: with SMTP id r7-v6mr15201268ljd.141.1544014078967; Wed, 05 Dec 2018 04:47:58 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:47:57 -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 14/15 v3] regulator: tps65090: Hand over GPIO to regulator core Date: Wed, 5 Dec 2018 13:47:20 +0100 Message-Id: <20181205124721.26624-15-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. ChangeLog v1->v2: - New patch handling this drivers GPIO descriptors properly. --- drivers/regulator/tps65090-regulator.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.19.2 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 Wed Dec 5 12:47:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152899 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp9256073ljp; Wed, 5 Dec 2018 04:48:09 -0800 (PST) X-Google-Smtp-Source: AFSGD/UD+ANyyGtJnp33Sef71D1WVXkybcY11VSDFzSzxlKiRz/r9YyWMtROD2jzTlrLAQsVfelP X-Received: by 2002:a62:1b50:: with SMTP id b77mr24542423pfb.36.1544014089809; Wed, 05 Dec 2018 04:48:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544014089; cv=none; d=google.com; s=arc-20160816; b=mmCMmSesR2Q34D72rAfNSLtUV1XJfTSnRGF3YTy2LZslPYi0eSHHbETe89l7LSiqFy +Rt5L/yK3qpC5hMZk4SDMBQB9vL7BmcMUx4A9AS/czMh2bCdn5l7qVLa7mQWWAzPSb19 X4WF8CVD7jXeQ3G8QzWpMKJ0n+zM5g8Y4pSHGmm3CW0bPzR1/Yfer3/QV+7HF6ZYUNQ/ MKuM786V0+sqyrhn0rFrvFsTxpexruNjVy1NVv22JFQu6qPWFUckvLO+QnuCq4Y6xdFr R+QeMEAZ3JYEyqc0ChcJt8qwd102SjSsv81WSjOrhB3vEc9e/Q81Is9ZiVgXKm9p0zLe Hfcw== 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=jvbe/TI6Rhb2D1rfWmfe80Bc3HpvIOlePt1WuzAwmR8=; b=ouO/qWTMge848tX5zsPY8rIXifP9ep5+5MRtPjK39+/NuEZI64a5tdfTJeTBEaO5mT NJZGQ9vh+HAUW1GjY7fw44tG3CHgMzlwOvK3GJ2/Nu4uF0T4j7rAHtoQLNXYcDcBVZfb REv9wE4XtCo9HkweiGGiNMLk3VcHKHp2Z7bgfv7iCFv4drgqj6rjx5sNKXnPvj2PdUFR S7CcJmPyvilZF/5R7s8fMxmu/vMf6u7fXRQjjn6fPrN+9OFh2Lx2huC6NUdGwg1lAQI1 JGvvMQNy7hcupD/DvpyIW3qkju16fbtvQKd9yEcN6funDt9HNyYmZlEnnd2D1njDJ/Jq 9qqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f8Ypw5eD; 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 u7si20831947pfu.270.2018.12.05.04.48.09; Wed, 05 Dec 2018 04:48:09 -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=f8Ypw5eD; 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 S1728009AbeLEMsI (ORCPT + 31 others); Wed, 5 Dec 2018 07:48:08 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:38063 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727774AbeLEMsD (ORCPT ); Wed, 5 Dec 2018 07:48:03 -0500 Received: by mail-lj1-f193.google.com with SMTP id c19-v6so18213880lja.5 for ; Wed, 05 Dec 2018 04:48:01 -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=jvbe/TI6Rhb2D1rfWmfe80Bc3HpvIOlePt1WuzAwmR8=; b=f8Ypw5eDceNhgRdXslCuTXFxSyiXSv8KrlT/tecx8xboeHWIn1NIKL3cwKZST+fa24 CycsVp/wytPMYh1JQbwYhBaXf2K/cBaQ/CfiXB4FfYF3IedTyrKD0ygERiyoWTpoYuYw GD7t1FcntszXPtsjkKJEV1xUtUGQiy5yCjXzg= 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=jvbe/TI6Rhb2D1rfWmfe80Bc3HpvIOlePt1WuzAwmR8=; b=Dsi8TtBXB0/0zyTeaKd8SunaemqfC2pOZPkVurMz+iddENM8pQ5+zNXsDLZAXzT9+I mxH14pQ3MjAy+wc21OjAznrSmbWQm+9iZoR10WR2Z8/nLLXlNcZ9hXrtcoZXaje4TfMT ioEQV5qVka2TVfDg6vsYTi4Cedi3SIWfnXZU8/PoE8UXtjxeH/jRMvOLRlm/Cdc/y9fW by/2tKH8UHY1R00izDDaFJWD1LouXlQQR/choxQIeFncSLpOfM9mJCfEac2zvRxpqN5d kZppsLqjeyaodxRMLI71iPBk5LY1P4fUUKjuYZkRBzaxkrCmTXAfk2MaGH6D3Fvw5Lpo QtDg== X-Gm-Message-State: AA+aEWbJ1CpoC06MVmGjOEEnqy5J58lnvzPKdG38HjE17AmJxBBtqyND zxwCxjBzpYQkuh+cCYUDOdg5lA== X-Received: by 2002:a2e:8786:: with SMTP id n6-v6mr10153266lji.100.1544014080987; Wed, 05 Dec 2018 04:48:00 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id e19-v6sm3797125ljf.67.2018.12.05.04.47.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 04:48:00 -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 15/15 v3] regulator: s2mps11: Hand over GPIO to regulator core Date: Wed, 5 Dec 2018 13:47:21 +0100 Message-Id: <20181205124721.26624-16-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181205124721.26624-1-linus.walleij@linaro.org> References: <20181205124721.26624-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 v2->v3: - Resending. 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.2 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)) {