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: 10220865 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 E985E60467 for ; Thu, 15 Feb 2018 10:40:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D86F229128 for ; Thu, 15 Feb 2018 10:40:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAE142912D; Thu, 15 Feb 2018 10:40:52 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4929E29128 for ; Thu, 15 Feb 2018 10:40:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755493AbeBOKkg (ORCPT ); Thu, 15 Feb 2018 05:40:36 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:50953 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755389AbeBOKjg (ORCPT ); Thu, 15 Feb 2018 05:39:36 -0500 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) Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , dri-devel@lists.freedesktop.org, Inki Dae , Rob Herring , Mark Rutland , Krzysztof Kozlowski , Chanwoo Choi , Archit Taneja , Laurent Pinchart , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-usb@vger.kernel.org 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+5PYLE4f34Du0XnxCXsFpseX2O1uLxrDpvFjPP7mCwW LWtltlh75C67xdLrF5ksWvceYXcQ8Fgzbw2jx+W+XiaP2R0zWT02repk87jffZzJY/OSeo++ LasYPT5vkgvgiOKySUnNySxLLdK3S+DKOHtjB3vBZ6mKQ8++MjUwHhfrYuTkkBAwkdjTtIa9 i5GLQ0hgBaPEpP8nWCCcz4wSl1oPsMNUtS7exgqRWMYo0fhiOZTzH6jl7To2kCo2AU2Jv5tv gtkiArES7y7tYgYpYha4wCJx4fQrsFHCAqES665tZgWxWQRUJXasbgazeQUsJFpa5jFDrJOX OPymCSjOwcEpYCkxZb4FyBwJgdtsEjvWX2GFqHGROHBwN9R5whKvjm+BsmUkOjsOMkE0dDNK nNrXyQzhTGGUOP/qMhNElbXE4eMXwSYxC/BJTNo2nRlkm4QAr0RHmxBEiYfEg0NHGCFsR4kl 639AA6aHUWLFvqvMExilFjAyrGIUTy0tzk1PLTbKSy3XK07MLS7NS9dLzs/dxAhMCaf/Hf+y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vWJTZb9907X+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> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.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) {