Skip to contentSkip to conversation

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

PATCH In review Shang XiaoJing 3 participants 8 messages Sep 29, 2022 – Oct 18, 2022

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

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

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes it more clear what is going on for the casual reviewer.

Shang XiaoJing (4):
ASoC: cs35l36: Use DIV_ROUND_UP() instead of open-coding it
ASoC: wm8978: Use DIV_ROUND_UP() instead of open-coding it
ASoC: rsnd: Use DIV_ROUND_UP() instead of open-coding it
ASoC: ti: davinci-mcasp: Use DIV_ROUND_UP() instead of open-coding it

 sound/soc/codecs/cs35l36.c   | 4 ++--
 sound/soc/codecs/wm8978.c    | 2 +-
 sound/soc/sh/rcar/core.c     | 4 ++--
 sound/soc/ti/davinci-mcasp.c | 7 +++----
 4 files changed, 8 insertions(+), 9 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/4 ASoC: cs35l36: Use DIV_ROUND_UP() instead of open-coding it

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes it more clear what is going on for the casual reviewer.

The Coccinelle references Commit e4d8aef21403 ("ALSA: usb: Use DIV_ROUND_UP() instead of open-coding it").

---
 sound/soc/codecs/cs35l36.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/cs35l36.c +2 -2
index 31ae752e242f..a078dd422ea1 100644
@@ -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,
Signature · 1 line
2.17.1
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH -next 1/4] ASoC: cs35l36: Use DIV_ROUND_UP() instead of open-coding it

Quoted 8 lines · Shang XiaoJing

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes it more clear what is going on for the casual reviewer.

The Coccinelle references Commit e4d8aef21403 ("ALSA: usb: Use DIV_ROUND_UP() instead of open-coding it").

---

Thanks,
Charles

#3 lore raw

PATCH 2/4 ASoC: wm8978: Use DIV_ROUND_UP() instead of open-coding it

In reply to Shang XiaoJing

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes it more clear what is going on for the casual reviewer.

The Coccinelle references Commit e4d8aef21403 ("ALSA: usb: Use DIV_ROUND_UP() instead of open-coding it").

---
 sound/soc/codecs/wm8978.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm8978.c +1 -1
index a682f8020eb6..aa2f55401a88 100644
@@ -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;
 
Signature · 1 line
2.17.1
Acked-by on v1 2/4
#4 lore raw

Re: [PATCH -next 2/4] ASoC: wm8978: Use DIV_ROUND_UP() instead of open-coding it

Quoted 8 lines · Shang XiaoJing

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes it more clear what is going on for the casual reviewer.

The Coccinelle references Commit e4d8aef21403 ("ALSA: usb: Use DIV_ROUND_UP() instead of open-coding it").

---

Thanks,
Charles

#5 lore raw

PATCH 3/4 ASoC: rsnd: Use DIV_ROUND_UP() instead of open-coding it

In reply to Shang XiaoJing

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes it more clear what is going on for the casual reviewer.

The Coccinelle references Commit e4d8aef21403 ("ALSA: usb: Use DIV_ROUND_UP() instead of open-coding it").

---
 sound/soc/sh/rcar/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sh/rcar/core.c +2 -2
index 7e380d71b0f8..4e21ebce03c6 100644
@@ -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;
 			}
 
Signature · 1 line
2.17.1
#6 lore raw

PATCH 4/4 ASoC: ti: davinci-mcasp: Use DIV_ROUND_UP() instead of open-coding it

In reply to Shang XiaoJing

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes it more clear what is going on for the casual reviewer.

The Coccinelle references Commit e4d8aef21403 ("ALSA: usb: Use DIV_ROUND_UP() instead of open-coding it").

---
 sound/soc/ti/davinci-mcasp.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
sound/soc/ti/davinci-mcasp.c +3 -4
index ca5d1bb6ac59..f5ac2ab77f5b 100644
@@ -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
Signature · 1 line
2.17.1
maintainer
#7 lore raw
In reply to Shang XiaoJing
Quoted 10 lines · Shang XiaoJing

Use DIV_ROUND_UP() instead of open-coding it, which intents and makes it more clear what is going on for the casual reviewer.

Shang XiaoJing (4):
ASoC: cs35l36: Use DIV_ROUND_UP() instead of open-coding it
ASoC: wm8978: Use DIV_ROUND_UP() instead of open-coding it
ASoC: rsnd: Use DIV_ROUND_UP() instead of open-coding it
ASoC: ti: davinci-mcasp: Use DIV_ROUND_UP() instead of open-coding it

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/4] ASoC: cs35l36: Use DIV_ROUND_UP() instead of open-coding it

      commit: ff091dd23b423e19c8191928daedf62eab6ce523
[2/4] ASoC: wm8978: Use DIV_ROUND_UP() instead of open-coding it
      commit: c54402609820427ff6f725f9182216e7cfe7cfa7
[3/4] ASoC: rsnd: Use DIV_ROUND_UP() instead of open-coding it
      commit: 4aa2b05a24a83cc618fab4c4d343f2179962e5ed
[4/4] ASoC: ti: davinci-mcasp: Use DIV_ROUND_UP() instead of open-coding it
      commit: 98059ddfd1ada95fc9f535ea9c08618aa44ad5d3

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark