Skip to contentSkip to conversation

drm: Use of_property_read_bool() for boolean properties

PATCH In review Rob Herring 2 participants 2 messages Mar 10, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: Use of_property_read_bool() for boolean properties

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. Convert reading boolean properties to to of_property_read_bool().

---
 drivers/gpu/drm/bridge/parade-ps8622.c | 2 +-
 drivers/gpu/drm/tiny/ofdrm.c           | 8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/bridge/parade-ps8622.c +1 -1
index 530ee6a19e7e..efa80e309b98 100644
@@ -496,7 +496,7 @@ static int ps8622_probe(struct i2c_client *client)
 		ps8622->lane_count = ps8622->max_lane_count;
 	}
 
-	if (!of_find_property(dev->of_node, "use-external-pwm", NULL)) {
+	if (!of_property_read_bool(dev->of_node, "use-external-pwm")) {
 		ps8622->bl = backlight_device_register("ps8622-backlight",
 				dev, ps8622, &ps8622_backlight_ops,
 				NULL);
drivers/gpu/drm/tiny/ofdrm.c +2 -6
index 6e349ca42485..76cd7f515bab 100644
@@ -162,13 +162,9 @@ static bool display_get_big_endian_of(struct drm_device *dev, struct device_node
 	bool big_endian;
 
 #ifdef __BIG_ENDIAN
-	big_endian = true;
-	if (of_get_property(of_node, "little-endian", NULL))
-		big_endian = false;
+	big_endian = !of_property_read_bool(of_node, "little-endian");
 #else
-	big_endian = false;
-	if (of_get_property(of_node, "big-endian", NULL))
-		big_endian = true;
+	big_endian = of_property_read_bool(of_node, "big-endian");
 #endif
 
 	return big_endian;
Signature · 1 line
2.39.2
reviewer Reviewed-by on v1 1/1
#1 lore raw

Hi Rob,

Thank you for the patch.

Quoted 4 lines · Rob Herring

It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. Convert reading boolean properties to to of_property_read_bool().

s/to to/to/ (or maybe "to use" ?)

With this,

Quoted 39 lines
---
 drivers/gpu/drm/bridge/parade-ps8622.c | 2 +-
 drivers/gpu/drm/tiny/ofdrm.c           | 8 ++------
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/gpu/drm/bridge/parade-ps8622.c +1 -1
index 530ee6a19e7e..efa80e309b98 100644
@@ -496,7 +496,7 @@ static int ps8622_probe(struct i2c_client *client)
 		ps8622->lane_count = ps8622->max_lane_count;
 	}
 
-	if (!of_find_property(dev->of_node, "use-external-pwm", NULL)) {
+	if (!of_property_read_bool(dev->of_node, "use-external-pwm")) {
 		ps8622->bl = backlight_device_register("ps8622-backlight",
 				dev, ps8622, &ps8622_backlight_ops,
 				NULL);
drivers/gpu/drm/tiny/ofdrm.c +2 -6
index 6e349ca42485..76cd7f515bab 100644
@@ -162,13 +162,9 @@ static bool display_get_big_endian_of(struct drm_device *dev, struct device_node
 	bool big_endian;
 
 #ifdef __BIG_ENDIAN
-	big_endian = true;
-	if (of_get_property(of_node, "little-endian", NULL))
-		big_endian = false;
+	big_endian = !of_property_read_bool(of_node, "little-endian");
 #else
-	big_endian = false;
-	if (of_get_property(of_node, "big-endian", NULL))
-		big_endian = true;
+	big_endian = of_property_read_bool(of_node, "big-endian");
 #endif
 
 	return big_endian;
Signature · 3 lines
Regards,

Laurent Pinchart