From patchwork Tue Jun 19 16:12:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 139194 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5397097lji; Tue, 19 Jun 2018 09:13:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI9MLeehlusl1p74ivsMXb6Rmc6Hp91u8s4Qribs1azx9EBoSPaX0GIQwt9iCVRm/DzS+Kp X-Received: by 2002:a62:f407:: with SMTP id r7-v6mr18623519pff.47.1529424794743; Tue, 19 Jun 2018 09:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529424794; cv=none; d=google.com; s=arc-20160816; b=i2EFjHPipxs/qsqzOKF76gZXJEjVmY9b886AddhRbNBHA5uhBwDQdYig01tk/wGsgG JIAApcHw5j2sQfdP2O9zVcSl1d/j14qkmemIdJE/O2XXou02gT+mRhSXdCXPXFqReODu 3EuK700/W/f2SZwZqXzkFUmA1pxjNzJGpFdugpy/vMzMNKzQUVaI/zfECj432Ang0BGq RSAeXba2UZSaIJN7f8q+FU7bGkJiTIjEHYidRBkfLwGYhoidLuXNvVrm3yGXmqZ5z2IE FV/2QrKSoeWOU4Iyj8e4nwfsAOGRqouLNNx/1i9UX1+ltzNJIp2lK0nxCjVU1heewxO8 p/dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=ge5oc7yqW67wYGbrRMzkL2NnUpylHKu0QJeWPQUx9Oc=; b=kqFu5U1KFj0xGVIB2TSgxHNqH13Rn6f6z7TgCpQjvUmDq/HqfpSLEekBT7IKsJ2rgZ ANqfxPejz87WrDeitd9w+mapkIAM4zBUrVrJzWfN8aF4CfMrhFS26v+uwfrzu3bCl+CA zTthb43QeoiFKqdUsT+EuW4U/ewut7+4qVQ4uKsSsrpb2DeNdpTtnl/PHXVkIQvzkTNq KqShLD/9IJCy1WGwDODq6uxsZ/5vaUAORa3ih2Bq3BebRIIR1hEXCkN5tEkPsCSomoTO eCys1KbHvBjGiqodMTDDj4wVOWuhKm4MoSxHnXZURjl1faIQlyKB6trLUK1srXPfRysy jWVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WJb0I4qg; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b26-v6si47991pff.278.2018.06.19.09.13.14; Tue, 19 Jun 2018 09:13:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WJb0I4qg; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967087AbeFSQNL (ORCPT + 13 others); Tue, 19 Jun 2018 12:13:11 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:53276 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966986AbeFSQNI (ORCPT ); Tue, 19 Jun 2018 12:13:08 -0400 Received: by mail-wm0-f66.google.com with SMTP id x6-v6so1317287wmc.3 for ; Tue, 19 Jun 2018 09:13:08 -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=WJb0I4qguAGnG8ViBOzfU+r1pGCxGFPMypZWxGj8Zy1JE1ASQ6jYNxoscXsvLtKpd8 hS66suuO7+lKL28ruoTr7NLUEjLW/Cl9DoO9ZhIiy284QAsmnzUjBEzYWVY8EIfpX0GD 2cPeZ/EcLO1TQMjFoZIOJ2hdpT20XVYY7y0Xc= 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=AQuCjICQgGqkauZjmFDh+Sq3Pyqfl2JiP2NhrEfmoXKyQXBEQhbftA/CeeqR4Nir/x N790tmMVhPtnVwYD4eoF8TXyP9OgFjCaNBs9cnPcFtw0/3pTcyx28mZkyF1Y36w95m6I O2cxslpKP56iP3PtqlB2yO004P0YXe0ZilhnWkKF+mhzaBpKbK3pm5IW0I18X95zCMXo QoCJTJGdnvBKlPMMd/KMzdScGptLDO9Bviz79hynrELWw72xvtIUsVatw08UMM3jYQqw BbzMhi0YS4f7q51p+oLkHqVlsRKedmfEvvu+S2H4tCGpOM8AmM/Ln2FY6/I/RnzCOQL5 8y3g== X-Gm-Message-State: APt69E124TW8fZcMcLX3w6D2u2VUfFiK/OqHFdrLV3uy+V2Yi5WPBo1e +Me53DwYzJc4OKDzE8Izd24HjQ== X-Received: by 2002:a1c:4189:: with SMTP id o131-v6mr11655598wma.7.1529424787406; Tue, 19 Jun 2018 09:13:07 -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 r5-v6sm47248wrp.59.2018.06.19.09.13.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jun 2018 09:13:06 -0700 (PDT) From: Srinivas Kandagatla To: gregkh@linuxfoundation.org Cc: robh+dt@kernel.org, kramasub@codeaurora.org, sdharia@quicinc.com, linux-kernel@vger.kernel.org, broonie@kernel.org, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v4 1/5] slimbus: core: add of_slim_device_get() helper Date: Tue, 19 Jun 2018 17:12:57 +0100 Message-Id: <20180619161301.4556-2-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180619161301.4556-1-srinivas.kandagatla@linaro.org> References: <20180619161301.4556-1-srinivas.kandagatla@linaro.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.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 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);