Received: by 10.223.185.116 with SMTP id b49csp1042369wrg; Fri, 16 Feb 2018 11:20:34 -0800 (PST) X-Google-Smtp-Source: AH8x22556UKIdIRNCFsddGt/qEJUp0gifRtUhC0yesL51Z9hdFhL/9oWwHTjj2Lb/Fnhk7LQAH75 X-Received: by 2002:a17:902:3a3:: with SMTP id d32-v6mr6756310pld.219.1518808833897; Fri, 16 Feb 2018 11:20:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518808833; cv=none; d=google.com; s=arc-20160816; b=cMT41LsSPqawhG1yozf47w99HGiB1ex9HT9SBMn7PmziDoLPQYqceq8xPUPAST70+R mj+u7GDm9rZGeaHLnd3CXcEYls2vKgE1lR4eKjyyuHvmoWvjOvWW2hM73v0j78qUrh+/ /MvKch5k9NsWG+BUItYTE7XVNSoCYs1ftOY3ihP5uMstwFxcT0cx+DYIMAyNvmO82yEP sD3s95SI/bU/s6LBIIlp+Hq7pz5AFL3KEigosvt/u3iMf+fubh2xFFkinbCyZuAwTcmW ld5BMNchLnjICiRw+aTLG7Ri6dFk3RLBbLkxrMLizMWKPSRFJmtBKETLa0eZ0SaHeaVq INIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:in-reply-to:subject:cc:to :from:dkim-signature:arc-authentication-results; bh=Zl8Cj/InzfHDcdXfc4o8AMrbmeuzg60raS7k6TU+EFY=; b=QY2ElqjkMDiL5XBlVoCWJcT9qLsUho8jubAVBVzftJdIF6MZ49B4xHwMH6C5utbod4 +HvV2E/hcZlrK9TY/ehpDaR0FrK59XS9AvaZiwoDSHRMKNtb9/IP8+CRaGED+pWW6lGD 5ATpTOx6SN8D1AqEuFvcWkcrqYBYx/v/Um9RjP5wxavGNu98XLWFXjzxgvLdvWtuyz2T lhE/1ZV9aE1Bbr9iTcZmEGeewUYiU4M8FjINCaM0T3iDCK/SJnQlaJby4qVi0ssK+yQD TYyyLUy1eSuxVYl1seJPIBUVvB6Zxa1+ov03mHQhyglITMDN8CtJgVWiSq7tvscVE0fJ hcRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=atne43y0; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1-v6si1767995pld.637.2018.02.16.11.20.19; Fri, 16 Feb 2018 11:20:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=atne43y0; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161803AbeBPRMm (ORCPT + 99 others); Fri, 16 Feb 2018 12:12:42 -0500 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:48408 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161754AbeBPRM0 (ORCPT ); Fri, 16 Feb 2018 12:12:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=Zl8Cj/InzfHDcdXfc4o8AMrbmeuzg60raS7k6TU+EFY=; b=atne43y0O8j7 cXFhB4xcWUPgRspW2dN0H6rZbWf4DAw1Fwlas00u8mqYl+CK3wktEREGbdyHv+KrNcXzesXroNHxx wV07zrNAajYg9hAgjp+I29dlTi1mLhn6sKpF53FzIYH2il3y1BhtQUbujfrd8EvmwhPvbGXfjHnks 469M0=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1emjYe-0004uU-ME; Fri, 16 Feb 2018 17:12:24 +0000 Received: from broonie by debutante with local (Exim 4.90_1) (envelope-from ) id 1emjYe-00085Z-7c; Fri, 16 Feb 2018 17:12:24 +0000 From: Mark Brown To: Linus Walleij Cc: Mark Brown , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Applied "regulator: core: Support passing an initialized GPIO enable descriptor" to the regulator tree In-Reply-To: <20180212131717.27193-2-linus.walleij@linaro.org> Message-Id: Date: Fri, 16 Feb 2018 17:12:24 +0000 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regulator: core: Support passing an initialized GPIO enable descriptor has been applied to the regulator tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From e45e290a882e2c0dc8ebb7dd21c66a8209d8e3a5 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 12 Feb 2018 14:16:57 +0100 Subject: [PATCH] regulator: core: Support passing an initialized GPIO enable descriptor We are currently passing a GPIO number from the global GPIO numberspace into the regulator core for handling enable GPIOs. This is not good since it ties into the global GPIO numberspace and uses gpio_to_desc() to overcome this. Start supporting passing an already initialized GPIO descriptor to the core instead: leaf drivers pick their descriptors, associated directly with the device node (or from ACPI or from a board descriptor table) and use that directly without any roundtrip over the global GPIO numberspace. This looks messy since it adds a bunch of extra code in the core, but at the end of the patch series we will delete the handling of the GPIO number and only deal with descriptors so things end up neat. Signed-off-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/core.c | 25 ++++++++++++++++--------- include/linux/regulator/driver.h | 3 +++ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index dd4708c58480..4549b93b0ff9 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1937,7 +1937,10 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, struct gpio_desc *gpiod; int ret; - gpiod = gpio_to_desc(config->ena_gpio); + if (config->ena_gpiod) + gpiod = config->ena_gpiod; + else + gpiod = gpio_to_desc(config->ena_gpio); list_for_each_entry(pin, ®ulator_ena_gpio_list, list) { if (pin->gpiod == gpiod) { @@ -1947,15 +1950,18 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, } } - ret = gpio_request_one(config->ena_gpio, - GPIOF_DIR_OUT | config->ena_gpio_flags, - rdev_get_name(rdev)); - if (ret) - return ret; + if (!config->ena_gpiod) { + ret = gpio_request_one(config->ena_gpio, + GPIOF_DIR_OUT | config->ena_gpio_flags, + rdev_get_name(rdev)); + if (ret) + return ret; + } pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL); if (pin == NULL) { - gpio_free(config->ena_gpio); + if (!config->ena_gpiod) + gpio_free(config->ena_gpio); return -ENOMEM; } @@ -4154,8 +4160,9 @@ regulator_register(const struct regulator_desc *regulator_desc, goto clean; } - if ((config->ena_gpio || config->ena_gpio_initialized) && - gpio_is_valid(config->ena_gpio)) { + if (config->ena_gpiod || + ((config->ena_gpio || config->ena_gpio_initialized) && + gpio_is_valid(config->ena_gpio))) { mutex_lock(®ulator_list_mutex); ret = regulator_ena_gpio_request(rdev, config); mutex_unlock(®ulator_list_mutex); diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 4c00486b7a78..4fc96cb8e5d7 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -19,6 +19,7 @@ #include #include +struct gpio_desc; struct regmap; struct regulator_dev; struct regulator_config; @@ -387,6 +388,7 @@ struct regulator_desc { * initialized, meaning that >= 0 is a valid gpio * identifier and < 0 is a non existent gpio. * @ena_gpio: GPIO controlling regulator enable. + * @ena_gpiod: GPIO descriptor controlling regulator enable. * @ena_gpio_invert: Sense for GPIO enable control. * @ena_gpio_flags: Flags to use when calling gpio_request_one() */ @@ -399,6 +401,7 @@ struct regulator_config { bool ena_gpio_initialized; int ena_gpio; + struct gpio_desc *ena_gpiod; unsigned int ena_gpio_invert:1; unsigned int ena_gpio_flags; }; -- 2.16.1