ALSA: Minor sparse warning fixes
cover ALSA: Minor sparse warning fixes
Hi,
this is a series of a few trivial fixes mostly for annotations that caused sparse warnings.
Takashi
===
Takashi Iwai (3):
ALSA: via82xx: Fix endianness annotations
ALSA: emu10k1: Fix endianness annotations
ALSA: emu8000: Fix the cast to __user pointer
sound/isa/sb/emu8000_pcm.c | 4 ++-- sound/pci/emu10k1/emu10k1_main.c | 4 +++- sound/pci/via82xx.c | 6 ++++-- sound/pci/via82xx_modem.c | 6 ++++-- 4 files changed, 13 insertions(+), 7 deletions(-)
Signature · 6 lines
2.16.4 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH 1/3 ALSA: via82xx: Fix endianness annotations
The internal page tables are in little endian, hence they should be__le32 type. This fixes the relevant sparse warnings:
sound/pci/via82xx.c:454:60: warning: incorrect type in assignment (different base types)
sound/pci/via82xx.c:454:60: expected unsigned int [usertype]
sound/pci/via82xx.c:454:60: got restricted __le32 [usertype]
....
No functional changes, just sparse warning fixes.
--- sound/pci/via82xx.c | 6 ++++-- sound/pci/via82xx_modem.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-)
sound/pci/via82xx.c +4 -2
@@ -414,6 +414,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre {unsigned int i, idx, ofs, rest;struct via82xx *chip =snd_pcm_substream_chip (substream); +__le32 *pgtbl;if (dev->table.area ==NULL ) {/* the start of each lists must be aligned to 8 bytes,
@@ -435,6 +436,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre/* fill the entries */ idx =0 ; ofs =0 ; + pgtbl = (__le32 *)dev->table.area;for (i =0 ; i < periods; i++) { rest = fragsize;/* fill descriptors for a period.
@@ -451,7 +453,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substrereturn -EINVAL ; } addr =snd_pcm_sgbuf_get_addr (substream, ofs); - ((u32 *)dev->table.area)[idx <<1 ] =cpu_to_le32 (addr); + pgtbl[idx <<1 ] =cpu_to_le32 (addr); r =snd_pcm_sgbuf_get_chunk_size (substream, ofs, rest); rest -= r;if (! rest) {
@@ -466,7 +468,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre"tbl %d: at %d size %d (rest %d)\n", idx, ofs, r, rest); */ - ((u32 *)dev->table.area)[(idx<<1 ) +1 ] =cpu_to_le32 (r | flag); + pgtbl[(idx<<1 ) +1 ] =cpu_to_le32 (r | flag); dev->idx_table[idx].offset = ofs; dev->idx_table[idx].size = r; ofs += r;
sound/pci/via82xx_modem.c +4 -2
@@ -267,6 +267,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre {unsigned int i, idx, ofs, rest;struct via82xx_modem *chip =snd_pcm_substream_chip (substream); +__le32 *pgtbl;if (dev->table.area ==NULL ) {/* the start of each lists must be aligned to 8 bytes,
@@ -288,6 +289,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre/* fill the entries */ idx =0 ; ofs =0 ; + pgtbl = (__le32 *)dev->table.area;for (i =0 ; i < periods; i++) { rest = fragsize;/* fill descriptors for a period.
@@ -304,7 +306,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substrereturn -EINVAL ; } addr =snd_pcm_sgbuf_get_addr (substream, ofs); - ((u32 *)dev->table.area)[idx <<1 ] =cpu_to_le32 (addr); + pgtbl[idx <<1 ] =cpu_to_le32 (addr); r =PAGE_SIZE - (ofs %PAGE_SIZE );if (rest < r) r = rest;
@@ -321,7 +323,7 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre"tbl %d: at %d size %d (rest %d)\n", idx, ofs, r, rest); */ - ((u32 *)dev->table.area)[(idx<<1 ) +1 ] =cpu_to_le32 (r | flag); + pgtbl[(idx<<1 ) +1 ] =cpu_to_le32 (r | flag); dev->idx_table[idx].offset = ofs; dev->idx_table[idx].size = r; ofs += r;
Signature · 6 lines
2.16.4 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH 2/3 ALSA: emu10k1: Fix endianness annotations
In reply to Takashi IwaiThe internal page tables are little endian, hence they should be__le32 type. This fixes the relevant sparse warning:
sound/pci/emu10k1/emu10k1_main.c:2013:51: warning: incorrect type in assignment (different base types)
sound/pci/emu10k1/emu10k1_main.c:2013:51: expected unsigned int [usertype]
sound/pci/emu10k1/emu10k1_main.c:2013:51: got restricted __le32 [usertype]
No functional changes, just sparse warning fixes.
--- sound/pci/emu10k1/emu10k1_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/pci/emu10k1/emu10k1_main.c +3 -1
@@ -1789,6 +1789,7 @@ int snd_emu10k1_create(struct snd_card *card,int idx, err;int is_audigy;size_t page_table_size; +__le32 *pgtbl;unsigned int silent_page;const struct snd_emu_chip_details *c;static const struct snd_device_ops ops = {
@@ -2009,8 +2010,9 @@ int snd_emu10k1_create(struct snd_card *card,/* Clear silent pages and set up pointers */ memset (emu->silent_page.area,0 , emu->silent_page.bytes); silent_page = emu->silent_page.addr << emu->address_mode; + pgtbl = (__le32 *)emu->ptb_pages.area;for (idx =0 ; idx < (emu->address_mode ?MAXPAGES1 :MAXPAGES0 ); idx++) - ((u32 *)emu->ptb_pages.area)[idx] =cpu_to_le32 (silent_page | idx); + pgtbl[idx] =cpu_to_le32 (silent_page | idx);/* set up voice indices */ for (idx =0 ; idx <NUM_G ; idx++) {
Signature · 6 lines
2.16.4 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH 3/3 ALSA: emu8000: Fix the cast to __user pointer
In reply to Takashi IwaiFixes the sparse warnings. The cast to __user pointer needs __force:
sound/isa/sb/emu8000_pcm.c:528:9: warning: cast removes address space '<asn:1>' of expression
No functional changes, just sparse warning fixes.
--- sound/isa/sb/emu8000_pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/isa/sb/emu8000_pcm.c +2 -2
@@ -435,7 +435,7 @@ enum {#define LOOP_WRITE (rec, offset, _buf, count, mode) \ do { \ struct snd_emu8000 *emu = (rec)->emu; \ - unsigned short *buf = (unsigned short *)(_buf); \ + unsigned short *buf = (__force unsigned short *)(_buf); \ snd_emu8000_write_wait(emu, 1); \ EMU8000_SMALW_WRITE(emu, offset); \ while (count > 0) { \
@@ -492,7 +492,7 @@ static int emu8k_pcm_silence(struct snd_pcm_substream *subs,#define LOOP_WRITE (rec, pos, _buf, count, mode) \ do { \ struct snd_emu8000 *emu = rec->emu; \ - unsigned short *buf = (unsigned short *)(_buf); \ + unsigned short *buf = (__force unsigned short *)(_buf); \ snd_emu8000_write_wait(emu, 1); \ EMU8000_SMALW_WRITE(emu, pos + rec->loop_start[0]); \ if (rec->voices > 1) \
Signature · 6 lines
2.16.4 _______________________________________________ Alsa-devel mailing list [email protected] https://mailman.alsa-project.org/mailman/listinfo/alsa-devel