From patchwork Thu Feb 11 21:50:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 78828 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1BLpJNC012540 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 11 Feb 2010 21:51:58 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nfgv7-0007zB-OF; Thu, 11 Feb 2010 21:49:57 +0000 Received: from sfi-mx-1.v28.ch3.sourceforge.com ([172.29.28.121] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1Nfgv6-0007z6-EO for dri-devel@lists.sourceforge.net; Thu, 11 Feb 2010 21:49:56 +0000 Received-SPF: pass (sfi-mx-1.v28.ch3.sourceforge.com: domain of gmail.com designates 209.85.219.215 as permitted sender) client-ip=209.85.219.215; envelope-from=zajec5@gmail.com; helo=mail-ew0-f215.google.com; Received: from mail-ew0-f215.google.com ([209.85.219.215]) by sfi-mx-1.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1Nfgv5-0001oy-GZ for dri-devel@lists.sourceforge.net; Thu, 11 Feb 2010 21:49:56 +0000 Received: by ewy7 with SMTP id 7so1598367ewy.6 for ; Thu, 11 Feb 2010 13:49:48 -0800 (PST) Received: by 10.213.111.18 with SMTP id q18mr1158446ebp.39.1265924987293; Thu, 11 Feb 2010 13:49:47 -0800 (PST) Received: from localhost.localdomain (c3-107.icpnet.pl [62.21.3.107]) by mx.google.com with ESMTPS id 28sm6691348eye.47.2010.02.11.13.49.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 11 Feb 2010 13:49:46 -0800 (PST) From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= To: dri-devel@lists.sourceforge.net, Dave Airlie Subject: [PATCH] drm/radeon/kms: simplify picking power state Date: Thu, 11 Feb 2010 22:50:06 +0100 Message-Id: <1265925006-3745-2-git-send-email-zajec5@gmail.com> X-Mailer: git-send-email 1.6.4.2 X-Spam-Score: -0.7 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 DKIM_VERIFIED Domain Keys Identified Mail: signature passes verification 0.0 DKIM_SIGNED Domain Keys Identified Mail: message has a signature 0.8 AWL AWL: From: address is in the auto white-list X-Headers-End: 1Nfgv5-0001oy-GZ X-BeenThere: dri-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 11 Feb 2010 21:52:00 +0000 (UTC) diff --git a/drivers/gpu/drm/radeon/radeon_pm.c b/drivers/gpu/drm/radeon/radeon_pm.c index a8e151e..f023435 100644 --- a/drivers/gpu/drm/radeon/radeon_pm.c +++ b/drivers/gpu/drm/radeon/radeon_pm.c @@ -81,60 +81,39 @@ static void radeon_print_power_mode_info(struct radeon_device *rdev) static struct radeon_power_state * radeon_pick_power_state(struct radeon_device *rdev, enum radeon_pm_state_type type) { - int i; - struct radeon_power_state *power_state = NULL; + int i, j; + enum radeon_pm_state_type wanted_types[2]; + int wanted_count; switch (type) { case POWER_STATE_TYPE_DEFAULT: default: return rdev->pm.default_power_state; case POWER_STATE_TYPE_POWERSAVE: - for (i = 0; i < rdev->pm.num_power_states; i++) { - if (rdev->pm.power_state[i].type == POWER_STATE_TYPE_POWERSAVE) { - power_state = &rdev->pm.power_state[i]; - break; - } - } - if (power_state == NULL) { - for (i = 0; i < rdev->pm.num_power_states; i++) { - if (rdev->pm.power_state[i].type == POWER_STATE_TYPE_BATTERY) { - power_state = &rdev->pm.power_state[i]; - break; - } - } - } + wanted_types[0] = POWER_STATE_TYPE_POWERSAVE; + wanted_types[1] = POWER_STATE_TYPE_BATTERY; + wanted_count = 2; break; case POWER_STATE_TYPE_BATTERY: - for (i = 0; i < rdev->pm.num_power_states; i++) { - if (rdev->pm.power_state[i].type == POWER_STATE_TYPE_BATTERY) { - power_state = &rdev->pm.power_state[i]; - break; - } - } - if (power_state == NULL) { - for (i = 0; i < rdev->pm.num_power_states; i++) { - if (rdev->pm.power_state[i].type == POWER_STATE_TYPE_POWERSAVE) { - power_state = &rdev->pm.power_state[i]; - break; - } - } - } + wanted_types[0] = POWER_STATE_TYPE_BATTERY; + wanted_types[1] = POWER_STATE_TYPE_POWERSAVE; + wanted_count = 2; break; case POWER_STATE_TYPE_BALANCED: case POWER_STATE_TYPE_PERFORMANCE: - for (i = 0; i < rdev->pm.num_power_states; i++) { - if (rdev->pm.power_state[i].type == type) { - power_state = &rdev->pm.power_state[i]; - break; - } - } + wanted_types[0] = type; + wanted_count = 1; break; } - if (power_state == NULL) - return rdev->pm.default_power_state; + for (i = 0; i < wanted_count; i++) { + for (j = 0; j < rdev->pm.num_power_states; j++) { + if (rdev->pm.power_state[j].type == wanted_types[i]) + return &rdev->pm.power_state[j]; + } + } - return power_state; + return rdev->pm.default_power_state; } static struct radeon_pm_clock_info * radeon_pick_clock_mode(struct radeon_device *rdev,