From nobody Sun Feb 8 18:15:16 2026 Received: from out-174.mta1.migadu.com (out-174.mta1.migadu.com [95.215.58.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 116BE156C73 for ; Fri, 3 May 2024 16:41:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714754505; cv=none; b=Rc+Xwbl4BvmEb+q2/kqGqn5eiK2xF6qBsycJpdezoe1kXjOzwfresllrqfCJ+ikkSIPefEISF88WMNSoeprDHPFdidOHAYFXVdEyuqgKcWI4WldYjXRktpLV1bF8AsxrkU3c0NtpXdHyEoudLHOzHC9D10CwhzutKLJlLAIwt0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714754505; c=relaxed/simple; bh=738etampJ9m37JMTtzzW2+WYdjJ/ZGAALPaqCLoaW6k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dk2TpWsuXqfsuaHAnILROWcO7MIa64ngQv+/CvzhOIRsn+tebz+ZCwaV3Wcnhz0bThCETGd6kNI3lx3pFKjdUB8l9p5ghj23pUiIUm5mUoqmetorZ/wDo84dSIRasw2AZpOdTVyN612vQGk2HkUuXXpngTJ6FglrVsz1/ayBCqE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=kR4prRwM; arc=none smtp.client-ip=95.215.58.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="kR4prRwM" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1714754502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PB1TUtuAuL++SWCo4tYuatJMpIlybQp31QpILaCl8YA=; b=kR4prRwMmpHQXCSr8gv/7Yz6tg6VXOJNY1k/nESj4xHi/P/SX6BWWQ3C2zKcmEAZOl4fjA 3ZPaVhGJHRIV8RRyuxYLqXxV1pT1IbOtU5k0w5MAcuqPQ4Wl+7WKCTQSt6clsStAcFPxb+ 3C5HxHqBOs0Omx4kf1Lx8YU9RWgLilA= From: Sui Jingfeng To: Andrzej Hajda Cc: Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v5 05/10] drm/bridge: sii902x: Switch to use fwnode APIs to acquire device properties Date: Sat, 4 May 2024 00:41:01 +0800 Message-Id: <20240503164106.1172650-6-sui.jingfeng@linux.dev> In-Reply-To: <20240503164106.1172650-1-sui.jingfeng@linux.dev> References: <20240503164106.1172650-1-sui.jingfeng@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Make this driver less DT-dependent by calling the freshly created helpers, also switch to use fwnode APIs to acquire additional device properties. One side benifit is that boilerplates get reduced, no functional changes for DT-based systems. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/sii902x.c | 45 ++++++++++++-------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii9= 02x.c index 8f84e98249c7..bc906b71c793 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -827,20 +827,17 @@ static int sii902x_audio_codec_init(struct sii902x *s= ii902x, .spdif =3D 0, .max_i2s_channels =3D 0, }; + struct fwnode_handle *fwnode =3D dev_fwnode(dev); u8 lanes[4]; int num_lanes, i; =20 - if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) { + if (!fwnode_property_present(fwnode, "#sound-dai-cells")) { dev_dbg(dev, "%s: No \"#sound-dai-cells\", no audio\n", __func__); return 0; } =20 - num_lanes =3D of_property_read_variable_u8_array(dev->of_node, - "sil,i2s-data-lanes", - lanes, 1, - ARRAY_SIZE(lanes)); - + num_lanes =3D fwnode_property_count_u8(fwnode, "sil,i2s-data-lanes"); if (num_lanes =3D=3D -EINVAL) { dev_dbg(dev, "%s: No \"sil,i2s-data-lanes\", use default <0>\n", @@ -852,7 +849,11 @@ static int sii902x_audio_codec_init(struct sii902x *si= i902x, "%s: Error gettin \"sil,i2s-data-lanes\": %d\n", __func__, num_lanes); return num_lanes; + } else { + fwnode_property_read_u8_array(fwnode, "sil,i2s-data-lanes", + lanes, num_lanes); } + codec_data.max_i2s_channels =3D 2 * num_lanes; =20 for (i =3D 0; i < num_lanes; i++) @@ -1096,8 +1097,8 @@ static int sii902x_init(struct sii902x *sii902x) if (ret) goto err_unreg_audio; =20 + drm_bridge_set_node(&sii902x->bridge, dev_fwnode(dev)); sii902x->bridge.funcs =3D &sii902x_bridge_funcs; - sii902x->bridge.of_node =3D dev->of_node; sii902x->bridge.timings =3D &default_sii902x_timings; sii902x->bridge.ops =3D DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID; =20 @@ -1118,7 +1119,6 @@ static int sii902x_init(struct sii902x *sii902x) static int sii902x_probe(struct i2c_client *client) { struct device *dev =3D &client->dev; - struct device_node *endpoint; struct sii902x *sii902x; static const char * const supplies[] =3D {"iovcc", "cvcc12"}; int ret; @@ -1147,27 +1147,14 @@ static int sii902x_probe(struct i2c_client *client) return PTR_ERR(sii902x->reset_gpio); } =20 - endpoint =3D of_graph_get_endpoint_by_regs(dev->of_node, 1, -1); - if (endpoint) { - struct device_node *remote =3D of_graph_get_remote_port_parent(endpoint); - - of_node_put(endpoint); - if (!remote) { - dev_err(dev, "Endpoint in port@1 unconnected\n"); - return -ENODEV; - } - - if (!of_device_is_available(remote)) { - dev_err(dev, "port@1 remote device is disabled\n"); - of_node_put(remote); - return -ENODEV; - } - - sii902x->next_bridge =3D of_drm_find_bridge(remote); - of_node_put(remote); - if (!sii902x->next_bridge) - return dev_err_probe(dev, -EPROBE_DEFER, - "Failed to find remote bridge\n"); + sii902x->next_bridge =3D drm_bridge_find_next_bridge_by_fwnode(dev_fwnode= (dev), 1); + if (!sii902x->next_bridge) { + return dev_err_probe(dev, -EPROBE_DEFER, + "Failed to find the next bridge\n"); + } else if (IS_ERR(sii902x->next_bridge)) { + ret =3D PTR_ERR(sii902x->next_bridge); + dev_err(dev, "Error on find the next bridge: %d\n", ret); + return ret; } =20 mutex_init(&sii902x->mutex); --=20 2.34.1