mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Viresh Kumar <viresh.kumar@linaro.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Lists linaro-kernel <linaro-kernel@lists.linaro.org>,
	Patch Tracking <patches@linaro.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2 Resend] cpuidle: free all state kobjects from cpuidle_free_state_kobj()
Date: Fri, 22 Nov 2013 10:50:29 +0100	[thread overview]
Message-ID: <528F28E5.2030900@linaro.org> (raw)
In-Reply-To: <CAKohpon_-QSPOMi4L6WJZL0akXymhRqhkEWpmzuczE6F-=VUBw@mail.gmail.com>

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


      reply	other threads:[~2013-11-22  9:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-21  3:24 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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=528F28E5.2030900@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®