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


Groups > linux.kernel > #1271078 > unrolled thread

[PATCH] usb: chipidea: removing of_find_property

Started bySaurabh Sengar <saurabh.truth@gmail.com>
First post2015-11-17 12:10 +0100
Last post2015-11-18 08:50 +0100
Articles 9 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [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

#1271078 — [PATCH] usb: chipidea: removing of_find_property

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-11-17 12:10 +0100
Subject[PATCH] usb: chipidea: removing of_find_property
Message-ID<qvMj7-4ds-7@gated-at.bofh.it>
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/

[toc] | [next] | [standalone]


#1271093

FromMåns Rullgård <mans@mansr.com>
Date2015-11-17 12:30 +0100
Message-ID<qvMCu-4n1-17@gated-at.bofh.it>
In reply to#1271078
Saurabh Sengar <saurabh.truth@gmail.com> writes:

> 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;

You don't need to use the pval temporary as of_property_read_u32 only
modifies the destination on success.

-- 
Måns Rullgård
mans@mansr.com
--
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/

[toc] | [prev] | [next] | [standalone]


#1271101 — [PATCH v2] usb: chipidea: removing of_find_property

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-11-17 12:50 +0100
Subject[PATCH v2] usb: chipidea: removing of_find_property
Message-ID<qvMVQ-4uY-1@gated-at.bofh.it>
In reply to#1271093
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>
---
v2: removed pval variable
 drivers/usb/chipidea/core.c | 61 +++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 35 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 965d0e2..916a20d 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -688,52 +688,43 @@ 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",
+				     &platdata->phy_clkgate_delay_us))
 
 	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",
+					&platdata->itc_setting);
+	if (ret && 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",
+				&platdata->ahb_burst_config);
+	if (!ret) {
 		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",
+				&platdata->tx_burst_size);
+	if (!ret) {
 		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",
+				&platdata->rx_burst_size);
+	if (!ret) {
 		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/

[toc] | [prev] | [next] | [standalone]


#1271111 — Re: [PATCH v2] usb: chipidea: removing of_find_property

FromMåns Rullgård <mans@mansr.com>
Date2015-11-17 12:50 +0100
SubjectRe: [PATCH v2] usb: chipidea: removing of_find_property
Message-ID<qvMVR-4uY-35@gated-at.bofh.it>
In reply to#1271101
Saurabh Sengar <saurabh.truth@gmail.com> writes:

> 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>
> ---
> v2: removed pval variable
>  drivers/usb/chipidea/core.c | 61 +++++++++++++++++++--------------------------
>  1 file changed, 26 insertions(+), 35 deletions(-)
>
> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> index 965d0e2..916a20d 100644
> --- a/drivers/usb/chipidea/core.c
> +++ b/drivers/usb/chipidea/core.c
> @@ -688,52 +688,43 @@ 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",
> +				     &platdata->phy_clkgate_delay_us))
>
>  	platdata->itc_setting = 1;

Drop that if().  Since we're ignoring of_property_read_u32() failing,
there is no need to test its return value, and code above incorrectly
makes the next statement conditional.

-- 
Måns Rullgård
mans@mansr.com
--
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/

[toc] | [prev] | [next] | [standalone]


#1271115 — [PATCH v3] usb: chipidea: removing of_find_property

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-11-17 13:00 +0100
Subject[PATCH v3] usb: chipidea: removing of_find_property
Message-ID<qvN5w-4yq-5@gated-at.bofh.it>
In reply to#1271111
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>
---
v2 : removed pval variable
v3 : removed unnecessary if condition
 drivers/usb/chipidea/core.c | 59 +++++++++++++++++++--------------------------
 1 file changed, 25 insertions(+), 34 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 965d0e2..960a925 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -688,52 +688,43 @@ 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",
+	of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
 				     &platdata->phy_clkgate_delay_us);
 
 	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",
+					&platdata->itc_setting);
+	if (ret && 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",
+				&platdata->ahb_burst_config);
+	if (!ret) {
 		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",
+				&platdata->tx_burst_size);
+	if (!ret) {
 		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",
+				&platdata->rx_burst_size);
+	if (!ret) {
 		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/

[toc] | [prev] | [next] | [standalone]


#1271836 — Re: [PATCH v3] usb: chipidea: removing of_find_property

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-11-18 05:10 +0100
SubjectRe: [PATCH v3] usb: chipidea: removing of_find_property
Message-ID<qw2ed-68Q-1@gated-at.bofh.it>
In reply to#1271115
Hi Peter,

Yes itc_setting is still optional, in case dts does not pass this
property, return type will be -EINVAL and there would be no problem.
The function will break only if there is 'No data'(-ENODATA) or
'overflow'(-ENODATA) error for this property.
In case this is not OK, I will send a another patch(v4) as you have suggested.

Regards,
Saurabh

On 18 November 2015 at 09:08, Peter Chen <peter.chen@freescale.com> wrote:
> On Tue, Nov 17, 2015 at 05:22:26PM +0530, Saurabh Sengar wrote:
>> 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>
>> ---
>> v2 : removed pval variable
>> v3 : removed unnecessary if condition
>>  drivers/usb/chipidea/core.c | 59 +++++++++++++++++++--------------------------
>>  1 file changed, 25 insertions(+), 34 deletions(-)
>>
>> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>> index 965d0e2..960a925 100644
>> --- a/drivers/usb/chipidea/core.c
>> +++ b/drivers/usb/chipidea/core.c
>> @@ -688,52 +688,43 @@ 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",
>> +     of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
>>                                    &platdata->phy_clkgate_delay_us);
>>
>>       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",
>> +                                     &platdata->itc_setting);
>> +     if (ret && ret != -EINVAL) {
>> +             dev_err(dev, "failed to get itc-setting\n");
>> +             return ret;
>>       }
>
> For this one, you may not need to check return value, since
> platdata->itc_setting is optional, and doesn't need to set
> any flags if platdata->itc_setting is valid.
>
> Other changes are ok for me.
>
> Peter
>
>>
>> -     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",
>> +                             &platdata->ahb_burst_config);
>> +     if (!ret) {
>>               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",
>> +                             &platdata->tx_burst_size);
>> +     if (!ret) {
>>               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",
>> +                             &platdata->rx_burst_size);
>> +     if (!ret) {
>>               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
>>
>
> --
>
> Best Regards,
> Peter Chen
--
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/

[toc] | [prev] | [next] | [standalone]


#1271839 — [PATCH v4] usb: chipidea: removing of_find_property

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-11-18 05:20 +0100
Subject[PATCH v4] usb: chipidea: removing of_find_property
Message-ID<qw2nU-6d6-15@gated-at.bofh.it>
In reply to#1271836
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>
---
v4 : removed return type check for optional property 'itc-setting'

 drivers/usb/chipidea/core.c | 57 +++++++++++++++++----------------------------
 1 file changed, 22 insertions(+), 35 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 965d0e2..3d1c3c5 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -688,52 +688,39 @@ 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",
+	of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
 				     &platdata->phy_clkgate_delay_us);
 
 	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;
-		}
-	}
 
-	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;
-		}
+	of_property_read_u32(dev->of_node, "itc-setting",
+					&platdata->itc_setting);
+
+	ret = of_property_read_u32(dev->of_node, "ahb-burst-config",
+				&platdata->ahb_burst_config);
+	if (!ret) {
 		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",
+				&platdata->tx_burst_size);
+	if (!ret) {
 		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",
+				&platdata->rx_burst_size);
+	if (!ret) {
 		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/

[toc] | [prev] | [next] | [standalone]


#1271859 — Re: [PATCH v4] usb: chipidea: removing of_find_property

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-11-18 07:20 +0100
SubjectRe: [PATCH v4] usb: chipidea: removing of_find_property
Message-ID<qw4g1-7vR-7@gated-at.bofh.it>
In reply to#1271839
On 18 November 2015 at 11:35, Peter Chen <peter.chen@freescale.com> wrote:
> On Wed, Nov 18, 2015 at 09:40:12AM +0530, Saurabh Sengar wrote:
>> 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>
>> ---
>> v4 : removed return type check for optional property 'itc-setting'
>>
>>  drivers/usb/chipidea/core.c | 57 +++++++++++++++++----------------------------
>>  1 file changed, 22 insertions(+), 35 deletions(-)
>>
>> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
>> index 965d0e2..3d1c3c5 100644
>> --- a/drivers/usb/chipidea/core.c
>> +++ b/drivers/usb/chipidea/core.c
>> @@ -688,52 +688,39 @@ 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",
>> +     of_property_read_u32(dev->of_node, "phy-clkgate-delay-us",
>>                                    &platdata->phy_clkgate_delay_us);
>>
>>       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;
>> -             }
>> -     }
>>
>> -     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;
>> -             }
>> +     of_property_read_u32(dev->of_node, "itc-setting",
>> +                                     &platdata->itc_setting);
>> +
>> +     ret = of_property_read_u32(dev->of_node, "ahb-burst-config",
>> +                             &platdata->ahb_burst_config);
>> +     if (!ret) {
>>               platdata->flags |= CI_HDRC_OVERRIDE_AHB_BURST;
>> +     } else if (ret != -EINVAL) {
>> +             dev_err(dev, "failed to get ahb-burst-config\n");
>> +             return ret;
>>       }

>Sorry, one more comment, why we don't quit if the 'ret' is other error
>value?
>
> Peter

We quit if error is anything other then -EINVAL.
In case of -EINVAL, it means we are deliberating ignoring that
property thus left it.
Also the previous functionality was like this when we were using
of_find_property().
Please let me know if this need to be changed, that we need to return
in all kind of error, I will fix it and send it in patch v5.


Regards,
Saurabh
--
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/

[toc] | [prev] | [next] | [standalone]


#1271897 — Re: [PATCH v4] usb: chipidea: removing of_find_property

FromSaurabh Sengar <saurabh.truth@gmail.com>
Date2015-11-18 08:50 +0100
SubjectRe: [PATCH v4] usb: chipidea: removing of_find_property
Message-ID<qw5F7-8kF-3@gated-at.bofh.it>
In reply to#1271859
On 18 November 2015 at 12:54, Peter Chen <peter.chen@freescale.com> wrote:
> I am clear now, I will queue it.


Thank you
--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web