Commit 1a87e641 authored by Rob Herring's avatar Rob Herring Committed by David S. Miller

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: default avatarSimon Horman <simon.horman@corigine.com>
Acked-by: Marc Kleine-Budde <mkl@pengutronix.de> # for net/can
Acked-by: default avatarKalle Valo <kvalo@kernel.org>
Acked-by: default avatarNicolas Ferre <nicolas.ferre@microchip.com>
Acked-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
Reviewed-by: default avatarWei Fang <wei.fang@nxp.com>
Signed-off-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 65d63e82
...@@ -93,20 +93,20 @@ static int cc770_get_of_node_data(struct platform_device *pdev, ...@@ -93,20 +93,20 @@ static int cc770_get_of_node_data(struct platform_device *pdev,
if (priv->can.clock.freq > 8000000) if (priv->can.clock.freq > 8000000)
priv->cpu_interface |= CPUIF_DMC; priv->cpu_interface |= CPUIF_DMC;
if (of_get_property(np, "bosch,divide-memory-clock", NULL)) if (of_property_read_bool(np, "bosch,divide-memory-clock"))
priv->cpu_interface |= CPUIF_DMC; priv->cpu_interface |= CPUIF_DMC;
if (of_get_property(np, "bosch,iso-low-speed-mux", NULL)) if (of_property_read_bool(np, "bosch,iso-low-speed-mux"))
priv->cpu_interface |= CPUIF_MUX; priv->cpu_interface |= CPUIF_MUX;
if (!of_get_property(np, "bosch,no-comperator-bypass", NULL)) if (!of_get_property(np, "bosch,no-comperator-bypass", NULL))
priv->bus_config |= BUSCFG_CBY; priv->bus_config |= BUSCFG_CBY;
if (of_get_property(np, "bosch,disconnect-rx0-input", NULL)) if (of_property_read_bool(np, "bosch,disconnect-rx0-input"))
priv->bus_config |= BUSCFG_DR0; priv->bus_config |= BUSCFG_DR0;
if (of_get_property(np, "bosch,disconnect-rx1-input", NULL)) if (of_property_read_bool(np, "bosch,disconnect-rx1-input"))
priv->bus_config |= BUSCFG_DR1; priv->bus_config |= BUSCFG_DR1;
if (of_get_property(np, "bosch,disconnect-tx1-output", NULL)) if (of_property_read_bool(np, "bosch,disconnect-tx1-output"))
priv->bus_config |= BUSCFG_DT1; priv->bus_config |= BUSCFG_DT1;
if (of_get_property(np, "bosch,polarity-dominant", NULL)) if (of_property_read_bool(np, "bosch,polarity-dominant"))
priv->bus_config |= BUSCFG_POL; priv->bus_config |= BUSCFG_POL;
prop = of_get_property(np, "bosch,clock-out-frequency", &prop_size); prop = of_get_property(np, "bosch,clock-out-frequency", &prop_size);
......
...@@ -4990,7 +4990,7 @@ static int macb_probe(struct platform_device *pdev) ...@@ -4990,7 +4990,7 @@ static int macb_probe(struct platform_device *pdev)
bp->jumbo_max_len = macb_config->jumbo_max_len; bp->jumbo_max_len = macb_config->jumbo_max_len;
bp->wol = 0; bp->wol = 0;
if (of_get_property(np, "magic-packet", NULL)) if (of_property_read_bool(np, "magic-packet"))
bp->wol |= MACB_WOL_HAS_MAGIC_PACKET; bp->wol |= MACB_WOL_HAS_MAGIC_PACKET;
device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET); device_set_wakeup_capable(&pdev->dev, bp->wol & MACB_WOL_HAS_MAGIC_PACKET);
......
...@@ -1393,9 +1393,9 @@ static struct dm9000_plat_data *dm9000_parse_dt(struct device *dev) ...@@ -1393,9 +1393,9 @@ static struct dm9000_plat_data *dm9000_parse_dt(struct device *dev)
if (!pdata) if (!pdata)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (of_find_property(np, "davicom,ext-phy", NULL)) if (of_property_read_bool(np, "davicom,ext-phy"))
pdata->flags |= DM9000_PLATF_EXT_PHY; pdata->flags |= DM9000_PLATF_EXT_PHY;
if (of_find_property(np, "davicom,no-eeprom", NULL)) if (of_property_read_bool(np, "davicom,no-eeprom"))
pdata->flags |= DM9000_PLATF_NO_EEPROM; pdata->flags |= DM9000_PLATF_NO_EEPROM;
ret = of_get_mac_address(np, pdata->dev_addr); ret = of_get_mac_address(np, pdata->dev_addr);
......
...@@ -4251,7 +4251,7 @@ fec_probe(struct platform_device *pdev) ...@@ -4251,7 +4251,7 @@ fec_probe(struct platform_device *pdev)
if (ret) if (ret)
goto failed_ipc_init; goto failed_ipc_init;
if (of_get_property(np, "fsl,magic-packet", NULL)) if (of_property_read_bool(np, "fsl,magic-packet"))
fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET; fep->wol_flag |= FEC_WOL_HAS_MAGIC_PACKET;
ret = fec_enet_init_stop_mode(fep, np); ret = fec_enet_init_stop_mode(fep, np);
......
...@@ -937,7 +937,7 @@ static int mpc52xx_fec_probe(struct platform_device *op) ...@@ -937,7 +937,7 @@ static int mpc52xx_fec_probe(struct platform_device *op)
priv->phy_node = of_parse_phandle(np, "phy-handle", 0); priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
/* the 7-wire property means don't use MII mode */ /* the 7-wire property means don't use MII mode */
if (of_find_property(np, "fsl,7-wire-mode", NULL)) { if (of_property_read_bool(np, "fsl,7-wire-mode")) {
priv->seven_wire_mode = 1; priv->seven_wire_mode = 1;
dev_info(&ndev->dev, "using 7-wire PHY mode\n"); dev_info(&ndev->dev, "using 7-wire PHY mode\n");
} }
......
...@@ -787,10 +787,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev) ...@@ -787,10 +787,10 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
else else
priv->interface = gfar_get_interface(dev); priv->interface = gfar_get_interface(dev);
if (of_find_property(np, "fsl,magic-packet", NULL)) if (of_property_read_bool(np, "fsl,magic-packet"))
priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET; priv->device_flags |= FSL_GIANFAR_DEV_HAS_MAGIC_PACKET;
if (of_get_property(np, "fsl,wake-on-filer", NULL)) if (of_property_read_bool(np, "fsl,wake-on-filer"))
priv->device_flags |= FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER; priv->device_flags |= FSL_GIANFAR_DEV_HAS_WAKE_ON_FILER;
priv->phy_node = of_parse_phandle(np, "phy-handle", 0); priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
......
...@@ -2939,9 +2939,9 @@ static int emac_init_config(struct emac_instance *dev) ...@@ -2939,9 +2939,9 @@ static int emac_init_config(struct emac_instance *dev)
} }
/* Fixup some feature bits based on the device tree */ /* Fixup some feature bits based on the device tree */
if (of_get_property(np, "has-inverted-stacr-oc", NULL)) if (of_property_read_bool(np, "has-inverted-stacr-oc"))
dev->features |= EMAC_FTR_STACR_OC_INVERT; dev->features |= EMAC_FTR_STACR_OC_INVERT;
if (of_get_property(np, "has-new-stacr-staopc", NULL)) if (of_property_read_bool(np, "has-new-stacr-staopc"))
dev->features |= EMAC_FTR_HAS_NEW_STACR; dev->features |= EMAC_FTR_HAS_NEW_STACR;
/* CAB lacks the appropriate properties */ /* CAB lacks the appropriate properties */
...@@ -3042,7 +3042,7 @@ static int emac_probe(struct platform_device *ofdev) ...@@ -3042,7 +3042,7 @@ static int emac_probe(struct platform_device *ofdev)
* property here for now, but new flat device trees should set a * property here for now, but new flat device trees should set a
* status property to "disabled" instead. * status property to "disabled" instead.
*/ */
if (of_get_property(np, "unused", NULL) || !of_device_is_available(np)) if (of_property_read_bool(np, "unused") || !of_device_is_available(np))
return -ENODEV; return -ENODEV;
/* Find ourselves in the bootlist if we are there */ /* Find ourselves in the bootlist if we are there */
...@@ -3333,7 +3333,7 @@ static void __init emac_make_bootlist(void) ...@@ -3333,7 +3333,7 @@ static void __init emac_make_bootlist(void)
if (of_match_node(emac_match, np) == NULL) if (of_match_node(emac_match, np) == NULL)
continue; continue;
if (of_get_property(np, "unused", NULL)) if (of_property_read_bool(np, "unused"))
continue; continue;
idx = of_get_property(np, "cell-index", NULL); idx = of_get_property(np, "cell-index", NULL);
if (idx == NULL) if (idx == NULL)
......
...@@ -242,7 +242,7 @@ static int rgmii_probe(struct platform_device *ofdev) ...@@ -242,7 +242,7 @@ static int rgmii_probe(struct platform_device *ofdev)
} }
/* Check for RGMII flags */ /* Check for RGMII flags */
if (of_get_property(ofdev->dev.of_node, "has-mdio", NULL)) if (of_property_read_bool(ofdev->dev.of_node, "has-mdio"))
dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO; dev->flags |= EMAC_RGMII_FLAG_HAS_MDIO;
/* CAB lacks the right properties, fix this up */ /* CAB lacks the right properties, fix this up */
......
...@@ -213,8 +213,7 @@ imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev) ...@@ -213,8 +213,7 @@ imx_dwmac_parse_dt(struct imx_priv_data *dwmac, struct device *dev)
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
int err = 0; int err = 0;
if (of_get_property(np, "snps,rmii_refclk_ext", NULL)) dwmac->rmii_refclk_ext = of_property_read_bool(np, "snps,rmii_refclk_ext");
dwmac->rmii_refclk_ext = true;
dwmac->clk_tx = devm_clk_get(dev, "tx"); dwmac->clk_tx = devm_clk_get(dev, "tx");
if (IS_ERR(dwmac->clk_tx)) { if (IS_ERR(dwmac->clk_tx)) {
......
...@@ -9271,7 +9271,7 @@ static int niu_get_of_props(struct niu *np) ...@@ -9271,7 +9271,7 @@ static int niu_get_of_props(struct niu *np)
if (model) if (model)
strcpy(np->vpd.model, model); strcpy(np->vpd.model, model);
if (of_find_property(dp, "hot-swappable-phy", NULL)) { if (of_property_read_bool(dp, "hot-swappable-phy")) {
np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER | np->flags |= (NIU_FLAGS_10G | NIU_FLAGS_FIBER |
NIU_FLAGS_HOTPLUG_PHY); NIU_FLAGS_HOTPLUG_PHY);
} }
......
...@@ -226,8 +226,7 @@ static int cpsw_phy_sel_probe(struct platform_device *pdev) ...@@ -226,8 +226,7 @@ static int cpsw_phy_sel_probe(struct platform_device *pdev)
if (IS_ERR(priv->gmii_sel)) if (IS_ERR(priv->gmii_sel))
return PTR_ERR(priv->gmii_sel); return PTR_ERR(priv->gmii_sel);
if (of_find_property(pdev->dev.of_node, "rmii-clock-ext", NULL)) priv->rmii_clock_external = of_property_read_bool(pdev->dev.of_node, "rmii-clock-ext");
priv->rmii_clock_external = true;
dev_set_drvdata(&pdev->dev, priv); dev_set_drvdata(&pdev->dev, priv);
......
...@@ -3583,13 +3583,11 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev, ...@@ -3583,13 +3583,11 @@ static int gbe_probe(struct netcp_device *netcp_device, struct device *dev,
/* init the hw stats lock */ /* init the hw stats lock */
spin_lock_init(&gbe_dev->hw_stats_lock); spin_lock_init(&gbe_dev->hw_stats_lock);
if (of_find_property(node, "enable-ale", NULL)) { gbe_dev->enable_ale = of_property_read_bool(node, "enable-ale");
gbe_dev->enable_ale = true; if (gbe_dev->enable_ale)
dev_info(dev, "ALE enabled\n"); dev_info(dev, "ALE enabled\n");
} else { else
gbe_dev->enable_ale = false;
dev_dbg(dev, "ALE bypass enabled*\n"); dev_dbg(dev, "ALE bypass enabled*\n");
}
ret = of_property_read_u32(node, "tx-queue", ret = of_property_read_u32(node, "tx-queue",
&gbe_dev->tx_queue_id); &gbe_dev->tx_queue_id);
......
...@@ -2709,8 +2709,7 @@ static int velocity_get_platform_info(struct velocity_info *vptr) ...@@ -2709,8 +2709,7 @@ static int velocity_get_platform_info(struct velocity_info *vptr)
struct resource res; struct resource res;
int ret; int ret;
if (of_get_property(vptr->dev->of_node, "no-eeprom", NULL)) vptr->no_eeprom = of_property_read_bool(vptr->dev->of_node, "no-eeprom");
vptr->no_eeprom = 1;
ret = of_address_to_resource(vptr->dev->of_node, 0, &res); ret = of_address_to_resource(vptr->dev->of_node, 0, &res);
if (ret) { if (ret) {
......
...@@ -1383,7 +1383,7 @@ struct velocity_info { ...@@ -1383,7 +1383,7 @@ struct velocity_info {
struct device *dev; struct device *dev;
struct pci_dev *pdev; struct pci_dev *pdev;
struct net_device *netdev; struct net_device *netdev;
int no_eeprom; bool no_eeprom;
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
u8 ip_addr[4]; u8 ip_addr[4];
......
...@@ -1455,12 +1455,11 @@ static int temac_probe(struct platform_device *pdev) ...@@ -1455,12 +1455,11 @@ static int temac_probe(struct platform_device *pdev)
* endianness mode. Default for OF devices is big-endian. * endianness mode. Default for OF devices is big-endian.
*/ */
little_endian = false; little_endian = false;
if (temac_np) { if (temac_np)
if (of_get_property(temac_np, "little-endian", NULL)) little_endian = of_property_read_bool(temac_np, "little-endian");
little_endian = true; else if (pdata)
} else if (pdata) {
little_endian = pdata->reg_little_endian; little_endian = pdata->reg_little_endian;
}
if (little_endian) { if (little_endian) {
lp->temac_ior = _temac_ior_le; lp->temac_ior = _temac_ior_le;
lp->temac_iow = _temac_iow_le; lp->temac_iow = _temac_iow_le;
......
...@@ -1177,14 +1177,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev) ...@@ -1177,14 +1177,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
uhdlc_priv->dev = &pdev->dev; uhdlc_priv->dev = &pdev->dev;
uhdlc_priv->ut_info = ut_info; uhdlc_priv->ut_info = ut_info;
if (of_get_property(np, "fsl,tdm-interface", NULL)) uhdlc_priv->tsa = of_property_read_bool(np, "fsl,tdm-interface");
uhdlc_priv->tsa = 1; uhdlc_priv->loopback = of_property_read_bool(np, "fsl,ucc-internal-loopback");
uhdlc_priv->hdlc_bus = of_property_read_bool(np, "fsl,hdlc-bus");
if (of_get_property(np, "fsl,ucc-internal-loopback", NULL))
uhdlc_priv->loopback = 1;
if (of_get_property(np, "fsl,hdlc-bus", NULL))
uhdlc_priv->hdlc_bus = 1;
if (uhdlc_priv->tsa == 1) { if (uhdlc_priv->tsa == 1) {
utdm = kzalloc(sizeof(*utdm), GFP_KERNEL); utdm = kzalloc(sizeof(*utdm), GFP_KERNEL);
......
...@@ -447,8 +447,7 @@ static int wlcore_probe_of(struct spi_device *spi, struct wl12xx_spi_glue *glue, ...@@ -447,8 +447,7 @@ static int wlcore_probe_of(struct spi_device *spi, struct wl12xx_spi_glue *glue,
dev_info(&spi->dev, "selected chip family is %s\n", dev_info(&spi->dev, "selected chip family is %s\n",
pdev_data->family->name); pdev_data->family->name);
if (of_find_property(dt_node, "clock-xtal", NULL)) pdev_data->ref_clock_xtal = of_property_read_bool(dt_node, "clock-xtal");
pdev_data->ref_clock_xtal = true;
/* optional clock frequency params */ /* optional clock frequency params */
of_property_read_u32(dt_node, "ref-clock-frequency", of_property_read_u32(dt_node, "ref-clock-frequency",
......
...@@ -1803,8 +1803,8 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev, ...@@ -1803,8 +1803,8 @@ struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
pdev = to_platform_device(dev->dev.parent); pdev = to_platform_device(dev->dev.parent);
if (pdev) { if (pdev) {
np = pdev->dev.of_node; np = pdev->dev.of_node;
if (np && (of_get_property(np, "mellanox,multi-host", NULL) || if (np && (of_property_read_bool(np, "mellanox,multi-host") ||
of_get_property(np, "mlx,multi-host", NULL))) of_property_read_bool(np, "mlx,multi-host")))
ndp->mlx_multi_host = true; ndp->mlx_multi_host = true;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment