serial: Use of_property_present() for testing DT property presence
authorRob Herring <robh@kernel.org>
Fri, 10 Mar 2023 14:47:26 +0000 (08:47 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 16 Mar 2023 12:02:11 +0000 (13:02 +0100)
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>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230310144727.1545630-1-robh@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c
drivers/tty/serial/sh-sci.c
drivers/tty/serial/sunzilog.c

index 84bc0e7687261bb8bfd13056d2906d98db4c9a7d..4d389e23bc011b38a74de6867d662372705647ac 100644 (file)
@@ -2264,8 +2264,7 @@ static int imx_uart_probe(struct platform_device *pdev)
        if (of_get_property(np, "fsl,dte-mode", NULL))
                sport->dte_mode = 1;
 
-       if (of_get_property(np, "rts-gpios", NULL))
-               sport->have_rtsgpio = 1;
+       sport->have_rtsgpio = of_property_present(np, "rts-gpios");
 
        if (of_get_property(np, "fsl,inverted-tx", NULL))
                sport->inverted_tx = 1;
index 7bd0807209299bba3f6c7af65a8d7f492d71e7de..a3e12e985e0dc91ceb0be760bf68a4b8f35ce9bf 100644 (file)
@@ -1573,7 +1573,7 @@ static void sci_request_dma(struct uart_port *port)
         * Don't request a dma channel if no channel was specified
         * in the device tree.
         */
-       if (!of_find_property(port->dev->of_node, "dmas", NULL))
+       if (!of_property_present(port->dev->of_node, "dmas"))
                return;
 
        chan = sci_request_dma_chan(port, DMA_MEM_TO_DEV);
index ccb809216e941d9283cf247d2942a195a2a502bf..0fbeb3dbd84312b2bf740e30f81a32ad05cdb8e7 100644 (file)
@@ -1403,7 +1403,7 @@ static int zs_probe(struct platform_device *op)
        int keyboard_mouse = 0;
        int err;
 
-       if (of_find_property(op->dev.of_node, "keyboard", NULL))
+       if (of_property_present(op->dev.of_node, "keyboard"))
                keyboard_mouse = 1;
 
        /* uarts must come before keyboards/mice */
@@ -1553,7 +1553,7 @@ static int __init sunzilog_init(void)
 
        for_each_node_by_name(dp, "zs") {
                num_sunzilog++;
-               if (of_find_property(dp, "keyboard", NULL))
+               if (of_property_present(dp, "keyboard"))
                        num_keybms++;
        }