diff mbox

[1/2] OMAP3: PM: Don't do unnecessary searches in omap_sr_vdd*_autocomp_store

Message ID 9ba9fdeeec0cd47fdcff6b689d2196665ea8bcbf.1240849197.git.ext-phil.2.carmody@nokia.com (mailing list archive)
State Accepted
Delegated to: Kevin Hilman
Headers show

Commit Message

Phil Carmody April 27, 2009, 4:26 p.m. UTC
From: Phil Carmody <ext-phil.2.carmody@nokia.com>

When setting to 0, we don't need to do searches for the resource by
its name. In the case where we do search, handle the error condition
cleanly.

Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
---
 arch/arm/mach-omap2/smartreflex.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index ae5c336..ce7d436 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -744,7 +744,6 @@  static ssize_t omap_sr_vdd1_autocomp_store(struct kobject *kobj,
 					struct kobj_attribute *attr,
 					const char *buf, size_t n)
 {
-	u32 current_vdd1opp_no;
 	unsigned short value;
 
 	if (sscanf(buf, "%hu", &value) != 1 || (value > 1)) {
@@ -752,13 +751,14 @@  static ssize_t omap_sr_vdd1_autocomp_store(struct kobject *kobj,
 		return -EINVAL;
 	}
 
-	current_vdd1opp_no = omap_pm_vdd1_get_opp();
-
-	if (value == 0)
+	if (value == 0) {
 		sr_stop_vddautocomap(SR1);
-	else
+	} else {
+		u32 current_vdd1opp_no = omap_pm_vdd1_get_opp();
+		if (IS_ERR_VALUE(current_vdd1opp_no))
+			return -ENODEV;
 		sr_start_vddautocomap(SR1, current_vdd1opp_no);
-
+	}
 	return n;
 }
 
@@ -782,7 +782,6 @@  static ssize_t omap_sr_vdd2_autocomp_store(struct kobject *kobj,
 					struct kobj_attribute *attr,
 					const char *buf, size_t n)
 {
-	u32 current_vdd2opp_no;
 	unsigned short value;
 
 	if (sscanf(buf, "%hu", &value) != 1 || (value > 1)) {
@@ -790,13 +789,14 @@  static ssize_t omap_sr_vdd2_autocomp_store(struct kobject *kobj,
 		return -EINVAL;
 	}
 
-	current_vdd2opp_no = omap_pm_vdd2_get_opp();
-
-	if (value == 0)
+	if (value == 0) {
 		sr_stop_vddautocomap(SR2);
-	else
+	} else {
+		u32 current_vdd2opp_no = omap_pm_vdd2_get_opp();
+		if (IS_ERR_VALUE(current_vdd2opp_no))
+			return -ENODEV;
 		sr_start_vddautocomap(SR2, current_vdd2opp_no);
-
+	}
 	return n;
 }