Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5639467img; Wed, 27 Mar 2019 12:14:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3I/YN3vN2hzmXc9G+AWeQQ6CZHKBwbmY9gnncsfGfGyzwlkOZ7Jj95OQTwMuWGXIvyqPy X-Received: by 2002:a62:2046:: with SMTP id g67mr31514076pfg.121.1553714042856; Wed, 27 Mar 2019 12:14:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553714042; cv=none; d=google.com; s=arc-20160816; b=tpcCl+qfFOhEHNeltqbeZbUbTQag5BqrNDjL0o/twJE3PpoGaeh0eGYItundQ5ba6i Hes4pINJ6fCj6/ECSGmujEHCCM+RY2f9rLCINuVrns89o4TW1PVrL0wkVur9UKmosoq8 vNCVotrDcjkXfohvAdzQG5Yn2n6gGHDC1RK/rAgVjc0bs3WZMVnMDoxccLWBANEUS78D HRJEncIx3Wc43QP25zGCiH0J8AkczjxhCx561O51Q62gt9NIrw0o9db2EK7TnoMj1/kR ibC+0z09vdY5L89kM+ASoDZg+TKA7ttGeMrVBl22j7PMdhlB3R3p4eucMO9E8MgsCK2p 0Zpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=V4NJLyPNGjY4ebyQcNpraWLwB5GjEUNnVcprHoz6lOQ=; b=HET/TlNbIwMldftTzokW+fccfi7WWjnmEXWPj4iCWk9d8mUnRaDC0KfEpcDTrf24qu k1FLFhNVtAT16wS78ddwWXqR6fhiXz9zj8U+acBQ3OczKJjMpYOVHduBv/k8wvmXOGCV WHbZSyz4NdX1HSt2Gu23fuCsEUV6TbAxr7q8vobqplJtDxi5h8SVeR6Xff2zTwaH68/4 hImwFMD4auy5fjp0p81uCqVUwljykuAPd8Y38aTyj3iDE4zUhNK9jE9wfv+rgMmAO6qw 7K+soFQGgpppVPP30/vqyLazNkgFSQP1VqXN3rAYSx7sAA6LHlGFZpGo2dyW8hdizMHr 9Y7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AXDWRNNb; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si19821772pge.192.2019.03.27.12.13.47; Wed, 27 Mar 2019 12:14:02 -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=@kernel.org header.s=default header.b=AXDWRNNb; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388770AbfC0SKQ (ORCPT + 99 others); Wed, 27 Mar 2019 14:10:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:52206 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732739AbfC0SKO (ORCPT ); Wed, 27 Mar 2019 14:10:14 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 099262147C; Wed, 27 Mar 2019 18:10:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553710213; bh=3ctWvtXHwfad4c0NepgnJRbv4myj51QEQatkQQG1QV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AXDWRNNbQ+RMUg5R6GjygxvGMipkhpuSFZl/5QBUTkciLDlhupwnDo3mqsdzeTELB 4RdyjFw0BPrAmqMSZ/k1sAIxdJSNSkybgemZZA3L//mz26XbUGhZJj5V9rYpRHqBFH IhepK1bD6LpwiDF6rUEI99OkRJWnlviL8dZrgBAo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kuninori Morimoto , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.0 255/262] ASoC: simple-card-utils: check "reg" property on asoc_simple_card_get_dai_id() Date: Wed, 27 Mar 2019 14:01:50 -0400 Message-Id: <20190327180158.10245-255-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kuninori Morimoto [ Upstream commit a0c426fe143328760c9fd565cd203a37a7b4fde8 ] We will get DAI ID from "reg" property if it has on DT, otherwise get it by counting port/endpoint. But in below case, we need to get DAI ID = 0 via port reg = <0>, but current implementation returns ID = 1, because it can't judge ID = 0 was from "non reg" or "reg = <0>". Thus, it will count port/endpoint number as "non reg" case. of_graph_parse_endpoint() implementation itself is not a problem, but because asoc_simple_card_get_dai_id() need to count port/endpoint number when "non reg" case, it need to know ID = 0 was from "non reg" or "reg = <0>". This patch fix this issue. port { reg = <0>; xxxx: endpoint@0 { }; => xxxx: endpoint@1 { }; }; Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/generic/simple-card-utils.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index b807a47515eb..336895f7fd1e 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -283,12 +283,20 @@ static int asoc_simple_card_get_dai_id(struct device_node *ep) /* use endpoint/port reg if exist */ ret = of_graph_parse_endpoint(ep, &info); if (ret == 0) { - if (info.id) + /* + * Because it will count port/endpoint if it doesn't have "reg". + * But, we can't judge whether it has "no reg", or "reg = <0>" + * only of_graph_parse_endpoint(). + * We need to check "reg" property + */ + if (of_get_property(ep, "reg", NULL)) return info.id; - if (info.port) + + node = of_get_parent(ep); + of_node_put(node); + if (of_get_property(node, "reg", NULL)) return info.port; } - node = of_graph_get_port_parent(ep); /* -- 2.19.1