From patchwork Mon Jun 18 07:45:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 138857 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3643852lji; Mon, 18 Jun 2018 00:46:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKYDUjnyrgWKKlqVu3HWzdZkDOg0QQAKW5JNIrCPxbFHduHj8bgR93sxr6OA2AUWkPoh6nq X-Received: by 2002:a63:b812:: with SMTP id p18-v6mr10355001pge.11.1529307974449; Mon, 18 Jun 2018 00:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529307974; cv=none; d=google.com; s=arc-20160816; b=cbGje8PluukESKTN+iOGShRPjwmU9dG/QQPg3ADGGXIvgDr34uqVzl/OC7pMxG75ZV DYrBcS/lJB4YI9cjduazEeI4uoJH2C3r60BMh3MH9eUtjYsOnjcn4bAQvlPTQXaqPbci 0dRt0W7Mm3oNxLzRyVuIr8WF9aqQICnQ6doI9HGb69h7xxjKM6WRVYNexrObQ9xMsdpY YPjj7HbUl/NXoB/F5yLqQyIVp2NlIKbTdi49uwRXSUcz9vt+D5zrNT6VCL5XoEr7KxAc ECCyvIxGXy/X7ZDmZ5e4XklEB3ELuu3RKelaw2lH7DGEMnPLRl6nvqmUW9WVva0HOSdn bDpw== 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=moOR63IXflDCWenxZdMutWzlSayR6HX5M/EswNi22T4=; b=K6TLQO6AGCtc6EZAF8E0DJ7DZYcQPd/QVT+e9GWjepUbTjPvmjbO+pyMOvl7dTq1o7 81mouFQ9N1QHCDW7VOT2fkTTCSFfPgNdfNrAa9Q11Mu1mkYRYko+qdFg5Hc2rNXExwnd hxTXdIhrckXV6nE6fmVBosn1tCM3TXc8XRTQjaSV8bYltYYQlkSuuOCryDLiBjBKs+P5 GMkO7DZwf/l7h6BppVan34HWaX5d45M/oh0OPM3sWFdLPpq3+KGO/fu6nDqoPQhpeoJ/ beunWr9tnLMWIj235oV4X/t9MC7OmXK9sRi2Fdo7NMbcIKvQv0W+M0IfjJv8RvrVeAST Z3mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FavQqBj5; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (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 w2-v6si11655956pgs.59.2018.06.18.00.46.14; Mon, 18 Jun 2018 00:46:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FavQqBj5; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755005AbeFRHqN (ORCPT + 5 others); Mon, 18 Jun 2018 03:46:13 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:39859 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754982AbeFRHqN (ORCPT ); Mon, 18 Jun 2018 03:46:13 -0400 Received: by mail-lf0-f65.google.com with SMTP id t2-v6so16724369lfd.6 for ; Mon, 18 Jun 2018 00:46:12 -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=mdTg14MkbiErOIsb9qzdOdJ3w+dtrWJ7tFqOCDf8yKo=; b=FavQqBj5yGA77wtxRMAsIp4hTgLLF8xQTiF8lZeq6dN3xjKcOdPmnlH80nNENZ0+um bH0y2+fBRHYTId40zUpffjlRfg9hxZ6frb0mpftxqObJG6SLO0MkqbUh7oeWkZ9gSU6D dkrpiCqTS6lj6Wk3JLPtU/1t7YPXBo8xCWpwk= 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=mdTg14MkbiErOIsb9qzdOdJ3w+dtrWJ7tFqOCDf8yKo=; b=pfourhT0Rj0gNe+ymwDC/x+w7LnrhyGuDoOk4NLOZvEWTw2Tc1XbCSGeXjIaWYGuoo S2wPPU5/+WjG7CS4vc27g7yJNyEf/jIop5hcI2rUeWjs86a/aKL0TJ7hGnmBk+qiTaC6 beM2h/gHw/+g79A39a48iItBnitSZY1TqiMDp15or0ViydTYmV1T9MwbrwIZ430YFFNb hJi7qw37xM+A0KLaZhevAaCgXuBZsGpLponcFszTs+nd1VM/WCeIM6wI2u5OalT0e9Zg +hOkOWehlUrtk7VSxdEa0N1225wT0oIdgLxn9ObYcajDAvOIt2ZXQtXdeWU9CAtGlOWl kkzA== X-Gm-Message-State: APt69E3kvLMRsc82+VG1EW1JaDLQdcKyLm08wP4w05HEx00YiJwZTrrz GYrK/A9TjTNlKy46PHta8W0bCg== X-Received: by 2002:a2e:4149:: with SMTP id o70-v6mr7742171lja.3.1529307971741; Mon, 18 Jun 2018 00:46:11 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id x18-v6sm2616390ljh.63.2018.06.18.00.46.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 00:46:10 -0700 (PDT) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, dev@lists.96boards.org Cc: John Stultz , Manivannan Sadhasivam , Rob Herring , Mark Rutland , Frank Rowand , Mark Brown , Michal Simek , Andy Shevchenko , Mika Westerberg , Arnd Bergmann , Linus Walleij Subject: [PATCH 1/5] RFC: gpio: Add API to explicitly name a consumer Date: Mon, 18 Jun 2018 09:45:52 +0200 Message-Id: <20180618074556.6944-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180618074556.6944-1-linus.walleij@linaro.org> References: <20180618074556.6944-1-linus.walleij@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The GPIO (descriptor) API registers a "label" naming what is currently using the GPIO line. Typically this is taken from things like the device tree node, so "reset-gpios" will result in he line being labeled "reset". The technical effect is pretty much zero: the use is for debug and introspection, such as "lsgpio" and debugfs files. However sometimes the user want this cuddly feeling of listing all GPIO lines and seeing exactly what they are for and it gives a very fulfilling sense of control. Especially in the cases when the device tree node doesn't provide a good name, or anonymous GPIO lines assigned just to "gpios" in the device tree because the usage is implicit. For these cases it may be nice to be able to label the line directly and explicitly. Signed-off-by: Linus Walleij --- drivers/gpio/gpiolib.c | 13 +++++++++++++ include/linux/gpio/consumer.h | 7 +++++++ 2 files changed, 20 insertions(+) -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e11a3bb03820..c6f77e806cb8 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3193,6 +3193,19 @@ int gpiod_cansleep(const struct gpio_desc *desc) } EXPORT_SYMBOL_GPL(gpiod_cansleep); +/** + * gpiod_set_consumer_name() - set the consumer name for the descriptor + * @desc: gpio to set the consumer name on + * @name: the new consumer name + */ +void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name) +{ + VALIDATE_DESC_VOID(desc); + /* Just overwrite whatever the previous name was */ + desc->label = name; +} +EXPORT_SYMBOL_GPL(gpiod_set_consumer_name); + /** * gpiod_to_irq() - return the IRQ corresponding to a GPIO * @desc: gpio whose IRQ will be returned (already requested) diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index 243112c7fa7d..e8aaf34dd65d 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -145,6 +145,7 @@ int gpiod_is_active_low(const struct gpio_desc *desc); int gpiod_cansleep(const struct gpio_desc *desc); int gpiod_to_irq(const struct gpio_desc *desc); +void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name); /* Convert between the old gpio_ and new gpiod_ interfaces */ struct gpio_desc *gpio_to_desc(unsigned gpio); @@ -467,6 +468,12 @@ static inline int gpiod_to_irq(const struct gpio_desc *desc) return -EINVAL; } +static inline void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name) +{ + /* GPIO can never have been requested */ + WARN_ON(1); +} + static inline struct gpio_desc *gpio_to_desc(unsigned gpio) { return ERR_PTR(-EINVAL);