From patchwork Tue Feb 27 12:22:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10245049 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 45B3660208 for ; Tue, 27 Feb 2018 12:22:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 341F820952 for ; Tue, 27 Feb 2018 12:22:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 285CE25F3E; Tue, 27 Feb 2018 12:22: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 A608B20952 for ; Tue, 27 Feb 2018 12:22:49 +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=pemJXbw/IjkehGpnrAh7pB4nOffV8DcpS35xFmdrAFo=; b=gvRVHTXX/fX7s5xwjjAiB2TEaf JN3Dj67Fsr2gl73vYJSnnJ17x6fQaPhWV0PcYR2soJHEANqe33HPZ/aPhNIf4N4udr7BwyOqtY8P0 +WV/CnSp15OkNusYtOu4SaIMeNam91u8xq49mwiYFlyVroBp7gTOi0/X5TRFSXux12ROTIXEim7+I CF4u16OpZzdo1xv5/GKxCPe4e4FQQrSW3VhORDrTDoAgXO3T38oGbby/+ptL7Z8o+yhMoWjic1oK+ rN4SKvcrxUI7YvDNMUx4Q0aDfWEZHwSI5fMOD+z7WwpDZhuAhUuJ70BpolX+1l7vTGZ7aBJ90fblS DLI5WbRw==; 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 1eqeHG-0003T1-B2; Tue, 27 Feb 2018 12:22:38 +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 1eqeH9-0003OD-LZ for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2018 12:22:35 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180227122217euoutp0263435189cc87d00473cdd6ef0a03e223~XLiVub8uW1494814948euoutp02r; Tue, 27 Feb 2018 12:22:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180227122217euoutp0263435189cc87d00473cdd6ef0a03e223~XLiVub8uW1494814948euoutp02r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519734137; bh=Mi8ycMvgA8e4rteBRO6BaKSxwGFllLz590urBEJMLis=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=O+6OOU7nVxilz4TowPN59edt8ptHaaqA+RzlCVttKfDIKwEuY58bUpuMh+8aW55cX VVyb6R+NrgnK5/AiOiu+ytBNwldetyz3cljP0CUQyr4SHtcjhDTfbwhQmIJ4jk7w7O Z4rNunzMnpj67OXyTeCxkmT0FHu2i5V3wV/adI+Q= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180227122216eucas1p254bdb1eff6b00bb7a91812bdd02c6592~XLiU242eU0469904699eucas1p2J; Tue, 27 Feb 2018 12:22:16 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 02.AD.05700.87D459A5; Tue, 27 Feb 2018 12:22:16 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180227122215eucas1p11a1a12c26665f032c666d10effaf15fc~XLiUCKNRq2465724657eucas1p1c; Tue, 27 Feb 2018 12:22:15 +0000 (GMT) X-AuditID: cbfec7f2-1dbff70000011644-21-5a954d783c3b Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F0.2D.04183.77D459A5; Tue, 27 Feb 2018 12:22:15 +0000 (GMT) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4T00BY46D2WF00@eusync1.samsung.com>; Tue, 27 Feb 2018 12:22:15 +0000 (GMT) From: Andrzej Hajda To: devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH v6 5/6] extcon: add possibility to get extcon device by OF node Date: Tue, 27 Feb 2018 13:22:07 +0100 Message-id: <20180227122207.23056-1-a.hajda@samsung.com> X-Mailer: git-send-email 2.16.2 In-reply-to: <5A953AF2.6030501@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEIsWRmVeSWpSXmKPExsWy7djPc7oVvlOjDBZOEba4te4cq0VTx1tW i40z1rNaXP/ynNVi/hGg2JWv79ksJt2fwGJx/vwGdovOiUvYLTY9vsZqcXnXHDaLGef3MVks WtbKbLH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EcVlk5Kak1mWWqRvl8CVcWzid/aC+dIVf/snMjUwvhHrYuTkkBAwkeibupG1 i5GLQ0hgCaPE15dboZxGJolz+6awglSxCWhK/N18kw3EFhGIlXh76jMzSBGzwAUWid8TZ7KD JIQF/CVmv2thBrFZBFQlvk34zQhi8wpYSKxcu4gZYp28xMKzV8FsTgFtiZ+nr4H1CgloSWw7 vphxAiPPAkaGVYwiqaXFuem5xUZ6xYm5xaV56XrJ+bmbGIFBu+3Yzy07GLveBR9iFOBgVOLh nSE3JUqINbGsuDL3EKMEB7OSCO/KxZOjhHhTEiurUovy44tKc1KLDzFKc7AoifOeN6iMEhJI TyxJzU5NLUgtgskycXBKNTBGrKpfZp+65OahN2tT54cozi4L/PFHIU/lywcWhmeq2leLDXhm Cqzg7djxd4PYW4nMqDvu2UJqfNuP97mqu1zR3HbhfP58TvsUxiXuCQkyTwQuC8ttiPl+j2el nGLFPj09q1/GZ/fefvSq8Od21x+cifYCy3exF0ypbjvW8Emk+qX1rbuXZu9UYinOSDTUYi4q TgQAxIwaclYCAAA= X-CMS-MailID: 20180227122215eucas1p11a1a12c26665f032c666d10effaf15fc X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180227122215eucas1p11a1a12c26665f032c666d10effaf15fc X-RootMTR: 20180227122215eucas1p11a1a12c26665f032c666d10effaf15fc References: <5A953AF2.6030501@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_042231_870163_AF5E617B X-CRM114-Status: GOOD ( 16.11 ) 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 --- v5: function renamed to extcon_find_edev_by_node (Andy) 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..8bff5fd18185 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_find_edev_by_node - Find the extcon device from devicetree. + * @node : OF node identifying edev + * + * Return the pointer of extcon device if success or ERR_PTR(err) if fail. + */ +struct extcon_dev *extcon_find_edev_by_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_find_edev_by_node(node); of_node_put(node); - return ERR_PTR(-EPROBE_DEFER); + return edev; } + #else + +struct extcon_dev *extcon_find_edev_by_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_find_edev_by_node); EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle); /** diff --git a/include/linux/extcon.h b/include/linux/extcon.h index 6d94e82c8ad9..7f033b1ea568 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_find_edev_by_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_find_edev_by_node(struct device_node *node) +{ + return ERR_PTR(-ENODEV); +} + static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) {