powerpc: Use of_property_present() for testing DT property presence
authorRob Herring <robh@kernel.org>
Fri, 10 Mar 2023 14:46:56 +0000 (08:46 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 30 Mar 2023 12:36:35 +0000 (23:36 +1100)
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.

Signed-off-by: Rob Herring <robh@kernel.org>
[mpe: Drop change in ppc4xx_probe_pci_bridge(), formatting]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230310144657.1541039-1-robh@kernel.org
arch/powerpc/kernel/legacy_serial.c
arch/powerpc/platforms/44x/iss4xx.c
arch/powerpc/platforms/44x/ppc476.c
arch/powerpc/platforms/cell/spu_manage.c
arch/powerpc/platforms/powermac/pic.c
arch/powerpc/platforms/powernv/opal-lpc.c
arch/powerpc/platforms/pseries/hotplug-cpu.c
arch/powerpc/platforms/pseries/vio.c
arch/powerpc/sysdev/mpic_msgr.c

index f048c424c525b0a735fe3f8503873d72a9049c0b..1a3b7f3513b407648b3557eb6140ebba7bf5fac5 100644 (file)
@@ -171,11 +171,11 @@ static int __init add_legacy_soc_port(struct device_node *np,
        /* We only support ports that have a clock frequency properly
         * encoded in the device-tree.
         */
-       if (of_get_property(np, "clock-frequency", NULL) == NULL)
+       if (!of_property_present(np, "clock-frequency"))
                return -1;
 
        /* if reg-offset don't try to use it */
-       if ((of_get_property(np, "reg-offset", NULL) != NULL))
+       if (of_property_present(np, "reg-offset"))
                return -1;
 
        /* if rtas uses this device, don't try to use it as well */
@@ -237,7 +237,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
         * Note: Don't even try on P8 lpc, we know it's not directly mapped
         */
        if (!of_device_is_compatible(isa_brg, "ibm,power8-lpc") ||
-           of_get_property(isa_brg, "ranges", NULL)) {
+           of_property_present(isa_brg, "ranges")) {
                taddr = of_translate_address(np, reg);
                if (taddr == OF_BAD_ADDR)
                        taddr = 0;
@@ -268,7 +268,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
         * compatible UARTs on PCI need all sort of quirks (port offsets
         * etc...) that this code doesn't know about
         */
-       if (of_get_property(np, "clock-frequency", NULL) == NULL)
+       if (!of_property_present(np, "clock-frequency"))
                return -1;
 
        /* Get the PCI address. Assume BAR 0 */
index 981972e8347ff520e09024e1d0ccf824f7c23d9d..ef883d97fe159cdf52e5ce3e80abdf698f3490a0 100644 (file)
@@ -52,7 +52,7 @@ static void __init iss4xx_init_irq(void)
 
        /* Find top level interrupt controller */
        for_each_node_with_property(np, "interrupt-controller") {
-               if (of_get_property(np, "interrupts", NULL) == NULL)
+               if (!of_property_present(np, "interrupts"))
                        break;
        }
        if (np == NULL)
index 3135e654a7436b145f328baec2cd9623f69b6401..fbc6edad481f8dddcaca849973adb2879596e190 100644 (file)
@@ -123,7 +123,7 @@ static void __init ppc47x_init_irq(void)
 
        /* Find top level interrupt controller */
        for_each_node_with_property(np, "interrupt-controller") {
-               if (of_get_property(np, "interrupts", NULL) == NULL)
+               if (!of_property_present(np, "interrupts"))
                        break;
        }
        if (np == NULL)
index f1ac4c7420690a5d5f5792966c55ba29aa3f29c4..74567b32c48c2ff5c66fec7ac9e34685538c7c0a 100644 (file)
@@ -402,7 +402,7 @@ static int __init of_has_vicinity(void)
        struct device_node *dn;
 
        for_each_node_by_type(dn, "spe") {
-               if (of_find_property(dn, "vicinity", NULL))  {
+               if (of_property_present(dn, "vicinity"))  {
                        of_node_put(dn);
                        return 1;
                }
index 8c8d8e0a7d13751ef7a17c3d05cb595693ebc4f9..7425f94e271e578f1a78796627ea558a12088632 100644 (file)
@@ -475,8 +475,7 @@ static int __init pmac_pic_probe_mpic(void)
 
        /* We can have up to 2 MPICs cascaded */
        for_each_node_by_type(np, "open-pic") {
-               if (master == NULL &&
-                   of_get_property(np, "interrupts", NULL) == NULL)
+               if (master == NULL && !of_property_present(np, "interrupts"))
                        master = of_node_get(np);
                else if (slave == NULL)
                        slave = of_node_get(np);
index d129d6d45a500b2b0d659b1c85ccb600ccc7937a..a16f07cdab267c5107dc650b41fc06b1cb335592 100644 (file)
@@ -403,7 +403,7 @@ void __init opal_lpc_init(void)
                return;
 
        /* Does it support direct mapping ? */
-       if (of_get_property(np, "ranges", NULL)) {
+       if (of_property_present(np, "ranges")) {
                pr_info("OPAL: Found memory mapped LPC bus on chip %d\n",
                        opal_lpc_chip_id);
                isa_bridge_init_non_pci(np);
index 982e5e4b5e065372657affa6eb80cdbc3e2c4c70..1a3cb313976a456d59a07c17acfe01835291d1f8 100644 (file)
@@ -493,7 +493,7 @@ static bool valid_cpu_drc_index(struct device_node *parent, u32 drc_index)
        bool found = false;
        int rc, index;
 
-       if (of_find_property(parent, "ibm,drc-info", NULL))
+       if (of_property_present(parent, "ibm,drc-info"))
                return drc_info_valid_index(parent, drc_index);
 
        /* Note that the format of the ibm,drc-indexes array is
index 770df9351aaa98afaa6c333ae8a869cb84ffcf8b..d54306a936d55eb330101d03087796a95711aa3e 100644 (file)
@@ -1440,7 +1440,7 @@ struct vio_dev *vio_register_device_node(struct device_node *of_node)
        viodev->dev.bus = &vio_bus_type;
        viodev->dev.release = vio_dev_release;
 
-       if (of_get_property(viodev->dev.of_node, "ibm,my-dma-window", NULL)) {
+       if (of_property_present(viodev->dev.of_node, "ibm,my-dma-window")) {
                if (firmware_has_feature(FW_FEATURE_CMO))
                        vio_cmo_set_dma_ops(viodev);
                else
index d75064fb7d12fedbf991e4f8585dea8eb19790d9..1a3ac0b5dd89ce6ca4302f0af73e03bf66ece592 100644 (file)
@@ -116,7 +116,7 @@ static unsigned int mpic_msgr_number_of_blocks(void)
 
                for (;;) {
                        snprintf(buf, sizeof(buf), "mpic-msgr-block%d", count);
-                       if (!of_find_property(aliases, buf, NULL))
+                       if (!of_property_present(aliases, buf))
                                break;
 
                        count += 1;