From patchwork Sun Sep 22 01:21:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20517 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f69.google.com (mail-qe0-f69.google.com [209.85.128.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 010EF25E85 for ; Sun, 22 Sep 2013 01:23:01 +0000 (UTC) Received: by mail-qe0-f69.google.com with SMTP id 1sf1930411qec.4 for ; Sat, 21 Sep 2013 18:23:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=XKz2GEsmtEFe3u6kaSWufKeCVo5BWIwSBSm+1o+1w3I=; b=lF9ShYLDE0081k/Xi3G4sMNyntNRLPRai72aPli7wNtaicgano9wHUKkRbhBm+rv3U khzCQwsYeyCeZlNxUZdMlzeMcuDm1zzTX3C9cFJ6JyOAg27daml3WCdnrpOcjQOm83Qs GkT5n/pzCkflzY8X2B03sTAD3CpnpB4Ry8vh24TA/SIvJKs4UDfr8lvY4UBViJNfWcg1 MVjh2giwm4FG7pEBJbpHEcoLyDEUTC+nZpaZu5OqrIMHBJ7bISwVV+aWqU6XCZ8f8B7t OyOwGOR1JH+Q21PUUspNNocIX+qNSjWn+usmjVv13INSheifvHHkkrQ3rjqdtsbOJblI UGWA== X-Gm-Message-State: ALoCoQkjBbZDNwHb51a9NCiZ/iB372Hs/GXHx/RgKfe8RkZLhfCkt9LyqxQAE6Caz6Uu1EIHEk3T X-Received: by 10.224.137.67 with SMTP id v3mr6642422qat.0.1379812981861; Sat, 21 Sep 2013 18:23:01 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.38.70 with SMTP id e6ls774833qek.77.gmail; Sat, 21 Sep 2013 18:23:01 -0700 (PDT) X-Received: by 10.58.77.65 with SMTP id q1mr14049722vew.8.1379812981772; Sat, 21 Sep 2013 18:23:01 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id ee8si4518652vdc.132.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:01 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jx11so1448924veb.35 for ; Sat, 21 Sep 2013 18:23:01 -0700 (PDT) X-Received: by 10.221.44.136 with SMTP id ug8mr14094863vcb.13.1379812981693; Sat, 21 Sep 2013 18:23:01 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp91751vcz; Sat, 21 Sep 2013 18:23:01 -0700 (PDT) X-Received: by 10.66.227.2 with SMTP id rw2mr77699pac.131.1379812980855; Sat, 21 Sep 2013 18:23:00 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id e5si15840099pba.147.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:00 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.220.50; Received: by mail-pa0-f50.google.com with SMTP id fb1so897747pad.9 for ; Sat, 21 Sep 2013 18:23:00 -0700 (PDT) X-Received: by 10.66.254.170 with SMTP id aj10mr73149pad.142.1379812980453; Sat, 21 Sep 2013 18:23:00 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id fa4sm28251099pab.17.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:22:59 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl, daniel.lezcano@linaro.org Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 15/21] cpuidle: free all state kobjects from cpuidle_free_state_kobj() Date: Sun, 22 Sep 2013 06:51:07 +0530 Message-Id: <503b7472308007b4c233b33d19f5a54c138212e7.1379779777.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Loop for states is currently present on callers side and so is replicated at several places. It would be better to move that inside cpuidle_free_state_kobj() instead. This patch does it. Signed-off-by: Viresh Kumar Acked-by: Daniel Lezcano --- drivers/cpuidle/sysfs.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index e918b6d..ade31a9 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -378,12 +378,17 @@ static struct kobj_type ktype_state_cpuidle = { .release = cpuidle_state_sysfs_release, }; -static inline void cpuidle_free_state_kobj(struct cpuidle_device *device, int i) +static inline void cpuidle_free_state_kobj(struct cpuidle_device *device, + int count) { - kobject_put(&device->kobjs[i]->kobj); - wait_for_completion(&device->kobjs[i]->kobj_unregister); - kfree(device->kobjs[i]); - device->kobjs[i] = NULL; + int i; + + for (i = 0; i < count; i++) { + kobject_put(&device->kobjs[i]->kobj); + wait_for_completion(&device->kobjs[i]->kobj_unregister); + kfree(device->kobjs[i]); + device->kobjs[i] = NULL; + } } /** @@ -419,8 +424,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device) return 0; error_state: - for (i = i - 1; i >= 0; i--) - cpuidle_free_state_kobj(device, i); + cpuidle_free_state_kobj(device, i); return ret; } @@ -430,10 +434,7 @@ error_state: */ static void cpuidle_remove_state_sysfs(struct cpuidle_device *device) { - int i; - - for (i = 0; i < device->state_count; i++) - cpuidle_free_state_kobj(device, i); + cpuidle_free_state_kobj(device, device->state_count); } #ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS