ALSA: core: Use DIV_ROUND_UP() instead of open-coding it
Subsystems (2)
PATCH 1/18 ALSA: core: Use DIV_ROUND_UP() instead of open-coding it
Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-(((x) + (y) - 1) / (y))
+DIV_ROUND_UP(x, y)
// </smpl>
--- sound/core/control.c | 4 ++-- sound/core/seq/seq_memory.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
sound/core/control.c +2 -2
@@ -836,7 +836,7 @@ static void fill_remaining_elem_value(struct snd_ctl_elem_value *control, {size_t offset = value_sizes[info->type] * info->count; - offset = (offset +sizeof (u32) -1 ) /sizeof (u32); + offset =DIV_ROUND_UP (offset,sizeof (u32));memset32 ((u32 *)control->value.bytes.data + offset, pattern,sizeof (control->value) /sizeof (u32) - offset); }
@@ -928,7 +928,7 @@ static int sanity_check_elem_value(struct snd_card *card,/* check whether the remaining area kept untouched */ offset = value_sizes[info->type] * info->count; - offset = (offset +sizeof (u32) -1 ) /sizeof (u32); + offset =DIV_ROUND_UP (offset,sizeof (u32)); p = (u32 *)control->value.bytes.data + offset;for (; offset <sizeof (control->value) /sizeof (u32); offset++, p++) {if (*p != pattern) {
sound/core/seq/seq_memory.c +1 -1
@@ -290,7 +290,7 @@ int snd_seq_event_dup(struct snd_seq_pool *pool, struct snd_seq_event *event, extlen =0 ;if (snd_seq_ev_is_variable (event)) { extlen = event->data.ext.len & ~SNDRV_SEQ_EXT_MASK ; - ncells = (extlen +sizeof (struct snd_seq_event ) -1 ) /sizeof (struct snd_seq_event ); + ncells =DIV_ROUND_UP (extlen,sizeof (struct snd_seq_event )); }if (ncells >= pool->total_elements)return -ENOMEM ;
Signature · 1 line
2.20.1
PATCH 2/18 ALSA: aloop: Use DIV_ROUND_UP() instead of open-coding it
Use DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-(((x) + (y) - 1) / (y))
+DIV_ROUND_UP(x, y)
// </smpl>
--- sound/drivers/aloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/drivers/aloop.c +1 -1
@@ -219,7 +219,7 @@ static int loopback_jiffies_timer_start(struct loopback_pcm *dpcm) dpcm->period_update_pending =1 ; } tick = dpcm->period_size_frac - dpcm->irq_pos; - tick = (tick + dpcm->pcm_bps -1 ) / dpcm->pcm_bps; + tick =DIV_ROUND_UP (tick, dpcm->pcm_bps);mod_timer (&dpcm->timer, jiffies + tick);return 0 ;
Signature · 1 line
2.20.1
PATCH 3/18 ALSA: asihpi: Use DIV_ROUND_UP() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-(((x) + (y) - 1) / (y))
+DIV_ROUND_UP(x, y)
// </smpl>
--- sound/pci/asihpi/hpidebug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/asihpi/hpidebug.c +1 -1
@@ -52,7 +52,7 @@ void hpi_debug_data(u16 *pdata, u32 len)int lines;int cols =8 ; - lines = (len + cols -1 ) / cols; + lines =DIV_ROUND_UP (len, cols);if (lines >8 ) lines =8 ;
Signature · 1 line
2.20.1
PATCH 4/18 ALSA: bt87x: Use DIV_ROUND_UP() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@r1@
expression x;
constant C1;
constant C2;
@@
(x + C1) / C2
@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
if int(C1) != int(C2) - 1: cocci.include_match(False)
except:
cocci.include_match(False)
@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_UP(x, C2)
// </smpl>
--- sound/pci/bt87x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/bt87x.c +2 -1
@@ -327,7 +327,8 @@ static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id) current_block = chip->current_line *16 / chip->lines; irq_block = status >>INT_RISCS_SHIFT ;if (current_block != irq_block) - chip->current_line = (irq_block * chip->lines +15 ) /16 ; + chip->current_line =DIV_ROUND_UP (irq_block * chip->lines, +16 );snd_pcm_period_elapsed (chip->substream); }
Signature · 1 line
2.20.1
PATCH 5/18 ALSA: cx46xx: Use DIV_ROUND_UP() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-(((x) + (y) - 1) / (y))
+DIV_ROUND_UP(x, y)
// </smpl>
--- sound/pci/cs46xx/cs46xx_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/cs46xx/cs46xx_lib.c +1 -1
@@ -813,7 +813,7 @@ static void snd_cs46xx_set_capture_sample_rate(struct snd_cs46xx *chip, unsigned correctionPerGOF = tmp1 /GOF_PER_SEC ; tmp1 -= correctionPerGOF *GOF_PER_SEC ; correctionPerSec = tmp1; - initialDelay = ((48000 *24 ) + rate -1 ) / rate; + initialDelay =DIV_ROUND_UP (48000 *24 , rate);/* * Fill in the VariDecimate control block.
Signature · 1 line
2.20.1
PATCH 6/18 ALSA: ctxfi: Use DIV_ROUND_UP() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-(((x) + (y) - 1) / (y))
+DIV_ROUND_UP(x, y)
// </smpl>
--- sound/pci/ctxfi/ctresource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/ctxfi/ctresource.c +1 -1
@@ -209,7 +209,7 @@ int rsc_mgr_init(struct rsc_mgr *mgr, enum RSCTYP type, mgr->type =NUM_RSCTYP ; - mgr->rscs =kzalloc (((amount +8 -1 ) /8 ),GFP_KERNEL ); + mgr->rscs =kzalloc (DIV_ROUND_UP (amount,8 ),GFP_KERNEL );if (!mgr->rscs)return -ENOMEM ;
Signature · 1 line
2.20.1
PATCH 7/18 ALSA: dummy: Use DIV_ROUND_UP() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-(((x) + (y) - 1) / (y))
+DIV_ROUND_UP(x, y)
// </smpl>
--- sound/drivers/dummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/drivers/dummy.c +1 -1
@@ -236,7 +236,7 @@ struct dummy_systimer_pcm {static void dummy_systimer_rearm (struct dummy_systimer_pcm *dpcm) {mod_timer (&dpcm->timer, jiffies + - (dpcm->frac_period_rest + dpcm->rate -1 ) / dpcm->rate); +DIV_ROUND_UP (dpcm->frac_period_rest, dpcm->rate)); }static void dummy_systimer_update (struct dummy_systimer_pcm *dpcm)
Signature · 1 line
2.20.1
PATCH 8/18 ALSA: emu10k1: Use DIV_ROUND_UP() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-(((x) + (y) - 1) / (y))
+DIV_ROUND_UP(x, y)
// </smpl>
--- sound/pci/emu10k1/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/emu10k1/memory.c +1 -1
@@ -375,7 +375,7 @@ int snd_emu10k1_alloc_pages_maybe_wider(struct snd_emu10k1 *emu, size_t size, struct snd_dma_buffer *dmab) {if (emu->iommu_workaround) { -size_t npages = (size +PAGE_SIZE -1 ) /PAGE_SIZE ; +size_t npages =DIV_ROUND_UP (size,PAGE_SIZE );size_t size_real = npages *PAGE_SIZE ;/*
Signature · 1 line
2.20.1
PATCH 9/18 ALSA: hda: Use DIV_ROUND_UP()/roundup() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() and roundup() instead of open-coding them. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-((((x) + (y) - 1) / (y)) * y)
+roundup(x, y)
@r1@
expression x;
constant C1;
constant C2;
@@
(x + C1) / C2
@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
print C1, C2
try:
if int(C1) != int(C2) - 1: cocci.include_match(False)
except:
cocci.include_match(False)
@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_UP(x, C2)
// </smpl>
--- sound/hda/hdac_stream.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
sound/hda/hdac_stream.c +2 -3
@@ -435,12 +435,11 @@ int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev) pos_adj = bus->bdl_pos_adj;if (!azx_dev->no_period_wakeup && pos_adj >0 ) { pos_align = pos_adj; - pos_adj = (pos_adj * runtime->rate +47999 ) /48000 ; + pos_adj =DIV_ROUND_UP (pos_adj * runtime->rate,48000 );if (!pos_adj) pos_adj = pos_align;else - pos_adj = ((pos_adj + pos_align -1 ) / pos_align) * - pos_align; + pos_adj =roundup (pos_adj, pos_align); pos_adj =frames_to_bytes (runtime, pos_adj);if (pos_adj >= period_bytes) { dev_warn(bus->dev, "Too big adjustment %d\n",
Signature · 1 line
2.20.1
PATCH 10/18 ALSA: lola: Use DIV_ROUND_UP() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@r1@
expression x;
constant C1;
constant C2;
@@
(x + C1) / C2
@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
if int(C1) != int(C2) - 1: cocci.include_match(False)
except:
cocci.include_match(False)
@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_UP(x, C2)
// </smpl>
--- sound/pci/lola/lola_clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/lola/lola_clock.c +1 -1
@@ -135,7 +135,7 @@ int lola_init_clock_widget(struct lola *chip, int nid) } nitems = chip->clock.items; - nb_verbs = (nitems +3 ) /4 ; + nb_verbs =DIV_ROUND_UP (nitems,4 ); idx =0 ; idx_list =0 ;for (i =0 ; i < nb_verbs; i++) {
Signature · 1 line
2.20.1
PATCH 11/18 ALSA: usb: Use DIV_ROUND_UP() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_UP() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-(((x) + (y) - 1) / (y))
+DIV_ROUND_UP(x, y)
// </smpl>
--- sound/usb/mixer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/mixer.c +2 -2
@@ -254,7 +254,7 @@ static int get_relative_value(struct usb_mixer_elem_info *cval, int val)if (val < cval->min)return 0 ;else if (val >= cval->max) -return (cval->max - cval->min + cval->res -1 ) / cval->res; +return DIV_ROUND_UP (cval->max - cval->min, cval->res);else return (val - cval->min) / cval->res; }
@@ -1338,7 +1338,7 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, } uinfo->value.integer.min =0 ; uinfo->value.integer.max = - (cval->max - cval->min + cval->res -1 ) / cval->res; +DIV_ROUND_UP (cval->max - cval->min, cval->res); }return 0 ; }
Signature · 1 line
2.20.1
PATCH 12/18 ALSA: vx: Use roundup() instead of open-coding it
In reply to Lars-Peter ClausenUse roundup() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-((((x) + (y) - 1) / (y)) * y)
+roundup(x, y)
// </smpl>
--- sound/drivers/vx/vx_pcm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/drivers/vx/vx_pcm.c +1 -2
@@ -1154,8 +1154,7 @@ static int vx_init_audio_io(struct vx_core *chip) chip->ibl.size =0 ;vx_set_ibl (chip, &chip->ibl);/* query the info */ if (preferred >0 ) { - chip->ibl.size = ((preferred + chip->ibl.granularity -1 ) / - chip->ibl.granularity) * chip->ibl.granularity; + chip->ibl.size =roundup (preferred, chip->ibl.granularity);if (chip->ibl.size > chip->ibl.max_size) chip->ibl.size = chip->ibl.max_size; }else
Signature · 1 line
2.20.1
PATCH 13/18 ALSA: oss: Use DIV_ROUND_CLOSEST() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-((x) + ((y) / 2)) / (y)
+DIV_ROUND_CLOSEST(x, y)
// </smpl>
--- sound/core/oss/mixer_oss.c | 2 +- sound/core/oss/rate.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
sound/core/oss/mixer_oss.c +1 -1
@@ -418,7 +418,7 @@ static long snd_mixer_oss_conv(long val, long omin, long omax, long nmin, long nif (orange ==0 )return 0 ; -return ((nrange * (val - omin)) + (orange /2 )) / orange + nmin; +return DIV_ROUND_CLOSEST (nrange * (val - omin), orange) + nmin; }/* convert from alsa native to oss values (0-100) */
sound/core/oss/rate.c +2 -2
@@ -193,7 +193,7 @@ static snd_pcm_sframes_t rate_src_frames(struct snd_pcm_plugin *plugin, snd_pcm_if (plugin->src_format.rate < plugin->dst_format.rate) { res = (((frames * data->pitch) + (BITS /2 )) >>SHIFT ); }else { - res = (((frames <<SHIFT ) + (data->pitch /2 )) / data->pitch); + res =DIV_ROUND_CLOSEST (frames <<SHIFT , data->pitch); }if (data->old_src_frames >0 ) {snd_pcm_sframes_t frames1 = frames, res1 = data->old_dst_frames;
@@ -224,7 +224,7 @@ static snd_pcm_sframes_t rate_dst_frames(struct snd_pcm_plugin *plugin, snd_pcm_return 0 ; data = (struct rate_priv *)plugin->extra_data;if (plugin->src_format.rate < plugin->dst_format.rate) { - res = (((frames <<SHIFT ) + (data->pitch /2 )) / data->pitch); + res =DIV_ROUND_CLOSEST (frames <<SHIFT , data->pitch); }else { res = (((frames * data->pitch) + (BITS /2 )) >>SHIFT ); }
Signature · 1 line
2.20.1
PATCH 14/18 ALSA: sonicvibes: Use DIV_ROUND_CLOSEST() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-((x) + ((y) / 2)) / (y)
+DIV_ROUND_CLOSEST(x, y)
// </smpl>
--- sound/pci/sonicvibes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/sonicvibes.c +1 -1
@@ -570,7 +570,7 @@ static void snd_sonicvibes_set_dac_rate(struct sonicvibes * sonic, unsigned intunsigned int div;unsigned long flags; - div = (rate *65536 +SV_FULLRATE /2 ) /SV_FULLRATE ; + div =DIV_ROUND_CLOSEST (rate *65536 ,SV_FULLRATE );if (div >65535 ) div =65535 ;spin_lock_irqsave (&sonic->reg_lock, flags);
Signature · 1 line
2.20.1
PATCH 15/18 ALSA: trident: Use DIV_ROUND_CLOSEST() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@
-((x) + ((y) / 2)) / (y)
+DIV_ROUND_CLOSEST(x, y)
@r1@
expression x;
constant C1;
constant C2;
@@
((x) + C1) / C2
@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
if int(C1) * 2 != int(C2): cocci.include_match(False)
except:
cocci.include_match(False)
@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_CLOSEST(x, C2)
// </smpl>
--- sound/pci/trident/trident_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/trident/trident_main.c +2 -2
@@ -678,7 +678,7 @@ static unsigned int snd_trident_convert_rate(unsigned int rate)else if (rate ==48000 ) delta =0x1000 ;else - delta = (((rate <<12 ) +24000 ) /48000 ) &0x0000ffff ; + delta =DIV_ROUND_CLOSEST (rate <<12 ,48000 ) &0x0000ffff ;return delta; }
@@ -1034,7 +1034,7 @@ static int snd_trident_capture_prepare(struct snd_pcm_substream *substream) ESO_bytes++;// Set channel sample rate, 4.12 format - val = (((unsigned int )48000L <<12 ) + (runtime->rate/2 )) / runtime->rate; + val =DIV_ROUND_CLOSEST (48000U <<12 , runtime->rate);outw (val,TRID_REG (trident,T4D_SBDELTA_DELTA_R ));// Set channel interrupt blk length
Signature · 1 line
2.20.1
PATCH 16/18 ALSA: ens1370: Use DIV_ROUND_CLOSEST() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@r1@
expression x;
constant C1;
constant C2;
@@
((x) + C1) / C2
@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
if int(C1) * 2 != int(C2): cocci.include_match(False)
except:
cocci.include_match(False)
@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_CLOSEST(x, C2)
// </smpl>
--- sound/pci/ens1370.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/ens1370.c +2 -2
@@ -752,7 +752,7 @@ static void snd_es1371_dac1_rate(struct ensoniq * ensoniq, unsigned int rate)unsigned int freq, r;mutex_lock (&ensoniq->src_mutex); - freq = ((rate <<15 ) +1500 ) /3000 ; + freq =DIV_ROUND_CLOSEST (rate <<15 ,3000 ); r = (snd_es1371_wait_src_ready (ensoniq) & (ES_1371_SRC_DISABLE |ES_1371_DIS_P2 |ES_1371_DIS_R1 )) |ES_1371_DIS_P1 ;
@@ -773,7 +773,7 @@ static void snd_es1371_dac2_rate(struct ensoniq * ensoniq, unsigned int rate)unsigned int freq, r;mutex_lock (&ensoniq->src_mutex); - freq = ((rate <<15 ) +1500 ) /3000 ; + freq =DIV_ROUND_CLOSEST (rate <<15 ,3000 ); r = (snd_es1371_wait_src_ready (ensoniq) & (ES_1371_SRC_DISABLE |ES_1371_DIS_P1 |ES_1371_DIS_R1 )) |ES_1371_DIS_P2 ;
Signature · 1 line
2.20.1
PATCH 17/18 ALSA: sis7019: Use DIV_ROUND_CLOSEST() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@r1@
expression x;
constant C1;
constant C2;
@@
((x) + C1) / C2
@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
if int(C1) * 2 != int(C2): cocci.include_match(False)
except:
cocci.include_match(False)
@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_CLOSEST(x, C2)
// </smpl>
--- sound/pci/sis7019.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/sis7019.c +1 -1
@@ -363,7 +363,7 @@ static u32 sis_rate_to_delta(unsigned int rate)else if (rate ==48000 ) delta =0x1000 ;else - delta = (((rate <<12 ) +24000 ) /48000 ) &0x0000ffff ; + delta =DIV_ROUND_CLOSEST (rate <<12 ,48000 ) &0x0000ffff ;return delta; }
Signature · 1 line
2.20.1
PATCH 18/18 ALSA: maestro: Use DIV_ROUND_CLOSEST() instead of open-coding it
In reply to Lars-Peter ClausenUse DIV_ROUND_CLOSEST() instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.
Generated using the following the Coccinelle semantic patch.
// <smpl>
@r1@
expression x;
constant C1;
constant C2;
@@
((x) + C1) / C2
@script:python@
C1 << r1.C1;
C2 << r1.C2;
@@
try:
if int(C1) * 2 != int(C2): cocci.include_match(False)
except:
cocci.include_match(False)
@@
expression r1.x;
constant r1.C1;
constant r1.C2;
@@
-(((x) + C1) / C2)
+DIV_ROUND_CLOSEST(x, C2)
// </smpl>
--- sound/pci/maestro3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/maestro3.c +1 -1
@@ -1245,7 +1245,7 @@ static void snd_m3_pcm_setup2(struct snd_m3 *chip, struct m3_dma *s, snd_pcm_format_width(runtime->format) == 16 ? 0 : 1);/* set up dac/adc rate */ - freq = ((runtime->rate <<15 ) +24000 ) /48000 ; + freq =DIV_ROUND_CLOSEST (runtime->rate <<15 ,48000 );if (freq) freq--;
Signature · 1 line
2.20.1
Takashi Iwai
AppliedQuoted 14 lines · Lars-Peter Clausen
Use
DIV_ROUND_UP()instead of open-coding it. This documents intent and makes it more clear what is going on for the casual reviewer.Generated using the following the Coccinelle semantic patch.
// <smpl>
@@
expression x, y;
@@(quoted diff) +1
-1-(((x) + (y) - 1) / (y)) +DIV_ROUND_UP(x, y)// </smpl>
Quoted 1 line
Signed-off-by Lars-Peter Clausen <[email protected]>
Thanks, applied now for 5.12 with all 18 patches.
Takashi