From patchwork Thu Oct 3 15:56:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20802 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f199.google.com (mail-ye0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 80D6925CAB for ; Thu, 3 Oct 2013 15:58:30 +0000 (UTC) Received: by mail-ye0-f199.google.com with SMTP id l4sf4107302yen.10 for ; Thu, 03 Oct 2013 08:58:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state: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=FSapnIjN4bopjuOZ4XfN1lJ39uSlSuLjGsrtksPMZ5Q=; b=YKB5sQLHp54O8S3lRsin91mc9zDKUqaqa5L4MJZaq4uhKqXMJt7QyUJ+0RVyed0Cam g9z6mrK1zxIOGQMtBNeRQlCjMmJRGUjWnS/jGuqVJ7s/rxba0+kyUG0lMkSoNBuwfn+Z GLSjkjbMSNT354O8QXK2jqp+k8KvqJhX+vAd+iIx7f+B1XOjGE1hKjSiYmQpwr0ZMFjv 7ABDzH4xTCYfRvkmBMaVMGZDzciaV5tFhsEIqvwktEiqgj+5UKloeaJTQinXz6maQvEK yHtXoAxesMlhvSnqz21SIo6/vDlbsnDpoaZiLyBzATT4JrIkRklW+7AstAUnzpP8qGb8 5DNA== X-Received: by 10.58.49.3 with SMTP id q3mr1397638ven.26.1380815910222; Thu, 03 Oct 2013 08:58:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.48.41 with SMTP id i9ls992151qen.44.gmail; Thu, 03 Oct 2013 08:58:30 -0700 (PDT) X-Received: by 10.58.77.65 with SMTP id q1mr7977924vew.8.1380815910091; Thu, 03 Oct 2013 08:58:30 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id qg2si1893695veb.12.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 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.178; Received: by mail-vc0-f178.google.com with SMTP id lh4so1090117vcb.23 for ; Thu, 03 Oct 2013 08:58:30 -0700 (PDT) X-Gm-Message-State: ALoCoQk11yKunUFiBwpTH6yyZ9GoFFdu72B+rxj5oTPY117xgiHvdxPP3ObaT8JDwideuw8wTmSg X-Received: by 10.52.227.6 with SMTP id rw6mr6735582vdc.19.1380815910013; Thu, 03 Oct 2013 08:58:30 -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 u4csp189249vcz; Thu, 3 Oct 2013 08:58:29 -0700 (PDT) X-Received: by 10.66.118.233 with SMTP id kp9mr3035538pab.182.1380815908749; Thu, 03 Oct 2013 08:58:28 -0700 (PDT) Received: from mail-pd0-f180.google.com (mail-pd0-f180.google.com [209.85.192.180]) by mx.google.com with ESMTPS id mo9si6039206pbc.216.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.180 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.180; Received: by mail-pd0-f180.google.com with SMTP id y10so2713423pdj.11 for ; Thu, 03 Oct 2013 08:58:28 -0700 (PDT) X-Received: by 10.66.149.231 with SMTP id ud7mr10574916pab.8.1380815908151; Thu, 03 Oct 2013 08:58:28 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id l8sm9062174pbl.22.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:27 -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 V2 13/16] cpuidle: free all state kobjects from cpuidle_free_state_kobj() Date: Thu, 3 Oct 2013 21:26:52 +0530 Message-Id: <61fdca8bd1502d7319bfaad29583013f0fbec6b4.1380815504.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.220.178 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