Skip to content

Commit 6a71ca7

Browse files
committed
sparc: Use of_property_present() for testing DT property presence
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. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more. Link: https://lore.kernel.org/r/20230310144659.1541247-1-robh@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
1 parent 6bb1504 commit 6a71ca7

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

arch/sparc/kernel/of_device_32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static int of_bus_pci_match(struct device_node *np)
2929
* parent as-is, not with the PCI translate
3030
* method which chops off the top address cell.
3131
*/
32-
if (!of_find_property(np, "ranges", NULL))
32+
if (!of_property_present(np, "ranges"))
3333
return 0;
3434

3535
return 1;
@@ -223,7 +223,7 @@ static int __init build_one_resource(struct device_node *parent,
223223
static int __init use_1to1_mapping(struct device_node *pp)
224224
{
225225
/* If we have a ranges property in the parent, use it. */
226-
if (of_find_property(pp, "ranges", NULL) != NULL)
226+
if (of_property_present(pp, "ranges"))
227227
return 0;
228228

229229
/* Some SBUS devices use intermediate nodes to express

arch/sparc/kernel/of_device_64.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static int of_bus_pci_match(struct device_node *np)
5858
* parent as-is, not with the PCI translate
5959
* method which chops off the top address cell.
6060
*/
61-
if (!of_find_property(np, "ranges", NULL))
61+
if (!of_property_present(np, "ranges"))
6262
return 0;
6363

6464
return 1;
@@ -78,7 +78,7 @@ static int of_bus_simba_match(struct device_node *np)
7878
* simba.
7979
*/
8080
if (of_node_name_eq(np, "pci")) {
81-
if (!of_find_property(np, "ranges", NULL))
81+
if (!of_property_present(np, "ranges"))
8282
return 1;
8383
}
8484

@@ -283,7 +283,7 @@ static int __init build_one_resource(struct device_node *parent,
283283
static int __init use_1to1_mapping(struct device_node *pp)
284284
{
285285
/* If we have a ranges property in the parent, use it. */
286-
if (of_find_property(pp, "ranges", NULL) != NULL)
286+
if (of_property_present(pp, "ranges"))
287287
return 0;
288288

289289
/* If the parent is the dma node of an ISA bus, pass

arch/sparc/kernel/of_device_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int of_bus_sbus_match(struct device_node *np)
162162
* don't have some intervening real bus that provides
163163
* ranges based translations.
164164
*/
165-
if (of_find_property(dp, "ranges", NULL) != NULL)
165+
if (of_property_present(dp, "ranges"))
166166
break;
167167

168168
dp = dp->parent;

arch/sparc/kernel/prom_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static void *fill_in_one_cpu(struct device_node *dp, int cpuid, int arg)
502502
struct device_node *portid_parent = NULL;
503503
int portid = -1;
504504

505-
if (of_find_property(dp, "cpuid", NULL)) {
505+
if (of_property_present(dp, "cpuid")) {
506506
int limit = 2;
507507

508508
portid_parent = dp;

arch/sparc/kernel/time_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ static int clock_probe(struct platform_device *op)
277277
return -ENODEV;
278278

279279
/* Only the primary RTC has an address property */
280-
if (!of_find_property(dp, "address", NULL))
280+
if (!of_property_present(dp, "address"))
281281
return -ENODEV;
282282

283283
m48t59_rtc.resource = &op->resource[0];

0 commit comments

Comments
 (0)