From patchwork Tue Jan 29 10:31:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 156954 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4490835jaa; Tue, 29 Jan 2019 02:32:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6mgv+A4oVxfiTZlw1RvED9QPB6kOxlyMwDFfIMXmvDcxAvDhEnnl9V2A0tqqUyk+lcpiG0 X-Received: by 2002:a65:40c5:: with SMTP id u5mr16118179pgp.46.1548757940775; Tue, 29 Jan 2019 02:32:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548757940; cv=none; d=google.com; s=arc-20160816; b=00vG3pXp28YEjng/mW6exEPupPVY7VTim87RnzGvkx6EtPOxJP9526nbD0qvNsOsEq /dN3VJTrcWIySpecNFB3FTNpn41OAgN+Cee2RthGa+PlKT6HfB8vBtpTthBvGXXfSBF4 WO2XGZKlDh25xC35Tn343Mqwb7NjNeOX56d9f6zLVoHVeH1qv8Jtt4ScF4IaWlEqis3S oR55/3qF0YPFs2+WWiIlPQo+KXzcTOrxmyOKEV3jd2XMUjHQ9YYAToJQK5QC43+KQLhq zHSB8PGA9jjwQsmv9Lex2OwHsTSTQ1DURi922eBlvqx+nbQCoR+eC+3TvhW2vuZ7WtrW K3Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sVatOVqMzKhR+NdEUtHoWq8wqeLbuPk9DS1DaHfqw4g=; b=b+umNE5kAzLeIi2mQ63BaFo1wWRKjdPFvxaBku6yrDfD+7Bw5Gbxd3IYEuE2h/LCow pTTPqyzO8r3IISk9+e/JDNtpHLV4koyDr8W1W6Zyv8dNvMrt9ynlmeJvQO7ZMPJRIq2Z J64xlezw7hYhvzYJnYYJgQFzrwfd4fCLIFFB+7q83DqgwaeUNaA0BXhAPaRcdGL3aw7A RRn/IYfItp47HFqsGhcXtY/VfT5uDhp6OR+wR2LXxmvjrFTnSWhgKTvbvjqsvz76rk6p LkWpPePK5ZrfaglqqhfcnRIQVjE3E0JGQBfGgHnYLGVbqTpTB+Fou3iAM907Z2mbdPXG llIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="BkQ5z/bs"; 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 85si34537856pfc.145.2019.01.29.02.32.20; Tue, 29 Jan 2019 02:32:20 -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="BkQ5z/bs"; 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 S1728526AbfA2KcS (ORCPT + 31 others); Tue, 29 Jan 2019 05:32:18 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45801 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728402AbfA2KcQ (ORCPT ); Tue, 29 Jan 2019 05:32:16 -0500 Received: by mail-lf1-f65.google.com with SMTP id b20so14200915lfa.12 for ; Tue, 29 Jan 2019 02:32:14 -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 :mime-version:content-transfer-encoding; bh=sVatOVqMzKhR+NdEUtHoWq8wqeLbuPk9DS1DaHfqw4g=; b=BkQ5z/bsar4BaV3H/6CCzKP2xXlZJhxTPIuCqtSuhM40+xFZNJSI+Sz4KkTsfTp49G PqzlKrhLwzKSU+RuqzyCiNct5jw/wGWdZDZOH215YrtDYt2DLAs3lARs/GRvMiRtV2ru 53axMeWAzs/PRe8+C8xOydaKiNTsm73nN0aGI= 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:mime-version:content-transfer-encoding; bh=sVatOVqMzKhR+NdEUtHoWq8wqeLbuPk9DS1DaHfqw4g=; b=k/zEqdU472sSAjQxEjlTytYYdGk0MWWsd2q+hqtk0ey7ygwOx+vb9DftBHhGQ+7Abg aM7a2OaczMZl62h2O5vwxpai4o3VF9uQvpwgqG9nOmnbJKI97FF+pPj1ptY7RJiRsyyS P+hRBGAuOPkPUxpiZg3tLN4sd7jQ4ZncYikAT3/UNgBSwv2yGF5VDeNF2v9lq3M9gp/g SBsMPoOkw1v5OwaJm2zCu/Yh0yYIknYC6vsV3UVsoQrN53Qrrh3z4mPQZAWb0j7OyEu5 GjImPNS4ckQplD/5jJpGWL6AwckNCl4fVqLks2pD+u+Z+KqcdqfW0LpUXEaellrjTQza uGIQ== X-Gm-Message-State: AJcUukejWorUvESWdWKDCrtFxLROQeFwO6xafgcbkNrjdfVYQCZcLWNu dnqT0bOFTU2iLrZBROpKLq4RKg== X-Received: by 2002:a19:8c1b:: with SMTP id o27mr18961154lfd.90.1548757934028; Tue, 29 Jan 2019 02:32:14 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id y9sm3471540lfe.75.2019.01.29.02.32.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Jan 2019 02:32:13 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Charles Keepax , Bartosz Golaszewski , Marek Szyprowski , Linus Walleij Subject: [PATCH 5/5 v10] regulator: core: Only support passing enable GPIO descriptors Date: Tue, 29 Jan 2019 11:31:56 +0100 Message-Id: <20190129103156.10139-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190129103156.10139-1-linus.walleij@linaro.org> References: <20190129103156.10139-1-linus.walleij@linaro.org> MIME-Version: 1.0 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. Tested-by: Marek Szyprowski Signed-off-by: Linus Walleij --- ChangeLog v9->v10: - Rebase on other changes. ChangeLog v8->v9: - Rebased on other changes. - Collected Marek's Tested-by. ChangeLog v7->v8: - Rebase on v5.0-rc1. ChangeLog v6->v7: - Resend with the rest. ChangeLog v4->v6: - Rebase on top of the other changes. - Renumber to fit the rest of the series. ChangeLog v3->v4: - Also drop ena_gpio_invert from driver data ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/core.c | 32 ++++++-------------------------- include/linux/regulator/driver.h | 12 +----------- 2 files changed, 7 insertions(+), 37 deletions(-) -- 2.20.1 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 48baa03ff3d8..bb688125ebd4 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -2236,35 +2235,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; list_add(&pin->list, ®ulator_ena_gpio_list); @@ -2287,7 +2270,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; @@ -4971,15 +4953,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; } /* The regulator core took over the GPIO descriptor */ diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 389bcaf7900f..e511e9d1cc86 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -401,13 +401,7 @@ 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_gpio_invert: Sense for GPIO enable control. - * @ena_gpio_flags: Flags to use when calling gpio_request_one() + * @ena_gpiod: GPIO controlling regulator enable. */ struct regulator_config { struct device *dev; @@ -416,11 +410,7 @@ 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; }; /*