/* Returns: calculated prescale - 1 for easy programming into SPI registers or negative error number if valid prescalar cannot be updated.  */
static int davinci_spi_get_prescale(struct davinci_spi *dspi, u32 max_speed_hz)
/* Returns: calculated prescale - 1 for easy programming into SPI registers or negative error number if valid prescalar cannot be updated.  */
static int davinci_spi_get_prescale(struct davinci_spi *dspi, u32 max_speed_hz)
{
    int ret;
    ret = DIV_ROUND_UP(clk_get_rate(dspi->clk), max_speed_hz);
    if (ret < 3) {
        rt_kprintf("spi clock freq too high\n");
        ret = 3;
    }
    if (ret > 256) {
        rt_kprintf("spi clock freq too litter\n");
        ret = 256;
    }
    return ret - 1;
}