From patchwork Fri May 25 14:36:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 136928 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3675311lji; Fri, 25 May 2018 07:38:42 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpScy98ZugePsDNJ0AiifBP2KWnv6g3iiU6yn1B7SUsk/yPFhgGvvyyUOUjSexCODfUW5Mu X-Received: by 2002:a62:3889:: with SMTP id f131-v6mr2844474pfa.173.1527259122769; Fri, 25 May 2018 07:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527259122; cv=none; d=google.com; s=arc-20160816; b=FZY2j2/22udVowFh5nh+m8PksPVJwfWBM7TsxpQDHG8zgo48s2lN8CzARJ84gXI1Uz ZXRle4/673UPg3n987fJ/9OXPw9zk62G4n2yFZEKGUwrdxAicouge0xypxy3cDmE0eBr kjXUj+4kACJWde5nsv4ewDNha5J9+GGIhJ3m6mnNAmOpZb3PvR2WRybIv3fOGccR69P/ YQKFbNuPctqPHMbt1yRVqTz10x3OvOw6mj/2Mf3Ck6mVogDnKu4QPUItbBtYSTROtShp +SQtnJxjlAQ9GY0lzE0+6APOm9LtI0VYKynuDL0q2xt4p23IFzywCrnBzGQ4MjKkSySQ As3A== 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=oUkKrmU5AVMZemQXTuIe+E4X5Oz1OuqiCCPkqRKqp/s=; b=dVI5gPgPe5SroGA7CyKzzkUfof8f0nxARvQHo8BCkxg0ykijegtzFeO+WLN4koo5Pw WqTtqmePxAKJ3HXwJWPXQbZbFRVIRHKIVJ7qMAwsFcGCXcxqN7C0NkpdkV2tkBIvQFhE ePiACXNhMCL+bUcASFTiC8PMKBS8KXA9yimppu4DIARFzJgr9Ibzoso8RU9RTxyRaaAf 5do4T4N6MexEb59qfKWMvjK5n+yvkaaQ4hEmh0sBAty+vmJetLAukhaOzVzQJ5iW2xaf AagnAQU5+nPD8VRhOj5WoPbwf1C6J9PO3WnuLzryq67EP92Q49aiN7PUEdiP+b1StjLG dtfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CcxqzJwc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (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 z16-v6si23106195plo.5.2018.05.25.07.38.42; Fri, 25 May 2018 07:38:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CcxqzJwc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966345AbeEYOij (ORCPT + 30 others); Fri, 25 May 2018 10:38:39 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40290 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965176AbeEYOib (ORCPT ); Fri, 25 May 2018 10:38:31 -0400 Received: by mail-wm0-f66.google.com with SMTP id x2-v6so7865518wmh.5 for ; Fri, 25 May 2018 07:38:30 -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=oUkKrmU5AVMZemQXTuIe+E4X5Oz1OuqiCCPkqRKqp/s=; b=CcxqzJwc//n40W23kF9Cw9s8D2+pdzleCSZXm3Xit1NyfofHmZoGOxN7yjC/WI9LTW rZjc+jM8t428aBjLD+XAahUEiXd9hodH+a9oDhQIdwOyHFfb8qlTu40MPV8ZknDlCRSA QkhwdqBRvfDkij6jH1eh5q8IQ6hmnpB5qomtA= 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=oUkKrmU5AVMZemQXTuIe+E4X5Oz1OuqiCCPkqRKqp/s=; b=f0ebXTteb0JKUUM6KbpN9Hth9+Iq9ve/FgHUyqaPbKWAbAQh22HPa1mABFIemabgPq WhJdt0/Yg7ywpKUB/npZutLmRSsjErqd/QquMNz3I2KWnnqdzzJbnzzadiUn1pN05vYc nZW7WfS0gyT064vpSRphXsykPvAwG/YFOrxMTfQzwkB++bmmn7cN2hLBIXDLGucVB64y QOF8LqUXgXESc2GXRjhMbS3eYGbnAopybrq8LQviwwF+iGqNtemWOjBsdFjIaHukWgvs v3bXZ4xxDBifG7ctx+BWz0Mijpzsb3vuLl7dkY8pvI0hcIks10qAV1vuy2FDlI29Katm 4UYQ== X-Gm-Message-State: ALKqPwdYN0E0a9A5c9ji3ciMMZBn5G2kzE38W/m3a8jwnK+9TrY4CkY0 0XVI5yLS5lw9UrT5qYu7qq4Ssg== X-Received: by 2002:a1c:1103:: with SMTP id 3-v6mr1929360wmr.26.1527259110002; Fri, 25 May 2018 07:38:30 -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 r6-v6sm26165729wrg.73.2018.05.25.07.38.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 May 2018 07:38:29 -0700 (PDT) From: Srinivas Kandagatla To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Srinivas Kandagatla Subject: [PATCH v3 8/8] slimbus: core: add of_slim_device_get() helper Date: Fri, 25 May 2018 15:36:18 +0100 Message-Id: <20180525143618.820-9-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180525143618.820-1-srinivas.kandagatla@linaro.org> References: <20180525143618.820-1-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 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 90af9eb26615..63801bcc5e60 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);