Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: 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 of_property_read_bool().

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> # for net/can
Acked-by: Kalle Valo <kvalo@kernel.org>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: Francois Romieu <romieu@fr.zoreil.com>
Reviewed-by: Wei Fang <wei.fang@nxp.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Rob Herring and committed by
David S. Miller
1a87e641 65d63e82

+36 -48
+6 -6
drivers/net/can/cc770/cc770_platform.c
··· 93 93 if (priv->can.clock.freq > 8000000) 94 94 priv->cpu_interface |= CPUIF_DMC; 95 95 96 - if (of_get_property(np, "bosch,divide-memory-clock", NULL)) 96 + if (of_property_read_bool(np, "bosch,divide-memory-clock")) 97 97 priv->cpu_interface |= CPUIF_DMC; 98 - if (of_get_property(np, "bosch,iso-low-speed-mux", NULL)) 98 + if (of_property_read_bool(np, "bosch,iso-low-speed-mux")) 99 99 priv->cpu_interface |= CPUIF_MUX; 100 100 101 101 if (!of_get_property(np, "bosch,no-comperator-bypass", NULL)) 102 102 priv->bus_config |= BUSCFG_CBY; 103 - if (of_get_property(np, "bosch,disconnect-rx0-input", NULL)) 103 + if (of_property_read_bool(np, "bosch,disconnect-rx0-input")) 104 104 priv->bus_config |= BUSCFG_DR0; 105 - if (of_get_property(np, "bosch,disconnect-rx1-input", NULL)) 105 + if (of_property_read_bool(np, "bosch,disconnect-rx1-input")) 106 106 priv->bus_config |= BUSCFG_DR1; 107 - if (of_get_property(np, "bosch,disconnect-tx1-output", NULL)) 107 + if (of_property_read_bool(np, "bosch,disconnect-tx1-output")) 108 108 priv->bus_config |= BUSCFG_DT1; 109 - if (of_get_property(np, "bosch,polarity-dominant", NULL)) 109 + if (of_property_read_bool(np, "bosch,polarity-dominant")) 110 110 priv->bus_config |= BUSCFG_POL; 111 111 112 112 prop = of_get_property(np, "bosch,clock-out-frequency", &prop_size);
+1 -1
drivers/net/ethernet/cadence/macb_main.c
··· 4990 4990 bp->jumbo_max_len = macb_config->jumbo_max_len; 4991 4991 4992 4992 bp->wol = 0; 4993 - if (of_get_property(np, "magic-packet", NULL)) 4993 + if (of_property_read_bool(np, "magic-packet")) 4994 4994 bp->wol |= MACB_WOL_HAS_MAGIC_PACKET; 4995 4995 device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET); 4996 4996
+2 -2
drivers/net/ethernet/davicom/dm9000.c
··· 1393 1393 if (!pdata) 1394 1394 return ERR_PTR(-ENOMEM); 1395 1395 1396 - if (of_find_property(np, "davicom,ext-phy", NULL)) 1396 + if (of_property_read_bool(np, "davicom,ext-phy")) 1397 1397 pdata->flags |= DM9000_PLATF_EXT_PHY; 1398 - if (of_find_property(np, "davicom,no-eeprom", NULL)) 1398 + if (of_property_read_bool(np, "davicom,no-eeprom")) 1399 1399 pdata->flags |= DM9000_PLATF_NO_EEPROM; 1400 1400 1401 1401 ret = of_get_mac_address(np, pdata->dev_addr);
+1 -1
drivers/net/ethernet/freescale/fec_main.c
··· 4251 4251 if (ret) 4252 4252 goto failed_ipc_init; 4253 4253 4254 - if (of_get_property(np, "fsl,magic-packet", NULL)) 4254 + if (of_property_read_bool(np, "fsl,magic-packet")) 4255 4255 fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET; 4256 4256 4257 4257 ret = fec_enet_init_stop_mode(fep, np);
+1 -1
drivers/net/ethernet/freescale/fec_mpc52xx.c
··· 937 937 priv->phy_node = of_parse_phandle(np, "phy-handle", 0); 938 938 939 939 /* the 7-wire property means don't use MII mode */ 940 - if (of_find_property(np, "fsl,7-wire-mode", NULL)) { 940 + if (of_property_read_bool(np, "fsl,7-wire-mode")) { 941 941 priv->seven_wire_mode = 1; 942 942 dev_info(&ndev->dev, "using 7-wire PHY mode\n"); 943 943 }
+2 -2
drivers/net/ethernet/freescale/gianfar.c
··· 787 787 else 788 788 priv->interface = gfar_get_interface(dev); 789 789 790 - if (of_find_property(np, "fsl,magic-packet", NULL)) 790 + if (of_property_read_bool(np, "fsl,magic-packet")) 791 791 priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET; 792 792 793 - if (of_get_property(np, "fsl,wake-on-filer", NULL)) 793 + if (of_property_read_bool(np, "fsl,wake-on-filer")) 794 794 priv->device_flags |= FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER; 795 795 796 796 priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
+4 -4
drivers/net/ethernet/ibm/emac/core.c
··· 2939 2939 } 2940 2940 2941 2941 /* Fixup some feature bits based on the device tree */ 2942 - if (of_get_property(np, "has-inverted-stacr-oc", NULL)) 2942 + if (of_property_read_bool(np, "has-inverted-stacr-oc")) 2943 2943 dev->features |= EMAC_FTR_STACR_OC_INVERT; 2944 - if (of_get_property(np, "has-new-stacr-staopc", NULL)) 2944 + if (of_property_read_bool(np, "has-new-stacr-staopc")) 2945 2945 dev->features |= EMAC_FTR_HAS_NEW_STACR; 2946 2946 2947 2947 /* CAB lacks the appropriate properties */ ··· 3042 3042 * property here for now, but new flat device trees should set a 3043 3043 * status property to "disabled" instead. 3044 3044 */ 3045 - if (of_get_property(np, "unused", NULL) || !of_device_is_available(np)) 3045 + if (of_property_read_bool(np, "unused") || !of_device_is_available(np)) 3046 3046 return -ENODEV; 3047 3047 3048 3048 /* Find ourselves in the bootlist if we are there */ ··· 3333 3333 3334 3334 if (of_match_node(emac_match, np) == NULL) 3335 3335 continue; 3336 - if (of_get_property(np, "unused", NULL)) 3336 + if (of_property_read_bool(np, "unused")) 3337 3337 continue; 3338 3338 idx = of_get_property(np, "cell-index", NULL); 3339 3339 if (idx == NULL)
+1 -1
drivers/net/ethernet/ibm/emac/rgmii.c
··· 242 242 } 243 243 244 244 /* Check for RGMII flags */ 245 - if (of_get_property(ofdev->dev.of_node, "has-mdio", NULL)) 245 + if (of_property_read_bool(ofdev->dev.of_node, "has-mdio")) 246 246 dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; 247 247 248 248 /* CAB lacks the right properties, fix this up */
+1 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
··· 213 213 struct device_node *np = dev->of_node; 214 214 int err = 0; 215 215 216 - if (of_get_property(np, "snps,rmii_refclk_ext", NULL)) 217 - dwmac->rmii_refclk_ext = true; 216 + dwmac->rmii_refclk_ext = of_property_read_bool(np, "snps,rmii_refclk_ext"); 218 217 219 218 dwmac->clk_tx = devm_clk_get(dev, "tx"); 220 219 if (IS_ERR(dwmac->clk_tx)) {
+1 -1
drivers/net/ethernet/sun/niu.c
··· 9271 9271 if (model) 9272 9272 strcpy(np->vpd.model, model); 9273 9273 9274 - if (of_find_property(dp, "hot-swappable-phy", NULL)) { 9274 + if (of_property_read_bool(dp, "hot-swappable-phy")) { 9275 9275 np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER | 9276 9276 NIU_FLAGS_HOTPLUG_PHY); 9277 9277 }
+1 -2
drivers/net/ethernet/ti/cpsw-phy-sel.c
··· 226 226 if (IS_ERR(priv->gmii_sel)) 227 227 return PTR_ERR(priv->gmii_sel); 228 228 229 - if (of_find_property(pdev->dev.of_node, "rmii-clock-ext", NULL)) 230 - priv->rmii_clock_external = true; 229 + priv->rmii_clock_external = of_property_read_bool(pdev->dev.of_node, "rmii-clock-ext"); 231 230 232 231 dev_set_drvdata(&pdev->dev, priv); 233 232
+3 -5
drivers/net/ethernet/ti/netcp_ethss.c
··· 3583 3583 /* init the hw stats lock */ 3584 3584 spin_lock_init(&gbe_dev->hw_stats_lock); 3585 3585 3586 - if (of_find_property(node, "enable-ale", NULL)) { 3587 - gbe_dev->enable_ale = true; 3586 + gbe_dev->enable_ale = of_property_read_bool(node, "enable-ale"); 3587 + if (gbe_dev->enable_ale) 3588 3588 dev_info(dev, "ALE enabled\n"); 3589 - } else { 3590 - gbe_dev->enable_ale = false; 3589 + else 3591 3590 dev_dbg(dev, "ALE bypass enabled*\n"); 3592 - } 3593 3591 3594 3592 ret = of_property_read_u32(node, "tx-queue", 3595 3593 &gbe_dev->tx_queue_id);
+1 -2
drivers/net/ethernet/via/via-velocity.c
··· 2709 2709 struct resource res; 2710 2710 int ret; 2711 2711 2712 - if (of_get_property(vptr->dev->of_node, "no-eeprom", NULL)) 2713 - vptr->no_eeprom = 1; 2712 + vptr->no_eeprom = of_property_read_bool(vptr->dev->of_node, "no-eeprom"); 2714 2713 2715 2714 ret = of_address_to_resource(vptr->dev->of_node, 0, &res); 2716 2715 if (ret) {
+1 -1
drivers/net/ethernet/via/via-velocity.h
··· 1383 1383 struct device *dev; 1384 1384 struct pci_dev *pdev; 1385 1385 struct net_device *netdev; 1386 - int no_eeprom; 1386 + bool no_eeprom; 1387 1387 1388 1388 unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 1389 1389 u8 ip_addr[4];
+4 -5
drivers/net/ethernet/xilinx/ll_temac_main.c
··· 1455 1455 * endianness mode. Default for OF devices is big-endian. 1456 1456 */ 1457 1457 little_endian = false; 1458 - if (temac_np) { 1459 - if (of_get_property(temac_np, "little-endian", NULL)) 1460 - little_endian = true; 1461 - } else if (pdata) { 1458 + if (temac_np) 1459 + little_endian = of_property_read_bool(temac_np, "little-endian"); 1460 + else if (pdata) 1462 1461 little_endian = pdata->reg_little_endian; 1463 - } 1462 + 1464 1463 if (little_endian) { 1465 1464 lp->temac_ior = _temac_ior_le; 1466 1465 lp->temac_iow = _temac_iow_le;
+3 -8
drivers/net/wan/fsl_ucc_hdlc.c
··· 1177 1177 uhdlc_priv->dev = &pdev->dev; 1178 1178 uhdlc_priv->ut_info = ut_info; 1179 1179 1180 - if (of_get_property(np, "fsl,tdm-interface", NULL)) 1181 - uhdlc_priv->tsa = 1; 1182 - 1183 - if (of_get_property(np, "fsl,ucc-internal-loopback", NULL)) 1184 - uhdlc_priv->loopback = 1; 1185 - 1186 - if (of_get_property(np, "fsl,hdlc-bus", NULL)) 1187 - uhdlc_priv->hdlc_bus = 1; 1180 + uhdlc_priv->tsa = of_property_read_bool(np, "fsl,tdm-interface"); 1181 + uhdlc_priv->loopback = of_property_read_bool(np, "fsl,ucc-internal-loopback"); 1182 + uhdlc_priv->hdlc_bus = of_property_read_bool(np, "fsl,hdlc-bus"); 1188 1183 1189 1184 if (uhdlc_priv->tsa == 1) { 1190 1185 utdm = kzalloc(sizeof(*utdm), GFP_KERNEL);
+1 -2
drivers/net/wireless/ti/wlcore/spi.c
··· 447 447 dev_info(&spi->dev, "selected chip family is %s\n", 448 448 pdev_data->family->name); 449 449 450 - if (of_find_property(dt_node, "clock-xtal", NULL)) 451 - pdev_data->ref_clock_xtal = true; 450 + pdev_data->ref_clock_xtal = of_property_read_bool(dt_node, "clock-xtal"); 452 451 453 452 /* optional clock frequency params */ 454 453 of_property_read_u32(dt_node, "ref-clock-frequency",
+2 -2
net/ncsi/ncsi-manage.c
··· 1803 1803 pdev = to_platform_device(dev->dev.parent); 1804 1804 if (pdev) { 1805 1805 np = pdev->dev.of_node; 1806 - if (np && (of_get_property(np, "mellanox,multi-host", NULL) || 1807 - of_get_property(np, "mlx,multi-host", NULL))) 1806 + if (np && (of_property_read_bool(np, "mellanox,multi-host") || 1807 + of_property_read_bool(np, "mlx,multi-host"))) 1808 1808 ndp->mlx_multi_host = true; 1809 1809 } 1810 1810