From patchwork Mon Feb 12 13:17:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 128073 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3202965ljc; Mon, 12 Feb 2018 05:20:14 -0800 (PST) X-Google-Smtp-Source: AH8x2272HwpHe+XLRVbqZJBQmTu7VniwVPZtzTykMPN+TyGipuPXGl3uiZyHLSf2szyjA4gEYAwI X-Received: by 10.98.102.88 with SMTP id a85mr11725775pfc.235.1518441614679; Mon, 12 Feb 2018 05:20:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518441614; cv=none; d=google.com; s=arc-20160816; b=k9BVcAImDm1Cf3feB2QIY5W1Ywdc3VXUnURMbvkbwsV3douhzx9Gn/SOGfqJnI76gZ ks8MKUh/NoJwKv7ZTiL9+Ox4T+R6zry5yyjYrKQd8U+a2ZVJtzxSMS9mG/2kSKLu3MMd wBvnAjpONXJyTl0t/1ZLFq7v+sPrOJ+Ycs8v03UMSsyzwI/rfyFLIqdCa3N1W8cra26x SEqRfQM7L7n+fMkJ3o6DTKy74JrXw/zdk5FIdn9BVMV3xWYOLddK8DATHtslfzS9iqcS QPEWtaQdHwvdqNWkJ8FTmgIJrze6NV+7rVHdZAyk3aGa6W5cQaizorKGzHgOh6CdtiEu ozVw== 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=CRRRWFLs1MMZzxBH5VTK+WBqEDX+9GS+bjOzGADhevw=; b=F54DiT9gXZzo+s533cZuvanNMmyq0eC/i79jnYN5MzDWVf878CAiQgHyA21k5M6nF4 6AxEU9bblIEcpEtR41oiFXKoEAXPlvxa9APUYYki0dWvM5W9pdRP/MQRQVEfft3mt7Ux asK5giCLC4vE2WDynaTXLiXg6C+bgunl/sXHg4k6V7UG1QhdnwdobEKSdKmOAGqrCPcS rMkJWIR1nklJRvclrsei+Z7TqzckgRjkLaKyF0l7tx5pHPwqMAWmuUtyMGOdzbKBbsXY XA+YIiNCV3Vb6HHWXeFCrgaciBGRUB+zOV8080ywqdqQTvHcEfwJYHr2VKd7SujuHZNu u8gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UWgkQYgL; 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.14; Mon, 12 Feb 2018 05:20:14 -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=UWgkQYgL; 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 S935431AbeBLNUL (ORCPT + 13 others); Mon, 12 Feb 2018 08:20:11 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:45213 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935289AbeBLNR7 (ORCPT ); Mon, 12 Feb 2018 08:17:59 -0500 Received: by mail-lf0-f66.google.com with SMTP id x196so20328777lfd.12 for ; Mon, 12 Feb 2018 05:17:58 -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=CRRRWFLs1MMZzxBH5VTK+WBqEDX+9GS+bjOzGADhevw=; b=UWgkQYgLLFK+1rZXuTxtTDSg+efu6MTVjmPgZ3MJv0xjeQbscv7E8HcNZR5H2KgoPC qhuwPA7bpXTY5MxdGVzHNSRGpgXIDsJDSwBA3Va/9x3p2A0Om/kwAxVsuJCiKNekfln0 R/NXk383c0sq4389Rpi/22FTe6+laPKZ9RCrE= 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=CRRRWFLs1MMZzxBH5VTK+WBqEDX+9GS+bjOzGADhevw=; b=TAIokbG/bkmcDXSaBQIZuwDKNtRX0xHqdOtZWIuaC1vES3DzYiNVsBeRbHWzOb4+5I bK80FY+fJpPDayRbX7KriMTHoIOVScPL9jL6ewYdk2P2mOCZLwkMcjbRtkSoaE1lY0Nz bEgbmCovtQ1Df46vPcYIHKdZYxUonFXxbiWLgS5ArdANmMoldTh0t5C6AggHzSLNpR8E 81jCWvgAXtNmsXsHN5aun7A41Ti41mq/OUTJpg2X2jdxRlQlVfk/+81WydmrV96mUOnM 1cON8x9hFztc2AJuhY1FETZKyYif+gAfcfBHA/w0K5cnxYk3g1PeeaJimIOghM2NvjIg ma1w== X-Gm-Message-State: APf1xPD51uBY7CRou5z7DsYuBv+6+DQ9gsZSgAAY/4YYnGDzY5+wVidQ GiIXp9zaYTB4J5DZFFNxsHRneg== X-Received: by 10.46.32.66 with SMTP id g63mr7461777ljg.75.1518441478120; Mon, 12 Feb 2018 05:17:58 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:17:57 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij , Krzysztof Kozlowski , Sangbeom Kim , Chanwoo Choi Subject: [PATCH 13/21] regulator: s2mps11: Pass descriptor instead of GPIO number Date: Mon, 12 Feb 2018 14:17:09 +0100 Message-Id: <20180212131717.27193-14-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. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Cc: Krzysztof Kozlowski Cc: Sangbeom Kim Cc: Chanwoo Choi Signed-off-by: Linus Walleij --- drivers/regulator/s2mps11.c | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) -- 2.14.3 diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 7726b874e539..9a1dca26362e 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include #include @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -57,7 +56,7 @@ struct s2mps11_info { * Array (size: number of regulators) with GPIO-s for external * sleep control. */ - int *ext_control_gpio; + struct gpio_desc **ext_control_gpiod; }; static int get_ramp_delay(int ramp_delay) @@ -524,7 +523,7 @@ static int s2mps14_regulator_enable(struct regulator_dev *rdev) case S2MPS14X: if (test_bit(rdev_get_id(rdev), s2mps11->suspend_state)) val = S2MPS14_ENABLE_SUSPEND; - else if (gpio_is_valid(s2mps11->ext_control_gpio[rdev_get_id(rdev)])) + else if (s2mps11->ext_control_gpiod[rdev_get_id(rdev)]) val = S2MPS14_ENABLE_EXT_CONTROL; else val = rdev->desc->enable_mask; @@ -818,7 +817,7 @@ static int s2mps14_pmic_enable_ext_control(struct s2mps11_info *s2mps11, static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, struct of_regulator_match *rdata, struct s2mps11_info *s2mps11) { - int *gpio = s2mps11->ext_control_gpio; + struct gpio_desc **gpio = s2mps11->ext_control_gpiod; unsigned int i; unsigned int valid_regulators[3] = { S2MPS14_LDO10, S2MPS14_LDO11, S2MPS14_LDO12 }; @@ -829,11 +828,20 @@ static void s2mps14_pmic_dt_parse_ext_control_gpio(struct platform_device *pdev, if (!rdata[reg].init_data || !rdata[reg].of_node) continue; - gpio[reg] = of_get_named_gpio(rdata[reg].of_node, - "samsung,ext-control-gpios", 0); - if (gpio_is_valid(gpio[reg])) - dev_dbg(&pdev->dev, "Using GPIO %d for ext-control over %d/%s\n", - gpio[reg], reg, rdata[reg].name); + gpio[reg] = devm_gpiod_get_from_of_node(&pdev->dev, + rdata[reg].of_node, + "samsung,ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s2mps11-LDO"); + if (IS_ERR(gpio[reg])) { + dev_err(&pdev->dev, "Failed to get control GPIO for %d/%s\n", + reg, rdata[reg].name); + continue; + } + if (gpio[reg]) + dev_dbg(&pdev->dev, "Using GPIO for ext-control over %d/%s\n", + reg, rdata[reg].name); } } @@ -1139,17 +1147,11 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) return -EINVAL; } - s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, - sizeof(*s2mps11->ext_control_gpio) * rdev_num, + s2mps11->ext_control_gpiod = devm_kmalloc(&pdev->dev, + sizeof(*s2mps11->ext_control_gpiod) * rdev_num, GFP_KERNEL); - if (!s2mps11->ext_control_gpio) + if (!s2mps11->ext_control_gpiod) return -ENOMEM; - /* - * 0 is a valid GPIO so initialize all GPIO-s to negative value - * to indicate that external control won't be used for this regulator. - */ - for (i = 0; i < rdev_num; i++) - s2mps11->ext_control_gpio[i] = -EINVAL; if (!iodev->dev->of_node) { if (iodev->pdata) { @@ -1179,8 +1181,6 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.dev = &pdev->dev; config.regmap = iodev->regmap_pmic; config.driver_data = s2mps11; - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio_initialized = true; for (i = 0; i < rdev_num; i++) { struct regulator_dev *regulator; @@ -1191,7 +1191,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) config.init_data = rdata[i].init_data; config.of_node = rdata[i].of_node; } - config.ena_gpio = s2mps11->ext_control_gpio[i]; + config.ena_gpiod = s2mps11->ext_control_gpiod[i]; regulator = devm_regulator_register(&pdev->dev, ®ulators[i], &config); @@ -1202,7 +1202,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) goto out; } - if (gpio_is_valid(s2mps11->ext_control_gpio[i])) { + if (s2mps11->ext_control_gpiod[i]) { ret = s2mps14_pmic_enable_ext_control(s2mps11, regulator); if (ret < 0) {