On 07/28/2015 03:38 AM, Peter Chen wrote: > +static void set_ep_max_packet_size (struct f_uac2_opts *uac2_opts, > + struct usb_endpoint_descriptor *ep_desc, unsigned int factor) > +{ > + int chmask; > + int srate; > + int ssize; > + u16 max_packet_size; > + > + if (ep_desc == &fs_epin_desc || ep_desc == &hs_epin_desc) { > + chmask = uac2_opts->p_chmask; > + srate = uac2_opts->p_srate; > + ssize = uac2_opts->p_ssize; > + } else { > + WARN_ON (ep_desc != &fs_epout_desc && ep_desc != &hs_epout_desc); > + chmask = uac2_opts->c_chmask; > + srate = uac2_opts->c_srate; > + ssize = uac2_opts->c_ssize; > + } > + > + max_packet_size = num_channels(chmask) * ssize * > + DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))); > + ep_desc->wMaxPacketSize = min(cpu_to_le16(max_packet_size), > + ep_desc->wMaxPacketSize); > +} Thinking about it again, it would probably be nicer to make this function return wMaxPacketSize directly: fs_epin_desc.wMaxPacketSize = calc_ep_max_packet_size(uac2_opts->p_chmask, uac2_opts->p_srate, uac2_opts->p_ssize, 1000); hs_epin_desc.wMaxPacketSize = calc_ep_max_packet_size(uac2_opts->p_chmask, uac2_opts->p_srate, uac2_opts->p_ssize, 8000); ... -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html