From patchwork Thu Nov 21 03:24:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 21659 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 18720205DF for ; Thu, 21 Nov 2013 03:24:23 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id md12sf7529507pbc.4 for ; Wed, 20 Nov 2013 19:24:23 -0800 (PST) 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=FSapnIjN4bopjuOZ4XfN1lJ39uSlSuLjGsrtksPMZ5Q=; b=FOUKtHwaP/jZe+IKcEGYkku7Plu7Ux9QWL3bsTAJAPvYudf5N7HUfdf+TebUePUgak XczI7MM5lDk5cFh2CQ9nKYf0tClgnVTOsKZnD3XsbZssnM0fWX3qjz33HmnRDY/tzhX+ fM+arqJJ/MmOUyidvz/fDJWddZwv+UzvWUXpkh+LYh+iBaL/rXYbwRBTT1sfLPw+jcXg CpXSxiKLZfrhFbGKJ6IMCVZDJPmoPV+21UScrvwWZqow7QvAAP2v13nI+tsHQrR3DQon OaaxZnFtb+HoW+Ws1cLIcoxZX8LEat39UfmsbH/TEzIhzu4E9V2sswGXBjaKBnEKZNyT o4ZA== X-Gm-Message-State: ALoCoQnhGRmQdtIA0prlK/hMmw/l24c/32I4w7uI1de8GpzjyJLsKgo1l32glVJv74k/r2rB8Zer X-Received: by 10.68.177.226 with SMTP id ct2mr1414483pbc.2.1385004262876; Wed, 20 Nov 2013 19:24:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.51.40 with SMTP id h8ls361727qeo.28.gmail; Wed, 20 Nov 2013 19:24:22 -0800 (PST) X-Received: by 10.221.47.193 with SMTP id ut1mr3628937vcb.8.1385004262718; Wed, 20 Nov 2013 19:24:22 -0800 (PST) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id a6si10259633vdp.91.2013.11.20.19.24.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Nov 2013 19:24:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id ij19so6419793vcb.17 for ; Wed, 20 Nov 2013 19:24:22 -0800 (PST) X-Received: by 10.58.216.74 with SMTP id oo10mr3633889vec.0.1385004262385; Wed, 20 Nov 2013 19:24:22 -0800 (PST) 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 u4csp398303vcz; Wed, 20 Nov 2013 19:24:21 -0800 (PST) X-Received: by 10.69.31.1 with SMTP id ki1mr4080375pbd.124.1385004261375; Wed, 20 Nov 2013 19:24:21 -0800 (PST) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by mx.google.com with ESMTPS id sn7si15746089pab.80.2013.11.20.19.24.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 Nov 2013 19:24:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.170 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.170; Received: by mail-pd0-f170.google.com with SMTP id g10so6225047pdj.29 for ; Wed, 20 Nov 2013 19:24:20 -0800 (PST) X-Received: by 10.66.217.166 with SMTP id oz6mr4115670pac.22.1385004260335; Wed, 20 Nov 2013 19:24:20 -0800 (PST) Received: from localhost ([122.167.133.207]) by mx.google.com with ESMTPSA id vh3sm8566738pbc.8.2013.11.20.19.24.17 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 20 Nov 2013 19:24:19 -0800 (PST) From: Viresh Kumar To: rjw@rjwysocki.net Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V2 Resend] cpuidle: free all state kobjects from cpuidle_free_state_kobj() Date: Thu, 21 Nov 2013 08:54:12 +0530 Message-Id: <8094ec60e0ad37d24ffbf146bc61515bd805c4fe.1385004181.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e 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.220.172 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. Acked-by: Daniel Lezcano Signed-off-by: Viresh Kumar --- 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