Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1468253
| From | Peter Chen <hzpeterchen@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v6 4/8] usb: core: add power sequence handling for USB devices |
| Date | 2016-08-23 05:30 +0200 |
| Message-ID | <s9azv-6Qj-9@gated-at.bofh.it> (permalink) |
| References | <s8RwR-38y-3@gated-at.bofh.it> <s9078-6Z-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Aug 22, 2016 at 12:09:54PM -0400, Alan Stern wrote:
> > > +
> > > +static int hub_of_pwrseq_on(struct device_node *np, struct usb_hub *hub)
> > > +{
> > > + struct pwrseq *pwrseq;
> > > + struct usb_pwrseq_node *pwrseq_node;
> > > + int ret;
> > > +
> > > + pwrseq = pwrseq_alloc_generic();
> > > + if (IS_ERR(pwrseq))
> > > + return PTR_ERR(pwrseq);
> > > +
> > > + ret = pwrseq_get(np, pwrseq);
> > > + if (ret)
> > > + goto pwr_free;
> > > +
> > > + ret = pwrseq_on(np, pwrseq);
> > > + if (ret)
> > > + goto pwr_put;
> > > +
> > > + pwrseq_node = kzalloc(sizeof(*pwrseq_node), GFP_KERNEL);
>
> You need to check that the kzalloc succeeded.
Ok.
>
> > > + pwrseq_node->pwrseq = pwrseq;
> > > + list_add(&pwrseq_node->list, &hub->pwrseq_on_list);
> > > +
> > > + return 0;
> > > +
> > > +pwr_put:
> > > + pwrseq_put(pwrseq);
> > > +pwr_free:
> > > + pwrseq_free(pwrseq);
> > > + return ret;
> > > +}
>
> This subroutine looks very generic. The only place where it cares that
> it was called for a USB hub is the list_add(), and that could easily
> become generic also (make this function take &hub->pwrseq_on_list as
> its second argument, instead of hub).
>
> It looks like this routine really belongs in the power sequence
> library.
>
I will export below two generic functions at pwrseq library:
int generic_pwrseq_on(struct device_node *np, struct list_head *head)
void generic_pwrseq_off(struct list_head *head)
delete this file, and call above APIs at hub.c.
> > > +
> > > +int hub_pwrseq_on(struct usb_hub *hub)
> > > +{
>
> The names of this routine and the subroutine above are too similar.
> After all, both functions require OF support.
>
I will add #ifdef CONFIG_OF for related code. And put the content at
hub_pwrseq_on at hub_probe directly, how about below?
hub_probe() {
...
if (hub_configure(hub, endpoint) >= 0) {
#ifdef CONFIG_OF
for_each_child_of_node(parent->of_node, np) {
ret = generic_pwrseq_on(np, hub);
if (ret)
return ret;
}
#else
return 0;
#endif
}
hub_disconnect(intf);
return ret;
}
--
Best Regards,
Peter Chen
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH v6 4/8] usb: core: add power sequence handling for USB devices Peter Chen <hzpeterchen@gmail.com> - 2016-08-22 09:10 +0200
Re: [PATCH v6 4/8] usb: core: add power sequence handling for USB devices Alan Stern <stern@rowland.harvard.edu> - 2016-08-22 18:20 +0200
Re: [PATCH v6 4/8] usb: core: add power sequence handling for USB devices Peter Chen <hzpeterchen@gmail.com> - 2016-08-23 05:30 +0200
Re: [PATCH v6 4/8] usb: core: add power sequence handling for USB devices Alan Stern <stern@rowland.harvard.edu> - 2016-08-23 17:40 +0200
csiph-web