All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
@ 2017-10-22 13:40   ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-10-22 13:40 UTC (permalink / raw)
  To: linux-arm-kernel, linux-pm, linux-samsung-soc, Chanwoo Choi,
	Krzysztof Kozlowski, Kukjin Kim, MyungJoo Ham, Kyungmin Park
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Oct 2017 15:33:06 +0200

Adjust jump targets so that a bit of exception handling can be better
reused at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/devfreq/exynos-bus.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index 49f68929e024..e38d456b2d7d 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -124,34 +124,33 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)
 
 	if (old_freq < new_freq) {
 		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
-		if (ret < 0) {
-			dev_err(bus->dev, "failed to set voltage\n");
-			goto out;
-		}
+		if (ret < 0)
+			goto report_failure;
 	}
 
 	ret = clk_set_rate(bus->clk, new_freq);
 	if (ret < 0) {
 		dev_err(dev, "failed to change clock of bus\n");
 		clk_set_rate(bus->clk, old_freq);
-		goto out;
+		goto unlock;
 	}
 
 	if (old_freq > new_freq) {
 		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
-		if (ret < 0) {
-			dev_err(bus->dev, "failed to set voltage\n");
-			goto out;
-		}
+		if (ret < 0)
+			goto report_failure;
 	}
 	bus->curr_freq = new_freq;
 
 	dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n",
 			old_freq, new_freq, clk_get_rate(bus->clk));
-out:
+unlock:
 	mutex_unlock(&bus->lock);
-
 	return ret;
+
+report_failure:
+	dev_err(bus->dev, "failed to set voltage\n");
+	goto unlock;
 }
 
 static int exynos_bus_get_dev_status(struct device *dev,
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH] devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
@ 2017-10-22 13:40   ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-10-22 13:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Oct 2017 15:33:06 +0200

Adjust jump targets so that a bit of exception handling can be better
reused at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/devfreq/exynos-bus.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index 49f68929e024..e38d456b2d7d 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -124,34 +124,33 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)
 
 	if (old_freq < new_freq) {
 		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
-		if (ret < 0) {
-			dev_err(bus->dev, "failed to set voltage\n");
-			goto out;
-		}
+		if (ret < 0)
+			goto report_failure;
 	}
 
 	ret = clk_set_rate(bus->clk, new_freq);
 	if (ret < 0) {
 		dev_err(dev, "failed to change clock of bus\n");
 		clk_set_rate(bus->clk, old_freq);
-		goto out;
+		goto unlock;
 	}
 
 	if (old_freq > new_freq) {
 		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
-		if (ret < 0) {
-			dev_err(bus->dev, "failed to set voltage\n");
-			goto out;
-		}
+		if (ret < 0)
+			goto report_failure;
 	}
 	bus->curr_freq = new_freq;
 
 	dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n",
 			old_freq, new_freq, clk_get_rate(bus->clk));
-out:
+unlock:
 	mutex_unlock(&bus->lock);
-
 	return ret;
+
+report_failure:
+	dev_err(bus->dev, "failed to set voltage\n");
+	goto unlock;
 }
 
 static int exynos_bus_get_dev_status(struct device *dev,
-- 
2.14.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH] devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
@ 2017-10-22 13:40   ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-10-22 13:40 UTC (permalink / raw)
  To: linux-arm-kernel

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 22 Oct 2017 15:33:06 +0200

Adjust jump targets so that a bit of exception handling can be better
reused at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/devfreq/exynos-bus.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
index 49f68929e024..e38d456b2d7d 100644
--- a/drivers/devfreq/exynos-bus.c
+++ b/drivers/devfreq/exynos-bus.c
@@ -124,34 +124,33 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)
 
 	if (old_freq < new_freq) {
 		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
-		if (ret < 0) {
-			dev_err(bus->dev, "failed to set voltage\n");
-			goto out;
-		}
+		if (ret < 0)
+			goto report_failure;
 	}
 
 	ret = clk_set_rate(bus->clk, new_freq);
 	if (ret < 0) {
 		dev_err(dev, "failed to change clock of bus\n");
 		clk_set_rate(bus->clk, old_freq);
-		goto out;
+		goto unlock;
 	}
 
 	if (old_freq > new_freq) {
 		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
-		if (ret < 0) {
-			dev_err(bus->dev, "failed to set voltage\n");
-			goto out;
-		}
+		if (ret < 0)
+			goto report_failure;
 	}
 	bus->curr_freq = new_freq;
 
 	dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n",
 			old_freq, new_freq, clk_get_rate(bus->clk));
-out:
+unlock:
 	mutex_unlock(&bus->lock);
-
 	return ret;
+
+report_failure:
+	dev_err(bus->dev, "failed to set voltage\n");
+	goto unlock;
 }
 
 static int exynos_bus_get_dev_status(struct device *dev,
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
  2017-10-22 13:40   ` SF Markus Elfring
  (?)
@ 2017-10-23  1:17     ` Chanwoo Choi
  -1 siblings, 0 replies; 9+ messages in thread
From: Chanwoo Choi @ 2017-10-23  1:17 UTC (permalink / raw)
  To: SF Markus Elfring, linux-arm-kernel, linux-pm, linux-samsung-soc,
	Krzysztof Kozlowski, Kukjin Kim, MyungJoo Ham, Kyungmin Park
  Cc: LKML, kernel-janitors

Hi Markus,

As I already commented on your other patch related to extcon-max14577,
this patch might remove the redundant error message. But, it makes
the code more complicated in side of readability. I prefer existing code.

On 2017년 10월 22일 22:40, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 22 Oct 2017 15:33:06 +0200
> 
> Adjust jump targets so that a bit of exception handling can be better
> reused at the end of this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/devfreq/exynos-bus.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> index 49f68929e024..e38d456b2d7d 100644
> --- a/drivers/devfreq/exynos-bus.c
> +++ b/drivers/devfreq/exynos-bus.c
> @@ -124,34 +124,33 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)
>  
>  	if (old_freq < new_freq) {
>  		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
> -		if (ret < 0) {
> -			dev_err(bus->dev, "failed to set voltage\n");
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto report_failure;
>  	}
>  
>  	ret = clk_set_rate(bus->clk, new_freq);
>  	if (ret < 0) {
>  		dev_err(dev, "failed to change clock of bus\n");
>  		clk_set_rate(bus->clk, old_freq);
> -		goto out;
> +		goto unlock;
>  	}
>  
>  	if (old_freq > new_freq) {
>  		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
> -		if (ret < 0) {
> -			dev_err(bus->dev, "failed to set voltage\n");
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto report_failure;
>  	}
>  	bus->curr_freq = new_freq;
>  
>  	dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n",
>  			old_freq, new_freq, clk_get_rate(bus->clk));
> -out:
> +unlock:
>  	mutex_unlock(&bus->lock);
> -
>  	return ret;
> +
> +report_failure:
> +	dev_err(bus->dev, "failed to set voltage\n");
> +	goto unlock;
>  }
>  
>  static int exynos_bus_get_dev_status(struct device *dev,
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
@ 2017-10-23  1:17     ` Chanwoo Choi
  0 siblings, 0 replies; 9+ messages in thread
From: Chanwoo Choi @ 2017-10-23  1:17 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Markus,

As I already commented on your other patch related to extcon-max14577,
this patch might remove the redundant error message. But, it makes
the code more complicated in side of readability. I prefer existing code.

On 2017년 10월 22일 22:40, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 22 Oct 2017 15:33:06 +0200
> 
> Adjust jump targets so that a bit of exception handling can be better
> reused at the end of this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/devfreq/exynos-bus.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> index 49f68929e024..e38d456b2d7d 100644
> --- a/drivers/devfreq/exynos-bus.c
> +++ b/drivers/devfreq/exynos-bus.c
> @@ -124,34 +124,33 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)
>  
>  	if (old_freq < new_freq) {
>  		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
> -		if (ret < 0) {
> -			dev_err(bus->dev, "failed to set voltage\n");
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto report_failure;
>  	}
>  
>  	ret = clk_set_rate(bus->clk, new_freq);
>  	if (ret < 0) {
>  		dev_err(dev, "failed to change clock of bus\n");
>  		clk_set_rate(bus->clk, old_freq);
> -		goto out;
> +		goto unlock;
>  	}
>  
>  	if (old_freq > new_freq) {
>  		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
> -		if (ret < 0) {
> -			dev_err(bus->dev, "failed to set voltage\n");
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto report_failure;
>  	}
>  	bus->curr_freq = new_freq;
>  
>  	dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n",
>  			old_freq, new_freq, clk_get_rate(bus->clk));
> -out:
> +unlock:
>  	mutex_unlock(&bus->lock);
> -
>  	return ret;
> +
> +report_failure:
> +	dev_err(bus->dev, "failed to set voltage\n");
> +	goto unlock;
>  }
>  
>  static int exynos_bus_get_dev_status(struct device *dev,
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH] devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
@ 2017-10-23  1:17     ` Chanwoo Choi
  0 siblings, 0 replies; 9+ messages in thread
From: Chanwoo Choi @ 2017-10-23  1:17 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Markus,

As I already commented on your other patch related to extcon-max14577,
this patch might remove the redundant error message. But, it makes
the code more complicated in side of readability. I prefer existing code.

On 2017? 10? 22? 22:40, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 22 Oct 2017 15:33:06 +0200
> 
> Adjust jump targets so that a bit of exception handling can be better
> reused at the end of this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/devfreq/exynos-bus.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/devfreq/exynos-bus.c b/drivers/devfreq/exynos-bus.c
> index 49f68929e024..e38d456b2d7d 100644
> --- a/drivers/devfreq/exynos-bus.c
> +++ b/drivers/devfreq/exynos-bus.c
> @@ -124,34 +124,33 @@ static int exynos_bus_target(struct device *dev, unsigned long *freq, u32 flags)
>  
>  	if (old_freq < new_freq) {
>  		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
> -		if (ret < 0) {
> -			dev_err(bus->dev, "failed to set voltage\n");
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto report_failure;
>  	}
>  
>  	ret = clk_set_rate(bus->clk, new_freq);
>  	if (ret < 0) {
>  		dev_err(dev, "failed to change clock of bus\n");
>  		clk_set_rate(bus->clk, old_freq);
> -		goto out;
> +		goto unlock;
>  	}
>  
>  	if (old_freq > new_freq) {
>  		ret = regulator_set_voltage_tol(bus->regulator, new_volt, tol);
> -		if (ret < 0) {
> -			dev_err(bus->dev, "failed to set voltage\n");
> -			goto out;
> -		}
> +		if (ret < 0)
> +			goto report_failure;
>  	}
>  	bus->curr_freq = new_freq;
>  
>  	dev_dbg(dev, "Set the frequency of bus (%luHz -> %luHz, %luHz)\n",
>  			old_freq, new_freq, clk_get_rate(bus->clk));
> -out:
> +unlock:
>  	mutex_unlock(&bus->lock);
> -
>  	return ret;
> +
> +report_failure:
> +	dev_err(bus->dev, "failed to set voltage\n");
> +	goto unlock;
>  }
>  
>  static int exynos_bus_get_dev_status(struct device *dev,
> 


-- 
Best Regards,
Chanwoo Choi
Samsung Electronics

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
  2017-10-23  1:17     ` Chanwoo Choi
  (?)
@ 2017-10-23  5:53       ` SF Markus Elfring
  -1 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-10-23  5:53 UTC (permalink / raw)
  To: Chanwoo Choi, linux-arm-kernel, linux-pm, linux-samsung-soc
  Cc: Krzysztof Kozlowski, Kukjin Kim, MyungJoo Ham, Kyungmin Park,
	LKML, kernel-janitors

> As I already commented on your other patch related to extcon-max14577,
> this patch might remove the redundant error message.

I hope that more software improvements can be achieved in this design direction.


> But, it makes the code more complicated in side of readability. I prefer existing code.

I prefer to avoid duplicated code a bit more.

Regards,
Markus

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
@ 2017-10-23  5:53       ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-10-23  5:53 UTC (permalink / raw)
  To: linux-arm-kernel

> As I already commented on your other patch related to extcon-max14577,
> this patch might remove the redundant error message.

I hope that more software improvements can be achieved in this design direction.


> But, it makes the code more complicated in side of readability. I prefer existing code.

I prefer to avoid duplicated code a bit more.

Regards,
Markus

^ permalink raw reply	[flat|nested] 9+ messages in thread

* devfreq/exynos-bus: Use common error handling code in exynos_bus_target()
@ 2017-10-23  5:53       ` SF Markus Elfring
  0 siblings, 0 replies; 9+ messages in thread
From: SF Markus Elfring @ 2017-10-23  5:53 UTC (permalink / raw)
  To: linux-arm-kernel

> As I already commented on your other patch related to extcon-max14577,
> this patch might remove the redundant error message.

I hope that more software improvements can be achieved in this design direction.


> But, it makes the code more complicated in side of readability. I prefer existing code.

I prefer to avoid duplicated code a bit more.

Regards,
Markus

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-10-23  5:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20171022134057epcas4p43e6f37b8994c28f6ef240536349811a8@epcas4p4.samsung.com>
2017-10-22 13:40 ` [PATCH] devfreq/exynos-bus: Use common error handling code in exynos_bus_target() SF Markus Elfring
2017-10-22 13:40   ` SF Markus Elfring
2017-10-22 13:40   ` SF Markus Elfring
2017-10-23  1:17   ` Chanwoo Choi
2017-10-23  1:17     ` Chanwoo Choi
2017-10-23  1:17     ` Chanwoo Choi
2017-10-23  5:53     ` SF Markus Elfring
2017-10-23  5:53       ` SF Markus Elfring
2017-10-23  5:53       ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.