Received: by 10.223.185.116 with SMTP id b49csp2393880wrg; Mon, 12 Feb 2018 08:52:27 -0800 (PST) X-Google-Smtp-Source: AH8x225sKangx137tOY+4ofOERvTxlOX0hmIIPhUmkUEFxuhyEVROQs6T1pkVL8C3m1g0Ig03Fqh X-Received: by 10.98.35.66 with SMTP id j63mr10975863pfj.140.1518454347725; Mon, 12 Feb 2018 08:52:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518454347; cv=none; d=google.com; s=arc-20160816; b=A0lMQGN+F/LM4ENSrnJjCJdfn0i81KJ3UcrlDAjHTX5ZX7L777J4KfEG4P2jTOcUB5 OTpCxnjIpJDR9eMH1Mytxb1z01c95Ak7RTYpETO+yS+pQbfoJoKrDC9gw1CLdQGdsAFp zzk+yxFvQ20caiJg/OZTadVmVK8AICAGEROkIIWpBbtOiaYPlMB/omB4pBAaUde7srcx 4nEIlDWuIW4M/n8+ErtTNjxN8LSIrEjmOKglBsF0HCYgOYLFLiNiXfd4q0ocw1ddwH79 JaMMVDcJ/LZDpPf7Ku/liqy0dx017FFqKIAV0fvH8V1/rvdKnyX8Uq9JDAH8BPrM/bbO ZPPA== 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=hV56I7sWTGwVFXEp+epsuR4hN0pjcz2XS+tAZUQ2L84=; b=dmh8Q1tT8OADMjLXc9YXw7QdtHsaGwTaVW7YJggjxQoDyywkrx7k6c+n5RTiR/qCkv PFBmSYjBmusDGKdP9kh2ookn8EP6qIzIF+mLgmWgy1iZOX9W0E8MRCvTs+ij9oq0Bkka eexNfITLCTrcd+PEW3KUyKSn+CmS5yrpFBqLhHaC079kaWUE64wS8ufDYWePE6hKL6ZY PaVw45s9FZCfI5Cw9kokoXUNOFktNdXqFln5XYMzqbV72BAJwzaH+B053yrDh7rmcT+A OoJXe991XN4J4x1R1sex/pgkFxwJwxoXzS4p9m8ZJK4m4KY/TkVJoNLWAEULNeHVMvz9 TIBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AftjiduH; 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 t10-v6si129173plq.569.2018.02.12.08.52.13; Mon, 12 Feb 2018 08:52:27 -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=AftjiduH; 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 S935334AbeBLNSK (ORCPT + 99 others); Mon, 12 Feb 2018 08:18:10 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:41044 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935318AbeBLNSH (ORCPT ); Mon, 12 Feb 2018 08:18:07 -0500 Received: by mail-lf0-f67.google.com with SMTP id f136so20376831lff.8 for ; Mon, 12 Feb 2018 05:18:06 -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=hV56I7sWTGwVFXEp+epsuR4hN0pjcz2XS+tAZUQ2L84=; b=AftjiduHnAhm6zevj4LgiC37g0L5xzoRBSWHSdztFCH9d6rN9yH4WkDDYs48xc/ZQF 6gdrpSB+t5+FeTMcHUvpWNPVg8XOoNP78DkTHUBL5QMAw+RRaZGhFqhvJ52N2qKHhDtL fgMfia2jpQLpY+y5LH/lhwKbgbAQc5/DR/zKE= 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=hV56I7sWTGwVFXEp+epsuR4hN0pjcz2XS+tAZUQ2L84=; b=JNKLCANdVYF9l8AQNJqz42nCpyzp5Y5RSpEh4n1hKHgCAFuKhm8fXsMBpn6BI9jZ+L 8ipC7FBI4ERs8JjJOMxFyqRO765uEhJboG66msFGi8DapgJpHlZI3H93pZXQ7tzX1M+b h9GT0pOWYeNvGrhtnLVfMqJLN7n2EOnzoIYuBodFDjwT1PwVyGQrT9sWapGkeSZ0QJ36 TLKwiMkhqGcRRVT/coRHJWqfy1cW4+GJ7B0k5FVbqOaoSLPKM+2KdRHhT+iZjamLbSVz n5Bw5fEcvH8CpWerOTFHSdxIxBfZIKAqNZVTHmcmfbr/6LEmzfDUxROO50C9VSUHrDyF 4lLQ== X-Gm-Message-State: APf1xPDg3fGJLNJlquOEgZ46jXmmtlajMgRr3jxx8PwXCu3hj0vJE7Bl k20ZEMSTlT9/8bw9YQ76Iy7ZNw== X-Received: by 10.46.85.157 with SMTP id g29mr1352170lje.118.1518441485826; Mon, 12 Feb 2018 05:18:05 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id r88sm1584648lje.30.2018.02.12.05.18.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 05:18:05 -0800 (PST) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Linus Walleij Subject: [PATCH 17/21] regulator: core: Only support passing enable GPIO descriptors Date: Mon, 12 Feb 2018 14:17:13 +0100 Message-Id: <20180212131717.27193-18-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 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 --- drivers/regulator/core.c | 32 ++++++-------------------------- include/linux/regulator/driver.h | 10 +--------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 4549b93b0ff9..fc5346d23fd7 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; }; /* -- 2.14.3