From patchwork Fri Jun 25 21:46:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nishanth Menon X-Patchwork-Id: 108152 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o5PLlFPW016773 for ; Fri, 25 Jun 2010 21:47:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932294Ab0FYVrK (ORCPT ); Fri, 25 Jun 2010 17:47:10 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:40634 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756580Ab0FYVqq (ORCPT ); Fri, 25 Jun 2010 17:46:46 -0400 Received: from dlep33.itg.ti.com ([157.170.170.112]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id o5PLkj7H020045 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 25 Jun 2010 16:46:45 -0500 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep33.itg.ti.com (8.13.7/8.13.7) with ESMTP id o5PLkgo3018172; Fri, 25 Jun 2010 16:46:42 -0500 (CDT) Received: from senorita (senorita.am.dhcp.ti.com [128.247.74.250]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id o5PLkgP15910; Fri, 25 Jun 2010 16:46:42 -0500 (CDT) Received: by senorita (Postfix, from userid 1000) id 8A6ECC259; Fri, 25 Jun 2010 16:46:41 -0500 (CDT) From: Nishanth Menon To: linux-omap Cc: Nishanth Menon , Kevin Hilman , Thara Gopinath Subject: [PM-SR] [PATCH 3/7] omap3: sr: enable/disable sr only if required Date: Fri, 25 Jun 2010 16:46:36 -0500 Message-Id: <1277502400-9915-4-git-send-email-nm@ti.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <1277502400-9915-1-git-send-email-nm@ti.com> References: <1277502400-9915-1-git-send-email-nm@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 25 Jun 2010 21:47:16 +0000 (UTC) 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; }