From patchwork Tue Dec 11 21:24:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 153523 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1111729ljp; Tue, 11 Dec 2018 13:26:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wg2Fv4z4JMZZuxvG9AFeh1PsXeyX0Yd9eA9b/ruH58xHt1HYTQHiEzSXWa8FEOxq8kU2Op X-Received: by 2002:a17:902:e012:: with SMTP id ca18mr17541834plb.218.1544563617551; Tue, 11 Dec 2018 13:26:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544563617; cv=none; d=google.com; s=arc-20160816; b=NQs6/ZXKtEyVKhDUbVnhLjTMxNgfoByEAUjKOGeC6zt8a3OaCQRbkGmM9vrDi1QWRg dpRWY07eNKy5DBoFzKfnOl+kI7AhOtMoyhr6eKFWwxioyem8WDqbRYWuSv2fDiL0s5xR 6ce0dNyrTy+3RtwSpaa9dQnBvpGuAkYjWSYQ8uD7RV1kh+NkAJ7X2cAy61d2FXzM6Aff dacRU+DxGaeCp/uNccsiFlD74dg4U2UqrzwsBNg6v6yafTGTioc/LBKzKnwrmJAxUSQ/ +GBww6E5ArnFt38q0mCeg41Ew5hMvfRKJJqlfmD1EHZHxDHm8qDMJ3pREJZnt8BZpBPK uQKg== 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=m2lg+HYTDvmXcVEMhNUeoqjV4EvN8ZqyoGB2eJbspRs=; b=xbJCh3cmTdOjrGtiQJWVvvzj4HzD8Uaowv5XY//pAq4bG6Qm2fL6aO2a82yuPW3S/Q 7Njm3rO920rj0LBc4bObHGH3pM8EoFkHBLXCxjlB/4cpk+LZojQ9ZQXv5xGon0SQjWi5 nxsRXHJLqU8dm7CyKIrIc0IU5F4tzmyRPP3m6CDpCKnBDl2eDaTjgSH9LaNZC4kTVvwe JtNhuwwA2Kxp2p0mdMqmmo9L1+xDsTdku51gCY4Bic9T8H2kjVsDB3lE/cmyiQqdS9Cd vkhicQQhIs76KvEapgu5Mh7IG3k3tpMt7Er4KTjM4fokj5Z+ww9dSn6oc1m4VNuKrQ35 2NVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iGuckx6t; 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 s9si12209347pgv.397.2018.12.11.13.26.57; Tue, 11 Dec 2018 13:26:57 -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=iGuckx6t; 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 S1726421AbeLKV0z (ORCPT + 31 others); Tue, 11 Dec 2018 16:26:55 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:33871 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbeLKV0v (ORCPT ); Tue, 11 Dec 2018 16:26:51 -0500 Received: by mail-lf1-f66.google.com with SMTP id p6so11933077lfc.1 for ; Tue, 11 Dec 2018 13:26:49 -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=m2lg+HYTDvmXcVEMhNUeoqjV4EvN8ZqyoGB2eJbspRs=; b=iGuckx6txHtsaiwQQZ5C4lF/BZhSERdfg4+S+RK8H5bGBo6hCO/ns8u80Ih9r2rW8X 3DiLL1DGOJipgvvb9mTGNcS7TpQyFPILJWuvvIn1aogfys9TMXoLUpho73c9dbqbvQb6 mO/FqYPeA97QAXSvWuVNmYzdLiiOTll/f/UP4= 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=m2lg+HYTDvmXcVEMhNUeoqjV4EvN8ZqyoGB2eJbspRs=; b=B8k7IEI4T9FE7KrTkj6zfI3JNUIk2UNCTKXHKj/Lpgj7uuq8pL+oMmO0cN4d/tG7DL uvbBRtcO6+njezHBU0FTZ4GqVAznXfHIo9Cskg+MZApL+wJrs9I0A3hyU2Fq1AnJSypH TJyO/8IOmRSHxzOwwhertMG2giL/gU5qK/zNT6WrynUkUkyFrxLxF6T+KK21nnT2LRk8 wE1T4VVlNOm5z+1Gyi+oW2WXwQYBk9fFzdF3kg8C7/+da/EaWQIjlmJsSoDBsXvkq6tR x/9Q7FLYZago6aYN0z50B8XiUHenMmK/g365cdAlgnWgOig/yjZxEu3pTo3FXTB/xojc yRSg== X-Gm-Message-State: AA+aEWZim4UpBKX+VSooWOopYaUFHPDFfNpRASNBb2/RC2P2+Iho6rMd Fkjpg750JnM4QO4bmws5EVP9jg== X-Received: by 2002:a19:a086:: with SMTP id j128mr9744614lfe.93.1544563608855; Tue, 11 Dec 2018 13:26:48 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id y11-v6sm2873870ljc.85.2018.12.11.13.26.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 11 Dec 2018 13:26:47 -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 v8] regulator: core: Only support passing enable GPIO descriptors Date: Tue, 11 Dec 2018 22:24:28 +0100 Message-Id: <20181211212428.28327-6-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181211212428.28327-1-linus.walleij@linaro.org> References: <20181211212428.28327-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. Signed-off-by: Linus Walleij --- ChangeLog v7->v8: - Rebase on recent fixes on the for-4.21 branch. 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.19.2 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 8f3aa151bb72..dc639548076e 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -2221,35 +2220,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); @@ -2272,7 +2255,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; @@ -4966,15 +4948,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; }; /*