Received: by 10.223.185.116 with SMTP id b49csp2394163wrg; Mon, 12 Feb 2018 08:52:47 -0800 (PST) X-Google-Smtp-Source: AH8x2264hxak1VM+SUAevWEPhFd82+e5WtkUNZ3XeRzgfWVbJpRfrn9Msr8oEb+9Dlg9n7abnZN4 X-Received: by 10.99.131.198 with SMTP id h189mr9873441pge.25.1518454367079; Mon, 12 Feb 2018 08:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518454367; cv=none; d=google.com; s=arc-20160816; b=Zcu4pZTaHqcNmPeJbtdBKhTyFIMfdh3n19WtFdjW1mUUoZNOyjj8kfzEee6jagxbT5 94B0Qeb/1b3Yl1ggxD31VQxhiDkwyP5ICCrdlkBm73Sp1wLReBvO4kO2x4UoF1nIhYFk tjlXk0qLueiw5l5emSGbAYEG+KesJwnSZcE5Cuz/o3SImtZvOtorpKuG+RuUzZUmhYQZ 7WlLiLC+FiEVNz14/Eu2P8cjGCuiogH3xTtpoRtLpEJd0AJ3+EIyiI2l2q3b5ljHZVJj TfbqdwyNHT7VtrRihSwO/wszVMA+e2Va3n1spPGXo+T8xA7M897vAjK3j5Y2qb9+rxye hh2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Jowt3NVe7JIhWHR8w1Z0NKR7kafoKEQYAcz0tncbGlk=; b=WwBBHQUec/k3CgLtl6EfrwV0FAw2LepISR9R0lfccat0TF5ElDhD7X6Xq9QAWuY0d/ Y8BVRZeZckLQ0fzLVFQ0pN10sBfzwAbIiEJGZNLlWylILCWmBjfhplXDQVM5EPuT6Rps 8QkXsaFV+/GT/oFjtamZ3WBHKp5sFezmGGRhZ6TUiF+y8P248Oga2Pdk0I3yEn6P0EVy JCISf/ywctLmLiIe/eLqJ5Irnbln+Q7XdiF4RQ/umNOVlmFVx6OPZCBwPMkEG/xwSZbl yAESXTIp47vrhHTc3zwK2zwRPDdJcbWHR06nWfLdFryFqxtdWyk9AUaBXhOgLMAgPAcr TC0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XNSFvyCu; 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 i12si292469pgt.301.2018.02.12.08.52.32; Mon, 12 Feb 2018 08:52:47 -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=XNSFvyCu; 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 S935436AbeBLNUb (ORCPT + 99 others); Mon, 12 Feb 2018 08:20:31 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:43100 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935272AbeBLNRz (ORCPT ); Mon, 12 Feb 2018 08:17:55 -0500 Received: by mail-lf0-f67.google.com with SMTP id q69so2534503lfi.10 for ; Mon, 12 Feb 2018 05:17:54 -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; bh=Jowt3NVe7JIhWHR8w1Z0NKR7kafoKEQYAcz0tncbGlk=; b=XNSFvyCumBL1geRxiMszE5wBuUdY1phHLrv7VIhO3YhFe5uxXUHlcsqQSy1mn3sYkt aVzL9QRpSijypAKsQyrwTv7vVAZLJQ/1F1hsrG2hJTyBJTjbv6VzV+Jlj0uvdopXJaKe brVBwCSXhS9FAL3/i8IlDDM/Ft0Ya6psZJ3S4= 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; bh=Jowt3NVe7JIhWHR8w1Z0NKR7kafoKEQYAcz0tncbGlk=; b=APYqYJVNxD1RHpjP3NSc4SKEcSfmf9bXXE0q/fChjJzT/1oe71ppUE/nth+SvkD6aS 7Wu+TAvH589T3WFZ+kZ1gf90HD2pkDfuwxwJcE7CrQkslP2gST3Hz4BbExX4KnSpRXXm VOQmxsuKjzbnMpczTTtlV+IfDCbuGy0RN7D1tY88XTa438S3wKRWgFFgR9zHTlkLrXFk H5eiS40remELgQXWWscWJZCjyPVo7fwSIsKyySMa7lytmkf+gYAo1DUr8e0Sy4raOLRS YGva7DhXYYENQTaWZzaMrgrB9bnoM3NV12JxmZoeybWk82WHFFufiSU50wsS+GRb/OFy +nsQ== X-Gm-Message-State: APf1xPBA4SjTMOXYXnoAS1N9WPWGm6flHdXX4syPXmbzbw7qi9X2GxhA R6k0eQMkxKW41yp05Ip0p9lcPA== X-Received: by 10.25.205.148 with SMTP id d142mr7098931lfg.9.1518441473957; Mon, 12 Feb 2018 05:17:53 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.17.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:53 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , MyungJoo Ham Subject: [PATCH 11/21] regulator: max8952: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:07 +0100 Message-Id: <20180212131717.27193-12-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180212131717.27193-1-linus.walleij@linaro.org> References: <20180212131717.27193-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number for the enable GPIO, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. All users of this regulator use device tree so the transition is pretty smooth. Cc: MyungJoo Ham Signed-off-by: Linus Walleij --- drivers/regulator/max8952.c | 18 +++++++++++++----- include/linux/regulator/max8952.h | 1 - 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c index 1096546c05e9..f1e77ed5dfec 100644 --- a/drivers/regulator/max8952.c +++ b/drivers/regulator/max8952.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -148,7 +149,6 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev) pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0); pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1); - pd->gpio_en = of_get_named_gpio(np, "max8952,en-gpio", 0); if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode)) dev_warn(dev, "Default mode not specified, assuming 0\n"); @@ -197,6 +197,8 @@ static int max8952_pmic_probe(struct i2c_client *client, struct regulator_config config = { }; struct max8952_data *max8952; struct regulator_dev *rdev; + struct gpio_desc *gpiod; + enum gpiod_flags gflags; int ret = 0, err = 0; @@ -224,11 +226,17 @@ static int max8952_pmic_probe(struct i2c_client *client, config.driver_data = max8952; config.of_node = client->dev.of_node; - config.ena_gpio = pdata->gpio_en; - if (client->dev.of_node) - config.ena_gpio_initialized = true; if (pdata->reg_data->constraints.boot_on) - config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + gpiod = devm_gpiod_get_optional(&client->dev, + "max8952,en", + gflags); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) + config.ena_gpiod = gpiod; rdev = devm_regulator_register(&client->dev, ®ulator, &config); if (IS_ERR(rdev)) { diff --git a/include/linux/regulator/max8952.h b/include/linux/regulator/max8952.h index 4dbb63a1d4ab..686c42c041b5 100644 --- a/include/linux/regulator/max8952.h +++ b/include/linux/regulator/max8952.h @@ -120,7 +120,6 @@ enum { struct max8952_platform_data { int gpio_vid0; int gpio_vid1; - int gpio_en; u32 default_mode; u32 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */ -- 2.14.3