From patchwork Mon Jan 21 09:12:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 156176 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp6153684jaa; Mon, 21 Jan 2019 01:12:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN44dLc2F8wN5ihitMHpIugW2N8e4+l6R+hIOv0QurMA/Mhyt/VLJV+r846ZZKZ8frqsK7xz X-Received: by 2002:a63:fb15:: with SMTP id o21mr27274262pgh.211.1548061948292; Mon, 21 Jan 2019 01:12:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548061948; cv=none; d=google.com; s=arc-20160816; b=aPRd4cH2SnBLRCibMe86XBHT+VoKCNfax0MIcZ1xnnKZfwBUJlCeoYwaH/yfMOdP7c 5E8sRnkQcwdi/ZlR8SLDNjP3nEjwjo+WBY6riEPmKXao3DKeT0N6sQWxiPmbPn04YFfx cLfrhaNva/ShFETF6EwxGKnfw9rzf2PfDQGpkxqhF9BRhR9ozrPLgtd3EaLtVbs16Q8n XMHVImg0qqIvgHisOTKLncRi+MSWyuc6fvyHS0DZRqb3UYUN+HN2T/tW455QgRQvsw6X D7lPNSfVz4PcSN66lqpJRpbyE8XbRM+H48e+PP0mg8KN1NjY8LsI4iPUDUVT70NVTEYn ih1A== 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=1Q9bbVMMBvFnUbxeWU6ZK7MPDRxOz3tVj3bfLkKLah4=; b=ymCAuuAqrEu70Z+y0Q/b3+PRoHta8KSOhSTZ8ZaRFZlj+3if2cKaoamMyvBFpHBV7C gQC35OoPgVqQ2kdl2grNE8LGqxWqMFwxuOu/hFq+L8+ECrIPxRTUpgJI3rcfLbJgL98P SCutxXYVOg/Kzaeq12paNZvIiX+P52Wxy4az3SA98+iW123s0IbyDgqjZG/8lnNUWLBM 9g5p7SoRgluV6EwR37zHuWJEwUwpqIr0Yn3ggIRDlqVTh2ygZReac6z57Ci254Lxo45f e6RZBE0opsNKBf45y/NGX/w4Ep36xUrCyMUXfxjxV25a4oMLruHAHN3e7ifGLGuFdTn7 FDKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=koRHqVkp; 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 c10si12050328pll.271.2019.01.21.01.12.28; Mon, 21 Jan 2019 01:12:28 -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=koRHqVkp; 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 S1726840AbfAUJM0 (ORCPT + 24 others); Mon, 21 Jan 2019 04:12:26 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:43704 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726597AbfAUJMY (ORCPT ); Mon, 21 Jan 2019 04:12:24 -0500 Received: by mail-lj1-f193.google.com with SMTP id q2-v6so16844604lji.10 for ; Mon, 21 Jan 2019 01:12:21 -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=1Q9bbVMMBvFnUbxeWU6ZK7MPDRxOz3tVj3bfLkKLah4=; b=koRHqVkpzqbrmQ6N9P1vOA/4aWpFEH42Q7gRpWin77E5VgEIlIO/f6cEfluNUwmJpp WxCKv6JzMFxvsoj1MHsQvVKoqHiaU1CDCS2FUfAO6m3Pk6CzCz79c0Lc12TU0q//4uca 30HW6mcoDxv6IxrpMF+NrCzgZd/9sr/ml0UDk= 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=1Q9bbVMMBvFnUbxeWU6ZK7MPDRxOz3tVj3bfLkKLah4=; b=AQ8rM+oviBh51y4mS5eHMoFVd/v6Nojv67n9ipmfassrMhkdauQ8sjIov8i1XUsHm/ iJ2hzTOC9LlLZ23fp+Abb4f+h3mloWb/2fvsMEscBNqfb6McfL1HfWNhm2zJqDbpbUpR arGhq41MFL4zgQMlrnzwCsb4MzeIU3jYBCZH6U4ELCsJ5WNB1yBviPyWAZCeaFlX4i1b zLP7hcM/PxV1pjFQfpSN0oPyErBCnPf2RYnBHS3kQciRD0PYhbZHkILYo8Qsi3rytVT6 /5VtWit/m/zK3ctRSEHdSGRzVwTPGUbJwoBpEYFWNpM/5WNLWClOHcYR5eOy7ST3vD0B 5IDA== X-Gm-Message-State: AJcUukd1rvZHmZqTY4LfHQj7NfCKUbj6LLjvBqg4HxoGbC6r8CzAgB8J riXwQ/qRQbnX+gxjA97rWz64Hw== X-Received: by 2002:a2e:458b:: with SMTP id s133-v6mr17115646lja.170.1548061940978; Mon, 21 Jan 2019 01:12:20 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j18-v6sm2131789ljc.52.2019.01.21.01.12.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Jan 2019 01:12:19 -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 v9] regulator: core: Only support passing enable GPIO descriptors Date: Mon, 21 Jan 2019 10:12:06 +0100 Message-Id: <20190121091206.18239-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121091206.18239-1-linus.walleij@linaro.org> References: <20190121091206.18239-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 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; }; /*