From patchwork Mon May 14 08:06:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135673 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439528lji; Mon, 14 May 2018 01:07:28 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrLYwzVy5bcPbruTbS1wVbCwAaT6NKoAtXwqJltaQsFHa89GO03F0/cMITlEoNE2qXZb9xA X-Received: by 2002:a62:5841:: with SMTP id m62-v6mr9310475pfb.116.1526285248469; Mon, 14 May 2018 01:07:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285248; cv=none; d=google.com; s=arc-20160816; b=N6wXEtEitlJi+OluWonYM9nSzeQAT6IinYn+/3k4GafMi2gbaPdr3kfcOsrtijKpYY 2ovZMK5dT2clqQrHuammH2c+LzKxFSrCKgn7zys7ifP4iBDIlhcu6hC4k7vGkkkVOJx8 FPJLvvtIjplCOss5Cq3YMqfRJ3rJin9KxjtNTTB9+mLxhsr6YzcSxRnsDff1jvB+Dg0M DzbrFO1wXvCZC7iY5jhZaN46aGXctz9V5GkHRxCnm5tqMEw6suG0zs98Zi78juKjweBW F528dvZ0ThOajvsx7XpfLsIa4r9RJ71qH3Thl0EiwS8jpiS570w4jSLB2PzyOdixkoSl 3TuQ== 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=9nalcnjUZwtmaa3nNf7lkkPs457m55ZkN12TbilrIc8=; b=YMXV0SKGDXMC/9mKSJuB2rZJ2Qo73KkrEfP7oytSwrmrMmLf+m+SjU1LVJSwqLivl3 zDEQk7uLZUbYL8iH7nSrEmgLG0SElxWCvoZi1SO2E/YsBhqtvYwY4/R9vX9JvBcndOjW eulUaJchVEO37wg0fY1PojsOLbp2cNKuykUIBPZYolRCMD5pgZ0+BtOopkWRhDAH7GPA zeWu9hJrmyWJScquQ9ckAgBGRbxMoLl55FcCCGplr6ipVuNJRl/dHy2yGEpmZ/A+9fH3 kay16Z6suhZnrAF8JAeQJC0iZq9iUjWIPcv8p5zD9paoCJQ3RINRcFxl5dsi9h+IW3K0 fQYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HUVBOIL4; 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 m198-v6si6785758pga.107.2018.05.14.01.07.28; Mon, 14 May 2018 01:07:28 -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=pass header.i=@linaro.org header.s=google header.b=HUVBOIL4; 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 S1752336AbeENIHY (ORCPT + 29 others); Mon, 14 May 2018 04:07:24 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:36047 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752208AbeENIHG (ORCPT ); Mon, 14 May 2018 04:07:06 -0400 Received: by mail-lf0-f66.google.com with SMTP id t129-v6so16536578lff.3 for ; Mon, 14 May 2018 01:07:05 -0700 (PDT) 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=9nalcnjUZwtmaa3nNf7lkkPs457m55ZkN12TbilrIc8=; b=HUVBOIL4wdGdQ2+mgbtzFQydlg26rnI+PJog3jnRxe11cHeIK5nj2nuAQtZiGbnKQy xq8Wngs0x68mpmzOYFSzWV3+z0q2o92YNjy2ZcVybiQJEsmbH585nPzOAg27x+3PSf6S ChhB1/SKoFyLdBgXKTmNMbhKh9KrBkSAJKowE= 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=9nalcnjUZwtmaa3nNf7lkkPs457m55ZkN12TbilrIc8=; b=tjJdJ4Q9GPayegTswVSTDMQtzkA2dI7IJVFpPpNYLt2ugqm0jwZ9OdKpaleQ1JMc8n FIiLkvI/PEj68GQbY0SyrDiyJmRn0O7hZcSfQ1pXyQ8tdzpScZQznxEx6UF2co62suP/ nMGvCbLFHxzJlHwugY2Wtdi1sI4L0FgOYYh8MwlJ7KJQ6MAVtrn2eTxYc4qyc4lpAhTs r9vDqOZYvJM3X7Ta73BGSQLvG9FgqAa56xq3+YZWjrW6znEEAEXaHjSepbjNWNcFiUAZ +4HOppBGrs1ZkZSnq/4eS62GSKdo2eC2IGYwxqm1efbb/5vYqIfat0NwmJ65K6jvxX6n /5LQ== X-Gm-Message-State: ALKqPweZBr3kX3X5bxuAcFuCACaQoshfjDd+Zg7pmSA8CkCk6o++k2ca uCrUIRVJkcPjaTo/ng0w+Z39Zw== X-Received: by 2002:a19:1142:: with SMTP id g63-v6mr6432969lfi.6.1526285224766; Mon, 14 May 2018 01:07:04 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.07.03 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:03 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , MyungJoo Ham Subject: [PATCH 08/19 v3] regulator: max8952: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:29 +0200 Message-Id: <20180514080640.12515-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-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 --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/max8952.c | 18 +++++++++++++----- include/linux/regulator/max8952.h | 1 - 2 files changed, 13 insertions(+), 6 deletions(-) -- 2.17.0 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 */