From patchwork Sun Apr 22 23:07:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133933 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp368361lji; Sun, 22 Apr 2018 16:10:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx49CtxXZKFpBxYtTXfcEK0Er2cPFCnPc+uww9MO34GOKRNd3ymBmOe8NVublgHDGJJrHYuUA X-Received: by 10.101.92.199 with SMTP id b7mr15085547pgt.138.1524438626391; Sun, 22 Apr 2018 16:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438626; cv=none; d=google.com; s=arc-20160816; b=Ai4SrLAaej1pn2d/peTmn6Xp1ZQYl03OOYMpQQji6N+GZUfWY6Got1oPrthedTmjl8 7TapDdwtBxEj+bPQjgyc6G8dVbM0Uvgp9nJae3nCvCOSw1PWT1YzvGTkApX92mhHIH9S +uX7K2Lzy7HOCdqk5MJPq97O8Kw8t6v93j7ndZvTTzIOko3vB4lB+r21jPJhqgfKe4tG FptL5US1W7smeKNi3OU+5w8jHxmHnlLbmneZmtUPtsskic+qKfbtOEaW8KGe5R6St0VT mmgRdAyntewubcUV4ivoQsfgDJJIoAtlHoSWExnL2tAREcwQhBSXLefilp4+fILdCFuY itXw== 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=1aAH3/DOprUFfoUxWrYf4OE5Jq3e3uU4AuGdfJ0Sdjc=; b=TeUO8RHuQmq1qqzcBqnz7Z5mC0RiywPEwyrNjXEGHLjhfVuaoEXEhr0arcnD9PC3ND XjVMkxbCvBTpt0FZ8oIgCbf7uvTLP7tCQ0RFc/4pMdV7l6ppwAK2E3OJ+LgmqJClyE/E wew1CXHecS8gNRXDySIw66zAf5XDw15R8dbJW8P9dqFvmLY9yU40IfJyPXZFyJzZU5lo Hi5k1gbkbWMPh0akMZm/ryMVC+a5/OXK7rF8WziR7HXpVLsn0mCy1xoYpA8P6No2YZKu 5tHnYsHrcM/is19o7S/ntEgnvxnvcSxm5Z46sOhsW3OjAn1j7xuFAP8swNwFePpnOz+d wq4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zu+i3/LD; 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 l85si10041497pfb.231.2018.04.22.16.10.26; Sun, 22 Apr 2018 16:10:26 -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=Zu+i3/LD; 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 S1753918AbeDVXKU (ORCPT + 29 others); Sun, 22 Apr 2018 19:10:20 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:45823 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753814AbeDVXKL (ORCPT ); Sun, 22 Apr 2018 19:10:11 -0400 Received: by mail-lf0-f65.google.com with SMTP id q5-v6so12198049lff.12 for ; Sun, 22 Apr 2018 16:10:11 -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=1aAH3/DOprUFfoUxWrYf4OE5Jq3e3uU4AuGdfJ0Sdjc=; b=Zu+i3/LDWJuYIvzki8dCWMUKjrHRSLcB5iZg8+s8ByghsrnB7PUk0QuVtgCk78lC4z xqfhwwfnz/VKU0HCkVZssu1B07oCrXr5RYdoDigB7YxkN99YRcdU+FjbXxW6D13drYYD lc1182x+heAV1EVhzS9DAY5BDmFI3QGV5Qlzw= 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=1aAH3/DOprUFfoUxWrYf4OE5Jq3e3uU4AuGdfJ0Sdjc=; b=MLd2Z7HrYa1k7GoXUW1lxzUOVWeDtW1YQmRFNHcxVsQd9iKkubd7U9yeNDpHLRJ9vc FHS3ul/mAK22PisbR8my8GO+nUgViT6xTF4MzK9fnckgqy5wlxFP7vcr2ewFlCBPorzP sCtbK5Q87XrKVcQzdBWyFJXC+3O3wVKOGG6UIyQjE6xFPohoD3PGSm1T3NP9K/+e5whK mb4MwLrlp6cmO4y8QwKOmfssudeEhvUNp3AAEEtbWGm5kxqxG9C4zB6pj6yUMa/0eOuc jJ71WfSBlkIC20lW1fUuCjwb1l52kOr2NlZNFl8F6JRA4jKB7ReLQFHic3LCdmiZ+can BhoQ== X-Gm-Message-State: ALQs6tA8wWjR0h/EzcIWBzgnJ2omFiuV1AjrBnVb84+0/tRYlXbj3IWA WOR2mzsv8WUyRuVqlBhlRGOssQ== X-Received: by 2002:a19:e583:: with SMTP id i3-v6mr6500123lfk.135.1524438607711; Sun, 22 Apr 2018 16:10:07 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id r25sm2036291ljc.8.2018.04.22.16.10.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:06 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , MyungJoo Ham Subject: [PATCH 08/18 v2] regulator: max8952: Pass descriptor instead of GPIO number Date: Mon, 23 Apr 2018 01:07:32 +0200 Message-Id: <20180422230742.3729-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180422230742.3729-1-linus.walleij@linaro.org> References: <20180422230742.3729-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 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.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 */