From: Phil Carmody <[email protected]>

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 <[email protected]>
---
 arch/arm/mach-omap2/smartreflex.c |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

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

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to