aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeyslan G. Bem <geyslan@gmail.com>2013-10-17 18:57:12 -0400
committerTakashi Iwai <tiwai@suse.de>2013-10-18 02:58:24 -0400
commitf1b4863a871d1ca2984bdaa8c88598690530a65c (patch)
tree1e21f32ea17328f279f9f67ebd2cf370def22abe
parenta4e9a38b40a0e2f7dad1a0b355896d23fbdd16e0 (diff)
ALSA: emu10k1: code refactoring
Partially restructures _snd_emu10k1_audigy_init_efx() and _snd_emu10k1_init_efx() functions. Be noted that the cast is demanded to use '__user'. So, in these cases, avoid patches based on the coccinelle 'drop_kmalloc_cast' semantic patch. Signed-off-by: Geyslan G. Bem <geyslan@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/emu10k1/emufx.c76
1 files changed, 45 insertions, 31 deletions
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 0275209ca82e..1f9c7c4bbcd8 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -1182,15 +1182,20 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
1182 u32 *gpr_map; 1182 u32 *gpr_map;
1183 mm_segment_t seg; 1183 mm_segment_t seg;
1184 1184
1185 if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL || 1185 err = -ENOMEM;
1186 (icode->gpr_map = (u_int32_t __user *) 1186 icode = kzalloc(sizeof(*icode), GFP_KERNEL);
1187 kcalloc(512 + 256 + 256 + 2 * 1024, sizeof(u_int32_t), 1187 if (!icode)
1188 GFP_KERNEL)) == NULL || 1188 return err;
1189 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, 1189
1190 sizeof(*controls), GFP_KERNEL)) == NULL) { 1190 icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024,
1191 err = -ENOMEM; 1191 sizeof(u_int32_t), GFP_KERNEL);
1192 goto __err; 1192 if (!icode->gpr_map)
1193 } 1193 goto __err_gpr;
1194 controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
1195 sizeof(*controls), GFP_KERNEL);
1196 if (!controls)
1197 goto __err_ctrls;
1198
1194 gpr_map = (u32 __force *)icode->gpr_map; 1199 gpr_map = (u32 __force *)icode->gpr_map;
1195 1200
1196 icode->tram_data_map = icode->gpr_map + 512; 1201 icode->tram_data_map = icode->gpr_map + 512;
@@ -1741,12 +1746,12 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
1741 emu->support_tlv = 0; /* clear again */ 1746 emu->support_tlv = 0; /* clear again */
1742 snd_leave_user(seg); 1747 snd_leave_user(seg);
1743 1748
1744 __err: 1749__err:
1745 kfree(controls); 1750 kfree(controls);
1746 if (icode != NULL) { 1751__err_ctrls:
1747 kfree((void __force *)icode->gpr_map); 1752 kfree((void __force *)icode->gpr_map);
1748 kfree(icode); 1753__err_gpr:
1749 } 1754 kfree(icode);
1750 return err; 1755 return err;
1751} 1756}
1752 1757
@@ -1813,18 +1818,26 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
1813 u32 *gpr_map; 1818 u32 *gpr_map;
1814 mm_segment_t seg; 1819 mm_segment_t seg;
1815 1820
1816 if ((icode = kzalloc(sizeof(*icode), GFP_KERNEL)) == NULL) 1821 err = -ENOMEM;
1817 return -ENOMEM; 1822 icode = kzalloc(sizeof(*icode), GFP_KERNEL);
1818 if ((icode->gpr_map = (u_int32_t __user *) 1823 if (!icode)
1819 kcalloc(256 + 160 + 160 + 2 * 512, sizeof(u_int32_t), 1824 return err;
1820 GFP_KERNEL)) == NULL || 1825
1821 (controls = kcalloc(SND_EMU10K1_GPR_CONTROLS, 1826 icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512,
1822 sizeof(struct snd_emu10k1_fx8010_control_gpr), 1827 sizeof(u_int32_t), GFP_KERNEL);
1823 GFP_KERNEL)) == NULL || 1828 if (!icode->gpr_map)
1824 (ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL)) == NULL) { 1829 goto __err_gpr;
1825 err = -ENOMEM; 1830
1826 goto __err; 1831 controls = kcalloc(SND_EMU10K1_GPR_CONTROLS,
1827 } 1832 sizeof(struct snd_emu10k1_fx8010_control_gpr),
1833 GFP_KERNEL);
1834 if (!controls)
1835 goto __err_ctrls;
1836
1837 ipcm = kzalloc(sizeof(*ipcm), GFP_KERNEL);
1838 if (!ipcm)
1839 goto __err_ipcm;
1840
1828 gpr_map = (u32 __force *)icode->gpr_map; 1841 gpr_map = (u32 __force *)icode->gpr_map;
1829 1842
1830 icode->tram_data_map = icode->gpr_map + 256; 1843 icode->tram_data_map = icode->gpr_map + 256;
@@ -2363,13 +2376,14 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
2363 snd_leave_user(seg); 2376 snd_leave_user(seg);
2364 if (err >= 0) 2377 if (err >= 0)
2365 err = snd_emu10k1_ipcm_poke(emu, ipcm); 2378 err = snd_emu10k1_ipcm_poke(emu, ipcm);
2366 __err: 2379__err:
2367 kfree(ipcm); 2380 kfree(ipcm);
2381__err_ipcm:
2368 kfree(controls); 2382 kfree(controls);
2369 if (icode != NULL) { 2383__err_ctrls:
2370 kfree((void __force *)icode->gpr_map); 2384 kfree((void __force *)icode->gpr_map);
2371 kfree(icode); 2385__err_gpr:
2372 } 2386 kfree(icode);
2373 return err; 2387 return err;
2374} 2388}
2375 2389