Unverified Commit 67ad4edf authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: Use DIV_ROUND_UP() instead of open-coding it

Merge series from Shang XiaoJing <shangxiaojing@huawei.com>:

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes
it more clear what is going on for the casual reviewer.
parents 974ada31 98059ddf
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -918,8 +918,8 @@ static int cs35l36_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
		fs1 = CS35L36_FS1_DEFAULT_VAL;
		fs2 = CS35L36_FS2_DEFAULT_VAL;
	} else {
		fs1 = 3 * ((CS35L36_FS_NOM_6MHZ * 4 + freq - 1) / freq) + 4;
		fs2 = 5 * ((CS35L36_FS_NOM_6MHZ * 4 + freq - 1) / freq) + 4;
		fs1 = 3 * DIV_ROUND_UP(CS35L36_FS_NOM_6MHZ * 4, freq) + 4;
		fs2 = 5 * DIV_ROUND_UP(CS35L36_FS_NOM_6MHZ * 4, freq) + 4;
	}

	regmap_write(cs35l36->regmap, CS35L36_TESTKEY_CTRL,
+1 −1
Original line number Diff line number Diff line
@@ -498,7 +498,7 @@ static int wm8978_configure_pll(struct snd_soc_component *component)

		if (4 * f_opclk < 3 * f_mclk)
			/* Have to use OPCLKDIV */
			opclk_div = (3 * f_mclk / 4 + f_opclk - 1) / f_opclk;
			opclk_div = DIV_ROUND_UP(3 * f_mclk / 4, f_opclk);
		else
			opclk_div = 1;

+2 −2
Original line number Diff line number Diff line
@@ -1581,9 +1581,9 @@ static int rsnd_hw_params(struct snd_soc_component *component,
				hw_params->cmask |= SNDRV_PCM_HW_PARAM_RATE;
			} else if (params_rate(hw_params) * k_up < io->converted_rate) {
				hw_param_interval(hw_params, SNDRV_PCM_HW_PARAM_RATE)->min =
					(io->converted_rate + k_up - 1) / k_up;
					DIV_ROUND_UP(io->converted_rate, k_up);
				hw_param_interval(hw_params, SNDRV_PCM_HW_PARAM_RATE)->max =
					(io->converted_rate + k_up - 1) / k_up;
					DIV_ROUND_UP(io->converted_rate, k_up);
				hw_params->cmask |= SNDRV_PCM_HW_PARAM_RATE;
			}

+3 −4
Original line number Diff line number Diff line
@@ -869,7 +869,7 @@ static int mcasp_common_hw_param(struct davinci_mcasp *mcasp, int stream,
	if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE)
		max_active_serializers = 1;
	else
		max_active_serializers = (channels + slots - 1) / slots;
		max_active_serializers = DIV_ROUND_UP(channels, slots);

	/* Default configuration */
	if (mcasp->version < MCASP_VERSION_3)
@@ -1002,8 +1002,7 @@ static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream,
	 */
	if (mcasp->tdm_mask[stream]) {
		active_slots = hweight32(mcasp->tdm_mask[stream]);
		active_serializers = (channels + active_slots - 1) /
			active_slots;
		active_serializers = DIV_ROUND_UP(channels, active_slots);
		if (active_serializers == 1)
			active_slots = channels;
		for (i = 0; i < total_slots; i++) {
@@ -1014,7 +1013,7 @@ static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream,
			}
		}
	} else {
		active_serializers = (channels + total_slots - 1) / total_slots;
		active_serializers = DIV_ROUND_UP(channels, total_slots);
		if (active_serializers == 1)
			active_slots = channels;
		else