2024-01-22 17:32:08

by Sui Jingfeng

[permalink] [raw]
Subject: [PATCH 5/5] drm-bridge: display-connector: Switch to use fwnode API

From: Sui Jingfeng <[email protected]>

Because API has wider coverage, it can be used on non-DT systems as well.

Signed-off-by: Sui Jingfeng <[email protected]>
---
drivers/gpu/drm/bridge/display-connector.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
index eb7e194e7735..2c3e54a458e8 100644
--- a/drivers/gpu/drm/bridge/display-connector.c
+++ b/drivers/gpu/drm/bridge/display-connector.c
@@ -243,8 +243,8 @@ static int display_connector_probe(struct platform_device *pdev)
case DRM_MODE_CONNECTOR_DVII: {
bool analog, digital;

- analog = of_property_read_bool(pdev->dev.of_node, "analog");
- digital = of_property_read_bool(pdev->dev.of_node, "digital");
+ analog = fwnode_property_present(pdev->dev.fwnode, "analog");
+ digital = fwnode_property_present(pdev->dev.fwnode, "digital");
if (analog && !digital) {
conn->bridge.type = DRM_MODE_CONNECTOR_DVIA;
} else if (!analog && digital) {
@@ -261,8 +261,8 @@ static int display_connector_probe(struct platform_device *pdev)
case DRM_MODE_CONNECTOR_HDMIA: {
const char *hdmi_type;

- ret = of_property_read_string(pdev->dev.of_node, "type",
- &hdmi_type);
+ ret = fwnode_property_read_string(pdev->dev.fwnode, "type",
+ &hdmi_type);
if (ret < 0) {
dev_err(&pdev->dev, "HDMI connector with no type\n");
return -EINVAL;
@@ -292,7 +292,7 @@ static int display_connector_probe(struct platform_device *pdev)
conn->bridge.interlace_allowed = true;

/* Get the optional connector label. */
- of_property_read_string(pdev->dev.of_node, "label", &label);
+ fwnode_property_read_string(pdev->dev.fwnode, "label", &label);

/*
* Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can provide
@@ -330,12 +330,13 @@ static int display_connector_probe(struct platform_device *pdev)
if (type == DRM_MODE_CONNECTOR_DVII ||
type == DRM_MODE_CONNECTOR_HDMIA ||
type == DRM_MODE_CONNECTOR_VGA) {
- struct device_node *phandle;
+ struct fwnode_handle *fwnode;

- phandle = of_parse_phandle(pdev->dev.of_node, "ddc-i2c-bus", 0);
- if (phandle) {
- conn->bridge.ddc = of_get_i2c_adapter_by_node(phandle);
- of_node_put(phandle);
+ fwnode = fwnode_find_reference(pdev->dev.fwnode, "ddc-i2c-bus", 0);
+ if (!IS_ERR_OR_NULL(fwnode)) {
+ dev_info(&pdev->dev, "has I2C bus property\n");
+ conn->bridge.ddc = i2c_get_adapter_by_fwnode(fwnode);
+ fwnode_handle_put(fwnode);
if (!conn->bridge.ddc)
return -EPROBE_DEFER;
} else {
@@ -380,6 +381,7 @@ static int display_connector_probe(struct platform_device *pdev)

conn->bridge.funcs = &display_connector_bridge_funcs;
conn->bridge.of_node = pdev->dev.of_node;
+ conn->bridge.fwnode = pdev->dev.fwnode;

if (conn->bridge.ddc)
conn->bridge.ops |= DRM_BRIDGE_OP_EDID
--
2.25.1



2024-01-23 02:39:11

by Laurent Pinchart

[permalink] [raw]
Subject: Re: [PATCH 5/5] drm-bridge: display-connector: Switch to use fwnode API

On Tue, Jan 23, 2024 at 12:32:20AM +0800, Sui Jingfeng wrote:
> From: Sui Jingfeng <[email protected]>
>
> Because API has wider coverage, it can be used on non-DT systems as well.
>
> Signed-off-by: Sui Jingfeng <[email protected]>
> ---
> drivers/gpu/drm/bridge/display-connector.c | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
> index eb7e194e7735..2c3e54a458e8 100644
> --- a/drivers/gpu/drm/bridge/display-connector.c
> +++ b/drivers/gpu/drm/bridge/display-connector.c
> @@ -243,8 +243,8 @@ static int display_connector_probe(struct platform_device *pdev)
> case DRM_MODE_CONNECTOR_DVII: {
> bool analog, digital;
>
> - analog = of_property_read_bool(pdev->dev.of_node, "analog");
> - digital = of_property_read_bool(pdev->dev.of_node, "digital");
> + analog = fwnode_property_present(pdev->dev.fwnode, "analog");
> + digital = fwnode_property_present(pdev->dev.fwnode, "digital");
> if (analog && !digital) {
> conn->bridge.type = DRM_MODE_CONNECTOR_DVIA;
> } else if (!analog && digital) {
> @@ -261,8 +261,8 @@ static int display_connector_probe(struct platform_device *pdev)
> case DRM_MODE_CONNECTOR_HDMIA: {
> const char *hdmi_type;
>
> - ret = of_property_read_string(pdev->dev.of_node, "type",
> - &hdmi_type);
> + ret = fwnode_property_read_string(pdev->dev.fwnode, "type",
> + &hdmi_type);
> if (ret < 0) {
> dev_err(&pdev->dev, "HDMI connector with no type\n");
> return -EINVAL;
> @@ -292,7 +292,7 @@ static int display_connector_probe(struct platform_device *pdev)
> conn->bridge.interlace_allowed = true;
>
> /* Get the optional connector label. */
> - of_property_read_string(pdev->dev.of_node, "label", &label);
> + fwnode_property_read_string(pdev->dev.fwnode, "label", &label);
>
> /*
> * Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can provide
> @@ -330,12 +330,13 @@ static int display_connector_probe(struct platform_device *pdev)
> if (type == DRM_MODE_CONNECTOR_DVII ||
> type == DRM_MODE_CONNECTOR_HDMIA ||
> type == DRM_MODE_CONNECTOR_VGA) {
> - struct device_node *phandle;
> + struct fwnode_handle *fwnode;
>
> - phandle = of_parse_phandle(pdev->dev.of_node, "ddc-i2c-bus", 0);
> - if (phandle) {
> - conn->bridge.ddc = of_get_i2c_adapter_by_node(phandle);
> - of_node_put(phandle);
> + fwnode = fwnode_find_reference(pdev->dev.fwnode, "ddc-i2c-bus", 0);
> + if (!IS_ERR_OR_NULL(fwnode)) {
> + dev_info(&pdev->dev, "has I2C bus property\n");

This looks like a debugging leftover.

> + conn->bridge.ddc = i2c_get_adapter_by_fwnode(fwnode);
> + fwnode_handle_put(fwnode);
> if (!conn->bridge.ddc)
> return -EPROBE_DEFER;
> } else {
> @@ -380,6 +381,7 @@ static int display_connector_probe(struct platform_device *pdev)
>
> conn->bridge.funcs = &display_connector_bridge_funcs;
> conn->bridge.of_node = pdev->dev.of_node;
> + conn->bridge.fwnode = pdev->dev.fwnode;

This goes in the right direction. Let's address the other drivers and
drop the OF-based calls in the same series :-)

>
> if (conn->bridge.ddc)
> conn->bridge.ops |= DRM_BRIDGE_OP_EDID

--
Regards,

Laurent Pinchart

2024-01-23 12:36:07

by Sui Jingfeng

[permalink] [raw]
Subject: Re: [PATCH 5/5] drm-bridge: display-connector: Switch to use fwnode API

Hi,


On 2024/1/23 09:20, Laurent Pinchart wrote:
> On Tue, Jan 23, 2024 at 12:32:20AM +0800, Sui Jingfeng wrote:
>> From: Sui Jingfeng<[email protected]>
>>
>> Because API has wider coverage, it can be used on non-DT systems as well.
>>
>> Signed-off-by: Sui Jingfeng<[email protected]>
>> ---
>> drivers/gpu/drm/bridge/display-connector.c | 22 ++++++++++++----------
>> 1 file changed, 12 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
>> index eb7e194e7735..2c3e54a458e8 100644
>> --- a/drivers/gpu/drm/bridge/display-connector.c
>> +++ b/drivers/gpu/drm/bridge/display-connector.c
>> @@ -243,8 +243,8 @@ static int display_connector_probe(struct platform_device *pdev)
>> case DRM_MODE_CONNECTOR_DVII: {
>> bool analog, digital;
>>
>> - analog = of_property_read_bool(pdev->dev.of_node, "analog");
>> - digital = of_property_read_bool(pdev->dev.of_node, "digital");
>> + analog = fwnode_property_present(pdev->dev.fwnode, "analog");
>> + digital = fwnode_property_present(pdev->dev.fwnode, "digital");
>> if (analog && !digital) {
>> conn->bridge.type = DRM_MODE_CONNECTOR_DVIA;
>> } else if (!analog && digital) {
>> @@ -261,8 +261,8 @@ static int display_connector_probe(struct platform_device *pdev)
>> case DRM_MODE_CONNECTOR_HDMIA: {
>> const char *hdmi_type;
>>
>> - ret = of_property_read_string(pdev->dev.of_node, "type",
>> - &hdmi_type);
>> + ret = fwnode_property_read_string(pdev->dev.fwnode, "type",
>> + &hdmi_type);
>> if (ret < 0) {
>> dev_err(&pdev->dev, "HDMI connector with no type\n");
>> return -EINVAL;
>> @@ -292,7 +292,7 @@ static int display_connector_probe(struct platform_device *pdev)
>> conn->bridge.interlace_allowed = true;
>>
>> /* Get the optional connector label. */
>> - of_property_read_string(pdev->dev.of_node, "label", &label);
>> + fwnode_property_read_string(pdev->dev.fwnode, "label", &label);
>>
>> /*
>> * Get the HPD GPIO for DVI, HDMI and DP connectors. If the GPIO can provide
>> @@ -330,12 +330,13 @@ static int display_connector_probe(struct platform_device *pdev)
>> if (type == DRM_MODE_CONNECTOR_DVII ||
>> type == DRM_MODE_CONNECTOR_HDMIA ||
>> type == DRM_MODE_CONNECTOR_VGA) {
>> - struct device_node *phandle;
>> + struct fwnode_handle *fwnode;
>>
>> - phandle = of_parse_phandle(pdev->dev.of_node, "ddc-i2c-bus", 0);
>> - if (phandle) {
>> - conn->bridge.ddc = of_get_i2c_adapter_by_node(phandle);
>> - of_node_put(phandle);
>> + fwnode = fwnode_find_reference(pdev->dev.fwnode, "ddc-i2c-bus", 0);
>> + if (!IS_ERR_OR_NULL(fwnode)) {
>> + dev_info(&pdev->dev, "has I2C bus property\n");
> This looks like a debugging leftover.


Yes, thanks a lot for reviewing.
I will pick up suggestions and go back to improve.


2024-03-20 20:32:39

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH 5/5] drm-bridge: display-connector: Switch to use fwnode API

On Tue, Jan 23, 2024 at 03:20:26AM +0200, Laurent Pinchart wrote:
> On Tue, Jan 23, 2024 at 12:32:20AM +0800, Sui Jingfeng wrote:

..

> > conn->bridge.of_node = pdev->dev.of_node;
> > + conn->bridge.fwnode = pdev->dev.fwnode;
>
> This goes in the right direction. Let's address the other drivers and
> drop the OF-based calls in the same series :-)

+1. BUT, please use device_set_node() instead of both lines.

--
With Best Regards,
Andy Shevchenko