diff mbox

[PM-SR,3/7] omap3: sr: enable/disable sr only if required

Message ID 1277502400-9915-4-git-send-email-nm@ti.com (mailing list archive)
State New, archived
Delegated to: Kevin Hilman
Headers show

Commit Message

Nishanth Menon June 25, 2010, 9:46 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index d63691b..9b5a10e 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -778,15 +778,26 @@  static int omap_sr_autocomp_show(void *data, u64 *val)
 static int omap_sr_autocomp_store(void *data, u64 val)
 {
 	struct omap_sr *sr_info = (struct omap_sr *) data;
+	u32 value = (u32) val;
 
 	if (!sr_info) {
 		pr_warning("%s: omap_sr struct for SR not found\n", __func__);
 		return -EINVAL;
 	}
-	if (!val)
-		sr_stop_vddautocomp(sr_info);
-	else
-		sr_start_vddautocomp(sr_info);
+
+	/* Sanity check */
+	if (value && (value != 1)) {
+		pr_err("%s: invalid value %d\n", __func__, value);
+		return -EINVAL;
+	}
+
+	/* change only if needed */
+	if (sr_info->is_autocomp_active ^ value) {
+		if (!val)
+			sr_stop_vddautocomp(sr_info);
+		else
+			sr_start_vddautocomp(sr_info);
+	}
 	return 0;
 }