* [PATCH V2 Resend] cpuidle: free all state kobjects from cpuidle_free_state_kobj()
@ 2013-11-21 3:24 Viresh Kumar
2013-11-21 13:09 ` Rafael J. Wysocki
0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2013-11-21 3:24 UTC (permalink / raw)
To: rjw; +Cc: linaro-kernel, patches, linux-pm, linux-kernel, Viresh Kumar
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 <daniel.lezcano@linaro.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
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
--
1.7.12.rc2.18.g61b472e
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2 Resend] cpuidle: free all state kobjects from cpuidle_free_state_kobj()
2013-11-21 3:24 [PATCH V2 Resend] cpuidle: free all state kobjects from cpuidle_free_state_kobj() Viresh Kumar
@ 2013-11-21 13:09 ` Rafael J. Wysocki
2013-11-21 15:48 ` Viresh Kumar
0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2013-11-21 13:09 UTC (permalink / raw)
To: Viresh Kumar; +Cc: linaro-kernel, patches, linux-pm, linux-kernel
On Thursday, November 21, 2013 08:54:12 AM Viresh Kumar wrote:
> 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 <daniel.lezcano@linaro.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> 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);
Well, doesn't the ordering actually matter? Your patch changes the ordering
here.
> 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
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2 Resend] cpuidle: free all state kobjects from cpuidle_free_state_kobj()
2013-11-21 13:09 ` Rafael J. Wysocki
@ 2013-11-21 15:48 ` Viresh Kumar
2013-11-22 9:50 ` Daniel Lezcano
0 siblings, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2013-11-21 15:48 UTC (permalink / raw)
To: Rafael J. Wysocki, Daniel Lezcano
Cc: Lists linaro-kernel, Patch Tracking, linux-pm@vger.kernel.org,
Linux Kernel Mailing List
On 21 November 2013 18:39, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Thursday, November 21, 2013 08:54:12 AM Viresh Kumar wrote:
>> 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 <daniel.lezcano@linaro.org>
>> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>> ---
>> 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);
>
> Well, doesn't the ordering actually matter? Your patch changes the ordering
> here.
I don't think it matters. And it was done in reverse order earlier to
save an extra
variable..
Daniel??
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH V2 Resend] cpuidle: free all state kobjects from cpuidle_free_state_kobj()
2013-11-21 15:48 ` Viresh Kumar
@ 2013-11-22 9:50 ` Daniel Lezcano
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2013-11-22 9:50 UTC (permalink / raw)
To: Viresh Kumar, Rafael J. Wysocki
Cc: Lists linaro-kernel, Patch Tracking, linux-pm@vger.kernel.org,
Linux Kernel Mailing List
On 11/21/2013 04:48 PM, Viresh Kumar wrote:
> On 21 November 2013 18:39, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
>> On Thursday, November 21, 2013 08:54:12 AM Viresh Kumar wrote:
>>> 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 <daniel.lezcano@linaro.org>
>>> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
>>> ---
>>> 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);
>>
>> Well, doesn't the ordering actually matter? Your patch changes the ordering
>> here.
>
> I don't think it matters. And it was done in reverse order earlier to
> save an extra
> variable..
Yes, that's correct. Without the reverse order we must declare a
variable for the error case to do 'for (j = 0; j < i; j++)'
Thanks
-- Daniel
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-11-22 9:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-21 3:24 [PATCH V2 Resend] cpuidle: free all state kobjects from cpuidle_free_state_kobj() Viresh Kumar
2013-11-21 13:09 ` Rafael J. Wysocki
2013-11-21 15:48 ` Viresh Kumar
2013-11-22 9:50 ` Daniel Lezcano
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.