From patchwork Thu Nov 15 08:01:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 151201 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6691721ljp; Thu, 15 Nov 2018 00:01:56 -0800 (PST) X-Google-Smtp-Source: AJdET5ew38Uc0ufMO0yX0MgkBdmHicgtdF6p6gim2Pzsy1erbs9NpwQpffoaS4W18qhbh0gaq217 X-Received: by 2002:a63:4c04:: with SMTP id z4mr4887550pga.312.1542268916421; Thu, 15 Nov 2018 00:01:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542268916; cv=none; d=google.com; s=arc-20160816; b=dGnJFKgIPKspPwLEIvGBzzzZuWy5bwbFBaDNaoRc7EbnwNzEGIgUuOdoVbbUs92b/H YpsGDmbo+0svh+IRHbAXaYgqWQk+a8DZ6yN6CzaC0QkQmNimCBqr0OQ7wHKT7vPOaCQl H8A+HLyuIAZvAl5zQaWPccn1CA27X4e+qoV+d8RnrIgB0Hv5pbnzVernA+XtP/FY/xLy j/asqVusMJFGxTAB7r0cygthTgYceaQ6xQRiopwoyuU772uo1aUaB9M22ERiqiUEta6W vw7PDAczqQvr+yDIJAQXt2SXzVg8PT6fr3bUfoQRHcvEn1SFErxW0tUVNqbgTJHFwmDY /LAQ== 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; bh=cRUDpkN83Jaf9IQM3ipsCZQ6aGbWpgr5owq1zz9T5U4=; b=GUMwxlnZK/gHNYgog436BKKucUEGqsOjGuEyyQ1WPdKGVKEGxj7koZNQfGiFf9CoQ1 Uc06Ng1xYliOOEMiOBENr6HtWje2QLz3smUDhw14k2vpWO6NBLPf858KqhA3RU21Si53 Dgtcdzh4An70ricB0dO1+9XkT8rGLCZA1j+2VtCca8NN5err9t6ac3ExzHc4du6duXD6 9Weusr7F7K+BB+A75pxMbfxGhbwnXzDgpuD8oOGwuhaNJ9TJk1WLvekPaKW1dNWZAo23 Y/AMHAtmXvUSt9HwaeWGVykCGXadyO0+hZ2+7FCyNrsEd97lur2NCPw530vv3ICp2gzr qbAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QFbx1fFr; 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 z61-v6si27451129plb.46.2018.11.15.00.01.56; Thu, 15 Nov 2018 00:01: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=QFbx1fFr; 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 S1732959AbeKOSIj (ORCPT + 32 others); Thu, 15 Nov 2018 13:08:39 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:44278 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729065AbeKOSIi (ORCPT ); Thu, 15 Nov 2018 13:08:38 -0500 Received: by mail-lf1-f65.google.com with SMTP id z13so13455390lfe.11 for ; Thu, 15 Nov 2018 00:01:51 -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=cRUDpkN83Jaf9IQM3ipsCZQ6aGbWpgr5owq1zz9T5U4=; b=QFbx1fFrDVQD4GDjnwzedh3woRcaXSa2om3SYgR/cbAfH69r6LuYSIqK1HGSaXoBgP tIyLfSAyc5i4oKExwD4+Kz4GmLcYDlgNsY69yStM6C77SX7/X9EdPxleqYsuQnM/SZNC bUlUQEgVfQSww1+6PTz64J75tM6KzljRR3xUM= 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=cRUDpkN83Jaf9IQM3ipsCZQ6aGbWpgr5owq1zz9T5U4=; b=QnciiBB8BCDVSxkeuuX6AJrDpOGCs7KJtMkOpgV2Ye7eZeA7AWxDbu3/6zrTS/oom+ 46YXOBwAJKACDZeKYbrlG9LVWAiDnWIRvc9Qh9r/pQz72l3bsY9MxKYqj7E7C0+iW/8P 57ey47Xtm4KzTM8HaaQjJWyTb05TAmWJOSu8AfT7TPH5pRLuB2MjuPDJNedPQr5IZBjj RgwKzpgH4Zd63iG0PfTu2KSTCkpSpZ8irHSlHW3GwGsgTaw9UibgVjidolNqYSLBfdc3 wmq/ilOqb456qyfV/XAdcFyVG/Y98kSgWPWLOLsKh13wDFV5smOOQf2B7k4JxIfKM8Ne 5m7A== X-Gm-Message-State: AGRZ1gJOJe1dDs+PnLYSj0CHLII9EQaYI0gBNj/PVAXzUDFfTGhYiVsL FyY19QpI/ZL+SKcPZTn2/bSsCQ== X-Received: by 2002:a19:d381:: with SMTP id k123mr2968044lfg.101.1542268910984; Thu, 15 Nov 2018 00:01:50 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o25sm4003427lfd.29.2018.11.15.00.01.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Nov 2018 00:01:49 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski , Linus Walleij Subject: [PATCH 8/8 v6] regulator: core: Only support passing enable GPIO descriptors Date: Thu, 15 Nov 2018 09:01:24 +0100 Message-Id: <20181115080124.7789-9-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181115080124.7789-1-linus.walleij@linaro.org> References: <20181115080124.7789-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 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.17.2 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 109bd2bee868..0eb5c48f1162 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -2015,35 +2014,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); @@ -2066,7 +2049,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; @@ -4336,15 +4318,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 a9c030192147..10ee158eac00 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h @@ -400,13 +400,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; @@ -415,11 +409,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; }; /*