Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1371354
| From | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v9 1/4] gadget: Introduce the usb charger framework |
| Date | 2016-04-05 11:50 +0200 |
| Message-ID | <rkvMu-13F-11@gated-at.bofh.it> (permalink) |
| References | <rj1GN-10N-5@gated-at.bofh.it> <rj1GO-10N-25@gated-at.bofh.it> <rkudH-9L-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On 5 April 2016 at 15:56, Peter Chen <hzpeterchen@gmail.com> wrote:
> On Fri, Apr 01, 2016 at 03:21:49PM +0800, Baolin Wang wrote:
>> +
>> +int devm_usb_charger_register(struct device *dev,
>> + struct usb_charger *uchger)
>> +{
>> + struct usb_charger **ptr;
>> + int ret;
>> +
>> + ptr = devres_alloc(devm_uchger_dev_unreg, sizeof(*ptr), GFP_KERNEL);
>> + if (!ptr)
>> + return -ENOMEM;
>> +
>> + ret = usb_charger_register(dev, uchger);
>> + if (ret) {
>> + devres_free(ptr);
>> + return ret;
>> + }
>> +
>> + *ptr = uchger;
>> + devres_add(dev, ptr);
>> +
>> + return 0;
>> +}
>> +EXPORT_SYMBOL_GPL(devm_usb_charger_register);
>
> When the above API is expected to call? Can we use the USB charger
> without USB gadget?
I think this is open for user to do their specific initialization for
usb charger. That depends on how to initialize your usb charger
structure.
>
>> +
>> +int usb_charger_init(struct usb_gadget *ugadget)
>> +{
>> + struct usb_charger *uchger;
>> + struct extcon_dev *edev;
>> + struct power_supply *psy;
>> + int ret;
>> +
>> + uchger = kzalloc(sizeof(struct usb_charger), GFP_KERNEL);
>> + if (!uchger)
>> + return -ENOMEM;
>> +
>> + uchger->type = UNKNOWN_TYPE;
>> + uchger->state = USB_CHARGER_DEFAULT;
>> + uchger->id = -1;
>> +
>> + if (ugadget->speed >= USB_SPEED_SUPER)
>> + uchger->cur_limit.sdp_cur_limit = DEFAULT_SDP_CUR_LIMIT_SS;
>> + else
>> + uchger->cur_limit.sdp_cur_limit = DEFAULT_SDP_CUR_LIMIT;
>
> We still haven't known bus speed here, it is better do it after
> setting configuration has finished.
OK. Make sense.
--
Baolin.wang
Best Regards
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: [PATCH v9 1/4] gadget: Introduce the usb charger framework Peter Chen <hzpeterchen@gmail.com> - 2016-04-05 10:10 +0200 Re: [PATCH v9 1/4] gadget: Introduce the usb charger framework Baolin Wang <baolin.wang@linaro.org> - 2016-04-05 11:50 +0200
csiph-web