Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp1706656lqb; Sun, 26 May 2024 13:23:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWoFUDsbh6AH8b4feOUsnSvLQNP25wAESC7mryZlTnZax/u28XgW7zh01TgGknlu4RzTvxNXf0uA7KBK6u6k5XdsskNNdXOyzHrg/a8wg== X-Google-Smtp-Source: AGHT+IG17x+GbiK4+KsODAAx0naQU04GTM0M0sunxhSlQuCra1qJF6RxdyUDr/dyJqbdzwFSdBkl X-Received: by 2002:a05:622a:14:b0:43a:df49:f8b7 with SMTP id d75a77b69052e-43fb0ea56a6mr83844991cf.36.1716755015030; Sun, 26 May 2024 13:23:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716755015; cv=pass; d=google.com; s=arc-20160816; b=IF02ypHvzt4HIj1jMJ0/JVHjVq9de/9jAT+J81un7z8k+I479C62zAeSvpfZGmVxXr 2cF/89sqxLMfy0nKrWUaTIXa/cCpW3wnXV8+/rtNyHkvvs3IjCtvZbh+TiT/RzXgAtOi e+xPolPZuiCZ0L+LiT+abFi+rDIrh2zTOC4HvzgZXBOJRDCfe7USRhVCla9qCbX4Vmcj PPT9PTbwyKyRNBKXUGh5hohNYxgcejGrm6det4aYNHsWwiNLwmYrx2wmXrtqaZa7lNWk d9MktqMKXf898xtcaEQhchhfUTn3qkbQ9MZvK2r6uOaGfN9YnjgLyWMHPAPc01PmBROp Gqxg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=obPPCFVCrE6Vzm1J73QBI5DbfGkJjhE7+q8Dgk4gceA=; fh=+9pjvWy/sQxAY6MxG8mZV2fAo+vnxCF8rB7oqMHgJRU=; b=pwXERHQHf8eVvGKw4R2pK78NS4fXXtt+LrN5ZXQ+0yq28ECx/om6MSFENyvtmbBMVa Yd7qwPKA24Hwb4tk6qfVFQCl7WuFFNI8gYaas+B6nXqd3HUYdByYlVxRxLceg57xnvBq 5U+BnufI+FSFSPEKIp4OxsQLv6HZZs8XSCCKdp/wejfBBNhP0wIUYhqYQuV0B2hL/LZ2 jf/EIbRobIR+izdjJ6uDtj1qXTzx/KRL1mjJwhNdfSVRoZOtQtva/4r+Xv1ZCkWoXAnF JtWXP34qXjZm7bc7xaUJIBMGOhdd8EIUemlJNotC2hOdh0vd/Dv6FgVqGLmGXZ0ZouvT VcHQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=AQIUxBsY; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-189863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189863-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43fb18a6e44si66294731cf.357.2024.05.26.13.23.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 13:23:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-189863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=AQIUxBsY; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-189863-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-189863-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8E0141C20CB5 for ; Sun, 26 May 2024 20:23:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C20DF139CF1; Sun, 26 May 2024 20:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="AQIUxBsY" Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (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 7D06E13AA32 for ; Sun, 26 May 2024 20:22:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716754932; cv=none; b=WnlRdH8m+aLgpiZLhuh7bCbKU+USI0T6pP75VYmMFEFz+24sre+UVEAQX3ShGlC7jHTAkfcEE4cyuQpZJ7Y3F/CfXjxuIcJiv17valMekqjBs+6dR6iYjk4+YLttRuAHzvrNMkTiYup7JLtFqCdINWBCkRp1YmMYkjkNDJHGmMs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716754932; c=relaxed/simple; bh=Kz/eqHbUCd4L4KVRWDsSIgK1BXZgJsrO1jg4j6T1dqg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WuplHKolNDWhqzXpLqr+f+/4ERBEsY0uSSEGNgfSP7NayRvdt77wojN+6YSPn4aAXMjTjAk6sfGzdmc8w793QqTmKvBI2a1Rq6FOa8EohOYn/DRnlstqpeAK8VU4y6HfY0v8BUoGiULRSVEKVPyALhPv/iIGn5PuOj8f48jXcWs= 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=AQIUxBsY; arc=none smtp.client-ip=95.215.58.170 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 X-Envelope-To: rfoss@kernel.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1716754928; 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=obPPCFVCrE6Vzm1J73QBI5DbfGkJjhE7+q8Dgk4gceA=; b=AQIUxBsYwLMZe/RsYxWV8cwFj0Kbzankyg7CYp0nqtGGtU/h4Qwq6L0BIhKKyLgnYpsin7 9ceB4nHWJhSEW6kiYxI7fPGmTmHJqVarAzdU+MwkuVCIPkxJXbDdHFDCPUyoR6yDC3LpRM zCVwYOq99UjadxhewG9wiVrgS8/1084= X-Envelope-To: laurent.pinchart@ideasonboard.com X-Envelope-To: dri-devel@lists.freedesktop.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: sui.jingfeng@linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sui Jingfeng To: Robert Foss , Laurent Pinchart Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sui Jingfeng Subject: [PATCH v6 08/10] drm/bridge: tfp410: Use fwnode APIs to acquire device properties Date: Mon, 27 May 2024 04:21:13 +0800 Message-Id: <20240526202115.129049-9-sui.jingfeng@linux.dev> In-Reply-To: <20240526202115.129049-1-sui.jingfeng@linux.dev> References: <20240526202115.129049-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: 8bit X-Migadu-Flow: FLOW_OUT Make this driver less DT-dependent by calling the newly created helpers, also switch to use fwnode APIs to acquire additional device properties. No functional changes for DT-based systems. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/bridge/ti-tfp410.c | 39 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c b/drivers/gpu/drm/bridge/ti-tfp410.c index 04a341133488..a1fae5e9dafd 100644 --- a/drivers/gpu/drm/bridge/ti-tfp410.c +++ b/drivers/gpu/drm/bridge/ti-tfp410.c @@ -261,8 +261,9 @@ static const struct drm_bridge_timings tfp410_default_timings = { static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) { + struct fwnode_handle *fwnode = dev_fwnode(dvi->dev); struct drm_bridge_timings *timings = &dvi->timings; - struct device_node *ep; + struct fwnode_handle *ep; u32 pclk_sample = 0; u32 bus_width = 24; u32 deskew = 0; @@ -283,14 +284,14 @@ static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) * and EDGE pins. They are specified in DT through endpoint properties * and vendor-specific properties. */ - ep = of_graph_get_endpoint_by_regs(dvi->dev->of_node, 0, 0); + ep = fwnode_graph_get_endpoint_by_id(fwnode, 0, 0, 0); if (!ep) return -EINVAL; /* Get the sampling edge from the endpoint. */ - of_property_read_u32(ep, "pclk-sample", &pclk_sample); - of_property_read_u32(ep, "bus-width", &bus_width); - of_node_put(ep); + fwnode_property_read_u32(ep, "pclk-sample", &pclk_sample); + fwnode_property_read_u32(ep, "bus-width", &bus_width); + fwnode_handle_put(ep); timings->input_bus_flags = DRM_BUS_FLAG_DE_HIGH; @@ -319,7 +320,7 @@ static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) } /* Get the setup and hold time from vendor-specific properties. */ - of_property_read_u32(dvi->dev->of_node, "ti,deskew", &deskew); + fwnode_property_read_u32(fwnode, "ti,deskew", &deskew); if (deskew > 7) return -EINVAL; @@ -331,12 +332,12 @@ static int tfp410_parse_timings(struct tfp410 *dvi, bool i2c) static int tfp410_init(struct device *dev, bool i2c) { - struct device_node *node; + struct fwnode_handle *fwnode = dev_fwnode(dev); struct tfp410 *dvi; int ret; - if (!dev->of_node) { - dev_err(dev, "device-tree data is missing\n"); + if (!fwnode) { + dev_err(dev, "firmware data is missing\n"); return -ENXIO; } @@ -356,15 +357,15 @@ static int tfp410_init(struct device *dev, bool i2c) return ret; /* Get the next bridge, connected to port@1. */ - node = of_graph_get_remote_node(dev->of_node, 1, -1); - if (!node) - return -ENODEV; - - dvi->next_bridge = of_drm_find_bridge(node); - of_node_put(node); - - if (!dvi->next_bridge) + dvi->next_bridge = drm_bridge_find_next_bridge_by_fwnode(fwnode, 1); + if (IS_ERR(dvi->next_bridge)) { + ret = PTR_ERR(dvi->next_bridge); + dev_err(dev, "Error in founding the next bridge: %d\n", ret); + return ret; + } else if (!dvi->next_bridge) { + dev_dbg(dev, "Next bridge not found, deferring probe\n"); return -EPROBE_DEFER; + } /* Get the powerdown GPIO. */ dvi->powerdown = devm_gpiod_get_optional(dev, "powerdown", @@ -416,10 +417,10 @@ static struct platform_driver tfp410_platform_driver = { /* There is currently no i2c functionality. */ static int tfp410_i2c_probe(struct i2c_client *client) { + struct fwnode_handle *fwnode = dev_fwnode(&client->dev); int reg; - if (!client->dev.of_node || - of_property_read_u32(client->dev.of_node, "reg", ®)) { + if (!fwnode || fwnode_property_read_u32(fwnode, "reg", ®)) { dev_err(&client->dev, "Can't get i2c reg property from device-tree\n"); return -ENXIO; -- 2.34.1