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

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Richard Leitner <richard.leitner@skidata.com>
Link: https://lore.kernel.org/r/20230310144729.1545857-1-robh@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Rob Herring 2023-03-10 08:47:28 -06:00 committed by Greg Kroah-Hartman
parent a3927e1a9f
commit f977caea50
6 changed files with 25 additions and 32 deletions

View file

@ -152,12 +152,12 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
* Check the various over current related properties. If over current
* detection is disabled we're not interested in the polarity.
*/
if (of_find_property(np, "disable-over-current", NULL)) {
if (of_property_read_bool(np, "disable-over-current")) {
data->disable_oc = 1;
} else if (of_find_property(np, "over-current-active-high", NULL)) {
} else if (of_property_read_bool(np, "over-current-active-high")) {
data->oc_pol_active_low = 0;
data->oc_pol_configured = 1;
} else if (of_find_property(np, "over-current-active-low", NULL)) {
} else if (of_property_read_bool(np, "over-current-active-low")) {
data->oc_pol_active_low = 1;
data->oc_pol_configured = 1;
} else {

View file

@ -753,7 +753,7 @@ static int ci_get_platdata(struct device *dev,
return ret;
}
if (of_find_property(dev->of_node, "non-zero-ttctrl-ttha", NULL))
if (of_property_read_bool(dev->of_node, "non-zero-ttctrl-ttha"))
platdata->flags |= CI_HDRC_SET_NON_ZERO_TTHA;
ext_id = ERR_PTR(-ENODEV);

View file

@ -508,8 +508,7 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg)
of_usb_update_otg_caps(hsotg->dev->of_node, &p->otg_caps);
}
if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL))
p->oc_disable = true;
p->oc_disable = of_property_read_bool(hsotg->dev->of_node, "disable-over-current");
}
static void dwc2_check_param_otg_cap(struct dwc2_hsotg *hsotg)

View file

@ -151,13 +151,13 @@ static int ehci_hcd_ppc_of_probe(struct platform_device *op)
of_node_put(np);
}
if (of_get_property(dn, "big-endian", NULL)) {
if (of_property_read_bool(dn, "big-endian")) {
ehci->big_endian_mmio = 1;
ehci->big_endian_desc = 1;
}
if (of_get_property(dn, "big-endian-regs", NULL))
if (of_property_read_bool(dn, "big-endian-regs"))
ehci->big_endian_mmio = 1;
if (of_get_property(dn, "big-endian-desc", NULL))
if (of_property_read_bool(dn, "big-endian-desc"))
ehci->big_endian_desc = 1;
ehci->caps = hcd->regs;

View file

@ -208,11 +208,8 @@ static int fsl_usb2_mph_dr_of_probe(struct platform_device *ofdev)
pdata->operating_mode = FSL_USB2_MPH_HOST;
} else {
if (of_get_property(np, "fsl,invert-drvvbus", NULL))
pdata->invert_drvvbus = 1;
if (of_get_property(np, "fsl,invert-pwr-fault", NULL))
pdata->invert_pwr_fault = 1;
pdata->invert_drvvbus = of_property_read_bool(np, "fsl,invert-drvvbus");
pdata->invert_pwr_fault = of_property_read_bool(np, "fsl,invert-pwr-fault");
/* setup mode selected in the device tree */
pdata->operating_mode = dev_data->op_mode;

View file

@ -410,10 +410,7 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
return -ENODEV;
}
if (of_get_property(np, "skip-config", NULL))
hub->skip_config = 1;
else
hub->skip_config = 0;
hub->skip_config = of_property_read_bool(np, "skip-config");
hub->gpio_reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (IS_ERR(hub->gpio_reset))
@ -431,40 +428,40 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
hub->device_id = USB251XB_DEF_DEVICE_ID;
hub->conf_data1 = USB251XB_DEF_CONFIG_DATA_1;
if (of_get_property(np, "self-powered", NULL)) {
if (of_property_read_bool(np, "self-powered")) {
hub->conf_data1 |= BIT(7);
/* Configure Over-Current sens when self-powered */
hub->conf_data1 &= ~BIT(2);
if (of_get_property(np, "ganged-sensing", NULL))
if (of_property_read_bool(np, "ganged-sensing"))
hub->conf_data1 &= ~BIT(1);
else if (of_get_property(np, "individual-sensing", NULL))
else if (of_property_read_bool(np, "individual-sensing"))
hub->conf_data1 |= BIT(1);
} else if (of_get_property(np, "bus-powered", NULL)) {
} else if (of_property_read_bool(np, "bus-powered")) {
hub->conf_data1 &= ~BIT(7);
/* Disable Over-Current sense when bus-powered */
hub->conf_data1 |= BIT(2);
}
if (of_get_property(np, "disable-hi-speed", NULL))
if (of_property_read_bool(np, "disable-hi-speed"))
hub->conf_data1 |= BIT(5);
if (of_get_property(np, "multi-tt", NULL))
if (of_property_read_bool(np, "multi-tt"))
hub->conf_data1 |= BIT(4);
else if (of_get_property(np, "single-tt", NULL))
else if (of_property_read_bool(np, "single-tt"))
hub->conf_data1 &= ~BIT(4);
if (of_get_property(np, "disable-eop", NULL))
if (of_property_read_bool(np, "disable-eop"))
hub->conf_data1 |= BIT(3);
if (of_get_property(np, "individual-port-switching", NULL))
if (of_property_read_bool(np, "individual-port-switching"))
hub->conf_data1 |= BIT(0);
else if (of_get_property(np, "ganged-port-switching", NULL))
else if (of_property_read_bool(np, "ganged-port-switching"))
hub->conf_data1 &= ~BIT(0);
hub->conf_data2 = USB251XB_DEF_CONFIG_DATA_2;
if (of_get_property(np, "dynamic-power-switching", NULL))
if (of_property_read_bool(np, "dynamic-power-switching"))
hub->conf_data2 |= BIT(7);
if (!of_property_read_u32(np, "oc-delay-us", &property_u32)) {
@ -487,17 +484,17 @@ static int usb251xb_get_ofdata(struct usb251xb *hub,
}
}
if (of_get_property(np, "compound-device", NULL))
if (of_property_read_bool(np, "compound-device"))
hub->conf_data2 |= BIT(3);
hub->conf_data3 = USB251XB_DEF_CONFIG_DATA_3;
if (of_get_property(np, "port-mapping-mode", NULL))
if (of_property_read_bool(np, "port-mapping-mode"))
hub->conf_data3 |= BIT(3);
if (data->led_support && of_get_property(np, "led-usb-mode", NULL))
hub->conf_data3 &= ~BIT(1);
if (of_get_property(np, "string-support", NULL))
if (of_property_read_bool(np, "string-support"))
hub->conf_data3 |= BIT(0);
hub->non_rem_dev = USB251XB_DEF_NON_REMOVABLE_DEVICES;