Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2947293imm; Thu, 24 May 2018 19:40:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqgmjPZJK/WZEa0uB9dpECAXipzp/AfzvNqryDIpK3Cb5DUSN4sdf6kU0D2HjqV+dRG7MTe X-Received: by 2002:a65:4ac8:: with SMTP id c8-v6mr489696pgu.246.1527216006418; Thu, 24 May 2018 19:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216006; cv=none; d=google.com; s=arc-20160816; b=R2nYc+ac0HifrdLpdgRASJZAm3vtyeDnqGRQFZ7Srl5lCGztlY8B74Cg+akh2jIw1H eBlLuMa9BezTnUWv9qKpCTKC5rLx6bDji12GU3TlHGUBcM9ZkvjlMpK9aPmB5nMxKYhS HAGN370mcUdyPm37pV11o1oJVKSstAR3sbfcWVPyIuXjQS6zHWeo8mbA9HYtWHePJ8Qt yPTglDBDnmIQzSdldpIzAp+U3KKPoF9G1Nx9G1ofq5Zzxw62ofuzur4NonOll5K5k/Hv L4OrW/XQXOLFc/+1poQRAFG1JU/pAUnrZeJkSbUfjDl6iCj9ufPOOO60wRX2Pgk2wuaL uO9w== 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=JQ/hk4VGNLGn3vpU0rCTq+8/JjD8lJlj4IWWyFhDPQk=; b=S1PnefptyNPmpTz4A0IPhNNJ+ObB2/3kZ0tDMG1B7Cu3lj0IG0KSQ7wq/Wu7AWRCuj 4NOhvbkisvJfT0Q/o7Mi22rnLdLkcXgw/2gT1mf+6UOIp3I1oPzLx3lanB/m0ULQHb4G Y9uctH4rHz1SrIjJcpx5EliE05X3cU0RxkCsL5HgX4++Q8qDjW793HZL80octKqeePVU 6NrKsxGzhkP1A1P8vl2vja48Cn6GY1vAC/h4tcS0U158SqbogK+kyvVnA0Atmqdcbs8P c3+4qbttDdxvSUAmOyIUbO23RZKRLHeMv1y84OsEgqeOBTOJKHrScitfSEWPUvedx5+C ICQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=wEDi05wj; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si22366906pfi.285.2018.05.24.19.39.51; Thu, 24 May 2018 19:40:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=wEDi05wj; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161167AbeEXTOe (ORCPT + 99 others); Thu, 24 May 2018 15:14:34 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:56596 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967742AbeEXTO2 (ORCPT ); Thu, 24 May 2018 15:14:28 -0400 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=JQ/hk4VGNLGn3vpU0rCTq+8/JjD8lJlj4IWWyFhDPQk=; b=wEDi05wjyqLH F3ftl5w9tMOW2GT1xpwETV39FKhdVHF7HUwTZXIxXO76RVuBHUvi57VGZEorzjZE/9P8p5nXnQHE+ UK7P7DzdQudfOmaX6L/EcGGxuyaarBsua15Bgo6Rd0Pyc3Q4uGHHgwkurTcpMWAe13RCLYOeBVRtl Vje6I=; 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 1fLvgt-0006LX-GY; Thu, 24 May 2018 19:14:23 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fLvgt-00069Z-0U; Thu, 24 May 2018 20:14:23 +0100 From: Mark Brown To: Linus Walleij Cc: Mark Brown , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Mikko Perttunen , Laxman Dewangan , linux-kernel@vger.kernel.org Subject: Applied "regulator: max8973: Pass descriptor instead of GPIO number" to the regulator tree In-Reply-To: <20180212131717.27193-8-linus.walleij@linaro.org> Message-Id: Date: Thu, 24 May 2018 20:14:23 +0100 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The patch regulator: max8973: Pass descriptor instead of GPIO number 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 e7d2be696faa3c8add5b21006ad8fec6b6ed85f1 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 14 May 2018 10:06:25 +0200 Subject: [PATCH] regulator: max8973: Pass descriptor instead of GPIO number Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. Signed-off-by: Linus Walleij Signed-off-by: Mark Brown --- drivers/regulator/max8973-regulator.c | 54 ++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index e0c747aa9f85..7cd493ec6315 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -114,7 +115,6 @@ struct max8973_chip { struct regulator_desc desc; struct regmap *regmap; bool enable_external_control; - int enable_gpio; int dvs_gpio; int lru_index[MAX8973_MAX_VOUT_REG]; int curr_vout_val[MAX8973_MAX_VOUT_REG]; @@ -567,7 +567,6 @@ static struct max8973_regulator_platform_data *max8973_parse_dt( pdata->enable_ext_control = of_property_read_bool(np, "maxim,externally-enable"); - pdata->enable_gpio = of_get_named_gpio(np, "maxim,enable-gpio", 0); pdata->dvs_gpio = of_get_named_gpio(np, "maxim,dvs-gpio", 0); ret = of_property_read_u32(np, "maxim,dvs-default-state", &pval); @@ -633,6 +632,8 @@ static int max8973_probe(struct i2c_client *client, struct max8973_chip *max; bool pdata_from_dt = false; unsigned int chip_id; + struct gpio_desc *gpiod; + enum gpiod_flags gflags; int ret; pdata = dev_get_platdata(&client->dev); @@ -647,8 +648,7 @@ static int max8973_probe(struct i2c_client *client, return -EIO; } - if ((pdata->dvs_gpio == -EPROBE_DEFER) || - (pdata->enable_gpio == -EPROBE_DEFER)) + if (pdata->dvs_gpio == -EPROBE_DEFER) return -EPROBE_DEFER; max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); @@ -696,15 +696,11 @@ static int max8973_probe(struct i2c_client *client, max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; - max->enable_gpio = (pdata->enable_gpio) ? pdata->enable_gpio : -EINVAL; max->enable_external_control = pdata->enable_ext_control; max->curr_gpio_val = pdata->dvs_def_state; max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; max->junction_temp_warning = pdata->junction_temp_warning; - if (gpio_is_valid(max->enable_gpio)) - max->enable_external_control = true; - max->lru_index[0] = max->curr_vout_reg; if (gpio_is_valid(max->dvs_gpio)) { @@ -757,27 +753,35 @@ static int max8973_probe(struct i2c_client *client, break; } - if (gpio_is_valid(max->enable_gpio)) { - config.ena_gpio_flags = GPIOF_OUT_INIT_LOW; - if (ridata && (ridata->constraints.always_on || - ridata->constraints.boot_on)) - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio = max->enable_gpio; + if (ridata && (ridata->constraints.always_on || + ridata->constraints.boot_on)) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + gflags); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) { + config.ena_gpiod = gpiod; + max->enable_external_control = true; } + break; case MAX77621: - if (gpio_is_valid(max->enable_gpio)) { - ret = devm_gpio_request_one(&client->dev, - max->enable_gpio, GPIOF_OUT_INIT_HIGH, - "max8973-en-gpio"); - if (ret) { - dev_err(&client->dev, - "gpio_request for gpio %d failed: %d\n", - max->enable_gpio, ret); - return ret; - } - } + /* + * We do not let the core switch this regulator on/off, + * we just leave it on. + */ + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) + max->enable_external_control = true; max->desc.enable_reg = MAX8973_VOUT; max->desc.enable_mask = MAX8973_VOUT_ENABLE; -- 2.17.0