From patchwork Mon Feb 12 13:17:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128074 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3203251ljc; Mon, 12 Feb 2018 05:20:35 -0800 (PST) X-Google-Smtp-Source: AH8x226DKQYwp0sPnkZhDffUGcVz1EzwxwQuVR+aSP3FoBBzkvkoveh54uTDaLiDHDkOcetNU/As X-Received: by 10.99.4.197 with SMTP id 188mr2781886pge.359.1518441634909; Mon, 12 Feb 2018 05:20:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441634; cv=none; d=google.com; s=arc-20160816; b=03NOV5w82pK+aKJbLtBlL3Bbpvx9PtMIv9W6eb1IlPTU/iAhhquw2i1WC8gXwsYeIp 3SISk/gXN7mRQRgLhI/ivfPF2fSVnGvUqZ/eWr8FCxPjRGdpk4qPwdS8PmxGPoBF5gex fEJNJX4G5Z5c6Kq1qjK+lf7koMsHF1+iZJ4KY+uuBmC6l0zFStf0d4YMR76gNj0kohW1 7w0noZGzIzzGq009C6vX/Aofompd0v1+JnDSLHo5TzSLcRrVMJxgDey1/rlrSzIItxks ysGe90dup7EN3yEkxj1jqSlDEhVcGDL5ef03N3JLCoUTwT6P0kYxHC7B4+7HXTNDPPiY a+bQ== 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 l9si2769133pff.155.2018.02.12.05.20.34; Mon, 12 Feb 2018 05:20: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=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 S935439AbeBLNUb (ORCPT + 13 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(-) -- 2.14.3 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 */