mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 12:16:41 +00:00
ALSA: emu10k1: properly assert E-MU FPGA access constaints
Assert the validity of the registers and values, as them being out of range would indicate an error in the driver. Consequently, don't bother returning error codes; they were ignored everywhere anyway. Signed-off-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Link: https://lore.kernel.org/r/20230421141006.1005539-1-oswald.buddenhagen@gmx.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
02a0d9c281
commit
10f212bd7a
@ -1819,9 +1819,9 @@ unsigned int snd_emu10k1_ptr20_read(struct snd_emu10k1 * emu, unsigned int reg,
|
|||||||
void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data);
|
void snd_emu10k1_ptr20_write(struct snd_emu10k1 *emu, unsigned int reg, unsigned int chn, unsigned int data);
|
||||||
int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int data);
|
int snd_emu10k1_spi_write(struct snd_emu10k1 * emu, unsigned int data);
|
||||||
int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
|
int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
|
||||||
int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, u32 reg, u32 value);
|
void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value);
|
||||||
int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, u32 reg, u32 *value);
|
void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value);
|
||||||
int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, u32 dst, u32 src);
|
void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 src);
|
||||||
unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc);
|
unsigned int snd_emu10k1_efx_read(struct snd_emu10k1 *emu, unsigned int pc);
|
||||||
void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb);
|
void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb);
|
||||||
void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb);
|
void snd_emu10k1_intr_disable(struct snd_emu10k1 *emu, unsigned int intrenb);
|
||||||
|
@ -233,15 +233,15 @@ int snd_emu10k1_i2c_write(struct snd_emu10k1 *emu,
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, u32 reg, u32 value)
|
void snd_emu1010_fpga_write(struct snd_emu10k1 *emu, u32 reg, u32 value)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (reg > 0x3f)
|
if (snd_BUG_ON(reg > 0x3f))
|
||||||
return 1;
|
return;
|
||||||
reg += 0x40; /* 0x40 upwards are registers. */
|
reg += 0x40; /* 0x40 upwards are registers. */
|
||||||
if (value > 0x3f) /* 0 to 0x3f are values */
|
if (snd_BUG_ON(value > 0x3f)) /* 0 to 0x3f are values */
|
||||||
return 1;
|
return;
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
spin_lock_irqsave(&emu->emu_lock, flags);
|
||||||
outl(reg, emu->port + A_IOCFG);
|
outl(reg, emu->port + A_IOCFG);
|
||||||
udelay(10);
|
udelay(10);
|
||||||
@ -251,15 +251,13 @@ int snd_emu1010_fpga_write(struct snd_emu10k1 * emu, u32 reg, u32 value)
|
|||||||
udelay(10);
|
udelay(10);
|
||||||
outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */
|
outl(value | 0x80 , emu->port + A_IOCFG); /* High bit clocks the value into the fpga. */
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, u32 reg, u32 *value)
|
void snd_emu1010_fpga_read(struct snd_emu10k1 *emu, u32 reg, u32 *value)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
if (reg > 0x3f)
|
if (snd_BUG_ON(reg > 0x3f))
|
||||||
return 1;
|
return;
|
||||||
reg += 0x40; /* 0x40 upwards are registers. */
|
reg += 0x40; /* 0x40 upwards are registers. */
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
spin_lock_irqsave(&emu->emu_lock, flags);
|
||||||
outl(reg, emu->port + A_IOCFG);
|
outl(reg, emu->port + A_IOCFG);
|
||||||
@ -268,21 +266,21 @@ int snd_emu1010_fpga_read(struct snd_emu10k1 * emu, u32 reg, u32 *value)
|
|||||||
udelay(10);
|
udelay(10);
|
||||||
*value = ((inl(emu->port + A_IOCFG) >> 8) & 0x7f);
|
*value = ((inl(emu->port + A_IOCFG) >> 8) & 0x7f);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Each Destination has one and only one Source,
|
/* Each Destination has one and only one Source,
|
||||||
* but one Source can feed any number of Destinations simultaneously.
|
* but one Source can feed any number of Destinations simultaneously.
|
||||||
*/
|
*/
|
||||||
int snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 * emu, u32 dst, u32 src)
|
void snd_emu1010_fpga_link_dst_src_write(struct snd_emu10k1 *emu, u32 dst, u32 src)
|
||||||
{
|
{
|
||||||
snd_emu1010_fpga_write(emu, 0x00, ((dst >> 8) & 0x3f) );
|
if (snd_BUG_ON(dst & ~0x71f))
|
||||||
snd_emu1010_fpga_write(emu, 0x01, (dst & 0x3f) );
|
return;
|
||||||
snd_emu1010_fpga_write(emu, 0x02, ((src >> 8) & 0x3f) );
|
if (snd_BUG_ON(src & ~0x71f))
|
||||||
snd_emu1010_fpga_write(emu, 0x03, (src & 0x3f) );
|
return;
|
||||||
|
snd_emu1010_fpga_write(emu, 0x00, dst >> 8);
|
||||||
return 0;
|
snd_emu1010_fpga_write(emu, 0x01, dst & 0x1f);
|
||||||
|
snd_emu1010_fpga_write(emu, 0x02, src >> 8);
|
||||||
|
snd_emu1010_fpga_write(emu, 0x03, src & 0x1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb)
|
void snd_emu10k1_intr_enable(struct snd_emu10k1 *emu, unsigned int intrenb)
|
||||||
|
Loading…
Reference in New Issue
Block a user