On Wed, Jul 18, 2018 at 3:25 PM, Johan Hovold <johan@xxxxxxxxxx> wrote: > The CP2102N equations for determining the actual baud rate can be used > also for other device types, so let's factor it out. > > Note that this removes the now unused cp210x_is_cp2102n() helper. > +static speed_t cp210x_get_actual_rate(struct usb_serial *serial, speed_t baud) > +{ > + struct cp210x_serial_private *priv = usb_get_serial_data(serial); > + unsigned int prescale = 1; > + unsigned int div; > + > + baud = clamp(baud, 300u, priv->max_speed); > + > + if (baud <= 365) > + prescale = 4; > + > + div = DIV_ROUND_CLOSEST(48000000, 2 * prescale * baud); > + baud = 48000000 / (2 * prescale * div); > + > + return baud; > +} > - if (cp210x_is_cp2102n(serial)) { > - int clk_div; > - int prescaler; > - > - baud = clamp(baud, 300u, priv->max_speed); > - prescaler = (baud <= 365) ? 4 : 1; > - clk_div = DIV_ROUND_CLOSEST(48000000, 2 * prescaler * baud); > - baud = 48000000 / (2 * prescaler * clk_div); > - } Looks like ping-pong type of changes. I think the factoring of this particular piece of code can be done in patch 3 in somewhat similar way. -- With Best Regards, Andy Shevchenko -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html