Commit 0e7ca66a authored by Takashi Iwai's avatar Takashi Iwai

ALSA: mixart: Proper endian notations

The miXart driver deals with big-endian values as raw data, while it
declares most of variables as u32.  This leads to sparse warnings like
  sound/pci/mixart/mixart.c:1203:23: warning: cast to restricted __be32

Fix them by properly defining the structs and add the explicit cast to
macros.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent be05e3de
...@@ -107,7 +107,7 @@ static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp, ...@@ -107,7 +107,7 @@ static int get_msg(struct mixart_mgr *mgr, struct mixart_msg *resp,
#ifndef __BIG_ENDIAN #ifndef __BIG_ENDIAN
size /= 4; /* u32 size */ size /= 4; /* u32 size */
for(i=0; i < size; i++) { for(i=0; i < size; i++) {
((u32*)resp->data)[i] = be32_to_cpu(((u32*)resp->data)[i]); ((u32*)resp->data)[i] = be32_to_cpu(((__be32*)resp->data)[i]);
} }
#endif #endif
...@@ -519,7 +519,7 @@ irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id) ...@@ -519,7 +519,7 @@ irqreturn_t snd_mixart_threaded_irq(int irq, void *dev_id)
/* Traces are text: the swapped msg_data has to be swapped back ! */ /* Traces are text: the swapped msg_data has to be swapped back ! */
int i; int i;
for(i=0; i<(resp.size/4); i++) { for(i=0; i<(resp.size/4); i++) {
(mixart_msg_data)[i] = cpu_to_be32((mixart_msg_data)[i]); ((__be32*)mixart_msg_data)[i] = cpu_to_be32((mixart_msg_data)[i]);
} }
#endif #endif
((char*)mixart_msg_data)[resp.size - 1] = 0; ((char*)mixart_msg_data)[resp.size - 1] = 0;
......
...@@ -73,30 +73,30 @@ static int mixart_wait_nice_for_register_value(struct mixart_mgr *mgr, ...@@ -73,30 +73,30 @@ static int mixart_wait_nice_for_register_value(struct mixart_mgr *mgr,
*/ */
struct snd_mixart_elf32_ehdr { struct snd_mixart_elf32_ehdr {
u8 e_ident[16]; u8 e_ident[16];
u16 e_type; __be16 e_type;
u16 e_machine; __be16 e_machine;
u32 e_version; __be32 e_version;
u32 e_entry; __be32 e_entry;
u32 e_phoff; __be32 e_phoff;
u32 e_shoff; __be32 e_shoff;
u32 e_flags; __be32 e_flags;
u16 e_ehsize; __be16 e_ehsize;
u16 e_phentsize; __be16 e_phentsize;
u16 e_phnum; __be16 e_phnum;
u16 e_shentsize; __be16 e_shentsize;
u16 e_shnum; __be16 e_shnum;
u16 e_shstrndx; __be16 e_shstrndx;
}; };
struct snd_mixart_elf32_phdr { struct snd_mixart_elf32_phdr {
u32 p_type; __be32 p_type;
u32 p_offset; __be32 p_offset;
u32 p_vaddr; __be32 p_vaddr;
u32 p_paddr; __be32 p_paddr;
u32 p_filesz; __be32 p_filesz;
u32 p_memsz; __be32 p_memsz;
u32 p_flags; __be32 p_flags;
u32 p_align; __be32 p_align;
}; };
static int mixart_load_elf(struct mixart_mgr *mgr, const struct firmware *dsp ) static int mixart_load_elf(struct mixart_mgr *mgr, const struct firmware *dsp )
......
...@@ -26,19 +26,19 @@ ...@@ -26,19 +26,19 @@
#include <sound/hwdep.h> #include <sound/hwdep.h>
#ifndef readl_be #ifndef readl_be
#define readl_be(x) be32_to_cpu(__raw_readl(x)) #define readl_be(x) be32_to_cpu((__force __be32)__raw_readl(x))
#endif #endif
#ifndef writel_be #ifndef writel_be
#define writel_be(data,addr) __raw_writel(cpu_to_be32(data),addr) #define writel_be(data,addr) __raw_writel((__force u32)cpu_to_be32(data),addr)
#endif #endif
#ifndef readl_le #ifndef readl_le
#define readl_le(x) le32_to_cpu(__raw_readl(x)) #define readl_le(x) le32_to_cpu((__force __le32)__raw_readl(x))
#endif #endif
#ifndef writel_le #ifndef writel_le
#define writel_le(data,addr) __raw_writel(cpu_to_le32(data),addr) #define writel_le(data,addr) __raw_writel((__force u32)cpu_to_le32(data),addr)
#endif #endif
#define MIXART_MEM(mgr,x) ((mgr)->mem[0].virt + (x)) #define MIXART_MEM(mgr,x) ((mgr)->mem[0].virt + (x))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment