diff mbox series

[09/10] of: property: Implement of_fwnode_property_present() by of_property_present()

Message ID 20241206-of_core_fix-v1-9-dc28ed56bec3@quicinc.com
State Changes Requested
Headers show
Series of: fix bugs and improve codes | expand

Checks

Context Check Description
robh/checkpatch success
robh/patch-applied fail build log

Commit Message

Zijun Hu Dec. 6, 2024, 12:52 a.m. UTC
From: Zijun Hu <quic_zijuhu@quicinc.com>

of_property_read_bool() is deprecated for non-boolean property, but
of_fwnode_property_present() still uses it.

Fix by using of_property_present() instead of of_property_read_bool().

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
 drivers/of/property.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rob Herring Dec. 9, 2024, 4:48 p.m. UTC | #1
On Thu, Dec 5, 2024 at 6:54 PM Zijun Hu <zijun_hu@icloud.com> wrote:
>
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> of_property_read_bool() is deprecated for non-boolean property, but
> of_fwnode_property_present() still uses it.
>
> Fix by using of_property_present() instead of of_property_read_bool().

of_property_present() just calls of_property_read_bool(). For now. I'm
working on making using of_property_read_bool() on non-boolean a
warning. No point in this change until that happens.

Rob
Zijun Hu Dec. 10, 2024, 12:44 p.m. UTC | #2
On 2024/12/10 00:48, Rob Herring wrote:
> On Thu, Dec 5, 2024 at 6:54 PM Zijun Hu <zijun_hu@icloud.com> wrote:
>>
>> From: Zijun Hu <quic_zijuhu@quicinc.com>
>>
>> of_property_read_bool() is deprecated for non-boolean property, but
>> of_fwnode_property_present() still uses it.
>>
>> Fix by using of_property_present() instead of of_property_read_bool().
> 
> of_property_present() just calls of_property_read_bool(). For now. I'm
> working on making using of_property_read_bool() on non-boolean a
> warning. No point in this change until that happens.
> 

what about below idea?

replace all of_property_read_bool() usages with of_property_present()
then remove the former.

> Rob
Robin Murphy Dec. 10, 2024, 1:37 p.m. UTC | #3
On 2024-12-10 12:44 pm, Zijun Hu wrote:
> On 2024/12/10 00:48, Rob Herring wrote:
>> On Thu, Dec 5, 2024 at 6:54 PM Zijun Hu <zijun_hu@icloud.com> wrote:
>>>
>>> From: Zijun Hu <quic_zijuhu@quicinc.com>
>>>
>>> of_property_read_bool() is deprecated for non-boolean property, but
>>> of_fwnode_property_present() still uses it.
>>>
>>> Fix by using of_property_present() instead of of_property_read_bool().
>>
>> of_property_present() just calls of_property_read_bool(). For now. I'm
>> working on making using of_property_read_bool() on non-boolean a
>> warning. No point in this change until that happens.
>>
> 
> what about below idea?
> 
> replace all of_property_read_bool() usages with of_property_present()
> then remove the former.

No, the whole reason of_property_present() was added in the first place 
is because reading the effective "value" of a boolean property is a 
semantically different operation from checking whether a property of any 
type exists. Therefore (ab)using a single function for both purposes, 
whichever way round, is not an ideal API design. The fact that they both 
happen to share the same implementation at the moment is, as Rob says, 
not something we want to be tied to forever.

Thanks,
Robin.
diff mbox series

Patch

diff --git a/drivers/of/property.c b/drivers/of/property.c
index 519bf9229e613906547b57d8c68e7b8558eff327..dca1a3ebccae1093b2b11f51e8e692bca854d0e3 100644
--- a/drivers/of/property.c
+++ b/drivers/of/property.c
@@ -966,7 +966,7 @@  of_fwnode_device_get_dma_attr(const struct fwnode_handle *fwnode)
 static bool of_fwnode_property_present(const struct fwnode_handle *fwnode,
 				       const char *propname)
 {
-	return of_property_read_bool(to_of_node(fwnode), propname);
+	return of_property_present(to_of_node(fwnode), propname);
 }
 
 static int of_fwnode_property_read_int_array(const struct fwnode_handle *fwnode,