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: 10231483 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 54BCD60209 for ; Wed, 21 Feb 2018 08:58:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B90A28807 for ; Wed, 21 Feb 2018 08:58:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FA0B28824; Wed, 21 Feb 2018 08:58:07 +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 3CE4C28807 for ; Wed, 21 Feb 2018 08:58:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751737AbeBUI5h (ORCPT ); Wed, 21 Feb 2018 03:57:37 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:54321 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752629AbeBUI4M (ORCPT ); Wed, 21 Feb 2018 03:56:12 -0500 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) 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: [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+5PYLE4f34Du0XnxCXsFpseX2O1uLxrDpvFjPP7mCwW LWtltlh75C67xdLrF5ksWvceYXcQ8Fgzbw2jx+W+XiaP2R0zWT02repk87jffZzJY/OSeo++ LasYPT5vkgvgiOKySUnNySxLLdK3S+DKOHtjB3vBZ6mKQ8++MjUwHhfrYuTkkBAwkfh6dSF7 FyMXh5DACkaJyXv2MEE4nxklPt15zgJT9WLhZBaIxDJGifs7dzFCOP8ZJb4cXcoGUsUmoCnx d/NNMFtEIFbi3aVdzCBFzAIXWCQunH7FDpIQFgiUmL/1EZjNIqAqsXfmTrAGXgELifeLP7BD rJOXOPymiRXE5hSwlPi9dxLYIAmB22wSr842MUEUuUi0P/jACmELS7w6vgWqWUais+MgE0RD N6PEqX2dUN1TGCXOv7oM1W0tcfj4RbBuZgE+iUnbpgMVcQDFeSU62oQgSjwkvm7rgyp3lJi6 4y0rxM89jBL7J79in8AotYCRYRWjeGppcW56arFhXmq5XnFibnFpXrpecn7uJkZgUjj97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v2ZMjHMvcmFaLTd17ZIe2a38JeeVWIozEg21mIuKEwGD 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> 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) {