linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lu Baolu <baolu.lu@linux.intel.com>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Felipe Balbi <balbi@kernel.org>,
	Greg KH <gregkh@linuxfoundation.org>,
	Sebastian Reichel <sre@kernel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	robh@kernel.org, Jun Li <jun.li@nxp.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Ruslan Bilovol <ruslan.bilovol@gmail.com>,
	Peter Chen <peter.chen@freescale.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	r.baldyga@samsung.com, grygorii.strashko@ti.com,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	Lee Jones <lee.jones@linaro.org>, Mark Brown <broonie@kernel.org>,
	John Stultz <john.stultz@linaro.org>,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	patches@opensource.wolfsonmicro.com,
	Linux PM list <linux-pm@vger.kernel.org>USB <lin>
Subject: Re: [PATCH v17 3/4] usb: gadget: Integrate with the usb gadget supporting for usb charger
Date: Tue, 11 Oct 2016 12:32:17 +0800	[thread overview]
Message-ID: <57FC6B51.9030205@linux.intel.com> (raw)
In-Reply-To: <CAMz4kuL5yk5EZQ37ofA39uK_JwYYH5DA_=Z+nLEMO06KvyQmDQ@mail.gmail.com>

Hi,

On 10/11/2016 12:07 PM, Baolin Wang wrote:
>>>  /*
>>> >> + * usb_charger_unregister() - Unregister a usb charger.
>>> >> + * @uchger - the usb charger to be unregistered.
>>> >> + */
>>> >> +static int usb_charger_unregister(struct usb_charger *uchger)
>>> >> +{
>>> >> +     ida_simple_remove(&usb_charger_ida, uchger->id);
>>> >> +     sysfs_remove_groups(&uchger->gadget->dev.kobj, usb_charger_groups);
>>> >> +
>>> >> +     mutex_lock(&charger_lock);
>>> >> +     list_del(&uchger->list);
>>> >> +     mutex_unlock(&charger_lock);
>>> >> +
>>> >> +     kfree(uchger);
>> >
>> > Any reasons you want to put kfree() here? You allocated the memory
>> > in usb_charger_init(). Isn't usb_charger_exit() a better place?
> The usb_charger_exit() will issue usb_charger_unregister() and we need
> use the usb_charger structure in usb_charger_unregister() to
> unregister the usb charger.
>

This seems not to be a strong reason. :-)

You can unregister the charger first and then free the structure.
Just do the reverse operation of what you have done in the init
function.

Best regards,
Lu Baolu

  reply	other threads:[~2016-10-11  4:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10  6:22 [PATCH v17 0/4] Introduce usb charger framework to deal with the usb gadget power negotation Baolin Wang
2016-10-10  6:22 ` [PATCH v17 1/4] usb: gadget: Introduce the usb charger framework Baolin Wang
     [not found]   ` <aec95e0e38c1f8ff11d9cc33fa6939c4072413a0.1476000169.git.baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-10-11  2:59     ` Lu Baolu
2016-10-11  4:05       ` Baolin Wang
2016-10-10  6:22 ` [PATCH v17 2/4] usb: gadget: Support for " Baolin Wang
2016-10-10  6:22 ` [PATCH v17 3/4] usb: gadget: Integrate with the usb gadget supporting for usb charger Baolin Wang
2016-10-11  3:06   ` Lu Baolu
2016-10-11  4:07     ` Baolin Wang
2016-10-11  4:32       ` Lu Baolu [this message]
2016-10-11  5:11         ` Baolin Wang
     [not found] ` <cover.1476000169.git.baolin.wang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2016-10-10  6:22   ` [PATCH v17 4/4] power: wm831x_power: Support USB charger current limit management Baolin Wang

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=57FC6B51.9030205@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=balbi@kernel.org \
    --cc=baolin.wang@linaro.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=grygorii.strashko@ti.com \
    --cc=john.stultz@linaro.org \
    --cc=jun.li@nxp.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=peter.chen@freescale.com \
    --cc=r.baldyga@samsung.com \
    --cc=robh@kernel.org \
    --cc=ruslan.bilovol@gmail.com \
    --cc=sre@kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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;
as well as URLs for NNTP newsgroup(s).