From patchwork Thu Feb 15 10:39:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10220883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1415160467 for ; Thu, 15 Feb 2018 10:44:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0098B28998 for ; Thu, 15 Feb 2018 10:44:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E65312912D; Thu, 15 Feb 2018 10:44:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E571C28998 for ; Thu, 15 Feb 2018 10:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-reply-to:Message-id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gHwuuiXEfNrsEz/RX3e+kAHUxx8ujjUPv+jLG7+Uswg=; b=g7Pbwsw5U1Db1RP4owxZu7YwYw osxASgq3rqliITVkBH3FQAJeSPEANUZDL1ovwZpt2qwd/wZMm0Eip2q5fp8Gl1DZpKn1m/2COQ5bR 8KYlR+z9ZVsLfdXg3AxL7RShtQqwZW17UJ0goOJCBUdmE8ew8kqeFn5mZkG9HXQ18ILmwA5254FFJ cTZOu27ocRd6/xU1uuswWkmYnTBWlkJ6ZtN4bWAiUVbuNfvcrOYuv8TV3u92GCzhfDSbx9JoY8aAh 9g85ACXg7PH1vXYWxJpuNoah/Ho3TGvWa1zCgmPMXNeR1whIWSqLzPompWTDlb/dYHFlH+lveyMPi UerVv5SA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1emH1v-000644-1x; Thu, 15 Feb 2018 10:44:43 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1emGxA-0001xU-N9 for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2018 10:39:53 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180215103934euoutp022b704cd55adbb500dabf13d333840873~TeZOOgJF61269412694euoutp02d; Thu, 15 Feb 2018 10:39:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180215103934euoutp022b704cd55adbb500dabf13d333840873~TeZOOgJF61269412694euoutp02d DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1518691174; bh=LRRZuLgkkk/LtuLxA2AZS84ozbVuf2KoGD79milDG0Q=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=MKGwdyCTqVea4DCJFZqW+V/Nb1NpW6nLal/Zl971rxj9eZuhzRsdVXjnwsBfmrcaO jOx5WQBBFrHbkygUvPtXV2Ac1p7jvtSGFJeD0XRFbo+CHZj94H89TMhKdbXETcVwSN gTVDsb/Ml38HqOP4Bbyoxf3a5+jSHtK6uRLbrFWU= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180215103931eucas1p26ce3183da0fefdca8d23d2879ca7dc45~TeZL8huA00207802078eucas1p27; Thu, 15 Feb 2018 10:39:31 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id E9.AE.17380.163658A5; Thu, 15 Feb 2018 10:39:29 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180215103928eucas1p1b2ef8630cf86f2799b4689d6786bdf4e~TeZI_A1PE1797517975eucas1p1J; Thu, 15 Feb 2018 10:39:28 +0000 (GMT) X-AuditID: cbfec7f4-b4fc79c0000043e4-d8-5a8563612542 Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id E4.AD.04178.063658A5; Thu, 15 Feb 2018 10:39:28 +0000 (GMT) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P46006GJTLN2910@eusync3.samsung.com>; Thu, 15 Feb 2018 10:39:28 +0000 (GMT) From: Andrzej Hajda To: devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [RFC PATCH v2 5/6] extcon: add possibility to get extcon device by OF node Date: Thu, 15 Feb 2018 11:39:19 +0100 Message-id: <20180215103920.32017-6-a.hajda@samsung.com> X-Mailer: git-send-email 2.16.1 In-reply-to: <20180215103920.32017-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEIsWRmVeSWpSXmKPExsWy7djP87qJya1RBrefmVrcWneO1aKp4y2r xcYZ61ktrn95zmox/whQ7MrX92wWk+5PYLE4f34Du0XnxCXsFpseX2O1uLxrDpvFjPP7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NySxLLdK3S+DKOHtjB3vBZ6mKQ8++MjUwHhfrYuTkkBAwkWhdvI0V xBYSWMIo0fROr4uRC8huZJKYd/QyM0iCTUBT4u/mm2wgtohArMTbU5+ZQYqYBS6wSPyeOJMd JCEsECqx4cBnsEksAqoSO1Y3g9m8AhYSLS3zmCG2yUscftMEFOfg4BSwlJgy3wJisYXExsnz WCcw8ixgZFjFKJJaWpybnltsqFecmFtcmpeul5yfu4kRGLDbjv3cvIPx0sbgQ4wCHIxKPLwG Ni1RQqyJZcWVuYcYJTiYlUR4P0a1RgnxpiRWVqUW5ccXleakFh9ilOZgURLnPW9QGSUkkJ5Y kpqdmlqQWgSTZeLglGpgZMjb1/auWf4cd125YIO8ya7LW/guGYf4HPCymBqgpmd6Y9G0qzHX WXz7Lv27cnXLGQXGxP6Yj2rTOYON5u87l/ArwnjhpkijaZkz/zX3XtgX+v3jWWW+mRGXAlMa Jx1OKVzodKLx+Z1M57vWJTZb9907X+fwTMUmumurvmbPznYX94+bHa/8VWIpzkg01GIuKk4E AMz8QntUAgAA X-CMS-MailID: 20180215103928eucas1p1b2ef8630cf86f2799b4689d6786bdf4e X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180215103928eucas1p1b2ef8630cf86f2799b4689d6786bdf4e X-RootMTR: 20180215103928eucas1p1b2ef8630cf86f2799b4689d6786bdf4e References: <20180215103920.32017-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180215_023949_043798_74F6D7BD X-CRM114-Status: GOOD ( 16.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Archit Taneja , linux-samsung-soc@vger.kernel.org, Laurent Pinchart , Chanwoo Choi , Bartlomiej Zolnierkiewicz , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Inki Dae , Andrzej Hajda , Rob Herring , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Since extcon property is not allowed in DT, extcon subsystem requires another way to get extcon device. Lets try the simplest approach - get edev by of_node. Signed-off-by: Andrzej Hajda Acked-by: Chanwoo Choi --- v2: changed label to follow local convention (Chanwoo) --- drivers/extcon/extcon.c | 44 ++++++++++++++++++++++++++++++++++---------- include/linux/extcon.h | 6 ++++++ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index cb38c2747684..c4972c4cb3bd 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1336,6 +1336,28 @@ void extcon_dev_unregister(struct extcon_dev *edev) EXPORT_SYMBOL_GPL(extcon_dev_unregister); #ifdef CONFIG_OF + +/* + * extcon_get_edev_by_of_node - Get the extcon device from devicetree. + * @node : OF node identyfying edev + * + * Return the pointer of extcon device if success or ERR_PTR(err) if fail. + */ +struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node) +{ + struct extcon_dev *edev; + + mutex_lock(&extcon_dev_list_lock); + list_for_each_entry(edev, &extcon_dev_list, entry) + if (edev->dev.parent && edev->dev.parent->of_node == node) + goto out; + edev = ERR_PTR(-EPROBE_DEFER); +out: + mutex_unlock(&extcon_dev_list_lock); + + return edev; +} + /* * extcon_get_edev_by_phandle - Get the extcon device from devicetree. * @dev : the instance to the given device @@ -1363,25 +1385,27 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) return ERR_PTR(-ENODEV); } - mutex_lock(&extcon_dev_list_lock); - list_for_each_entry(edev, &extcon_dev_list, entry) { - if (edev->dev.parent && edev->dev.parent->of_node == node) { - mutex_unlock(&extcon_dev_list_lock); - of_node_put(node); - return edev; - } - } - mutex_unlock(&extcon_dev_list_lock); + edev = extcon_get_edev_by_of_node(node); of_node_put(node); - return ERR_PTR(-EPROBE_DEFER); + return edev; } + #else + +struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node) +{ + return ERR_PTR(-ENOSYS); +} + struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) { return ERR_PTR(-ENOSYS); } + #endif /* CONFIG_OF */ + +EXPORT_SYMBOL_GPL(extcon_get_edev_by_of_node); EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); /** diff --git a/include/linux/extcon.h b/include/linux/extcon.h index 6d94e82c8ad9..b47e0c7f01fe 100644 --- a/include/linux/extcon.h +++ b/include/linux/extcon.h @@ -230,6 +230,7 @@ extern void devm_extcon_unregister_notifier_all(struct device *dev, * Following APIs get the extcon_dev from devicetree or by through extcon name. */ extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name); +extern struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node); extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index); @@ -283,6 +284,11 @@ static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) return ERR_PTR(-ENODEV); } +static inline struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node) +{ + return ERR_PTR(-ENODEV); +} + static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) {