From patchwork Thu Dec 6 12:43:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153012 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479080ljp; Thu, 6 Dec 2018 04:44:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xi+J05SJgdtdIX0toh/ldJbkdooDa+7CSLSr/nkj04jJP9q0vlv+RKLIgV+9oQG10zwymH X-Received: by 2002:a17:902:b68d:: with SMTP id c13mr28124500pls.102.1544100246601; Thu, 06 Dec 2018 04:44:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100246; cv=none; d=google.com; s=arc-20160816; b=UMojzGCJeHYhjoVxpepcEAK448ClbqcaxFQ4wkae4tvQCkRi220JTDs0C0ZPQemiwn Aho4w3OSugoQniSOjG3sdf/9ocd7rGgHNQvs4ruVVwK6uaPYhGRB66nkx6Syku62BKnh zcYoWAAYa9etJHheBA5aIyQOdsuov7EC4QEweUimuvNgvU2VPMV8Apy+ZXT1AwkGRj8y jOSe/bo2/aH170+tZiI9bdQHmao6A6slTOKpdrq402GvW7aun211kLcrCXUTDrKPYu+4 1QUiAMM9D4uLFZUUjmQJev2Uaiz9WYIj/dzkiSRbqLVtt5rBKN+7RS5/fDDNypEvKsuc TwUg== 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=tOxZO3nUb+U86qEGSI5iNJyT/exUrePPUOkDnR1qhVY=; b=MlsYc+MmjwDjvw/Frorr3LOXS4k0t3zPqE7ukcNYsm1JYuuwzvuZ9IW8QlZsNT/Izn V7h7TVZkKVo3amfXiiPUYYNfXcmbdj06tKn3dou/2YAhQ0CUTA2kk3MGuIl/PJ6RVIVR RxtfvqWi5UPP9iPTxRqECV65mqjpDNQq3fMwCeoj3TstEE0NU0mcqUdRYNtqTZ4wCVMZ 6In63PRzU/JfKAVBVj0pEzfIoDR8vqT85fEOms0tmPuS5qS1IUr72pc4lA3kv/fF3HcH N8Gtcqa7mjXaAVeTupib0fNhGGSI1qmklJKQYnifm6UV7tNBuijw37NavDESxQ3LNwYb EOXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T3X5npWw; 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 x18si230714pfm.39.2018.12.06.04.44.06; Thu, 06 Dec 2018 04:44: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=T3X5npWw; 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 S1729588AbeLFMoF (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:05 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40014 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbeLFMoE (ORCPT ); Thu, 6 Dec 2018 07:44:04 -0500 Received: by mail-lj1-f193.google.com with SMTP id n18-v6so276346lji.7 for ; Thu, 06 Dec 2018 04:44:02 -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=tOxZO3nUb+U86qEGSI5iNJyT/exUrePPUOkDnR1qhVY=; b=T3X5npWw2s5gDwjGiLO+z4UcfTzTL+V9W6JjAq/wlgfmrZibqqOvRt/UPDTVaB69XZ WyO4zfZDSLcoELOUhCR1CMbxCwQheZiPalM0O75Q1ayPsBgA16ZCic7T/GRUncqXco9Z nvZMwx3wmO/9AQ0rbSHRkPsXafK90QOTFWcJs= 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=tOxZO3nUb+U86qEGSI5iNJyT/exUrePPUOkDnR1qhVY=; b=AWaCml/AypbzpMxCQ+ion08yijUYPTbmfsokL5n+9gPwETLpG+3+V7yYliiKD4UESR dl2Ebh2mF7XFLyJCiDPFay5Km0NcgGb7JEC1kd8GtB1ViKA6VTCjxBWSRjGQC8ucdSuF Cf9f7EaLO3NIGUurk8uUCLW6S7nQixZx7bBotBdOkGfTrLyIXwlwuAMnnfbx6GgNbYP0 MpOgASERIq5FdWH3Tf0AviY4VkRTC/h6QxJ3wfOy+0abTb6FFjTMLVRp76ziZ7rx+Aa2 HLkLmnC0lFDSbX2FhGXLcJuNeS0Vd3Q3gjl06QOvsnz3y7gbq5VcBzSOl4ZxdGKzuIyN CBpQ== X-Gm-Message-State: AA+aEWZmlW07gKfeSqUP0Pmbp0JRSCE0mHOAQAnGPsGCOFaiPFGJkJNk xc1F0v67MsD60A1FgtmvbgWW7w== X-Received: by 2002:a2e:1f01:: with SMTP id f1-v6mr17921486ljf.129.1544100241274; Thu, 06 Dec 2018 04:44:01 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.43.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44: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 01/15 v4] regulator: core: Track dangling GPIO descriptors Date: Thu, 6 Dec 2018 13:43:37 +0100 Message-Id: <20181206124351.10155-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. ChangeLog v2->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 Thu Dec 6 12:43:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153026 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10480232ljp; Thu, 6 Dec 2018 04:45:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/XEdD0GRdDsRdnykV7NUcVwcQRhdZwZsuC25nH0Dq3u7sMOCkWQPLXSlASxUQIfN7MGhUzy X-Received: by 2002:a17:902:830a:: with SMTP id bd10mr28310218plb.321.1544100326183; Thu, 06 Dec 2018 04:45:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100326; cv=none; d=google.com; s=arc-20160816; b=aBCbiM3xg4NB4TBtdlW5kWPEYGGd/g0td1IRQCny42lxKQ1wZ6BI32MN9yKD3WfRh4 +dnJJ2+tgZMQBqsUk6kEVKvrjto29QIpdpgIVAR+xyn8j+G0Gi/OGBVPkSZ+Nh8SVflk 152inD60BXARZ+p5iWxrnj7jH8JJZfV34mGVta07b14NgClbOzelgB/XSzDI5q7VEBO9 cJzVbTtwtJniI/5V65L0GcX8jrj4F173hzDHp0KPkS5jDdeOtjyw+skmzJSlycYN0uRJ 62mSRHXm7o9zNSbPtvAFemIIm7jFjv3xR2RQI/Q/4kdw7trWZdCmPWJln10J3zHpK5QT speg== 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=9VEANXWZbVqprII34eupTEX+PE8o+MRtLs3B6IBk600=; b=DQG1aij7sqxLy9IdG3EAR/zG+T+ZJkIeFExjHuzqfqSGMFWpgrMv2jE2DsGOZHZT/V UNrhYYXr9t4T8xeXYw+KJ31Y3c5t1mfL/F8syYNf3YmXQHICwydnTzDm0owOPp6kXF9U TgaxvVW3QhBa8B4NPqW90Y3j3VoraJ8a8FSYsmW6wx+xG7EIccas1xJ/txkpZrRWVJa6 34oRdpwNWeizD28FNN6JQoF0bV2eqV3FV4XUHFTHzNoU/1JknEq8FfUdv2jW6hRG6Qzx CeODKU2heSjtE5Wr5Jn5N3837JZQI5xcxdjSNiADAsJR5EDJU3dKH7jlCWlKnBBwwqjh RANA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IPMamB9K; 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 v184si204339pgd.295.2018.12.06.04.45.25; Thu, 06 Dec 2018 04:45:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IPMamB9K; 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 S1729631AbeLFMoJ (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:09 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:41264 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729543AbeLFMoG (ORCPT ); Thu, 6 Dec 2018 07:44:06 -0500 Received: by mail-lj1-f193.google.com with SMTP id k15-v6so269922ljc.8 for ; Thu, 06 Dec 2018 04:44:04 -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=9VEANXWZbVqprII34eupTEX+PE8o+MRtLs3B6IBk600=; b=IPMamB9KYnwZi438OBhj+UVdVNuf5OLp++/S263ecahVnGvJcBonnfx10j8cDroEnd UYqmDTZ6XfqtuWHP1tlFGCZs3RjBSXSC7G55YMjP9vILMfjAAMVMxAkr8jJhQPy4NKFa aa1nyT9xfe/GA/hj59Pciz+PvJYVDlK3E0XqM= 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=9VEANXWZbVqprII34eupTEX+PE8o+MRtLs3B6IBk600=; b=L05IFQgumb8nA+NE7JF2ZlL/JmI5d05CB1rL60j0ewkxkSHk8a0XQRldvxmrfhDUMZ RYVsukLyn302bMHeCpnfVqe1o6t/g1eKjxpMEqxz8WyuMNVLuSeLM1mhqmGLdeNIYNnK 9o2iKKsAthj9at0fK6DuUMkziqoyQb4xaXaw4sv7mJWAjYrXgVpvW4cG8sYCsWkQ54fx jb/DQTj1TBQSjhw8xh76E3l3YmAcC+MxxmL9lmL3cu8a52+hei5mHDGBrD6UeUtrdzTS S6ubeCS7ghnVI2FgONf3M+DYXLb5zi61FS6FMbxrt1tOz8Ri2Cr8aVkAt/L/ewx1wCA0 ZRDQ== X-Gm-Message-State: AA+aEWZXRN8kv8nwch9Vi1RrkmSOkE9pYl1rgHGgjm9m0p15YXIMfthG 4OUIYV502pH/hRlXWJrpuSo96REMz+1JJQ== X-Received: by 2002:a2e:478f:: with SMTP id u137-v6mr18104660lja.142.1544100243897; Thu, 06 Dec 2018 04:44:03 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:02 -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 v4] regulator: fixed: Let core handle GPIO descriptor Date: Thu, 6 Dec 2018 13:43:38 +0100 Message-Id: <20181206124351.10155-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153013 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479179ljp; Thu, 6 Dec 2018 04:44:13 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xx2373gI8U3eXDYnNO6d0XAK/b3FfI1zjOq/kywRcNQpV9ihTtQl5aZDHZqskHyDFCP/qB X-Received: by 2002:a17:902:a9c4:: with SMTP id b4mr28148751plr.298.1544100252865; Thu, 06 Dec 2018 04:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100252; cv=none; d=google.com; s=arc-20160816; b=WXHWtzv7L5HLLTdgXatvEIz6XwyYGFNoWYrwcIK9Yx3Se5DaYV3DSxK5hC5nkqXI6c ieunKX6jFOwPTBiFkFnet9+CJGy9GLcU38SEUJhClAKKAKaDowYHsqhO5ccFFfz8sJ7P VJIL5wZ/0JTidAzyTUPTVNyeFkBRQNrGjvEski9dqq/tCUUsDkm4fWan2ho7Pi2TB2J7 gE+YkVq6zuVkD3gytOfKdElSpBC4mDycxSLsO9BYQKhgqMz8DdgJRQ2UQhvRQeBl2acR ju5+ANqNJvFJ2ZwvZ7qArOtLfh7/auWinCZauHkz7e4yso+vUk6fqrFyPFJH6dC0L0L4 91nA== 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=lJvN9Rzv+0xPXleQeFq/pULseUhFiIrJUg0MsYbkIQQ=; b=RsaNNN6hVys6MkLEc8/uUuydV9So7f9/6jXzqTOGBGt6IM3aT9CIQ0RCMwuZUipQT7 eg0IutfzYtS/98QWFqSiLvHpwgVQBhakA0pHgn+fZ4soBNCYZxsmN9H7ZdegcPlQv2MG FQXS4lY9+3vQgQHbl4ZWC9GMKmBTFiKoLujclLZ90xeLpuAN5/g99pPJheIQ4JrK7M1O Wn4DKQawVOn5WU3x0j00yO/ediF8LAEIyoo/Zf5ECjihLjoNOYcP4bMPAdXD1w+o7X3f RXH0NMRLRAN742xGy//4kBMu/zh5KKqOgUy+an9TsoDOrrWQWjRS9mymukX4SO0UNmDi XNlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jErdw6p7; 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 p17si201618pfk.275.2018.12.06.04.44.12; Thu, 06 Dec 2018 04:44:12 -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=jErdw6p7; 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 S1729651AbeLFMoL (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:11 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:35133 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727832AbeLFMoI (ORCPT ); Thu, 6 Dec 2018 07:44:08 -0500 Received: by mail-lj1-f195.google.com with SMTP id x85-v6so305847ljb.2 for ; Thu, 06 Dec 2018 04:44:07 -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=lJvN9Rzv+0xPXleQeFq/pULseUhFiIrJUg0MsYbkIQQ=; b=jErdw6p7lQSVYfE6FJqDsTaFKkD2INS1kz7U5/VH+Oe1DtxgVxoQejsEyhJn8aa/Uj rnhKSwjdozbLDI7C96cU2XyAuQJmIVq0+NbZVqX1KV41SRUxoreovVGDZZlFSeJ1IZ+I 3ycGk3aT/73Q+ed3Lv17SxV0u4yq/4lRq4T9c= 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=lJvN9Rzv+0xPXleQeFq/pULseUhFiIrJUg0MsYbkIQQ=; b=AmSD562DStkg2B8W4/bIPe6Zs0IaByyGkwfG/+pK6Y8ujTymwKnMH4nZ7mdInRJMGq iba1ExPM3IYpWsG1uk1uJz87R6srp35hpypr6tYXdQJ3nwxHGbQG5pjnHSElHH64uIf7 Nwq44jylqnQMGZXus1WeHHxM7I52rdzKDpe7jpTERCrOHWuM4LsiNDjaadUs97khT8nB m2GD11jssrhOTWSlKk+OQCcjvQzSFi/blwj+CfzDddONbAYJzzGraamBwLmRnKszG3Zb Ydmjo+T1pTaL6Sag1AvgzC2KwMCFWGKNSYeieQJb4EMMdyazxHRNLN5gR7PdqFNMEndb 2g6Q== X-Gm-Message-State: AA+aEWbaGstLTRRc5IwHP91EOMhjp689u7wD0GEg3K8mS/b54jC0UPFO mcmHNmUp/oVtl6bzZgtVSOhVHg== X-Received: by 2002:a2e:9e95:: with SMTP id f21-v6mr18222992ljk.128.1544100246324; Thu, 06 Dec 2018 04:44:06 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:04 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 03/15 v4] regulator: lm363x: Let core handle GPIO descriptor Date: Thu, 6 Dec 2018 13:43:39 +0100 Message-Id: <20181206124351.10155-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153025 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10480123ljp; Thu, 6 Dec 2018 04:45:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/X4+7/pVK7Qx0cbdEeThn/BJhGVwbalqHQ/aA9niKTikpiKXu12rkLHEWAc75hZjPYGVa6v X-Received: by 2002:a17:902:6f09:: with SMTP id w9mr28834916plk.309.1544100319831; Thu, 06 Dec 2018 04:45:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100319; cv=none; d=google.com; s=arc-20160816; b=EONLraLhlGYqsMeONmj8riLznNglkYC6M2OWWdv1xANzAWdhTHC5opVLAIEpWe+3ac xLz0kLDNlN3hPc7XSXSUEbtbRI7yb8rifCNVybRYGM6KjOc7/mVGCK3lOEGXG2Dx7ffF qmE3+F3hNfW3CNHu+AI93yQId520/KZP7eIh//kBlAJquvqrfQhqk4el1ad5E6VB6dL2 VYaHKWOXPGj+dC45Qp2nAcXEQ+NzPjZlJK0VT52BbX2YTXsszavQzzWIKWLlw+bDHK6b 0muLIBuJ9tHHV/rfjU/CSmNOc0rQl35iNCT8HmHJLwPJ7nfAvlGVGFa4GHJqAIXasS/F qE5Q== 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=pL3UIbDRXGJXlxTb/OqBWSX/UpAtCHnsGG4EwMeQdvI=; b=m8+waWDRK/9St7aix97yLhsseAtvn0jT5mS5GrRoC1hMnDfMVgjwU0ZlAV0v/0fJ+7 B2RTi35/19VQd6ceqIQ4p9kixHlsLjQiP1bZrbL9AgnpaEIaenkEWJgTlM3WBinqKsj8 CtgbYXptyasZWorbEye1dQR2aXqIKbs9PML5CePLwCjx9WnKga5KHXHI6srFjoaIQRtR PDPRqTw7DE/u9hon5BUIbxiqPFw0ZFYKls924b6JtHvC2srWnLKn0utUIESbUMF1cWOt XiZuSRyMO8gF4/D42StT3OSeguEHPL0Cjts75idaA1trpCmWkQWSNwXBpEgRwbfTEUWi 6xzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WyzqRLE0; 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 u3si203988pgj.300.2018.12.06.04.45.19; Thu, 06 Dec 2018 04:45:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WyzqRLE0; 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 S1729670AbeLFMoP (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:15 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44524 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729596AbeLFMoK (ORCPT ); Thu, 6 Dec 2018 07:44:10 -0500 Received: by mail-lf1-f67.google.com with SMTP id z13so218800lfe.11 for ; Thu, 06 Dec 2018 04:44:09 -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=pL3UIbDRXGJXlxTb/OqBWSX/UpAtCHnsGG4EwMeQdvI=; b=WyzqRLE0v9z8tUxdFVxS+i+eOALl7dl3FF9/qTkz1/Yi6jbfr2nSgpSnhDu/CFzljn JyrIpgpdfRVV8ubR7yEOB6LxStlCgsN2B9YZ45brsond4LJcNuz+x8rwgs1k5ccGh+tB 2UcaP8TZJKLDfZ883kJRQDslfQ90JMozG5eC0= 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=pL3UIbDRXGJXlxTb/OqBWSX/UpAtCHnsGG4EwMeQdvI=; b=FTo1SbYhZ+f/NNSVf1TDrYPkZ4VRIuzmB17xKynqG1xGOp7kAt5AWBT088zfZJBaw0 I7056fBZTCFy4yscfqDlidGYQzDTRFl4MeNdTD/OaC7REleP9DK1xv2/YrDvRxH3opmU bzwt4pr83b3vM679pmNw8xYFF4CjyffidJptv9N6NTjEMr46SQ7KIc/UfB0yEKrMpZeN uDesNxzqQNWdLrjtwZm8BD6LxLsMFx+JvlUYZ2txJIQMbVDdmQsqZP5V9iTPGE6PKCx/ h/uD5VxfSIhoCsHwSS1IKbWBytMlBca2hjGzf9+3QiQLmghg9Uovf/XIEfC5pmTfWybb PaaA== X-Gm-Message-State: AA+aEWaOnp4DQp78iOnf6kU264V3qKvZS337xKD8kj5cvBPR9rACebl5 8PosgHB8C/ChgLkCwgbJHxNdzLu0sidA8g== X-Received: by 2002:a19:f813:: with SMTP id a19mr16137149lff.67.1544100248276; Thu, 06 Dec 2018 04:44:08 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:07 -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 v4] regulator: lp8788-ldo: Let core handle GPIO descriptor Date: Thu, 6 Dec 2018 13:43:40 +0100 Message-Id: <20181206124351.10155-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153014 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479238ljp; Thu, 6 Dec 2018 04:44:17 -0800 (PST) X-Google-Smtp-Source: AFSGD/WRa7t5ubDJW2EBAya8xhD89w1siK0NLP1/gfhJ285fQZ5UH9pv9G+Sf0yeTwoP87iYe2Jx X-Received: by 2002:a63:1f1c:: with SMTP id f28mr24046100pgf.193.1544100257069; Thu, 06 Dec 2018 04:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100257; cv=none; d=google.com; s=arc-20160816; b=c7hZCr7k3ooXV03D1loYzoBpk7dMOQohW1vU4hqUad2AuCKxJb/uSN9e6Lt0I9AHFP 4xRxNqgmIbx8rnYA2dGdM07IP0LKJIPqZo+V6gsd5l83RhcXkqBRZ7VYQzdUtC5ukBo3 pLJpVrYg6Cv3fwAoj8JYsw5MtIgbziPkV4MayQ2LeJrsVPJaVeYLWHqKlDaT/jlSa+DZ yewFoQiAB523suMuNNcfoiJrNcMtmiJ37J1iEvm8tBrbzR0MfwzxEjvCKeF2EVPUvg9d 2jB3f7ao0SI3lIpD4h3JCOyqiubS+hwNs06z/zz6k5FWUX8Pjnog1xwjP+0cwufdfuWA zkgw== 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=x/2aw+P83R8elX2tp0ut9Zm1k1q1tBogpgmcBikeeU0=; b=hpfmoqTXFnaHfKwQ//Sxruli+7OKMtcMCiukeAKK9Cm8Azzn+wn6xeGt1vWWokC5D1 quM/KJTxDlKf0jeaPpTbGA0RQSk+FKhJMEpycFOzuvoCwrVw3PAr45uKsd+r2Qvi53l/ 43quQxfnTh1rFqfxyWz2iKtcT58eMGmEPv7nf3sh+6Be/7rnDqCNptmTdbyppCQlfMLh AdwgOIBkmbVTR0omqg/EZBXw6mAqOTBKekBfkSGlieSb3/6CCIzmi4Gi0waiyYei0mtq qAGe56VZfrnLMOLqF7Woer4Fuo4KkZ5YbVPfm1zlTIQItG1Q/ZkPHcmNqcpATt9oWu+A YyZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ui+zLHTp; 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 p17si201618pfk.275.2018.12.06.04.44.16; Thu, 06 Dec 2018 04:44:17 -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=Ui+zLHTp; 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 S1729527AbeLFMoQ (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:16 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:46785 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729650AbeLFMoM (ORCPT ); Thu, 6 Dec 2018 07:44:12 -0500 Received: by mail-lf1-f65.google.com with SMTP id f23so210797lfc.13 for ; Thu, 06 Dec 2018 04:44:11 -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=x/2aw+P83R8elX2tp0ut9Zm1k1q1tBogpgmcBikeeU0=; b=Ui+zLHTpafJQyKa25wAkhePyr5xNBilE4jN/WQ5QNhqvVoUhFUlI+0sqFvLIkJgkO7 dLTgZ5hYpqbBTZn5nW1g9hv8hIEiMMEDzqCzTwOr84M/mOZTxO2jtqHfiz5lA/uobIvF uiCu+ZDPRzEQKcSvRxzpJSx7ACOsr8+8fV87Y= 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=x/2aw+P83R8elX2tp0ut9Zm1k1q1tBogpgmcBikeeU0=; b=dA4zGxaF+KuYrinVzgm5RYz40zz/zDoTmwndW461y3bsQF1sH2r7xUlEvIFH433Hl+ YN5moL7PsuTJjn0Xz/1+eIKoWkGId+3P1623YxCGJ0i+1f4XhQDJf+EXNZZBM6lcm83C Hv5q7Uw2252M6mhmIG19CX/BRcF/lJD34f8u1vVdzwbNBAGR7Q4m/QjQmjzsmmNecMwj Aru6v6BtDBn5eJpbgPF3itmkess32Tl2yro8MY6N4eE6nnPekECQw0tChMRbLBcxKyIb lB51YZc++MiCePqw2LMrc3bSEC0vLkWsmyXp9S7w1/h4BoLigfAqe9u7HnHw9NoQzelu lILw== X-Gm-Message-State: AA+aEWa4WNL0Ne0BSxJ1GZRqG87vifEM7pIZ3yHJ4sCgl+0e8MQLFyLf 2pIX0FipfmA8iFLM9Rae6jQ2HA== X-Received: by 2002:a19:d857:: with SMTP id p84mr16351987lfg.44.1544100250347; Thu, 06 Dec 2018 04:44:10 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:09 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 05/15 v4] regulator: max8952: Let core handle GPIO descriptor Date: Thu, 6 Dec 2018 13:43:41 +0100 Message-Id: <20181206124351.10155-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153015 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479263ljp; Thu, 6 Dec 2018 04:44:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/WYPDNjSBWnmbZoeX3nxl3M2gxVZlFaZnjklg4DT9AxnniiLdh+HDCzitalEYDjwAfvsVeE X-Received: by 2002:a62:7e13:: with SMTP id z19mr28330103pfc.94.1544100259041; Thu, 06 Dec 2018 04:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100259; cv=none; d=google.com; s=arc-20160816; b=nHLoPxZJ0w6e4oG04hQheYyyheTgwvdQqkVnggK99ZQ+ARRVss/cvV6G4tibMkmdK2 3F8vQLe0tob8ORq4SyzJK0asOcNFmAO9grVv45IoEgE1+f+d+IMOoo041XGnpRs49GNZ W6NyEhRO76Z7Yt6kn6MUA9KaEr2mjpeQFWDZb0jpVktZXWPDKpw3OBW1NsXxS0+hCB9n xeTDr+pXvAOP52ZIMMwthK+F6mzU0OJFyIroQIIhX5R0GO03gakqYtROD2sr7QBmMVPZ 6a6JMFnP1j4hZD9f55ZiwdqXTokcPZXqQJbM84druR8aYnCw8UXnkGaHSLXiY+TfFTBb l0fw== 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=w6Ox8Mcvx6qj2ecBv6EZkuh7tLbIfkFEDjl421pVmOo=; b=kLb/PfON5AST2rHC9zRXWAnhF7HxpWoHAxfw2BvJYPIbGfQJgFzD8mDzNuZ7WpKqdk vqno8QRCTzesHxRhnY7gDovAPjcIlpmd/CNfQvLO2nRQYvOu/WK4QgVf9x6crUemhcCg pCFKEhcywED69rInqnAFS2x1kyhLNsxe3JD+c1o8O4+hZGJO8fcn183ZHY//1bTjnQar YFAUYujaN1mf3Zpxbdva4gLwyqdEiSykrIHUYbTGgmyOmQ7YdC9WJ+f1gGV0ndmeqJhE l+VLtL6FHmGwaXjovigGGOI37vW+hbhqOvkt6UfHLwu2c97W/T1sTbXJNyGUiWPTyzJZ +tUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Exs3l52N; 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 f10si190892pgl.528.2018.12.06.04.44.18; Thu, 06 Dec 2018 04:44:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Exs3l52N; 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 S1729563AbeLFMoR (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:17 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35143 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729654AbeLFMoO (ORCPT ); Thu, 6 Dec 2018 07:44:14 -0500 Received: by mail-lj1-f193.google.com with SMTP id x85-v6so306098ljb.2 for ; Thu, 06 Dec 2018 04:44:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w6Ox8Mcvx6qj2ecBv6EZkuh7tLbIfkFEDjl421pVmOo=; b=Exs3l52NznD1n7lUvDbYRlz83GaegJEOGuuT2CAyvobNmKs23nhCZ9PQf1619Xslnx 5Aj77Y++cxygbOfwBS0zSPPvOXl6LEFDZ28QEXFwYBzd2tZ+xS17KTpWJSsaE5FqtCuY 4gORsEiBnZzcM4yheYQlYacST6D65sWcHB/LE= 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=w6Ox8Mcvx6qj2ecBv6EZkuh7tLbIfkFEDjl421pVmOo=; b=DCsHTQgVWlw98CvJoqjS1bMk1L6X2jhBI1//izkZGKZTHL/jdc5IzA9ra7Qi/amKhQ wGQABK2trrXbxaMH77yXDzxHA2iDRoyukLNSBbXALPUIFJpkGwbXlKXkf3T+8ydXyeUr 1EI/hhEyGLduXH3JmUFF2ZFLMZ/iiv9nX7H3ymKZZacF5akcAAoI4WHWRYL0ECl8yr8Y mcqZJBpHJGM3oLdloMllTJCCwYHAFNuUlhTV0fLflmWFnZXxEMXtnB3To5nHQbXRU6jv HDx7+4D0xgX5EeBJYvXMLq6xE7UtFi/+3rUK4oB8xsjACLkDOZaTQ3pskPeJ1qCCuEo/ UKEw== X-Gm-Message-State: AA+aEWY5w0vMI2pUgVo3ch7RLyYeqc856kLu0bLlLgf8FBOgZXyZoIA+ Sv3CWbDmxJapxY7raoAdzP9H6g== X-Received: by 2002:a2e:9059:: with SMTP id n25-v6mr18270637ljg.155.1544100252514; Thu, 06 Dec 2018 04:44:12 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:11 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 06/15 v4] gpio: Export gpiod_get_from_of_node() Date: Thu, 6 Dec 2018 13:43:42 +0100 Message-Id: <20181206124351.10155-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153016 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479302ljp; Thu, 6 Dec 2018 04:44:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/X+pkTc/iHLe1amb+NjXdHElghnRW7u2YATnG8fANywx2WLFZ6ZLXVyyoAodfynJriMzXpT X-Received: by 2002:a63:f30d:: with SMTP id l13mr24197405pgh.399.1544100261700; Thu, 06 Dec 2018 04:44:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100261; cv=none; d=google.com; s=arc-20160816; b=aLrg+sdK/DlUMbuKc5IKfSuXR8bL9FSwTOmEIsPovIANLISqbQazP0hBXNILd7F/Ev CR1U7mhr+6gWQetrLymPmspKTERp4l4vGAYCIDHVXZznbDNyMWCw088mJCgsZNxBHJZK 4o2UvmEJwo9eSQgSNCWDG9KWtnqreZQWhaGggyvixgEMU2xkjPP/L07H9rSgrnmW3DTQ pxj/IeA3ZrEOY+j8PJfLTUXYXSfkTgP+SkwJ4XzpNycbPcJ1UEVZ5ZnV1/qGRihehdGJ gHwzpZkLwups+U5NXYrKvXvxwOFK45D/TyVq4dvNobpPXqRdaN9JarFufj5hqqXsUzm1 ZFCg== 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=EGdG41X/n1r/5ZJbvZ7uuuwkxYAx3vmZpL8IIUge2Cg=; b=OXvuuVQuf6N8WCz3I4brtFRC1RrsbaXlbfXE5lw3yhlToQDJTW8IRvCo/rOOl9Pkwv HLPZmL9gLskwFwFF16CI/i4NXN5Ex6Sg1+sKpyMXCzGdoHaA3Gvfu04VExK5vJqgc/Lb s/ST720DVsaMKnno3AcRyK00vrzPzThvGqJwekpANG4+YTzZTp3x9c24/39C5yMTm45a Zu6RVuBB/hHCxqeTU4Ruq3cG9Ch8C/aVMttKRWYoL0aL+S6eWtvifHpUeIXFS3v3pXyt ex1EOfOwQXjxaKVrvjrml87EBxoimepoTaOF9Db3Q/GH+NWuNYcJvejvZDGmfwWCzSmI 10jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cEoEamDO; 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 f10si190892pgl.528.2018.12.06.04.44.21; Thu, 06 Dec 2018 04:44:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cEoEamDO; 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 S1729713AbeLFMoU (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:20 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34490 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729667AbeLFMoQ (ORCPT ); Thu, 6 Dec 2018 07:44:16 -0500 Received: by mail-lf1-f67.google.com with SMTP id p6so262513lfc.1 for ; Thu, 06 Dec 2018 04:44:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EGdG41X/n1r/5ZJbvZ7uuuwkxYAx3vmZpL8IIUge2Cg=; b=cEoEamDOJyLyhIXSAcJMkITLJvl5A4GFRyZHi/JsUzQla3+KgMqYSyqfzX0hrBgqca cV+C1eb9qjhERcqSeXkyU6Fau6T3+SOAT2j4qOKDlpdI6VjdjeKYqeh4N8BSgAORz7hu IGDMdfNWDNt+A+0O/vWMWTYZE20pRK8s4fNtg= 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=EGdG41X/n1r/5ZJbvZ7uuuwkxYAx3vmZpL8IIUge2Cg=; b=Gx4c8QEEbUW9ev4uQ9ZnMZxvH8GbFsi1H+8lgvOSqmEPz/p2v0CdYLCwKKGOT6U7B1 fcsugL/i6opX+LhOm6e02CPLWX3zE4azHHEfTOzcs4vIZK+3P4K+xNHVbYETZL1IbJja mR6dMzFkiddk32lTpSn8wCimzuoYEH5KpXXgKl+rF1cs0Iv/bG/Q+YLQw8n6S0Bz3M2z 8X93pvTIngnBs4H64vZuf4zMlV5joJJlk1phYKZk8HyvTMSNcwsjWCVXY/r+iPhF9cbL fCEIqiqWAEdupX9rpp7N/8YcjuDxMsJ9FNlnj7kNJPSzxzIVt3tijsN5wpk4pOWUF0Iv QjIQ== X-Gm-Message-State: AA+aEWbOwEfwkutZCjSXPH1MSj744wUeU/JsJKd5Ahry/6F/hCupaVYQ /ud6WkVJ3e9Wr4P0s9DRYMd7Qw== X-Received: by 2002:a19:4345:: with SMTP id m5mr16370319lfj.142.1544100254402; Thu, 06 Dec 2018 04:44:14 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:13 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 07/15 v4] regulator: max77686: Let core handle GPIO descriptor Date: Thu, 6 Dec 2018 13:43:43 +0100 Message-Id: <20181206124351.10155-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153024 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479980ljp; Thu, 6 Dec 2018 04:45:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/VQtTKmwSeH8ejIxd4guCrFnj0U+sxQFZPzu8zWyFQXYXN2350ajMv7V6BGL+ubrnrsUaGV X-Received: by 2002:a63:e055:: with SMTP id n21mr24211165pgj.397.1544100310121; Thu, 06 Dec 2018 04:45:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100310; cv=none; d=google.com; s=arc-20160816; b=rTQmr3S+aH0mINChEUETLICbkg3aSv+RYuPbq5BmMLPaPysyL1ebc1rCk2g2knr8cZ Vg4ICkHu3AeAxC6PO0MsLTPRgRk3F2eGUmg15dp3nffgTatpQ+Nxe2cDDTXPvoaEYCLc Zmugo3zxPIBQNehPdHy2ZcnGsxrkKg8/pAW/3+21V2nVm8fwod/hfHeeMa7FugvjbR1f cPrIR8WPz4zMsafc7iaFDnSYEZtc0ZWI1apnzIR2FK+l7wNvtI+Bo8iRsinWksSKzARQ VXXnF6hPdS2uIGlcczowM+SZkPZt+HGsaj5yM/rziwMzMQ/8Kn/ROQUufjmf9EJVLtRp Wrzg== 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=6UCfXd8FomOG2PyW0T35K10v1EsE1DAdxPlQYdOdXf0=; b=duVL1EvWzSw0jGJd0nB23mnnOG8FQBZooLPrdRefP2L6oedW8AoiOZ5dhkGYySne9V MKlEciVbhxEEkUYZj7YwAu7hfV31hyjAksyo04QGqaZp/e4P5w3yJBDK1tN0XdQeyDHC wMIkA2FrFREu+JxKUENHMHZQuGB0z/43iTI+1IZMi1ih+zZlZKCuKhmqVA/W77p+YpOw GIxWI00N3ig11366Ys1BOHfRfPIsl/jOnEf00DUm5UW0DCZJfZql/3mvEqjhwemB3Bbr QLQLac+38u6QO1hFItbCiHbZ6PDuazcLMSJxtR7R6GJqSeL0JciyCK6FVZfkE6joUZGd anGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AwUeMEPs; 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 u3si203988pgj.300.2018.12.06.04.45.09; Thu, 06 Dec 2018 04:45:10 -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=AwUeMEPs; 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 S1729858AbeLFMpJ (ORCPT + 31 others); Thu, 6 Dec 2018 07:45:09 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:41151 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729446AbeLFMoS (ORCPT ); Thu, 6 Dec 2018 07:44:18 -0500 Received: by mail-lf1-f67.google.com with SMTP id c16so231216lfj.8 for ; Thu, 06 Dec 2018 04:44:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6UCfXd8FomOG2PyW0T35K10v1EsE1DAdxPlQYdOdXf0=; b=AwUeMEPsVL8O86NQN8PsH4kGpM4py+TWzmkDBMtuAcU1F5sAcjIlVPvSbvyteBn817 xrYEvA0ELxHei6jvJB5vhlZ2VrjkXFLTkYKLE0s8jUBTL/MtSwuTITyplP+PLUIP0OAL 2ZIQpZGdq0SioQ9GsY3XrX2ohrebkA3+ns5Qc= 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=6UCfXd8FomOG2PyW0T35K10v1EsE1DAdxPlQYdOdXf0=; b=VW3UDWzyKW+m7y9wvsWbLu5UsCRUW85uTvUxxCc6BS2XPZENSrNtIJlX7bsTF5JtEW 0dvoN7GWittQ5kW4jINWD18jFJJ7u9b/HaCHr5SggWtKF8NevG8/AZxW9tDA8jiLiWwp 1gy3TR1w3Sp4RKIbYfWi3gaXpl6dM831wNvWtsgw2WuMWS4XB0+mRMnXsvqjEmcEKTxh 8T/MeA00rlNCwo/nqdLgBs5ZGFMeJzC62Z25iist8cpLr2Fk8m80L6bX60W8//vclm87 /hHs1zNq7SzbKFLESFxiY5IMvPiPQIqLR4g3yzYF2+Q9RUcv1buq/dCG9oT9gdiLfNNN 9JTw== X-Gm-Message-State: AA+aEWbrc3Ke8Zpq8vwvc06rDuoFxwN4QodsWykmhs7EONKVSUJaLjKg lNVgvYAeE1Pgu4PUCdTLyD/DuQ== X-Received: by 2002:a19:1019:: with SMTP id f25mr16368839lfi.54.1544100256624; Thu, 06 Dec 2018 04:44:16 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:15 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 08/15 v4] gpio: Enable nonexclusive gpiods from DT nodes Date: Thu, 6 Dec 2018 13:43:44 +0100 Message-Id: <20181206124351.10155-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153017 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479372ljp; Thu, 6 Dec 2018 04:44:25 -0800 (PST) X-Google-Smtp-Source: AFSGD/XOTEsc3qVNKhR4GMygFM0Rc+q9d6c1+i7DJJOU1Yx7JZUxDG3JC6lWZ0EevE28oAAd73sY X-Received: by 2002:a17:902:2dc3:: with SMTP id p61mr27445968plb.166.1544100265372; Thu, 06 Dec 2018 04:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100265; cv=none; d=google.com; s=arc-20160816; b=jQCl/GNnpgLMKOrCnRgqpEIzvBrq+LxKvnuiF07/IFpcP7FEh2L2heFy5vQUlDIUVg BwuEAo+Kn1LnLjf/h0GcHo7ChN1VIc6jJWTB6nK3VbN7f/A9T+G8ZwGKw5nXEgPgUMpX UvaYC1wc5KK84wpLj0cAIzDedu77CVGVPjQ8BOThdW3906RGg+jN63F3pOx79D726OKj UR7VptlKOBLcvNBTYCDSHxHbdeh0KIjALpiAcOu4PRLIXu5dgH9FSulA50Z+uVlydO16 90nmsgAGRRVAWyOZysUZASLxKI8LpaJyT83T3UDRe5XKgAbjlwWF8h7a3VpktnB7zUIY 5PtQ== 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=AhlKqI8Sf7OwwyTXqg/8o97lEVTsK7W63wvXXbyp2DA=; b=qYqVH/3W6zAnZ6aRrZcGo+quXQWBtoqRzr7dHVtMg2o6sE2BpwBdQycAi3SMcnodcF lDxqfdVTx0j7TC/7LREcr1cnLcK/vkcJB23r8WjG61y4cMKE3obg97PsEVwQ62paae3X K14k8ylbaU/phtuEaBPldpV6T6kxf3VwxFjz/X0gHuZP31/ssVM/x5DlImSWvNNvcNQm /u4XLbYGru6iEJ8mRL3+1cPQ8XHurrNec+QHGPfQ6bSYf5AgI7Uq+Mv3JyjajvJVrjU6 CpXVY8tYEnud/d6irRykWffGy7XCz2ETg4TpUV5kPi/v83cS9XJshi86SHAmGDTPeeTv 285w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NgNgybUV; 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 h68si208548plb.375.2018.12.06.04.44.24; Thu, 06 Dec 2018 04:44:25 -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=NgNgybUV; 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 S1729729AbeLFMoX (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:23 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:39866 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbeLFMoV (ORCPT ); Thu, 6 Dec 2018 07:44:21 -0500 Received: by mail-lf1-f68.google.com with SMTP id n18so239933lfh.6 for ; Thu, 06 Dec 2018 04:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AhlKqI8Sf7OwwyTXqg/8o97lEVTsK7W63wvXXbyp2DA=; b=NgNgybUVYedAJyqssM+aetsaZYtCBJqAHmLXHKsu3elwVSMH2cra2hWqdiJXCErpFG VHMSM+gH3wRZw3Z8T6u4zUWhIdEbC62+nMuhFjLTzG7ulzovGCDz6ofeyDuVmt2dz5yN njJut7HTp1QVbwoRnO5rwv9NTpFteEL7OtwTo= 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=AhlKqI8Sf7OwwyTXqg/8o97lEVTsK7W63wvXXbyp2DA=; b=tA84c2cEVBA1d+g8wCBC/UXwEEXuFZ+xuNqJurLKu/r5jWdughMQ6AQu3EH/N2YTFz NEEuBLKQLoNrN/zvXvVJfXw2oU0YkH3RJtHQT8n/mmwGP4PmbzNMjQX4/mo/axZJJtEZ nHOJrjbLII52v6qt1x8+OvU1/e+k46nHaYXvCV7ldEneBRSPdO6pUNCmkJ8arRGs+GfC /flROkxwXF016NCQyr6KfsEodcmydiXN/QnkVNrS0a0IF6SZt6dhjCeFnzEq38zsSHEI jGhomFhkqFOkDJSgUzLuhnFpqaE8/Acgh6Ta4Pv27TL8/HvVztqeSG/cz+g5d6x+PKyO ZVBA== X-Gm-Message-State: AA+aEWZBuhRq+PTDfrfsb2KZaucd5CuZs/HkVV5Gsa2PHp50BCK3RSvl EgU5lFCK3l7kWra2dfdplr21JQ== X-Received: by 2002:a19:22c2:: with SMTP id i185mr14023531lfi.2.1544100258697; Thu, 06 Dec 2018 04:44:18 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:17 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 09/15 v4] gpio: devres: Handle nonexclusive GPIOs Date: Thu, 6 Dec 2018 13:43:45 +0100 Message-Id: <20181206124351.10155-10-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Pass a pointer to a pointer &desc instead of just the descriptor pointer: it is the memory address storing the pointer that hooks into resource management. 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..f9591b5c9748 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 Thu Dec 6 12:43:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153023 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479858ljp; Thu, 6 Dec 2018 04:45:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/XV/7t0aK5xUOt3wrfbh+g1U3OicvFxsZtx+zXBmbDfVmdlmovFdbCBApHzfcVT3qqvZ2Ft X-Received: by 2002:a17:902:b903:: with SMTP id bf3mr27523277plb.289.1544100301648; Thu, 06 Dec 2018 04:45:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100301; cv=none; d=google.com; s=arc-20160816; b=TDrt2YbP+IgFqGORyWHbAi4clhkcLjq+37cxGWJOKcQkBdQbNWIFkoYM3CHwzwkK0c Jv3ztBgwpaylXAKRIil8CQwrSGHe6GHCyALByX4dyn39GllxcWFOMd38HykRIrWhe2xa y9MJNy6LEb3DHAZMzmWpqELfUaPJFKcx7kKu93kgfb+/pve1KDN8y/EPoieC1nutpTJO GrgDk2CFUiDMKY5elluB+pKWOJfxqLa+VbJkIEKNJstmQtgaUaJXlHfXR4Vdq6La15a+ FoHaC8MlHLMqT0S9HKPIiBQ7TKKd5vdBCrIEcLxQaHO+zKCji2em02dm3N/ZHcNBfLVm u2fA== 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=m0RHJZseajc2Hw4Z+KYKfKkiR8hwIO3G8Y+psnfNew4=; b=ygZPXws2fGQRcry/JQTDDTWCs5eJO5jBBKKOijokjN2o9GGB4eokve43SvYdH0jAMT DkCNgOxKQ0v5hf2CCvdYplyAzdND+G5kPtwC3vEGAdWigqh7hFDheGhdnKR4EbTL12m+ 3vfqt1vLn0PmL68pOqleYivBUaJzGrzAOSXiZAfUATf8JvTgxVn+FJBm5y1f6tQ9hS7X 1B3lI/UzJcoeGubGj4LARizR46b/xyiYAEdC78P9b39A+R5HM8ayHRTlMLlftr6Ynu2u oyQJdttBO5qJRcT1xUmrytrieY2tQ4NF+bOulIJ9ubs7BFWuL6Aa6exryzX9V83PR7xx +c9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b4Y9SCB7; 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 p64si240753pfg.79.2018.12.06.04.45.01; Thu, 06 Dec 2018 04:45:01 -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=b4Y9SCB7; 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 S1729746AbeLFMo1 (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:27 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:38811 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729667AbeLFMoY (ORCPT ); Thu, 6 Dec 2018 07:44:24 -0500 Received: by mail-lf1-f67.google.com with SMTP id p86so246668lfg.5 for ; Thu, 06 Dec 2018 04:44:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m0RHJZseajc2Hw4Z+KYKfKkiR8hwIO3G8Y+psnfNew4=; b=b4Y9SCB7D7zraqlNG7d7lOK10xEvKIP5VAAtxCJ+nEq3Jvjc1pEw1WosBwP1QCyeko 7brm4VxHcNOiLQbaYmMAvZDdYrwJRpjFj7Z737OxwFwYlJ9ftG/43Vnd6x2epVLVW4X6 4rSnlJTTTWWI3doFqTN+NUj0B6oYk4m9XQ0PU= 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=m0RHJZseajc2Hw4Z+KYKfKkiR8hwIO3G8Y+psnfNew4=; b=n4ycO43DeNYBWW8T95A+6M6JpGH4pCedHBk8xkDX7lY9Q2GmXrwrAWC+949pnc/FgX CcNPNrzxfmufzh9Ql8PZEt21bBYHK3VQyKQbgenlGx3U3voHHYBzKEIxKPMohc/hRsLH +0tuh/Cppj+d6jl7hLjDDw92RCyOVnssA4r5UzZ8HCTFjBUGTdYrtfWiMRQU+jJvF6uc jM0XkptWTX/rFZNVqxhuMh11hblUntOa0S8lcpYe99AAt57v8WAeHjwFZg/TaeZiGezi 93n7TjvJQf3fBTfvJwTSnFNmxGeMXG1+c/dHMdgwv8zMvsJzMppc8tfpRG0LFNtjIhbm lbWg== X-Gm-Message-State: AA+aEWYUl3b9S1sc1RVl+LWE6gOoeSqrmSGKDpbGQ1oE7GZzao466yF6 KAbe9TrfhRy2346PKDX3RILYww== X-Received: by 2002:a19:5059:: with SMTP id z25mr16458447lfj.120.1544100260998; Thu, 06 Dec 2018 04:44:20 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:19 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 10/15 v4] gpio: Add devm_gpiod_unhinge() Date: Thu, 6 Dec 2018 13:43:46 +0100 Message-Id: <20181206124351.10155-11-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Pass a pointer to a pointer &desc instead of just the descriptor pointer: it is the memory address storing the pointer that hooks into resource management. 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 f9591b5c9748..0acc2cc6e868 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 Thu Dec 6 12:43:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153018 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479452ljp; Thu, 6 Dec 2018 04:44:30 -0800 (PST) X-Google-Smtp-Source: AFSGD/WmtVWsp0yO8U86cl6WZIpEgaWOiGm8LC8TB9tA+iLVpZADdq/G+FSdAELpfMedsh93eTpE X-Received: by 2002:a63:5a08:: with SMTP id o8mr22619172pgb.185.1544100270211; Thu, 06 Dec 2018 04:44:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100270; cv=none; d=google.com; s=arc-20160816; b=xldWEl9QiglaCw/rYxjVv67Pjavr8Am+O2Eyot/kKGdB+EME3UI8n3zZHu+RNQLhtV Z7sZRBeOngui6J9c5uWxpU/AY/OSJLMjcQpf+Lgcx94ptT9nmWu3BsZLcEs44lhBTdzp oh7UGVgNlBxIsiSk6GKzAGIIu7LmspeTqRvGnQwoGnPRFSx0BAN8iG46S62mXlNvwLnf QucDt+bcGmXcjZjf7trTic6n3pW6GbhWKg0UKMUiK0JqYx+zh3TWqC1sZqpOyQdIVnnw eRkROC4G6g9mlCDdSkgR2IbiPBgO801zo5b9kjY40JRUHzUXU9v6iBBSdIKsf1uUVQdy DBWg== 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=4y2b8gfjVdDJn6awlRT6qg9t1Md297IZ+m34M/dErEA=; b=hi+68fvVHiDGhcR8xO3ZtuYNPcMer/wJoLwODk1yW/Ywofgpjc62mooFhR/JXt5lYL COP5VeohugaxwlQckuPA1EdDKjrMmU3XbRqwtp2+5AqEWMpmVePP0R3ojXWru+Q1crg+ p9UYyGNgQU4VFIzpxuc9mFDBhKx0FjnNClCUJ5VQe1MDrzxWIaXb+QSQDq/XGz1NGId1 LaiN9CXDA0nBtKHnhtcNl7TaqrtGW2oiKdIx9hp8DM7RJcOOn5f95gpkvC0aRuaIROCB MMIHoHM/VDkepdRjWsku9BnpzovVAqLE/RtLYHuFzYalvIXTnh3aa+/cPcMOfFFrTv8V mIbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=INbC4BzP; 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 h68si208548plb.375.2018.12.06.04.44.29; Thu, 06 Dec 2018 04:44:30 -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=INbC4BzP; 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 S1729762AbeLFMo2 (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:28 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:34505 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbeLFMoZ (ORCPT ); Thu, 6 Dec 2018 07:44:25 -0500 Received: by mail-lf1-f66.google.com with SMTP id p6so262885lfc.1 for ; Thu, 06 Dec 2018 04:44:24 -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=4y2b8gfjVdDJn6awlRT6qg9t1Md297IZ+m34M/dErEA=; b=INbC4BzPSiBO1R9J+pKLcyUU3/vHy0yg3IarqReUW6CnBPkVWAujz8muLjx44C3Hb5 fYQa/g7RQ9A+C0JGdv0fS84V2zG72nmF6Bp1bTJZzELcq/GqtoY2qRMwT0pOF21EJ1GY vwXOy/b7874WUOMW3jep1wUr77MhxaB3nWdxo= 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=4y2b8gfjVdDJn6awlRT6qg9t1Md297IZ+m34M/dErEA=; b=WzWSFR3te0KfWUhUOG9prw9RWgoJQTR3Z1w36DVuse2ZBkQk03FzYfCCtAcnvjbx/2 gHFHnAXsTwkbMEppn8FSuuucBQkg8PDQnW1b/7isd/MZzEfS4OfojLlrUIk3139sGWwQ abRZ/bA5brfKZ4fxIaayuSsiWlv05AKNQoj82A9Yb0KWES3l1Dk6doC1iHOxTors1oTC zNFTBwQtnUNvoJU3Mgybos3ncyhRCUKoCoc6iiEHq3mCt+tc4AewxWLM2EYZ+hdqra0/ GJp05MWNfj2lScm9RF8VOy/vAnVWTLzxlGFmJ2REklhQ0TsOskSzckKTIbP1o3d5WOF6 fHIw== X-Gm-Message-State: AA+aEWaegiI54oeOgL9OVa4fdjI/2TIJKICpYXM5yU9lRu4D1v0VgA6d 3s5Q660e6gWsHLxh0SYA6WzhKw== X-Received: by 2002:a19:641d:: with SMTP id y29mr15632212lfb.14.1544100263304; Thu, 06 Dec 2018 04:44:23 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:22 -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 v4] regulator: max8973: Let core handle GPIO descriptor Date: Thu, 6 Dec 2018 13:43:47 +0100 Message-Id: <20181206124351.10155-12-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 probe path of this driver is a bit complex: sometimes the GPIO descriptor is passed to the regulator core, sometimes it is not. To handle it in a simple way: stick with the devm_* resource management and unhinge the GPIO descriptor devres handling right before passing it to the regulator core, if we pass it to the regulator core. Fixes: e7d2be696faa ("regulator: max8973: Pass descriptor instead of GPIO number") Signed-off-by: Linus Walleij --- ChangeLog v3->v4: - Stick with devm_*, use devm_gpiod_unhinge() to handle the descriptor for lifecycling in the regulator core as suggested by Charles. 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.19.2 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index e7a58b509032..9aee1444181d 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -808,7 +808,13 @@ static int max8973_probe(struct i2c_client *client, config.of_node = client->dev.of_node; config.regmap = max->regmap; - /* Register the regulators */ + /* + * Register the regulators + * Turn the GPIO descriptor over to the regulator core for + * lifecycle management if we pass an ena_gpiod. + */ + if (config.ena_gpiod) + devm_gpiod_unhinge(&client->dev, config.ena_gpiod); rdev = devm_regulator_register(&client->dev, &max->desc, &config); if (IS_ERR(rdev)) { ret = PTR_ERR(rdev); From patchwork Thu Dec 6 12:43:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153022 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479804ljp; Thu, 6 Dec 2018 04:44:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/UD03kH1HgJHAyY9Nn+n/oHnn+v3spAlHZ3GJwVwLTZj2G9UWApP4doFEMIeDfR7s5aLGvW X-Received: by 2002:a62:6503:: with SMTP id z3mr27641029pfb.169.1544100296633; Thu, 06 Dec 2018 04:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100296; cv=none; d=google.com; s=arc-20160816; b=WDDKQ+RM1kYSiRUVLKZjSKjFPpKcHLB0qRUgFp0fahUW9ApaVerZ4VdyVruRchP+cA B8pBFGgwlXAa6xHEAbJNLH48nzsMxOCBY7kNYOQupFWFEIlWWrlJiWaAgOUY3/cpoBGI KECjeiFp9MXT0tPN6WKcgRBwG//FWvEz1H1i0p5NIkjjP0GwNtTpskQLWJ0FZbxZzHAQ 5lmy9LCiIf/uQuw/tGt9v3bRCLl1mfLL6z9jHZbJtHJVVLVzgNRvR6i0d+ZLrKlf5W1p LkYaE+LUQGzUNqsvrwQbYhqmFrFYbU5hFTWQSYqgDs+cyhrnCIOM7TlgMu6v6lGPMF89 Q0JA== 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=vyagLHp/sFfdrPUwP8QrUjF5aczl7hYJlH6LPWav89U=; b=khPZAXZcJNwBV2nkshSOwJUNQZm4UolXAI3yo8+XwIp5AsVhGAc+nx19QjuwBw0lBQ PI2oEk1lrAXxA9VomwG/7AiVQYyHYLOfqjvkACSHEyirnzoDeXpqW4e8IyFwEJ3CEQte T9EVvdwjHDtZEcqL3vB7j7+ZfjX+3qjyGcPMLPb+hiVxbf0+tRsv5rZUsP6ea4SYh5Kk d/f0n/d2AL/XnE3gOJswJ5RxcvSXIGAxxjBJakoOgdh6xvcI9yzTemCIkgJZUBf8+ccX 2DU/+RKjgsvZqxeyuJc4qSVuMxOwviKSQMBogfXTmOEjc8LSz/iUrDj6ng8bcPC8ngc/ wgIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ACbcqWTZ; 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 p64si240753pfg.79.2018.12.06.04.44.56; Thu, 06 Dec 2018 04:44: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=ACbcqWTZ; 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 S1729843AbeLFMoz (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:55 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:41162 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729738AbeLFMo1 (ORCPT ); Thu, 6 Dec 2018 07:44:27 -0500 Received: by mail-lf1-f65.google.com with SMTP id c16so231548lfj.8 for ; Thu, 06 Dec 2018 04:44:26 -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=vyagLHp/sFfdrPUwP8QrUjF5aczl7hYJlH6LPWav89U=; b=ACbcqWTZu4q1jZsuA2mpyfmQGyAZoHlMQQIMiFP7co3YT9RQXoeUfxzdeEZ33JThn1 p4NmIPn1kdMpUX68Qdxj6ZWsm/sbdMMDY44qUrU30Erz3WqktKdt/RXJvd2D95hWurjb t0PZwrZY24g32YAmjf/Ox/kHurhjEfz/zvp0Y= 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=vyagLHp/sFfdrPUwP8QrUjF5aczl7hYJlH6LPWav89U=; b=LYIqdPufLxzlLEpkvuWGcBjqegwSMF/tauDHGCyEX2qvG0E9erqIemYEVmPAPdmeCj 9kra3DuwdplFt9DvRnqduE8DwvpxnbJ1d9tsiPLDkFtdq3Tu5XsZMrFtAnrJEdPJBlia Ai7+R1RotOIzWHUA4CaFE2C04AiXd0HKY+OCCkZg0apQmpXgqiDNNNSbZrqGb1Z17ZT2 xyfFvdBpGeOwyUyqc9Rq0i6jIuzK19QmTEofQCGq+hCVeUWSjDsLqRw7eyRAOt76GcZT gu2zNmORo5CF2kCi7hhI9LBS+LX7/SB/ORukZMHIK2THZkyn89Z2LQ4MhNScPw/XN/hl 20qw== X-Gm-Message-State: AA+aEWZ/m3jCjZ8x5w9gGiLacGI6Pvk4YiSxFHpkGRScZfOKHQQ+45Jr PPVOgl3KdraYyj+jtDdOGvCkUQ== X-Received: by 2002:a19:c014:: with SMTP id q20mr15686432lff.16.1544100265323; Thu, 06 Dec 2018 04:44:25 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:24 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 12/15 v4] regulator: da9211: Hand over GPIO to regulator core Date: Thu, 6 Dec 2018 13:43:48 +0100 Message-Id: <20181206124351.10155-13-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153019 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479502ljp; Thu, 6 Dec 2018 04:44:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/VwyrURtrToIeEr52r1t6ub/R54T9RSxOE1l6igzKgQ760sJxUebKrtfY1bMoT8rYRDHty8 X-Received: by 2002:a62:c28e:: with SMTP id w14mr28297318pfk.115.1544100274233; Thu, 06 Dec 2018 04:44:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100274; cv=none; d=google.com; s=arc-20160816; b=BleVxonOqeuDjmtQaYyG+YzsqNrEGGoSwqF/POOG0AHIuwEja2fe8WkGEoczlPE1Td dPmP6g3WHM18N6ZNJibB7aGm2c8yQGVzJxLG4zkx7MER696JmVUyHKPDmagJ6gkkEv34 aLWAJONXXzByZYV2qxz9TjPitChao31gX7eri6DcUezs5x2Vn8+sAS57ONyfYnTLqip9 jbueKNHKc9tmwFE6wW3rPz2b2LKktOmvgWm6A567Pb46z8g+4rSLx3V4gA1/k3AhEdOc 63AUPL4u/sW7aS5pMlntING4Lfi1Dqo+BaTgJxTUWvCBeyCavExMitUowRg+SFmN8DbT zJAA== 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=zGDBokyGc+waU3E1xYhS96RewI7zWHyNAJ0hdJjfFDM=; b=074D+Hy39rwz+B4RHoX4T2mXXSZlWmISadPggADMh5RchJJ/zJRXZi8rhusGVyNYyJ +Uk1jq7eHRg6WPKCGF2Lb3PBZEXwaN4fcOXa0Alle36LhimsfB3gaKyZjxUxBMFBDgJd RsQ90iSkEU/pE2q271zKZAYcFwXeREoKcKr1utVtQ7W49M2YuIb8mnt/wxcsQOaFJfwC yhxAtBpzEW3ZSsDTtXGk6/amTSM7bjIVveBCxbNiKRpuZWdh679XUkfYvENgzQ6e+rAG X+YcAsxd4utFREOuqOO7RwtXZAFlvb8MabjSIJAu1TS6WTNAbsFMJqIrENgzJQHu/g3g D3Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NrPm+qib; 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 f15si213227plr.144.2018.12.06.04.44.33; Thu, 06 Dec 2018 04:44:34 -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=NrPm+qib; 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 S1729786AbeLFMod (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:33 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:36416 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729754AbeLFMo3 (ORCPT ); Thu, 6 Dec 2018 07:44:29 -0500 Received: by mail-lj1-f195.google.com with SMTP id g11-v6so297501ljk.3 for ; Thu, 06 Dec 2018 04:44:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zGDBokyGc+waU3E1xYhS96RewI7zWHyNAJ0hdJjfFDM=; b=NrPm+qibyIgVlHSHLt0ZviQ+VgMeGK8smdvRd0xLjh9KoI4Mb7eRkh4l+ILhBr09S2 6AT3GiijfrzgnToNM+R9QdtDXKN569AsHfzWqp87ZhY4SuMImYBcRE4VqRA96XlthQV+ hIDlkvfDpGN9KiC4UnU6dz205zFamiPxaSBww= 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=zGDBokyGc+waU3E1xYhS96RewI7zWHyNAJ0hdJjfFDM=; b=cQrESawUA2/rRZj+KgvjNqH0tvTtTJeVL89/C5NmWPbiyksWX9NS1gYyWM1iidw0Z1 CfS/Y+86KoCquMshlXpVpDJtO8Li00T+6PitCwubonKp2ep1PDdmLlcZts5yDpteYIG+ Oibr4scLGumlBB5iGVLbqX8JkncrF+Q54ur9BGCtxCJnGhlvfUFwIzUfPo/A4jfdf+0J fIyyql7gZ9yc7qjV9vwbe8oAsSc35lH4/OYAvfwsoz/JC5JiM60elESFXQQP4DiTHAdx 6Dy+f/2fEYMv9v5JqGZlFH/+vF5XZFkrbsOg1sTCwZtg8IHldUA6PWoLCP2h1xgfvaBn /WXw== X-Gm-Message-State: AA+aEWYSVTx8nkrpv/CnRQ6jkTHt+E+5upISysk2s5SMMdZKMMTHhCJa hnQZAn4XbhmQYqdCoKUsEQcJ5Q== X-Received: by 2002:a2e:841:: with SMTP id g1-v6mr19744345ljd.21.1544100267205; Thu, 06 Dec 2018 04:44:27 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:26 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 13/15 v4] regulator: s5m8767: Hand over GPIO to regulator core Date: Thu, 6 Dec 2018 13:43:49 +0100 Message-Id: <20181206124351.10155-14-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153020 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479556ljp; Thu, 6 Dec 2018 04:44:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/WeoPhGA5CoQJiKI+22wlTnwldZlsC6RVdWM8ckZMHH/DN6Wj99vlSAJUHd+KLB6zEZBN2T X-Received: by 2002:a17:902:5588:: with SMTP id g8mr28202456pli.22.1544100277419; Thu, 06 Dec 2018 04:44:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100277; cv=none; d=google.com; s=arc-20160816; b=zbfFFLBl0eZ4WY2gKg0Ye5QiAzSfVDRobeMUUeWpBf5ZpoyRbyEb8eThYuQeS1vV92 dcYp09Dxhfm3uJ/F/A9go0OxvO1SR51x36eQvcQZhhUc4s7/wuQBFXvyX6iYrWQV3cyd V6fV82FPW9L66aVVeuLN2lykmBqaPpgR5WnmoMmogqEo6uFejPZJPaek7C5UxfqK4A6I cZQTfWI8u/FydU8WPhF8b1j1yI5ItsOQBR+/Ouw1MLHo3gF/cQDx/rxl6vo8dS/m1snU y0hmT0C+5VyEMer7OOup+lr4D+jK0F5GJfsLRkLbsulkA+8us/vmz1RoYrimrs1owMcJ Jcqw== 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=IltXzK2ZK9ZHKfiax7WiboCIbWrRkEm6SH9GClgJw54=; b=cJhIxKd/1Xv9GMF8551EUYCNrG5yoiRDUUFGK0FkCan1zUYfEAO7kkUavjcbG+9sk0 MhJmuOOoLEWEL5AEnayeZp2IWIEruP0b/kTrtUP95AuFUOfCtDcrCi5LufSoJlkEip/v 5vxkNEGGwYDbt7+Jm7XPLjcH/cOPAruJQNIgOExOi7ah8HJAHAxJuRMVygN6bVdac+cb wuUiyw9WKbTbu/cdtWyxBBp736vruPgumetQZP58p4fMu2S/WDvhSvBpjH25HozgWrQj L4yXcX/Kx6BByNdpWyNpZNPxl3GquCrTFKRRn6hRNzRheosLYlvKfrM4A/KXQ3xx8dzm L1FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UwaP5cZ6; 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 f15si213227plr.144.2018.12.06.04.44.36; Thu, 06 Dec 2018 04:44: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=UwaP5cZ6; 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 S1729799AbeLFMof (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:35 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:43416 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729369AbeLFMob (ORCPT ); Thu, 6 Dec 2018 07:44:31 -0500 Received: by mail-lj1-f194.google.com with SMTP id 83-v6so258543ljf.10 for ; Thu, 06 Dec 2018 04:44:30 -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=IltXzK2ZK9ZHKfiax7WiboCIbWrRkEm6SH9GClgJw54=; b=UwaP5cZ669Dbom7ZVrBTTqZdxfNr5vdfG0h8GBbULJ0pwa9g2JVOAOFClMYPId9u3N xfD0mt3KE+HQn11PRhKXdbO+54gkHXSFuWlAAWe/jfSTIx1pL6I7hi3yA3fJw9HN55kJ 1nqFC4yeiZ2xlL3n4v6ZVsmWwb08WEOIIw6ro= 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=IltXzK2ZK9ZHKfiax7WiboCIbWrRkEm6SH9GClgJw54=; b=DRGFqDFOwcrltAhYXjoTcZa6xsUaeAprnDOIWBGncy9NnAdrpu4X1TOt3cPJPIm38E zZxDSF3X6jW11l7geoIvpNg98lPLlSQFnSs3lPUZeQLOkNyvTyKVVIc0qDB53hYa1B5Y v2LjugasHxmpGxs+C0Y0Vbsyy6J8J2CKQWhF+r5Xi2CNRx40ZDAKr1sj7xp1vKxLNJou vKWS/j+vH6BZXTWMLl9Ty0Mr65+sIPOwIeA4cDl2h+GiYl+C8OiGpUsftajbukWiZZmv jnbQlUeE7v38QDzjWnoaI1tRTuwM75BznOjOA+8UqK8JPlq77vVpiLxvslMVOTqcD9SX ax4A== X-Gm-Message-State: AA+aEWZQq1vGZZoPt0F3g7wps/VoOFvb0gcpyRP9b59dJvQy+3VFlguQ oTJ8/Yv8KOZh0THmBYP2t6rchA== X-Received: by 2002:a2e:4503:: with SMTP id s3-v6mr18556920lja.44.1544100269257; Thu, 06 Dec 2018 04:44:29 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:28 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 14/15 v4] regulator: tps65090: Hand over GPIO to regulator core Date: Thu, 6 Dec 2018 13:43:50 +0100 Message-Id: <20181206124351.10155-15-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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 Thu Dec 6 12:43:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153021 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp10479618ljp; Thu, 6 Dec 2018 04:44:42 -0800 (PST) X-Google-Smtp-Source: AFSGD/V4IOVYZJ5C6aS43IO1/cCcmzcJOrrY1yC3vciNNo0btd+v+6st31jG6vEu6CXMsWLhzowd X-Received: by 2002:a63:b4c:: with SMTP id a12mr24340567pgl.131.1544100282452; Thu, 06 Dec 2018 04:44:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544100282; cv=none; d=google.com; s=arc-20160816; b=oqis6EoOOhqHp61OgFpyzD8NrucALe3D1nEQcfyl1iCXkr4UPhAS6JaGhZQKz/QDse Fu3zOg0jqDcRnEtVS/lWBZSfLJPd7M9dHvXTS2l8FF50/OKyexGEj0AgprNvh7w5f6M+ wVqwg+5Raj/Jn4MsFVI99qYLM+qY2bEPksFxpW/MYQfC+aCWR6cV/pb5XH+xrezLPsRy r+khM/NyvilVGFKoQLhFl8Q9bBTR8vg5YZ4hys49G8pBRtet/TMupTfKLQ4MRFfAc5b2 GWxLK1BLmgZ8wI2oAvyGfmMAB/MK7MTwzCKLZynU6IVNiqR+WEH9rJLFQttboa6eApnN CtNQ== 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=oKAz9vRWrhcJiPEjNMOm6R3Q3uTXzg6siwroEfHHagQ=; b=n5kJhpX1HpuNkvtQjPjl8hvb6otcGjpXtHFtI+8WD5yfxJ/vuUl0ANONHUwxbkdCsJ 2WN9F2JKe6JdlBrxKjblDRKR+RfVwbc7K2LnCMt3q3XMh2Lhe00p+G82SiuIl1CClUtv gS7dvNevg1jQDgdRFlbOdxkkbVEZYf1PbpjiOMXxPeZ744jr9ALGt0q6TXDTtCOAbRbU tevudAExEuZal2RdGoDjSGqHET+fpyeDL8EB0wGX2y0IHYogzCdVgvXCH2O9bO+iyGcG 5+Upt1N4kfKxgmq48elZDj9FFQzCnFe0Klnz1mZn0009Y+lJcRrUae4VlKKzMT+IZRcV 8ntw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ktqeeb5a; 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 f15si213227plr.144.2018.12.06.04.44.42; Thu, 06 Dec 2018 04:44:42 -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=Ktqeeb5a; 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 S1729820AbeLFMok (ORCPT + 31 others); Thu, 6 Dec 2018 07:44:40 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43421 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729778AbeLFMod (ORCPT ); Thu, 6 Dec 2018 07:44:33 -0500 Received: by mail-lj1-f195.google.com with SMTP id 83-v6so258638ljf.10 for ; Thu, 06 Dec 2018 04:44: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=oKAz9vRWrhcJiPEjNMOm6R3Q3uTXzg6siwroEfHHagQ=; b=Ktqeeb5ahv6w7WsxGlX9ficcZonMkHkUSX3y6h8JQbWBgbxCEyoUWhzMQnSfcnWdHg clj0NZdLA2ufjwYQXwVIytvZdSs1peFUgOw5MCUw0mRGUPfuc6cdlQ0ev+kcGKcD7t9z Q85XnfFi/KdI5kYfk+cxJa7Mv3p4rkk/63eIk= 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=oKAz9vRWrhcJiPEjNMOm6R3Q3uTXzg6siwroEfHHagQ=; b=EAdaWdhDMou2E5oPxNZkjuOnIzul4vE22XM5dJlSm+GP9IqV9nP8fV4Xz1kD2aPzd4 Eg7v9FH/tUkUq2JlcYDNTLvpoVK2fT0aQK7V4q0yiX04OZVbv3+bhUrKWZobjaS88f3G bZvlesyqpJ2zT7UIdOxTYfISyCD1pf0PQwLcRoLnQJ7fKDURL7ZZ0mPAyoP0MUEQUDp5 2qXD9ccBzq5MwcxE6c640hoqDslUC6lQctGOwdCPaVMYXoop99X1PhcEzCh9ejpLn4gW I1G443Vv5U+14j+SzzAhpFBs3leWk3WIr4lWqSM2mqH25k0rgFL8eUdUYAOA/tPScNgi p+4g== X-Gm-Message-State: AA+aEWZ4Q5gxF4vuv+TUhntL+VEJhN6gWtwmPfo5Ls8ztwMzi84qV/TE 1cj9g0eus2vfamJV/pJTIZ0+7w== X-Received: by 2002:a2e:55d3:: with SMTP id g80-v6mr20109433lje.78.1544100271217; Thu, 06 Dec 2018 04:44:31 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j25-v6sm44071lji.77.2018.12.06.04.44.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 04:44:30 -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 v4] regulator: s2mps11: Hand over GPIO to regulator core Date: Thu, 6 Dec 2018 13:43:51 +0100 Message-Id: <20181206124351.10155-16-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181206124351.10155-1-linus.walleij@linaro.org> References: <20181206124351.10155-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 v3->v4: - Resending. 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)) {