From nobody Wed Dec 31 03:10:49 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4306C4332F for ; Tue, 14 Nov 2023 15:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233637AbjKNPJ4 (ORCPT ); Tue, 14 Nov 2023 10:09:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233473AbjKNPJh (ORCPT ); Tue, 14 Nov 2023 10:09:37 -0500 Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909E6198 for ; Tue, 14 Nov 2023 07:09:32 -0800 (PST) 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=1699974131; 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=cnL8rRLdhxEUHMmzuPbpEqxboZkciFsFzGYdTqdV4zg=; b=PKDm94kMbgxgRSLDoJDDSVLVgpcMTPt7BhKDKq9u6fu0bN01BjveNYWGPsleYtML9yc6Vd eKvVW8SN4uT1AYUPGnTKzuZUQsbFIhPRfNrOrlPK588nvpPe3PyohC6pRUszauqnKiTdjK GJIH4tNSxWQ8DotrzwByn2N/K9Jo9og= From: Sui Jingfeng To: Phong LE , Neil Armstrong Cc: Laurent Pinchart , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sui Jingfeng Subject: [PATCH 3/8] drm/bridge: it66121: Add a helper function to read bus width Date: Tue, 14 Nov 2023 23:01:25 +0800 Message-Id: <20231114150130.497915-4-sui.jingfeng@linux.dev> In-Reply-To: <20231114150130.497915-1-sui.jingfeng@linux.dev> References: <20231114150130.497915-1-sui.jingfeng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Sui Jingfeng Group those relavent code lines (which with common purpose) into one helper function, suppress the dependency on DT to function level. Just trivial cleanup, no functional change. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/ite-it66121.c | 32 ++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/ite-it66121.c b/drivers/gpu/drm/bridge/= ite-it66121.c index 83dbdbfc9ed8..0f78737adc83 100644 --- a/drivers/gpu/drm/bridge/ite-it66121.c +++ b/drivers/gpu/drm/bridge/ite-it66121.c @@ -320,6 +320,26 @@ static inline struct it66121_ctx *bridge_to_it66121(st= ruct drm_bridge *bridge) return container_of(bridge, struct it66121_ctx, bridge); } =20 +static int it66121_of_read_bus_width(struct device *dev, u32 *bus_width) +{ + struct device_node *np; + u32 bw; + + np =3D of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); + if (!np) + return -EINVAL; + + of_property_read_u32(np, "bus-width", &bw); + of_node_put(np); + + if (bw !=3D 12 && bw !=3D 24) + return -EINVAL; + + *bus_width =3D bw; + + return 0; +} + static const struct regmap_range_cfg it66121_regmap_banks[] =3D { { .name =3D "it66121", @@ -1525,19 +1545,13 @@ static int it66121_probe(struct i2c_client *client) if (!ctx) return -ENOMEM; =20 - ep =3D of_graph_get_endpoint_by_regs(dev->of_node, 0, 0); - if (!ep) - return -EINVAL; - ctx->dev =3D dev; ctx->client =3D client; ctx->info =3D i2c_get_match_data(client); =20 - of_property_read_u32(ep, "bus-width", &ctx->bus_width); - of_node_put(ep); - - if (ctx->bus_width !=3D 12 && ctx->bus_width !=3D 24) - return -EINVAL; + ret =3D it66121_of_read_bus_width(dev, &ctx->bus_width); + if (ret) + return ret; =20 ep =3D of_graph_get_remote_node(dev->of_node, 1, -1); if (!ep) { --=20 2.34.1