Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1498608
| From | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v17 3/4] usb: gadget: Integrate with the usb gadget supporting for usb charger |
| Date | 2016-10-11 07:20 +0200 |
| Message-ID | <sqXDP-2uv-1@gated-at.bofh.it> (permalink) |
| References | <sqCg1-6f6-1@gated-at.bofh.it> <sqCg1-6f6-7@gated-at.bofh.it> <sqVC1-1hs-15@gated-at.bofh.it> <sqWy5-1Px-1@gated-at.bofh.it> <sqX17-21p-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi Baolu,
On 11 October 2016 at 12:32, Lu Baolu <baolu.lu@linux.intel.com> wrote:
> 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.
Make sense to me. I will modify this in next version. Thanks for your comments.
--
Baolin.wang
Best Regards
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v17 0/4] Introduce usb charger framework to deal with the usb gadget power negotation Baolin Wang <baolin.wang@linaro.org> - 2016-10-10 08:30 +0200
[PATCH v17 4/4] power: wm831x_power: Support USB charger current limit management Baolin Wang <baolin.wang@linaro.org> - 2016-10-10 08:30 +0200
[PATCH v17 3/4] usb: gadget: Integrate with the usb gadget supporting for usb charger Baolin Wang <baolin.wang@linaro.org> - 2016-10-10 08:30 +0200
Re: [PATCH v17 3/4] usb: gadget: Integrate with the usb gadget supporting for usb charger Lu Baolu <baolu.lu@linux.intel.com> - 2016-10-11 05:10 +0200
Re: [PATCH v17 3/4] usb: gadget: Integrate with the usb gadget supporting for usb charger Baolin Wang <baolin.wang@linaro.org> - 2016-10-11 06:10 +0200
Re: [PATCH v17 3/4] usb: gadget: Integrate with the usb gadget supporting for usb charger Lu Baolu <baolu.lu@linux.intel.com> - 2016-10-11 06:40 +0200
Re: [PATCH v17 3/4] usb: gadget: Integrate with the usb gadget supporting for usb charger Baolin Wang <baolin.wang@linaro.org> - 2016-10-11 07:20 +0200
[PATCH v17 2/4] usb: gadget: Support for the usb charger framework Baolin Wang <baolin.wang@linaro.org> - 2016-10-10 08:30 +0200
[PATCH v17 1/4] usb: gadget: Introduce the usb charger framework Baolin Wang <baolin.wang@linaro.org> - 2016-10-10 08:30 +0200
Re: [PATCH v17 1/4] usb: gadget: Introduce the usb charger framework Lu Baolu <baolu.lu@linux.intel.com> - 2016-10-11 05:00 +0200
csiph-web