/* Set controller clock rate @s slave @spd clock rate in Hz  */
static int spi_m2s_hw_clk_set(struct m2s_spi_dsc *s, unsigned int spd)
/* Set controller clock rate @s slave @spd clock rate in Hz  */
static int spi_m2s_hw_clk_set(struct m2s_spi_dsc *s, unsigned int spd)
{
	int i;
	unsigned int h;
	int ret = 0;
	h = s->ref_clk;
	for (i = 0; i <= 255; i++) {
		if (h / ((i + 1) << 1) <= spd)
			break;
	}
	if (i > 255) {
		ret = -EINVAL;
		goto done;
	}
	M2S_SPI(s)->clk_gen = i;
done:
	return ret;
}