Skip to content

Commit 4d23359

Browse files
cladischJaroslav Kysela
authored andcommitted
[ALSA] sparse address space annotations
ALSA Core,RawMidi Midlevel,ALSA<-OSS emulation,ALSA sequencer RME32 driver,RME96 driver,EMU10K1/EMU10K2 driver,NM256 driver Add sparse annotations where we do strange this with __iomem/__user pointers. Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
1 parent 49045d3 commit 4d23359

8 files changed

Lines changed: 33 additions & 19 deletions

File tree

‎sound/core/memory.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ int __exit snd_memory_info_done(void)
249249
int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count)
250250
{
251251
#if defined(__i386__) || defined(CONFIG_SPARC32)
252-
return copy_to_user(dst, (const void*)src, count) ? -EFAULT : 0;
252+
return copy_to_user(dst, (const void __force*)src, count) ? -EFAULT : 0;
253253
#else
254254
char buf[256];
255255
while (count) {
@@ -280,7 +280,7 @@ int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size
280280
int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count)
281281
{
282282
#if defined(__i386__) || defined(CONFIG_SPARC32)
283-
return copy_from_user((void*)dst, src, count) ? -EFAULT : 0;
283+
return copy_from_user((void __force *)dst, src, count) ? -EFAULT : 0;
284284
#else
285285
char buf[256];
286286
while (count) {

‎sound/core/oss/pcm_oss.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,9 @@ static ssize_t snd_pcm_oss_write1(snd_pcm_substream_t *substream, const char __u
850850
return xfer > 0 ? xfer : -EAGAIN;
851851
}
852852
} else {
853-
tmp = snd_pcm_oss_write2(substream, (const char *)buf, runtime->oss.period_bytes, 0);
853+
tmp = snd_pcm_oss_write2(substream,
854+
(const char __force *)buf,
855+
runtime->oss.period_bytes, 0);
854856
if (tmp <= 0)
855857
return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
856858
runtime->oss.bytes += tmp;
@@ -926,7 +928,8 @@ static ssize_t snd_pcm_oss_read1(snd_pcm_substream_t *substream, char __user *bu
926928
xfer += tmp;
927929
runtime->oss.buffer_used -= tmp;
928930
} else {
929-
tmp = snd_pcm_oss_read2(substream, (char *)buf, runtime->oss.period_bytes, 0);
931+
tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
932+
runtime->oss.period_bytes, 0);
930933
if (tmp <= 0)
931934
return xfer > 0 ? (snd_pcm_sframes_t)xfer : tmp;
932935
runtime->oss.bytes += tmp;

‎sound/core/rawmidi.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,9 @@ static ssize_t snd_rawmidi_read(struct file *file, char __user *buf, size_t coun
984984
spin_lock_irq(&runtime->lock);
985985
}
986986
spin_unlock_irq(&runtime->lock);
987-
count1 = snd_rawmidi_kernel_read1(substream, (unsigned char *)buf, count, 0);
987+
count1 = snd_rawmidi_kernel_read1(substream,
988+
(unsigned char __force *)buf,
989+
count, 0);
988990
if (count1 < 0)
989991
return result > 0 ? result : count1;
990992
result += count1;
@@ -1213,7 +1215,9 @@ static ssize_t snd_rawmidi_write(struct file *file, const char __user *buf, size
12131215
spin_lock_irq(&runtime->lock);
12141216
}
12151217
spin_unlock_irq(&runtime->lock);
1216-
count1 = snd_rawmidi_kernel_write1(substream, (unsigned char *)buf, count, 0);
1218+
count1 = snd_rawmidi_kernel_write1(substream,
1219+
(unsigned char __force *)buf,
1220+
count, 0);
12171221
if (count1 < 0)
12181222
return result > 0 ? result : count1;
12191223
result += count1;

‎sound/core/seq/seq_clientmgr.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,9 @@ static ssize_t snd_seq_read(struct file *file, char __user *buf, size_t count, l
413413
}
414414
count -= sizeof(snd_seq_event_t);
415415
buf += sizeof(snd_seq_event_t);
416-
err = snd_seq_expand_var_event(&cell->event, count, (char *)buf, 0, sizeof(snd_seq_event_t));
416+
err = snd_seq_expand_var_event(&cell->event, count,
417+
(char __force *)buf, 0,
418+
sizeof(snd_seq_event_t));
417419
if (err < 0)
418420
break;
419421
result += err;
@@ -1009,7 +1011,8 @@ static ssize_t snd_seq_write(struct file *file, const char __user *buf, size_t c
10091011
}
10101012
/* set user space pointer */
10111013
event.data.ext.len = extlen | SNDRV_SEQ_EXT_USRPTR;
1012-
event.data.ext.ptr = (char*)buf + sizeof(snd_seq_event_t);
1014+
event.data.ext.ptr = (char __force *)buf
1015+
+ sizeof(snd_seq_event_t);
10131016
len += extlen; /* increment data length */
10141017
} else {
10151018
#ifdef CONFIG_COMPAT

‎sound/pci/emu10k1/emufx.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static void snd_emu10k1_write_op(emu10k1_fx8010_code_t *icode, unsigned int *ptr
470470
{
471471
u_int32_t *code;
472472
snd_assert(*ptr < 512, return);
473-
code = (u_int32_t *)icode->code + (*ptr) * 2;
473+
code = (u_int32_t __force *)icode->code + (*ptr) * 2;
474474
set_bit(*ptr, icode->code_valid);
475475
code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff);
476476
code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff);
@@ -485,7 +485,7 @@ static void snd_emu10k1_audigy_write_op(emu10k1_fx8010_code_t *icode, unsigned i
485485
{
486486
u_int32_t *code;
487487
snd_assert(*ptr < 1024, return);
488-
code = (u_int32_t *)icode->code + (*ptr) * 2;
488+
code = (u_int32_t __force *)icode->code + (*ptr) * 2;
489489
set_bit(*ptr, icode->code_valid);
490490
code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
491491
code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
@@ -1042,7 +1042,7 @@ static int __devinit _snd_emu10k1_audigy_init_efx(emu10k1_t *emu)
10421042
err = -ENOMEM;
10431043
goto __err;
10441044
}
1045-
gpr_map = (u32 *)icode->gpr_map;
1045+
gpr_map = (u32 __force *)icode->gpr_map;
10461046

10471047
icode->tram_data_map = icode->gpr_map + 512;
10481048
icode->tram_addr_map = icode->tram_data_map + 256;
@@ -1431,7 +1431,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
14311431
__err:
14321432
kfree(controls);
14331433
if (icode != NULL) {
1434-
kfree((void *)icode->gpr_map);
1434+
kfree((void __force *)icode->gpr_map);
14351435
kfree(icode);
14361436
}
14371437
return err;
@@ -1511,7 +1511,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu)
15111511
err = -ENOMEM;
15121512
goto __err;
15131513
}
1514-
gpr_map = (u32 *)icode->gpr_map;
1514+
gpr_map = (u32 __force *)icode->gpr_map;
15151515

15161516
icode->tram_data_map = icode->gpr_map + 256;
15171517
icode->tram_addr_map = icode->tram_data_map + 160;
@@ -2032,7 +2032,7 @@ static int __devinit _snd_emu10k1_init_efx(emu10k1_t *emu)
20322032
kfree(ipcm);
20332033
kfree(controls);
20342034
if (icode != NULL) {
2035-
kfree((void *)icode->gpr_map);
2035+
kfree((void __force *)icode->gpr_map);
20362036
kfree(icode);
20372037
}
20382038
return err;

‎sound/pci/nm256/nm256.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ static void snd_nm256_setup_stream(nm256_t *chip, nm256_stream_t *s,
840840
runtime->hw = *hw_ptr;
841841
runtime->hw.buffer_bytes_max = s->bufsize;
842842
runtime->hw.period_bytes_max = s->bufsize / 2;
843-
runtime->dma_area = (void*) s->bufptr;
843+
runtime->dma_area = (void __force *) s->bufptr;
844844
runtime->dma_addr = s->bufptr_addr;
845845
runtime->dma_bytes = s->bufsize;
846846
runtime->private_data = s;

‎sound/pci/rme32.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,8 @@ snd_rme32_playback_hw_params(snd_pcm_substream_t * substream,
692692
if (err < 0)
693693
return err;
694694
} else {
695-
runtime->dma_area = (void *)(rme32->iobase + RME32_IO_DATA_BUFFER);
695+
runtime->dma_area = (void __force *)(rme32->iobase +
696+
RME32_IO_DATA_BUFFER);
696697
runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER;
697698
runtime->dma_bytes = RME32_BUFFER_SIZE;
698699
}
@@ -746,7 +747,8 @@ snd_rme32_capture_hw_params(snd_pcm_substream_t * substream,
746747
if (err < 0)
747748
return err;
748749
} else {
749-
runtime->dma_area = (void *)rme32->iobase + RME32_IO_DATA_BUFFER;
750+
runtime->dma_area = (void __force *)rme32->iobase +
751+
RME32_IO_DATA_BUFFER;
750752
runtime->dma_addr = rme32->port + RME32_IO_DATA_BUFFER;
751753
runtime->dma_bytes = RME32_BUFFER_SIZE;
752754
}

‎sound/pci/rme96.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,8 @@ snd_rme96_playback_hw_params(snd_pcm_substream_t *substream,
985985
snd_pcm_runtime_t *runtime = substream->runtime;
986986
int err, rate, dummy;
987987

988-
runtime->dma_area = (void *)(rme96->iobase + RME96_IO_PLAY_BUFFER);
988+
runtime->dma_area = (void __force *)(rme96->iobase +
989+
RME96_IO_PLAY_BUFFER);
989990
runtime->dma_addr = rme96->port + RME96_IO_PLAY_BUFFER;
990991
runtime->dma_bytes = RME96_BUFFER_SIZE;
991992

@@ -1037,7 +1038,8 @@ snd_rme96_capture_hw_params(snd_pcm_substream_t *substream,
10371038
snd_pcm_runtime_t *runtime = substream->runtime;
10381039
int err, isadat, rate;
10391040

1040-
runtime->dma_area = (void *)(rme96->iobase + RME96_IO_REC_BUFFER);
1041+
runtime->dma_area = (void __force *)(rme96->iobase +
1042+
RME96_IO_REC_BUFFER);
10411043
runtime->dma_addr = rme96->port + RME96_IO_REC_BUFFER;
10421044
runtime->dma_bytes = RME96_BUFFER_SIZE;
10431045

0 commit comments

Comments
 (0)