Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1009940yba; Thu, 4 Apr 2019 02:20:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrgmgX0ooP/TCOBMJz2A9hiKOV3k1OBDSoDX3oDCTPho2d4ZEvj2lYkTdhwYbnF5GRK4SB X-Received: by 2002:aa7:9389:: with SMTP id t9mr4832148pfe.60.1554369640562; Thu, 04 Apr 2019 02:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554369640; cv=none; d=google.com; s=arc-20160816; b=w8PmXS5a4DN8BHXPRtRQIxiPpzkXN8vzUJVXMm16mYfo4ot4m2/Gy5ZLSQPCYnIrhu +Svf78S52c0FOTJrg+wdHl98A+hnvQvRomfffjTW3hEJo6gntkhaBN5kicAOdNGnC5P4 vr/83IEjBHXRig+n1gNvQatZvqIx2QCuBayWUyi9SXFXgmkMorwvq9V1XmXZchuJbWV8 AyctyxyMQJ6H9fiMVwPBB958pu+HJQ10hr9naYplVkKtDOt++5iaYyoExI4nYGz1OKEa 31RiHDStjXzEG1A+Hx9whg6F+q0tICQi+YS0UP8Sq1LdHJ8ItwEJA4ArPaQvps0sYgLY tyLg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1kXWuqhGDQqTTbFsut8lQomFeVNR+Zt+tMJ7QoBpI5k=; b=CZCvTGDOYfhYt3K0TiR6gCXSoioUooqZ6ryaRdP0da75TgEcS17UW29Qz04EmJ+Gso q81KzeEaOg92rWi7JUsvO7fVQJ3yF56TXcEpo2ZSJeGBcD9ODNteeo0JUw5GqkrNJwzF DTCie8l+7JSyTp3XSOYq8W9RCH1+XemWUZS0ED2V7uL/VQ6AXDUBJeXiBmfMu0LQbzZy xA40/bMkrv01Zw3YB1SBOtUyiKx1GjxVkNFrFJOYZAHvRtdig89cOwvZYuGEJqh7Hj3N pHLQ9TWqnw/4jEvtzkL3tGkdacI4HRKowIAcdPm0wgoOT7XHvzxa0BJhvDmfv+D0JmLp RxGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=doZjhzVS; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si16115316pgh.139.2019.04.04.02.20.25; Thu, 04 Apr 2019 02:20:40 -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=doZjhzVS; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388352AbfDDJSW (ORCPT + 99 others); Thu, 4 Apr 2019 05:18:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:60444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbfDDJSU (ORCPT ); Thu, 4 Apr 2019 05:18:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AC4E20652; Thu, 4 Apr 2019 09:18:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554369499; bh=n1eSbOFubPJbrdns4g9N5OXl47tZJRTp54wLxM+dZTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=doZjhzVSg6bdN1h/fNIGJOQDRKF75ROBVqnDgYMXprpX3M/G7VDyyoxoz+hulNDWc qTgY2BHm5blyft0f+DF0DXq6CXqHf19bjiG/7hnjibgBcSOrHUVjs1V+JQCHVO/FhU nmqETHOhyGNsQ55SxWiPzdcFNtwh4k1GXFZbbZ+4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kuninori Morimoto , Mark Brown , Sasha Levin Subject: [PATCH 5.0 239/246] ASoC: simple-card-utils: check "reg" property on asoc_simple_card_get_dai_id() Date: Thu, 4 Apr 2019 10:48:59 +0200 Message-Id: <20190404084627.662480505@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084619.236418459@linuxfoundation.org> References: <20190404084619.236418459@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ [ 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