From patchwork Thu Oct 16 13:11:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 38812 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8BF5920973 for ; Thu, 16 Oct 2014 13:12:02 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf1892185lbg.5 for ; Thu, 16 Oct 2014 06:12:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=q6BtTiQ5pVw7Uc7EaKZ57CR/PJSPAyfWvWT2TXWJgeo=; b=CEBOdDyZ1GA9yy59Kn2mRRKEwLhsbHflrzEX2aCBFyGKD6Ibb1JL2QQ/tvk4f/VYoh ndg3FrTfjg2ya56jljD2O2v8BUGvJtYIWKhvqR+Ut9EMNdJHMBVOnJQUafKQTfDxdITB /WR+HTvOw8qMmCEY2fv436dP1a+X0NRPM9g9OQeHFGbmfuriGiF/Yf09LXB5h+c3BEdd dCBS5iuficF5eZi1yrt/vExMV72BcYCwe4Fgxw+9z8XVBoVUL3NJg1ghXYfT+NrFDsQu j+ujCYUNDkgMvFixSv60OsK4MOM3fEMRNXdNJ2YQJrStj2YgCFPmiJ+qiDczag/cUH91 ICBg== X-Gm-Message-State: ALoCoQnnl+OqjUFDPQSG1pscjyMlFpm/p8e3i14DnXRMAtYM5q2c/IKuSp3ruBKuS0iuOsLac3ht X-Received: by 10.112.40.161 with SMTP id y1mr251524lbk.13.1413465120677; Thu, 16 Oct 2014 06:12:00 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.230 with SMTP id m6ls174171laa.89.gmail; Thu, 16 Oct 2014 06:12:00 -0700 (PDT) X-Received: by 10.152.87.98 with SMTP id w2mr1499191laz.27.1413465120504; Thu, 16 Oct 2014 06:12:00 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com [209.85.215.44]) by mx.google.com with ESMTPS id yf1si9647946lab.63.2014.10.16.06.12.00 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 16 Oct 2014 06:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id hs14so2841842lab.31 for ; Thu, 16 Oct 2014 06:12:00 -0700 (PDT) X-Received: by 10.112.97.135 with SMTP id ea7mr1634408lbb.46.1413465120057; Thu, 16 Oct 2014 06:12:00 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp36161lbz; Thu, 16 Oct 2014 06:11:59 -0700 (PDT) X-Received: by 10.68.228.33 with SMTP id sf1mr1489783pbc.14.1413465118532; Thu, 16 Oct 2014 06:11:58 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ru9si18925254pab.173.2014.10.16.06.11.57 for ; Thu, 16 Oct 2014 06:11:58 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752617AbaJPNLz (ORCPT + 27 others); Thu, 16 Oct 2014 09:11:55 -0400 Received: from mailout4.w1.samsung.com ([210.118.77.14]:39785 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751872AbaJPNLx (ORCPT ); Thu, 16 Oct 2014 09:11:53 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NDJ00GX2GSEINB0@mailout4.w1.samsung.com> for linux-kernel@vger.kernel.org; Thu, 16 Oct 2014 14:14:38 +0100 (BST) X-AuditID: cbfec7f4-b7f156d0000063c7-3a-543fc417d3b0 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 81.18.25543.714CF345; Thu, 16 Oct 2014 14:11:51 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NDJ00KNAGNMOE30@eusync2.samsung.com>; Thu, 16 Oct 2014 14:11:51 +0100 (BST) From: Marek Szyprowski To: linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Chanwoo Choi , MyungJoo Ham , Tomasz Figa Subject: [PATCH] extcon: Implement OF-based extcon lookup properly Date: Thu, 16 Oct 2014 15:11:44 +0200 Message-id: <1413465104-26201-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNJMWRmVeSWpSXmKPExsVy+t/xK7riR+xDDNY/k7G4/uU5q8XlXXPY LNYeuctucbtxBZvFql1/GB1YPXbOusvu0bdlFaPH501yAcxRXDYpqTmZZalF+nYJXBk9uy+w FbzkrdjasIO5gfE6dxcjJ4eEgInE1/1djBC2mMSFe+vZuhi5OIQEljJKLFqxihXC6WOS+P// GBtIFZuAoUTX2y4wW0RAQWJz7zOwImaB5YwSX9bfABslLOAk8WplA5jNIqAqMefAUxYQm1fA Q2LR7tvMEOvkJP6/XME0gZF7ASPDKkbR1NLkguKk9FxDveLE3OLSvHS95PzcTYyQAPiyg3Hx MatDjAIcjEo8vBrB9iFCrIllxZW5hxglOJiVRHhnHwQK8aYkVlalFuXHF5XmpBYfYmTi4JRq YIxX88osjvpnaDFPe2+GUNiVwmUzFlZyLzm3+dwl5utTpprO/sKbxb5Ys+1Mb0l5jkjkeU6u HPY7L7atm7v49anFG/m+pJzbFLQ2Mt3iMluXef7dp7+bddUEJwrNuOqUUvNI99yLJbUqV54f 6/6hJ1TMVsHsx5sQ+/+936mXVsatvTGmehbvDJRYijMSDbWYi4oTATrt4D7eAQAA Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: m.szyprowski@samsung.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Tomasz Figa Platform bus is not the only way to have extcon devices, so current implementation of of_extcon_get_extcon_dev() is broken. Also using parent device node only to get device name is quite ugly. This patch reimplements of_extcon_get_extcon_dev() to do exactly the same as extcon_get_extcon_dev() but instead of comparing names, compare node pointers. Signed-off-by: Tomasz Figa [mszyprow: simplified the code] Signed-off-by: Marek Szyprowski --- drivers/extcon/extcon-class.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c index 4c2f2c543bb7..043dcd9946c9 100644 --- a/drivers/extcon/extcon-class.c +++ b/drivers/extcon/extcon-class.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -997,13 +998,16 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index) return ERR_PTR(-ENODEV); } - edev = extcon_get_extcon_dev(node->name); - if (!edev) { - dev_err(dev, "unable to get extcon device : %s\n", node->name); - 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); + return edev; + } } + mutex_unlock(&extcon_dev_list_lock); - return edev; + return ERR_PTR(-EPROBE_DEFER); } #else struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)