From patchwork Wed Feb 21 08:55:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Hajda X-Patchwork-Id: 10231465 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 BF77360209 for ; Wed, 21 Feb 2018 08:56:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B541328A9B for ; Wed, 21 Feb 2018 08:56:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9C1828AA0; Wed, 21 Feb 2018 08:56:47 +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=ham 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 191E428A9B for ; Wed, 21 Feb 2018 08:56:46 +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=BWPWkVJSbLsGrXzlPNGytq/4Po 4NWWRa8sP2A5W/N/vgoV/2AtON3zC7KtJbuaQXeo0tg+m5sK6nw6z1XO2oWIhteusU1sFuHgYZ4Cg EmgnmADn+HS5fdq6z5h0ZLIRW7cMN2GXZBuCZSwJ36Lb33kQ67/6PtulkgRV5SGWHiJoEPxAAhWUB ScvSuDsYIhu8m+/Pk6C3OWlF9JPaWmfS5iaNtzwJZUt+j4BVqL+cfCjgKojuUWWuIbCq8WCe2e0m0 pDwTKJfB1yVX24//vWAtcZ8DYzvfMArQdNUoufkTC//bGTgDqDg+9rkjE55W4ZKQF/EQ/teNovY2j 5aECdacg==; 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 1eoQCX-000874-5l; Wed, 21 Feb 2018 08:56:33 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eoQCP-00080Q-9n for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2018 08:56:28 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180221085610euoutp01f870dbf6b39d0cce3651c10cd745f702~VS2p-qCeU2475124751euoutp01K; Wed, 21 Feb 2018 08:56:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180221085610euoutp01f870dbf6b39d0cce3651c10cd745f702~VS2p-qCeU2475124751euoutp01K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1519203370; bh=LRRZuLgkkk/LtuLxA2AZS84ozbVuf2KoGD79milDG0Q=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=Y1lBWqEJf1cBy/1V4jxUbaMSDdhRaPmtKN1/iogS3jlHV4ed5RSVY3oFvN+PbuQkK llG32ZOBHvfJUJLWXqRY8j9mr6RABp60pFPpujkG/HsdjgnDFyTNutbfooafR+nuIE bdcuW8xgPiQ+U214lQGAyCtftLN9oUgIxloQg7wU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180221085609eucas1p13e2eae89dd568823ed79ce1738d962c5~VS2pg_9Y40838708387eucas1p1y; Wed, 21 Feb 2018 08:56:09 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 54.EC.05700.9243D8A5; Wed, 21 Feb 2018 08:56:09 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180221085608eucas1p162d2e579a1cc887672b722458edb98fe~VS2o3BiZq0840308403eucas1p1D; Wed, 21 Feb 2018 08:56:08 +0000 (GMT) X-AuditID: cbfec7f2-5ffe19c000011644-4b-5a8d3429323a Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id DE.C5.04178.8243D8A5; Wed, 21 Feb 2018 08:56:08 +0000 (GMT) Received: from AMDC2768.DIGITAL.local ([106.120.43.17]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P4H00IT3STE0I20@eusync4.samsung.com>; Wed, 21 Feb 2018 08:56:08 +0000 (GMT) From: Andrzej Hajda To: devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH v4 5/6] extcon: add possibility to get extcon device by OF node Date: Wed, 21 Feb 2018 09:55:40 +0100 Message-id: <20180221085541.14556-6-a.hajda@samsung.com> X-Mailer: git-send-email 2.16.1 In-reply-to: <20180221085541.14556-1-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMIsWRmVeSWpSXmKPExsWy7djPc7qaJr1RBlOOCFncWneO1aKp4y2r xcYZ61ktrn95zmox/whQ7MrX92wWk+5PYLE4f34Du0XnxCXsFpseX2O1uL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+DKOHtjB3vBZ6mKQ8++MjUwHhfrYuTkkBAwkXixcDIL iC0ksIRR4tX58C5GLiC7kUni0L0dYAk2AU2Jv5tvsoHYIgKxEm9PfWYGKWIWuMAi8XviTHaQ hLCAv8TThTfAbBYBVYm9M3eCNfAKWEi8X/yBHWKbvMThN02sIDangKXE772TmCE2W0h8OPeV fQIjzwJGhlWMIqmlxbnpucWGesWJucWleel6yfm5mxiBIbvt2M/NOxgvbQw+xCjAwajEw2uh 0xMlxJpYVlyZe4hRgoNZSYS3Uqg3Sog3JbGyKrUoP76oNCe1+BCjNAeLkjjveYPKKCGB9MSS 1OzU1ILUIpgsEwenVAOjn7vLB44aOf0kOR2pAONbcyoTepMP9aZ4H7yqXGI0JzFlXfnSEzYp iwyO9PHO/PvpXU5pbVyuv8FXEelXmWfy9vxkLfnQnn9jh+7zdYLmSy/mrbK2P2Yz6avpae1t 4v8btv7//L8zd5+BYcq+wPDnRd13v2ZMjHMvcmFaLTd17ZIe2a38JeeVWIozEg21mIuKEwGD oLF2VQIAAA== X-CMS-MailID: 20180221085608eucas1p162d2e579a1cc887672b722458edb98fe X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180221085608eucas1p162d2e579a1cc887672b722458edb98fe X-RootMTR: 20180221085608eucas1p162d2e579a1cc887672b722458edb98fe References: <20180221085541.14556-1-a.hajda@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180221_005625_538689_E4349AFB X-CRM114-Status: GOOD ( 15.01 ) 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) {