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: 872061 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XNSFvyCu"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zg5rt4kB6z9sRW for ; Tue, 13 Feb 2018 00:20:46 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933383AbeBLNUa (ORCPT ); Mon, 12 Feb 2018 08:20:30 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:38467 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935273AbeBLNRz (ORCPT ); Mon, 12 Feb 2018 08:17:55 -0500 Received: by mail-lf0-f67.google.com with SMTP id g72so20371435lfg.5 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=Vb3MpADTT7aNmqQq0c+4FXHJVyxp2iJY4CSRbpH4A3VYCcM0zcIX97q11KqCLPvoF4 0R5wSTWGbZ++IJUSTpTVOpKe51Fc2xdjnOgU+qFdY5o89JZfyOmYC6vIrDK740KsbaKy nIHGkqH93UXxVUyIg866/Jn1QIPOhMEdxeHjjMh4VeIhRQLtHP0r4OG9DJUWKlERfbeu Wu4sfRnrUoqilLwoftCmKdCLGenv5ht7+PWzTJxzSecf8IWb2Vd52v3ik5EPd/qKcVQf 6MSiF2q1tq8XaGUUfwvFumknC1qgV19bVQJFKzViSrsUQTy62NuHP7XyDKnxJzS8n2qM PrcA== X-Gm-Message-State: APf1xPCDBdDRRb88Sd2iQTtA98pE8X8rsD5M3Jw0Kpd3mQMSQ46f/qDx JQOuAz3M7mf1ifuVZEsdBtc99g== X-Google-Smtp-Source: AH8x226e/SF8ovVnak8om+lcwsvj42ncxcO+AluAT8w/F7KxBWoATnk/GpWVOsP/WzX3sWAlMXkM5g== 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-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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 */