From patchwork Mon May 14 08:06:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135681 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1442107lji; Mon, 14 May 2018 01:10:09 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrKCndS1YhEJLW9gDyt3HYoDjwUaxvApXgqPt/v5jrvW9q7T3m4LAM08mO2RPO7RUDUE/A2 X-Received: by 2002:a17:902:bb83:: with SMTP id m3-v6mr8833303pls.236.1526285409291; Mon, 14 May 2018 01:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285409; cv=none; d=google.com; s=arc-20160816; b=gcpoUqXUKjhb/pm58l9i8thuFrkYNdr1TmJ3xCNII1EeqXlt16vimdR/JejVnVqWdi ir2WsRM4C8la12vQIwg3lR/tCC67E72YoS4RvoRVe8NNO8mXc/ngvb/wsyfcrWnk4crI IgRMOMIUTpaR5Y4vx6/lTgCaau3P6L7hZzL1M63uW8BCJNqFZJJyp4GvgMP5PzegY68n cMdXGykQ8Wko/g7oG8mIAszaEpCnrLQbYbmnO9vBxSXizq0UdYiYlTTRDOReYAF7tLD/ aIyHoyD+dCu5SrEKrlSpdlBiJi+MXUms2lil75/GH9l0adeFHbuc/gH1QR9JhU6Vv1+Z ai0A== 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=NRsU+Nm5wHTXMw1TK9pS6fTPuZmCyvD6pDQmV73AWnM=; b=u6JhT39IUl5pb545yzSC2Y8k5j0KDSoprPwiBEPFiItwkIsmkhMruJ3a1Wkcue8ip0 C6qO5+hFvUq5Z+tRhbDBpnnldjVxjmbKyllYKFttFoVV0tAH6w/y9K9vNUj0jRZVj4kH eZEfL3mYZr5Yo55+LTQArbmyqCkH9YCqEf+kafEqPlZ6IbybnF3lnetg0GlX4YaHPYVB ZJm+tRI7v+5KMkZapbrAeQzhqh/5x2ANsNLr783XtOmsSd3vD7JVHDUnoLZms8M7yiGn BxlwgkGsvUKg8mDJsduw4Olk0H7Ni3Smh9K1lI4u/SK50VnoPzpU4GX05bawMv/Zxjwa G1Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MxjuDmZp; 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 h65-v6si7376872pgc.357.2018.05.14.01.10.09; Mon, 14 May 2018 01:10:09 -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=MxjuDmZp; 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 S1752537AbeENIKE (ORCPT + 29 others); Mon, 14 May 2018 04:10:04 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:32830 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752276AbeENIHU (ORCPT ); Mon, 14 May 2018 04:07:20 -0400 Received: by mail-lf0-f66.google.com with SMTP id h9-v6so15560619lfi.0 for ; Mon, 14 May 2018 01:07:19 -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=NRsU+Nm5wHTXMw1TK9pS6fTPuZmCyvD6pDQmV73AWnM=; b=MxjuDmZpP9P8q21gM8efyaMazHNNTq+Zqqo355Gop0PDr6DezVPc7n/qPNaKLCJFTf b507kWBVYTe3OYCLq7dSzpsT47kIh27WEVO+lEbS3/5iPQRZkip9+Vqa9FN/9iAuH5A5 Upsz7AxtJA9u6j44t/xgGZIomU1/uOHO+sn3w= 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=NRsU+Nm5wHTXMw1TK9pS6fTPuZmCyvD6pDQmV73AWnM=; b=WgKUIOn3bVu9bxd3ixHe+teFe0nEvk47uN5TjJKpX3tw4M5+myyRLyxT04jVL3VJNc +LAG52O5BKWzwAjVKaeeAdC6ml+iXSrrDnwT+1ygOiCJiqYWs2Pp8CXRFTVP24fH9cVD gbLLbuj0fC5ng7gHxZJFSCgzsnotSia/5SNCj92DGcCrVGjYbo+sWfaSMw0vUAFLnSGY HMKNkXyQBgwcJ3LbB49ksLcgRMQgSA8dXIaWzwVjImlV9Stto6rlzz2HRaKspYlH9WBX X0ZETQyClCBSfhugaoVcM3Lt1l+ifOVtfQhPyOhncG7+OuF05hN7JU2x+k5/iUIAn1ga vVsA== X-Gm-Message-State: ALKqPwcu4WI+k8kd2KEDKWCibJ2ehXhJ2/I1P7TYGIJCOXOTatIzDaSO HfcgbxdzuHo9+BsLSR4RePzA/g== X-Received: by 2002:a19:ea48:: with SMTP id i69-v6mr3961766lfh.118.1526285238891; Mon, 14 May 2018 01:07:18 -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.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:17 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 14/19 v3] regulator: core: Only support passing enable GPIO descriptors Date: Mon, 14 May 2018 10:06:35 +0200 Message-Id: <20180514080640.12515-15-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 Now that we changed all providers to pass descriptors into the core for enable GPIOs instead of a global GPIO number, delete the support for passing GPIO numbers in, and we get a cleanup and size reduction in the core, and from a GPIO point of view we use the modern, cleaner interface. Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/core.c | 32 ++++++-------------------------- include/linux/regulator/driver.h | 10 +--------- 2 files changed, 7 insertions(+), 35 deletions(-) -- 2.17.0 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d4803460a557..8d56f9b906b0 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -1935,35 +1934,19 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev, { struct regulator_enable_gpio *pin; struct gpio_desc *gpiod; - int ret; - if (config->ena_gpiod) - gpiod = config->ena_gpiod; - else - gpiod = gpio_to_desc(config->ena_gpio); + gpiod = config->ena_gpiod; list_for_each_entry(pin, ®ulator_ena_gpio_list, list) { if (pin->gpiod == gpiod) { - rdev_dbg(rdev, "GPIO %d is already used\n", - config->ena_gpio); + rdev_dbg(rdev, "GPIO is already used\n"); goto update_ena_gpio_to_rdev; } } - if (!config->ena_gpiod) { - ret = gpio_request_one(config->ena_gpio, - GPIOF_DIR_OUT | config->ena_gpio_flags, - rdev_get_name(rdev)); - if (ret) - return ret; - } - pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL); - if (pin == NULL) { - if (!config->ena_gpiod) - gpio_free(config->ena_gpio); + if (pin == NULL) return -ENOMEM; - } pin->gpiod = gpiod; pin->ena_gpio_invert = config->ena_gpio_invert; @@ -1987,7 +1970,6 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) if (pin->gpiod == rdev->ena_pin->gpiod) { if (pin->request_count <= 1) { pin->request_count = 0; - gpiod_put(pin->gpiod); list_del(&pin->list); kfree(pin); rdev->ena_pin = NULL; @@ -4160,15 +4142,13 @@ regulator_register(const struct regulator_desc *regulator_desc, goto clean; } - if (config->ena_gpiod || - ((config->ena_gpio || config->ena_gpio_initialized) && - gpio_is_valid(config->ena_gpio))) { + if (config->ena_gpiod) { mutex_lock(®ulator_list_mutex); ret = regulator_ena_gpio_request(rdev, config); mutex_unlock(®ulator_list_mutex); if (ret != 0) { - rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", - config->ena_gpio, ret); + rdev_err(rdev, "Failed to request enable GPIO: %d\n", + ret); goto clean; } } diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 4fc96cb8e5d7..8900c230c899 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -384,13 +384,8 @@ struct regulator_desc { * NULL). * @regmap: regmap to use for core regmap helpers if dev_get_regmap() is * insufficient. - * @ena_gpio_initialized: GPIO controlling regulator enable was properly - * initialized, meaning that >= 0 is a valid gpio - * identifier and < 0 is a non existent gpio. - * @ena_gpio: GPIO controlling regulator enable. - * @ena_gpiod: GPIO descriptor controlling regulator enable. + * @ena_gpiod: GPIO controlling regulator enable. * @ena_gpio_invert: Sense for GPIO enable control. - * @ena_gpio_flags: Flags to use when calling gpio_request_one() */ struct regulator_config { struct device *dev; @@ -399,11 +394,8 @@ struct regulator_config { struct device_node *of_node; struct regmap *regmap; - bool ena_gpio_initialized; - int ena_gpio; struct gpio_desc *ena_gpiod; unsigned int ena_gpio_invert:1; - unsigned int ena_gpio_flags; }; /*