From patchwork Sat Dec 1 15:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 152637 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp4934535ljp; Sat, 1 Dec 2018 07:53:21 -0800 (PST) X-Google-Smtp-Source: AFSGD/WB+zGmka/0nB3mhze/+747XsXus+ZXsU5JtcqUIWay1O3JxEkbM6dANHEA1BmRuW4j3dz/ X-Received: by 2002:a17:902:7107:: with SMTP id a7mr9663010pll.290.1543679601735; Sat, 01 Dec 2018 07:53:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543679601; cv=none; d=google.com; s=arc-20160816; b=Vrip+9B6yTwQv4Qd07iy8mme5GbUC3fkOIgnCKM0R0DsMS7/v5X/3kbqigOxxmZrXd YGrquXtT0W0KmmqqxWK/WIS4DXfvoso8M3+1vJAncVH1piC3Ux5ak8yD9msqvW0qNds6 auc/64T8BDN3S+7q9PpJRK2yDYywLsFLiKNqIz/gwxlJ/Xs5Z7Cb/f40cMSXKG/UaPCh gg/nFRsHV2D0Xe2CEIcJBXxF2Q44eBKBfynVYXY7/C6gf0FA07E0n5PxT3OotGPdn+DN bNMZWaFvObfHt2NPdQSmzgrlBae7vK9Hx47ObhgJYzum+N0XoO/XWP+HrKjtYaM+vpma NaGw== 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=BrPFi/hYRcSPeEznRnCiUx3rZp8u++LmCL/2uJqnCDA=; b=htnveRaLGbnYnomDiB4oEcUFhAj4ki4u1WActEYgbkL8GJ5SWzqWP0C2YR5XbX3Xp2 VNRT/DqW17WYDtrWnaGU9y5EvURGcF6RLDaEhP2lnAIzniIaj1HhnvyTooUbwp41l9Sk Rzl5wL0kyjnigNsM3zckYcX58S1w4+xFlYAQjkqVFJMh0rnRjFrwH59728gIj7yQKJa1 563lPqxXFEd1HXLPuF75MwxpQY7UWO+x1bPpYuruPoOBIQSfNgjGn81P64kqgoYFgEpv dD1BfMb5pJnfUCiDGVL0H6YmbqwChaxbmf7rNYMpKeB2xWJ1azwCJLHRVNIgTeS6qnmx wOpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KFpIXWvX; 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 g33si7806409pgm.426.2018.12.01.07.53.21; Sat, 01 Dec 2018 07:53:21 -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=KFpIXWvX; 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 S1727305AbeLBDGH (ORCPT + 32 others); Sat, 1 Dec 2018 22:06:07 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45218 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727226AbeLBDGH (ORCPT ); Sat, 1 Dec 2018 22:06:07 -0500 Received: by mail-lf1-f65.google.com with SMTP id b20so6179823lfa.12 for ; Sat, 01 Dec 2018 07:53:17 -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=BrPFi/hYRcSPeEznRnCiUx3rZp8u++LmCL/2uJqnCDA=; b=KFpIXWvX/c7KhKGC2JIPNiTBFev/AFC5/8JBt3xSiKj9q7RUbEK2RmjHLOAq7ZI/dH Pniq4IyCwgKEqkqknDyCXy6e6BB228uyedRfGLqAyQEVGBX0zyJnCP4yaD8Cghsje0dX gwwszSAHDIlrrako15Fn5N6CyByDXBsehnlCI= 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=BrPFi/hYRcSPeEznRnCiUx3rZp8u++LmCL/2uJqnCDA=; b=E+niyMj7s1WPV08sPqucLz+oJkMQdIQ88XiJTx6rwV/zJFWVZqCL++EMcISfaeYszH 6zvyLCHFmU7L6snZdm+NBfrWGbyr9QSO01xWhw/Ehi9sz2qCHTYC1J+WOU54Fn8Ivh/o p5x/rhdfX0i8KVZqO4ftMi98fMITVBNnv5US/r/VOfIH+It2t8Dzdzzl356WWyQM5PWu vA4hH8eaH4aM8QnoTRtvfvrGXtBGtkHH+JNXvG1nUAeCZvILywT9o0X0GKoHDuXCnpnZ 1uEz0mWCeTCGR6watKDMv+AIeiHrAfebQ7DmTuWPuUGgEoHrZq37H8MyNLri4mZFr2Cr JZpg== X-Gm-Message-State: AA+aEWaZZQYK/Dc2fTt6G36ZiGCo7Yu0NJTaYJ1EjoDTmtUX3VhcMVA9 fWBpSBV1XNO9dS+3pizZhVY0Fw== X-Received: by 2002:a19:2c92:: with SMTP id s140mr5654825lfs.42.1543679596440; Sat, 01 Dec 2018 07:53:16 -0800 (PST) Received: from localhost.localdomain (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id 13-v6sm1365426ljj.49.2018.12.01.07.53.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 01 Dec 2018 07:53:15 -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 07/13 v2] gpio: Export gpiod_get_from_of_node() Date: Sat, 1 Dec 2018 16:41:45 +0100 Message-Id: <20181201154151.14890-8-linus.walleij@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181201154151.14890-1-linus.walleij@linaro.org> References: <20181201154151.14890-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 This function already exist inside gpiolib, we were just reluctant to make it available to the kernel at large as the devm_* seemed to be enough for anyone. However we found out that regulators need to do their own lifecycle/refcounting on GPIO descriptors and explicitly call gpiod_put() when done with a descriptor, so export this function so we can hand the refcounting over to the regulator core for these descriptors after retrieveal. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Resending --- drivers/gpio/gpiolib.h | 6 ------ include/linux/gpio/consumer.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) -- 2.19.1 diff --git a/drivers/gpio/gpiolib.h b/drivers/gpio/gpiolib.h index 087d865286a0..bc57f0dc5953 100644 --- a/drivers/gpio/gpiolib.h +++ b/drivers/gpio/gpiolib.h @@ -201,12 +201,6 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep, struct gpio_array *array_info, unsigned long *value_bitmap); -/* This is just passed between gpiolib and devres */ -struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, - const char *propname, int index, - enum gpiod_flags dflags, - const char *label); - extern struct spinlock gpio_lock; extern struct list_head gpio_devices; diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index f2f887795d43..348885f2f3d3 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -172,6 +172,10 @@ int desc_to_gpio(const struct gpio_desc *desc); struct device_node; struct fwnode_handle; +struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, + const char *propname, int index, + enum gpiod_flags dflags, + const char *label); struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, struct device_node *node, const char *propname, int index, @@ -517,6 +521,15 @@ static inline int desc_to_gpio(const struct gpio_desc *desc) struct device_node; struct fwnode_handle; +static inline +struct gpio_desc *gpiod_get_from_of_node(struct device_node *node, + const char *propname, int index, + enum gpiod_flags dflags, + const char *label) +{ + return ERR_PTR(-ENOSYS); +} + static inline struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev, struct device_node *node,