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 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html