From patchwork Thu May 17 08:58:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 136121 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp2011479lji; Thu, 17 May 2018 02:01:02 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrNdxTxWjKxxecODphsC9b3CxYjsRhXchgE8+Trnlp4KSWvy2AZSftYGJNSLCGnVNtGDJaM X-Received: by 2002:a1c:5946:: with SMTP id n67-v6mr1066853wmb.32.1526547662069; Thu, 17 May 2018 02:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526547662; cv=none; d=google.com; s=arc-20160816; b=wsFe842XlYcI9rB25ecyamvvzhL/O3gguhjLCHoFrMG75iACqOTrj8Cfc9EMlxufrg ZsYHVJoHSmPpjXikGFMV9Iz1ZxihArWUdTljZ8de1giOmH+mYCa8dUkohmSErlEhlyoO 5FQsPhgyT2SMTqNYv4dezUFGCrCZj864a7plSxv9TL5Pp4nX4iLIyVQk/6tUwZVWzOvS S5/ficGA0GJLPrDnVaNGNFgdNIItkRZ06yP9A8Qoa0YwIOpgmZoi5hXsGlsAnlFRrah9 3Mopgx20SWuH+I844iMbxhm/VQ9PvSvgHc5lrQHP7xaignoOxtl12TwUZQUfqx8v7/pt vxRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to:arc-authentication-results; bh=JIg7nMUzU+w9UO/UXuBeCwC/wHGljvrJWSlP2B3z080=; b=TgDGr2HdZ8PEL19I7qLZSRfhY/UTHCp8dzxXe4WLdZyYoTKwzcltxuE9OmA6JGz0De DjPAQBoGLHlrEDlKyGeQkL8fkTsiWqG3KHYSyTFPF0vZdL9+vcjj36laOYWyxZx0Ng7N HVw0VOlQ4NWQTd0ZTvEEwAv8TU0wS1Gr4eMa9WZbiBpiQFWZC+iolTXSOWLMod2O0DFH 7F8zCWetnrpUP0YbDZ09QQzAlFeJNKLK5hvLsFDO2MkxYvgGCe+sUlafRT+4eZ9RCEBo bfb0kCAX8nEWRfI4jEkXO/vivKKhwIfzYX2ZthMR+rIfwZxDiHQi24gvoTeAU87DTxRL WC3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dh73ebEC; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id 22-v6si3434775wma.107.2018.05.17.02.01.01; Thu, 17 May 2018 02:01:02 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=dh73ebEC; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 051D826706F; Thu, 17 May 2018 11:01:01 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 159672671C0; Thu, 17 May 2018 11:00:59 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS autolearn=disabled version=3.4.0 Received: from mail-wr0-f194.google.com (mail-wr0-f194.google.com [209.85.128.194]) by alsa0.perex.cz (Postfix) with ESMTP id 5F464267046 for ; Thu, 17 May 2018 11:00:57 +0200 (CEST) Received: by mail-wr0-f194.google.com with SMTP id i14-v6so4823842wre.2 for ; Thu, 17 May 2018 02:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=orK3jueeD8iKHAfbK5diacUPArijIBIe08XpYi0WLvQ=; b=dh73ebECVAKMZMbdkgmVoHbg/kxZ1iBngciOWdTvOD6aEfMHj+dDMtj9uEThRgpK3U tlO8fhGpPta7WfYYRfTlxxzxdN6GxwJ8pcYvh0y5Ofuvz2MkGfvQW3jjPFSHZNY4mXte rKwjCDcisjMetst4EuFYNBCiFM3n2JTVTklpc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=orK3jueeD8iKHAfbK5diacUPArijIBIe08XpYi0WLvQ=; b=o5vn3zZCfz4Wb57aczfHkvvGoXz2MgArn7NwK/B0FuUx04zFLtKg5aNCaH5UsyMsj4 phTiIkow7nWQppVAcRIlHoYcNA37X9v29GAXprxfxSHGlcw3GeLYSUIYFUMj5AfBLhj4 37PzDOXwv8epQvc/KzL8nvz8UXO1U9pr4neObN1/f3Vo7cSSqMXSuag6Ixxx8tmNSuDu 3eIUovHm1hT7h+bQsvAzQtbP2OrXccl1JkPr+uscq1I3CiOtCcbTIFGzZf1Xv/R5Fq55 UX9fssifxweXMQPJlUUvyJWqi95fFnojG2ELOe9IC3WZp2+XSnz+QaWrcmevY9+3HY93 DKLw== X-Gm-Message-State: ALKqPwfSeKi0MgRU3TxFpPhWQcm29vONiGNb6vXlGrG0ITFJJghkCFNo 1R/bSWwK10n2QDn3PmxzZ/JcQKJTStY= X-Received: by 2002:adf:ac64:: with SMTP id v91-v6mr3229379wrc.80.1526547656817; Thu, 17 May 2018 02:00:56 -0700 (PDT) Received: from localhost.localdomain (cpc90716-aztw32-2-0-cust92.18-1.cable.virginm.net. [86.26.100.93]) by smtp.gmail.com with ESMTPSA id y84-v6sm4123098wmg.44.2018.05.17.02.00.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 May 2018 02:00:56 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Date: Thu, 17 May 2018 09:58:43 +0100 Message-Id: <20180517085850.14276-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180517085850.14276-1-srinivas.kandagatla@linaro.org> References: <20180517085850.14276-1-srinivas.kandagatla@linaro.org> Cc: alsa-devel@alsa-project.org, srinivas.kandagatla@linaro.org, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH v2 1/8] slimbus: core: add of_slim_device_get() helper X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org On SLIMBus controllers like Qcom NGD(non ported device), controller can request logical address once the remote side is powered, having a helper function like this to explicitly enumerate the bus is helpful. Also codec drivers which are taking to interface device would need such a helper too. Signed-off-by: Srinivas Kandagatla --- drivers/slimbus/core.c | 39 +++++++++++++++++++++++++++++++++++++++ include/linux/slimbus.h | 2 ++ 2 files changed, 41 insertions(+) -- 2.16.2 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/drivers/slimbus/core.c b/drivers/slimbus/core.c index 7ddfc675b131..88248a4ecad9 100644 --- a/drivers/slimbus/core.c +++ b/drivers/slimbus/core.c @@ -356,6 +356,45 @@ struct slim_device *slim_get_device(struct slim_controller *ctrl, } EXPORT_SYMBOL_GPL(slim_get_device); +static int of_slim_match_dev(struct device *dev, void *data) +{ + struct device_node *np = data; + struct slim_device *sbdev = to_slim_device(dev); + + return (sbdev->dev.of_node == np); +} + +static struct slim_device *of_find_slim_device(struct slim_controller *ctrl, + struct device_node *np) +{ + struct slim_device *sbdev; + struct device *dev; + + dev = device_find_child(ctrl->dev, np, of_slim_match_dev); + if (dev) { + sbdev = to_slim_device(dev); + return sbdev; + } + + return NULL; +} + +/** + * of_slim_get_device() - get handle to a device using dt node. + * + * @ctrl: Controller on which this device will be added/queried + * @np: node pointer to device + * + * Return: pointer to a device if it has already reported. Creates a new + * device and returns pointer to it if the device has not yet enumerated. + */ +struct slim_device *of_slim_get_device(struct slim_controller *ctrl, + struct device_node *np) +{ + return of_find_slim_device(ctrl, np); +} +EXPORT_SYMBOL_GPL(of_slim_get_device); + static int slim_device_alloc_laddr(struct slim_device *sbdev, bool report_present) { diff --git a/include/linux/slimbus.h b/include/linux/slimbus.h index c36cf121d2cd..efa36a852dc3 100644 --- a/include/linux/slimbus.h +++ b/include/linux/slimbus.h @@ -138,6 +138,8 @@ static inline void slim_set_devicedata(struct slim_device *dev, void *data) dev_set_drvdata(&dev->dev, data); } +struct slim_device *of_slim_get_device(struct slim_controller *ctrl, + struct device_node *np); struct slim_device *slim_get_device(struct slim_controller *ctrl, struct slim_eaddr *e_addr); int slim_get_logical_addr(struct slim_device *sbdev);