Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1271078

[PATCH] usb: chipidea: removing of_find_property

From Saurabh Sengar <saurabh.truth@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] usb: chipidea: removing of_find_property
Date 2015-11-17 12:10 +0100
Message-ID <qvMj7-4ds-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


call to of_find_property() before of_property_read_u32() is unnecessary.
of_property_read_u32() anyway calls to of_find_property() only.

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
---
 drivers/usb/chipidea/core.c | 67 ++++++++++++++++++++++-----------------------
 1 file changed, 32 insertions(+), 35 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 965d0e2..8a4c22c 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -643,6 +643,7 @@ static int ci_get_platdata(struct device *dev,
 	struct extcon_dev *ext_vbus, *ext_id;
 	struct ci_hdrc_cable *cable;
 	int ret;
+	u32 pval;
 
 	if (!platdata->phy_mode)
 		platdata->phy_mode = of_usb_get_phy_mode(dev->of_node);
@@ -688,52 +689,48 @@ static int ci_get_platdata(struct device *dev,
 	if (usb_get_maximum_speed(dev) == USB_SPEED_FULL)
 		platdata->flags |= CI_HDRC_FORCE_FULLSPEED;
 
-	if (of_find_property(dev->of_node, "phy-clkgate-delay-us", NULL))
-		of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
-				     &platdata->phy_clkgate_delay_us);
+	if (!of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
+				     &pval))
+		platdata->phy_clkgate_delay_us = pval;
 
 	platdata->itc_setting = 1;
-	if (of_find_property(dev->of_node, "itc-setting", NULL)) {
-		ret = of_property_read_u32(dev->of_node, "itc-setting",
-			&platdata->itc_setting);
-		if (ret) {
-			dev_err(dev,
-				"failed to get itc-setting\n");
-			return ret;
-		}
+
+	ret = of_property_read_u32(dev->of_node, "itc-setting", &pval);
+	if (!ret)
+		platdata->itc_setting = pval;
+	else if (ret != -EINVAL) {
+		dev_err(dev, "failed to get itc-setting\n");
+		return ret;
 	}
 
-	if (of_find_property(dev->of_node, "ahb-burst-config", NULL)) {
-		ret = of_property_read_u32(dev->of_node, "ahb-burst-config",
-			&platdata->ahb_burst_config);
-		if (ret) {
-			dev_err(dev,
-				"failed to get ahb-burst-config\n");
-			return ret;
-		}
+	ret = of_property_read_u32(dev->of_node, "ahb-burst-config",
+				&pval);
+	if (!ret) {
+		platdata->ahb_burst_config = pval;
 		platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST;
+	} else if (ret != -EINVAL) {
+		dev_err(dev, "failed to get ahb-burst-config\n");
+		return ret;
 	}
 
-	if (of_find_property(dev->of_node, "tx-burst-size-dword", NULL)) {
-		ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword",
-			&platdata->tx_burst_size);
-		if (ret) {
-			dev_err(dev,
-				"failed to get tx-burst-size-dword\n");
-			return ret;
-		}
+	ret = of_property_read_u32(dev->of_node, "tx-burst-size-dword",
+				&pval);
+	if (!ret) {
+		platdata->tx_burst_size = pval;
 		platdata->flags |= CI_HDRC_OVERRIDE_TX_BURST;
+	} else if (ret != -EINVAL) {
+		dev_err(dev, "failed to get tx-burst-size-dword\n");
+		return ret;
 	}
 
-	if (of_find_property(dev->of_node, "rx-burst-size-dword", NULL)) {
-		ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword",
-			&platdata->rx_burst_size);
-		if (ret) {
-			dev_err(dev,
-				"failed to get rx-burst-size-dword\n");
-			return ret;
-		}
+	ret = of_property_read_u32(dev->of_node, "rx-burst-size-dword",
+				&pval);
+	if (!ret) {
+		platdata->rx_burst_size = pval;
 		platdata->flags |= CI_HDRC_OVERRIDE_RX_BURST;
+	} else if (ret != -EINVAL) {
+		dev_err(dev, "failed to get rx-burst-size-dword\n");
+		return ret;
 	}
 
 	ext_id = ERR_PTR(-ENODEV);
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] usb: chipidea: removing of_find_property Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-17 12:10 +0100
  Re: [PATCH] usb: chipidea: removing of_find_property Måns Rullgård <mans@mansr.com> - 2015-11-17 12:30 +0100
    [PATCH v2] usb: chipidea: removing of_find_property Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-17 12:50 +0100
      Re: [PATCH v2] usb: chipidea: removing of_find_property Måns Rullgård <mans@mansr.com> - 2015-11-17 12:50 +0100
        [PATCH v3] usb: chipidea: removing of_find_property Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-17 13:00 +0100
          Re: [PATCH v3] usb: chipidea: removing of_find_property Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-18 05:10 +0100
            [PATCH v4] usb: chipidea: removing of_find_property Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-18 05:20 +0100
              Re: [PATCH v4] usb: chipidea: removing of_find_property Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-18 07:20 +0100
                Re: [PATCH v4] usb: chipidea: removing of_find_property Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-18 08:50 +0100

csiph-web