From patchwork Mon Feb 12 13:17:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128058 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3201026ljc; Mon, 12 Feb 2018 05:17:56 -0800 (PST) X-Google-Smtp-Source: AH8x225fvxmbFPNwGCjR4ULQDYgvTQYC5VfmL5KYVDS1seKV4n9SMTWbUMOJG8ibO04lVuGtmAVm X-Received: by 10.101.97.81 with SMTP id o17mr9131337pgv.31.1518441476268; Mon, 12 Feb 2018 05:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441476; cv=none; d=google.com; s=arc-20160816; b=h924vaNALhpbWFjVqKn8zWTHzxunQtKCsmd7+mEma5mYdMVHzzcQN3clCLMLRC33nO kpcVT30oVTA9+0Yrqu+FHUH/u6AgGiejLso9RkzzjqUvt4w0TJBAlc4lKwcBLhtVyJp0 CkvSXU3hZvzWtZZ7+L/BSU9xgxk5LpzhvODrdP5PlRoU8pziBb8WaxmHBkDdRnzOQsAU RE4XZDCQwyCd128IqgJZHHMIRXipDxto2+QDH3JpweE4dJYfcCy8Tlojxa3/3kWO0HBv gJqACnDW4Vmcjhxfi3ZYNzfD1gZVqxpwGI7u8Lns9ZfuCv/KQw7Sxh0K5Syyt45ZJh4l 2RAQ== 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=RsyPz2byMebkgBefjoKnveLBv1V/plcLVf4UjmoVAf4=; b=beQT3Ujk0PPk3AACQnOPTy5VNJM0vX7jfM296fHM4Ufb/KA9qM2we/s0+32o2bnaoa q8HWdsTaMDpNbefYApNTnR2YxzFEQPuZpbdaLLMQex8VPKFeodxd7U/YcIMd9z2ASD6v UWlbB4KRyfmP66R+Z/LFeKc+NWX2LQDMXccEmOJjJPUmjgaYQKeMs2HZ9sW2/un2A0gS v8LlU/zdWjlqnO4S7n9kojvImqKT1/Rwe1wLQ4Zqot/aJ8lbRh5Xss6Ptf/SoCM4NZmi nBt8DRQK/au/bJ9MmrdFCPnV9qG9FgjEGN9IItucLt5uFhR3gy/venkn6ofHnH6OPVZ1 CXbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=e4d+SiCL; 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 a84si2768073pfk.123.2018.02.12.05.17.55; Mon, 12 Feb 2018 05:17:56 -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=e4d+SiCL; 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 S935265AbeBLNRt (ORCPT + 13 others); Mon, 12 Feb 2018 08:17:49 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:40992 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935244AbeBLNRo (ORCPT ); Mon, 12 Feb 2018 08:17:44 -0500 Received: by mail-lf0-f67.google.com with SMTP id f136so20375354lff.8 for ; Mon, 12 Feb 2018 05:17:43 -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=RsyPz2byMebkgBefjoKnveLBv1V/plcLVf4UjmoVAf4=; b=e4d+SiCL6f2fuxG7TkAUd5qnqGwY0RNSCU7ausWcDU4aemEVtmhGzLo4K0syYQmXe3 6FwVmkFmWBKwtwTxppZbcplY8ZTrUa9W4AmwruIh9goLR/afJrCyVBFGICodWQhQhohR O0DNE+1euvyyXaB8v88+HNLIknuUY7Hit/+yQ= 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=RsyPz2byMebkgBefjoKnveLBv1V/plcLVf4UjmoVAf4=; b=IQ1vDZIcp68ZEB+DVU0j5ker1YSAceOyMhdlak8MiCZA0xymPagFXiC+O3hi0xOz0S 8RDtoXYwtUAfvgUvzFmQ+dVBVFaLZZDHoURBd6a6kGTz0vC3dUZ6Pyl+tDoGIM9oziud rgSpLwRemY8Yc2Gvy3syQRwvR4a8sgmATBzHGbiL5poyTRjZvXpEbqZWOPefhAPMBtGh 0b0kGOmC7PAJ+x29pQPB7fAM5gFQxNdHrcliLHkq9dYcbr0gifHe8q8t3N/JQj59KaIA fwF5ZAUk5oBCXdblYJxI0+IF682lc7MvOWKYxsa4J7Ud4wEAxipEL7KGSzMBzeZc8a/q swxw== X-Gm-Message-State: APf1xPCDOTIfb4x5tWHHVwe8rJsJSFY4vyZgpeLLNHZ3ObZgZnP79MaV fj2YrJUtw2kSSzbd2ywfI9JSdg== X-Received: by 10.46.18.148 with SMTP id 20mr1908421ljs.2.1518441463125; Mon, 12 Feb 2018 05:17:43 -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.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:42 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 06/21] regulator: da9211: Pass descriptors instead of GPIO numbers Date: Mon, 12 Feb 2018 14:17:02 +0100 Message-Id: <20180212131717.27193-7-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 This augments the DA9211 regulator driver to fetch its GPIO descriptors directly from the device tree using the newly exported devm_get_gpiod_from_child(). Signed-off-by: Linus Walleij --- drivers/regulator/da9211-regulator.c | 23 +++++++++++------------ include/linux/regulator/da9211.h | 4 +++- 2 files changed, 14 insertions(+), 13 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c index 9b8f47617724..6c122b3df5d0 100644 --- a/drivers/regulator/da9211-regulator.c +++ b/drivers/regulator/da9211-regulator.c @@ -15,7 +15,6 @@ */ #include -#include #include #include #include @@ -25,7 +24,7 @@ #include #include #include -#include +#include #include #include #include "da9211-regulator.h" @@ -294,9 +293,12 @@ static struct da9211_pdata *da9211_parse_regulators_dt( pdata->init_data[n] = da9211_matches[i].init_data; pdata->reg_node[n] = da9211_matches[i].of_node; - pdata->gpio_ren[n] = - of_get_named_gpio(da9211_matches[i].of_node, - "enable-gpios", 0); + pdata->gpiod_ren[n] = devm_gpiod_get_from_of_node(dev, + da9211_matches[i].of_node, + "enable", + 0, + GPIOD_OUT_HIGH, + "da9211-enable"); n++; } @@ -382,13 +384,10 @@ static int da9211_regulator_init(struct da9211 *chip) config.regmap = chip->regmap; config.of_node = chip->pdata->reg_node[i]; - if (gpio_is_valid(chip->pdata->gpio_ren[i])) { - config.ena_gpio = chip->pdata->gpio_ren[i]; - config.ena_gpio_initialized = true; - } else { - config.ena_gpio = -EINVAL; - config.ena_gpio_initialized = false; - } + if (chip->pdata->gpiod_ren[i]) + config.ena_gpiod = chip->pdata->gpiod_ren[i]; + else + config.ena_gpiod = NULL; chip->rdev[i] = devm_regulator_register(chip->dev, &da9211_regulators[i], &config); diff --git a/include/linux/regulator/da9211.h b/include/linux/regulator/da9211.h index f2fd2d3bf58f..d1f2073e4d5f 100644 --- a/include/linux/regulator/da9211.h +++ b/include/linux/regulator/da9211.h @@ -21,6 +21,8 @@ #define DA9211_MAX_REGULATORS 2 +struct gpio_desc; + enum da9211_chip_id { DA9211, DA9212, @@ -39,7 +41,7 @@ struct da9211_pdata { * 2 : 2 phase 2 buck */ int num_buck; - int gpio_ren[DA9211_MAX_REGULATORS]; + struct gpio_desc *gpiod_ren[DA9211_MAX_REGULATORS]; struct device_node *reg_node[DA9211_MAX_REGULATORS]; struct regulator_init_data *init_data[DA9211_MAX_REGULATORS]; };