From patchwork Sun Apr 22 23:07:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 133939 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp369185lji; Sun, 22 Apr 2018 16:11:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+X9hOpQ4Q6y9bVdIl+pLPJpYeI3+qyijE1Dh5SGuK+SCcTiJplC+JPUhU6T7+MUoPnF5HH X-Received: by 2002:a17:902:2468:: with SMTP id m37-v6mr19066759plg.388.1524438693767; Sun, 22 Apr 2018 16:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524438693; cv=none; d=google.com; s=arc-20160816; b=d+0r/lbrV3SaBQnPgEvDSYWPP9SN2cEWjsWPrNTZyESVy+q61MxwpT6AzgvdqKO779 S9OVY5zvMK93o1urxfKE6IbKuCL/BLHVXv7bsbSlKYXJk+j+jRPG4Us6zz98VMTTg/yb 42XRhp++RhsPk9Jj+Gsc9xeduyN9q5Utf3b3E2yDnHaluetUcs2TjoojFB4rNRe4gpb7 LxrcF4+3xTy3Mwp67zPhpo9k0xHnyPOZHxr/sDlNP/QOHYZIwbFz6FIs6iPw179TOqYN OjpyLiBNhYdoMFWBhdL4UAGhciTK6MdeScSaNpwZCtFWP2eXkmkz2gRYxArVnyNUE8KU OdBg== 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=bvUwSfPlLXNjYDfEUysugWaA6ERrGpW293bv67/MPbk=; b=M6YwfkEsZRjIXs4el/vSFHlSvvjhYWJ4STF97PwqRs6oF6SCjV2t5BY5BIqHu8LupA 3OknMsvHvEwUot20l9A8QqN/PFmDzLr6PPMlYkyz9cEMmzj3ex/v/pt71zclvQbKpbdP skxddsSiCrmtDk/ySGYYMEb9HjIkTGZz8h2bKtTWCpUwAG+T1VaLcF8utOK2oXeNG3Jn /fGn8jjQwJtEmlTLp57o8YeuYIFUqKukkdYjQTD2Woj2NPJFJgOUoAQKdustwW90MAla NLmBfor9oYvRxjxf9WifTBOJ3d6tAid4K8KkIWR3JewsSII/9lK14M8DO7E34sT9Iwyt 57YA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=V8FAmtSN; 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 y7-v6si10569375plh.583.2018.04.22.16.11.33; Sun, 22 Apr 2018 16:11:33 -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=V8FAmtSN; 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 S1754037AbeDVXLb (ORCPT + 29 others); Sun, 22 Apr 2018 19:11:31 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35072 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753814AbeDVXKX (ORCPT ); Sun, 22 Apr 2018 19:10:23 -0400 Received: by mail-lf0-f68.google.com with SMTP id r125-v6so12231950lfe.2 for ; Sun, 22 Apr 2018 16:10:22 -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=bvUwSfPlLXNjYDfEUysugWaA6ERrGpW293bv67/MPbk=; b=V8FAmtSNTg3dCo8ij24qzvaX2aqn1Sa4/06eHQ8VPx656KCDMgbfXzqo79o/NdVgCi rgxe1Tv1L7Q3NoQruaf2OKDn1qwupe8XFka3bXG+GyXOB2M31dCXHwEL0ypzwt0hy/nO UCULjnEckwdIwvRsQmOic1DDZ7R1hr3ikAn7g= 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=bvUwSfPlLXNjYDfEUysugWaA6ERrGpW293bv67/MPbk=; b=E2s7cJSKwja9ULEj7IJOteI31nGRtB7uNKys8eGuZcXtz6JkGMGFQgrsIDSw89NSvu JGVSu+7NGvvU1juc/pHT1xruiNga5PDJBlk66QjGLoXAOZQdhcP3AoD1KmSl9BVdWiG+ 5PDxuRpqSt+YPSbcpz2NRrFsR+wOqfJpATXTS16/UhjC2oyG1/eMf0mjSfbPZd8Lvr3o kbZp01TiJWBj9jIc1jYlSCsnya3LpO7S6IsxdQRt1rR8sCLzNAVIPRcSXz9ommMAu2/A 4alRP4aqfAMZ8C+V2dMGj/FVBO/EuTjOXwM3Cr64WDSzSrHpKU6bCYpV+Kmn5hMLfK57 nrdQ== X-Gm-Message-State: ALQs6tDSIrAG2CNVAoGP9V07QuX82UnS+YHf6+cn08Camsqza3RtZeZ2 LYCGsxN0D97LifbtBU9nIWhULA== X-Received: by 2002:a19:4e4a:: with SMTP id c71-v6mr7816508lfb.42.1524438622054; Sun, 22 Apr 2018 16:10:22 -0700 (PDT) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id r25sm2036291ljc.8.2018.04.22.16.10.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Apr 2018 16:10:21 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 14/18 v2] regulator: core: Only support passing enable GPIO descriptors Date: Mon, 23 Apr 2018 01:07:38 +0200 Message-Id: <20180422230742.3729-14-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180422230742.3729-1-linus.walleij@linaro.org> References: <20180422230742.3729-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 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.14.3 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; }; /*