Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 11665C77B6E for ; Wed, 12 Apr 2023 11:53:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9F6BF85FAC; Wed, 12 Apr 2023 13:53:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=metanate.com header.i=@metanate.com header.b="cP8qPfji"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E09B68598A; Wed, 12 Apr 2023 13:53:09 +0200 (CEST) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12B7585F70 for ; Wed, 12 Apr 2023 13:53:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=john@metanate.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=0+eqZzsTTO/X37suK3DTqewA2ydjVa85oBu+gq33I24=; b=cP 8qPfji0yvGEUX4OjI3ACZnOdopspwo3elBTq1L0iCd/mq1r8alrQAhdZzTtJNS3TN5BuGS47R8HBq +r4rVXjcjyjbV2RTTNOmo22oY3ut8vuEmJC1wX8A98UIcgywCA/xHeUwNaHIdjl0Qw/HZMK2Qi3z7 ULkYEWR8OTeQFzDzjqR2/PJh9LfBdzfemSaf+D4afijUkr4nw080dHARBWBxsC6oFpFNLV8kLdi78 WqNXQ8lPZcli+5gk8n5OSj5DYljt28ZwsSPhIt1jEzejTCm+1wosL4O/5UW9BBbw3TDCiFZ9132ZN BNtnvapJTFbCqIV2xqiR+s+yg1yMzpow==; Received: from dougal.metanate.com ([192.168.88.1] helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pmZ26-0000vF-Ro; Wed, 12 Apr 2023 12:53:04 +0100 From: John Keeping To: u-boot@lists.denx.de Cc: John Keeping , Simon Glass , Philipp Tomsich , Kever Yang Subject: [PATCH 1/2] rockchip: use standard dr_mode parsing function Date: Wed, 12 Apr 2023 12:52:52 +0100 Message-Id: <20230412115253.1283568-1-john@metanate.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated: YES X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Instead of duplicating the string values here, use usb_get_dr_mode() to handle the property lookup and converting the values to an enum. This is implemented with a switch in preparation for the next patch which adds extra handling for peripheral mode. Signed-off-by: John Keeping --- arch/arm/mach-rockchip/board.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c index f1f70c81d0..6d33d65780 100644 --- a/arch/arm/mach-rockchip/board.c +++ b/arch/arm/mach-rockchip/board.c @@ -212,6 +212,7 @@ void enable_caches(void) #include #if defined(CONFIG_USB_GADGET_DWC2_OTG) +#include #include static struct dwc2_plat_otg_data otg_data = { @@ -223,18 +224,23 @@ static struct dwc2_plat_otg_data otg_data = { int board_usb_init(int index, enum usb_init_type init) { ofnode node; - const char *mode; bool matched = false; /* find the usb_otg node */ node = ofnode_by_compatible(ofnode_null(), "snps,dwc2"); while (ofnode_valid(node)) { - mode = ofnode_read_string(node, "dr_mode"); - if (mode && strcmp(mode, "otg") == 0) { + switch (usb_get_dr_mode(node)) { + case USB_DR_MODE_OTG: matched = true; break; + + default: + break; } + if (matched) + break; + node = ofnode_by_compatible(node, "snps,dwc2"); } if (!matched) { -- 2.40.0