Commit 13e9a3ed authored by Takashi Iwai's avatar Takashi Iwai

ALSA: sb: Proper endian notations

The data types defined in SB CSP driver code are all in little-endian,
hence the proper type like __le32 should be used.

Spotted by sparse, a warning like:
  sound/isa/sb/sb16_csp.c:330:14: warning: cast to restricted __le32
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 7e49aadf
...@@ -60,18 +60,18 @@ MODULE_FIRMWARE("sb16/ima_adpcm_capture.csp"); ...@@ -60,18 +60,18 @@ MODULE_FIRMWARE("sb16/ima_adpcm_capture.csp");
* RIFF data format * RIFF data format
*/ */
struct riff_header { struct riff_header {
__u32 name; __le32 name;
__u32 len; __le32 len;
}; };
struct desc_header { struct desc_header {
struct riff_header info; struct riff_header info;
__u16 func_nr; __le16 func_nr;
__u16 VOC_type; __le16 VOC_type;
__u16 flags_play_rec; __le16 flags_play_rec;
__u16 flags_16bit_8bit; __le16 flags_16bit_8bit;
__u16 flags_stereo_mono; __le16 flags_stereo_mono;
__u16 flags_rates; __le16 flags_rates;
}; };
/* /*
...@@ -314,7 +314,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, ...@@ -314,7 +314,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
unsigned short func_nr = 0; unsigned short func_nr = 0;
struct riff_header file_h, item_h, code_h; struct riff_header file_h, item_h, code_h;
__u32 item_type; __le32 item_type;
struct desc_header funcdesc_h; struct desc_header funcdesc_h;
unsigned long flags; unsigned long flags;
...@@ -326,7 +326,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, ...@@ -326,7 +326,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
if (copy_from_user(&file_h, data_ptr, sizeof(file_h))) if (copy_from_user(&file_h, data_ptr, sizeof(file_h)))
return -EFAULT; return -EFAULT;
if ((file_h.name != RIFF_HEADER) || if ((le32_to_cpu(file_h.name) != RIFF_HEADER) ||
(le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) { (le32_to_cpu(file_h.len) >= SNDRV_SB_CSP_MAX_MICROCODE_FILE_SIZE - sizeof(file_h))) {
snd_printd("%s: Invalid RIFF header\n", __func__); snd_printd("%s: Invalid RIFF header\n", __func__);
return -EINVAL; return -EINVAL;
...@@ -336,7 +336,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, ...@@ -336,7 +336,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
if (copy_from_user(&item_type, data_ptr, sizeof(item_type))) if (copy_from_user(&item_type, data_ptr, sizeof(item_type)))
return -EFAULT; return -EFAULT;
if (item_type != CSP__HEADER) { if (le32_to_cpu(item_type) != CSP__HEADER) {
snd_printd("%s: Invalid RIFF file type\n", __func__); snd_printd("%s: Invalid RIFF file type\n", __func__);
return -EINVAL; return -EINVAL;
} }
...@@ -346,12 +346,12 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, ...@@ -346,12 +346,12 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
if (copy_from_user(&item_h, data_ptr, sizeof(item_h))) if (copy_from_user(&item_h, data_ptr, sizeof(item_h)))
return -EFAULT; return -EFAULT;
data_ptr += sizeof(item_h); data_ptr += sizeof(item_h);
if (item_h.name != LIST_HEADER) if (le32_to_cpu(item_h.name) != LIST_HEADER)
continue; continue;
if (copy_from_user(&item_type, data_ptr, sizeof(item_type))) if (copy_from_user(&item_type, data_ptr, sizeof(item_type)))
return -EFAULT; return -EFAULT;
switch (item_type) { switch (le32_to_cpu(item_type)) {
case FUNC_HEADER: case FUNC_HEADER:
if (copy_from_user(&funcdesc_h, data_ptr + sizeof(item_type), sizeof(funcdesc_h))) if (copy_from_user(&funcdesc_h, data_ptr + sizeof(item_type), sizeof(funcdesc_h)))
return -EFAULT; return -EFAULT;
...@@ -378,7 +378,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, ...@@ -378,7 +378,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
return -EFAULT; return -EFAULT;
/* init microcode blocks */ /* init microcode blocks */
if (code_h.name != INIT_HEADER) if (le32_to_cpu(code_h.name) != INIT_HEADER)
break; break;
data_ptr += sizeof(code_h); data_ptr += sizeof(code_h);
err = snd_sb_csp_load_user(p, data_ptr, le32_to_cpu(code_h.len), err = snd_sb_csp_load_user(p, data_ptr, le32_to_cpu(code_h.len),
...@@ -391,7 +391,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p, ...@@ -391,7 +391,7 @@ static int snd_sb_csp_riff_load(struct snd_sb_csp * p,
if (copy_from_user(&code_h, data_ptr, sizeof(code_h))) if (copy_from_user(&code_h, data_ptr, sizeof(code_h)))
return -EFAULT; return -EFAULT;
if (code_h.name != MAIN_HEADER) { if (le32_to_cpu(code_h.name) != MAIN_HEADER) {
snd_printd("%s: Missing 'main' microcode\n", __func__); snd_printd("%s: Missing 'main' microcode\n", __func__);
return -EINVAL; return -EINVAL;
} }
......
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