ALSA: ca0106: Use guard() for spin locks
Clean up the code using guard() for spin locks. Merely code refactoring, and no behavior change. Signed-off-by: Takashi Iwai <tiwai@suse.de> Link: https://patch.msgid.link/20250829144342.4290-16-tiwai@suse.depull/476/head
parent
637a399944
commit
22ec127926
|
|
@ -332,16 +332,13 @@ unsigned int snd_ca0106_ptr_read(struct snd_ca0106 * emu,
|
||||||
unsigned int reg,
|
unsigned int reg,
|
||||||
unsigned int chn)
|
unsigned int chn)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
unsigned int regptr;
|
||||||
unsigned int regptr, val;
|
|
||||||
|
|
||||||
regptr = (reg << 16) | chn;
|
regptr = (reg << 16) | chn;
|
||||||
|
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
guard(spinlock_irqsave)(&emu->emu_lock);
|
||||||
outl(regptr, emu->port + CA0106_PTR);
|
outl(regptr, emu->port + CA0106_PTR);
|
||||||
val = inl(emu->port + CA0106_DATA);
|
return inl(emu->port + CA0106_DATA);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void snd_ca0106_ptr_write(struct snd_ca0106 *emu,
|
void snd_ca0106_ptr_write(struct snd_ca0106 *emu,
|
||||||
|
|
@ -350,14 +347,12 @@ void snd_ca0106_ptr_write(struct snd_ca0106 *emu,
|
||||||
unsigned int data)
|
unsigned int data)
|
||||||
{
|
{
|
||||||
unsigned int regptr;
|
unsigned int regptr;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
regptr = (reg << 16) | chn;
|
regptr = (reg << 16) | chn;
|
||||||
|
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
guard(spinlock_irqsave)(&emu->emu_lock);
|
||||||
outl(regptr, emu->port + CA0106_PTR);
|
outl(regptr, emu->port + CA0106_PTR);
|
||||||
outl(data, emu->port + CA0106_DATA);
|
outl(data, emu->port + CA0106_DATA);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int snd_ca0106_spi_write(struct snd_ca0106 * emu,
|
int snd_ca0106_spi_write(struct snd_ca0106 * emu,
|
||||||
|
|
@ -451,24 +446,20 @@ int snd_ca0106_i2c_write(struct snd_ca0106 *emu,
|
||||||
|
|
||||||
static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb)
|
static void snd_ca0106_intr_enable(struct snd_ca0106 *emu, unsigned int intrenb)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
|
||||||
unsigned int intr_enable;
|
unsigned int intr_enable;
|
||||||
|
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
guard(spinlock_irqsave)(&emu->emu_lock);
|
||||||
intr_enable = inl(emu->port + CA0106_INTE) | intrenb;
|
intr_enable = inl(emu->port + CA0106_INTE) | intrenb;
|
||||||
outl(intr_enable, emu->port + CA0106_INTE);
|
outl(intr_enable, emu->port + CA0106_INTE);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb)
|
static void snd_ca0106_intr_disable(struct snd_ca0106 *emu, unsigned int intrenb)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
|
||||||
unsigned int intr_enable;
|
unsigned int intr_enable;
|
||||||
|
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
guard(spinlock_irqsave)(&emu->emu_lock);
|
||||||
intr_enable = inl(emu->port + CA0106_INTE) & ~intrenb;
|
intr_enable = inl(emu->port + CA0106_INTE) & ~intrenb;
|
||||||
outl(intr_enable, emu->port + CA0106_INTE);
|
outl(intr_enable, emu->port + CA0106_INTE);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1138,26 +1129,20 @@ static unsigned short snd_ca0106_ac97_read(struct snd_ac97 *ac97,
|
||||||
unsigned short reg)
|
unsigned short reg)
|
||||||
{
|
{
|
||||||
struct snd_ca0106 *emu = ac97->private_data;
|
struct snd_ca0106 *emu = ac97->private_data;
|
||||||
unsigned long flags;
|
|
||||||
unsigned short val;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
guard(spinlock_irqsave)(&emu->emu_lock);
|
||||||
outb(reg, emu->port + CA0106_AC97ADDRESS);
|
outb(reg, emu->port + CA0106_AC97ADDRESS);
|
||||||
val = inw(emu->port + CA0106_AC97DATA);
|
return inw(emu->port + CA0106_AC97DATA);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void snd_ca0106_ac97_write(struct snd_ac97 *ac97,
|
static void snd_ca0106_ac97_write(struct snd_ac97 *ac97,
|
||||||
unsigned short reg, unsigned short val)
|
unsigned short reg, unsigned short val)
|
||||||
{
|
{
|
||||||
struct snd_ca0106 *emu = ac97->private_data;
|
struct snd_ca0106 *emu = ac97->private_data;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
guard(spinlock_irqsave)(&emu->emu_lock);
|
||||||
outb(reg, emu->port + CA0106_AC97ADDRESS);
|
outb(reg, emu->port + CA0106_AC97ADDRESS);
|
||||||
outw(val, emu->port + CA0106_AC97DATA);
|
outw(val, emu->port + CA0106_AC97DATA);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_ca0106_ac97(struct snd_ca0106 *chip)
|
static int snd_ca0106_ac97(struct snd_ca0106 *chip)
|
||||||
|
|
|
||||||
|
|
@ -281,16 +281,14 @@ static void snd_ca0106_proc_reg_write32(struct snd_info_entry *entry,
|
||||||
struct snd_info_buffer *buffer)
|
struct snd_info_buffer *buffer)
|
||||||
{
|
{
|
||||||
struct snd_ca0106 *emu = entry->private_data;
|
struct snd_ca0106 *emu = entry->private_data;
|
||||||
unsigned long flags;
|
|
||||||
char line[64];
|
char line[64];
|
||||||
u32 reg, val;
|
u32 reg, val;
|
||||||
while (!snd_info_get_line(buffer, line, sizeof(line))) {
|
while (!snd_info_get_line(buffer, line, sizeof(line))) {
|
||||||
if (sscanf(line, "%x %x", ®, &val) != 2)
|
if (sscanf(line, "%x %x", ®, &val) != 2)
|
||||||
continue;
|
continue;
|
||||||
if (reg < 0x40 && val <= 0xffffffff) {
|
if (reg < 0x40 && val <= 0xffffffff) {
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
guard(spinlock_irqsave)(&emu->emu_lock);
|
||||||
outl(val, emu->port + (reg & 0xfffffffc));
|
outl(val, emu->port + (reg & 0xfffffffc));
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -300,13 +298,13 @@ static void snd_ca0106_proc_reg_read32(struct snd_info_entry *entry,
|
||||||
{
|
{
|
||||||
struct snd_ca0106 *emu = entry->private_data;
|
struct snd_ca0106 *emu = entry->private_data;
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
unsigned long flags;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
snd_iprintf(buffer, "Registers:\n\n");
|
snd_iprintf(buffer, "Registers:\n\n");
|
||||||
for(i = 0; i < 0x20; i+=4) {
|
for(i = 0; i < 0x20; i+=4) {
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
scoped_guard(spinlock_irqsave, &emu->emu_lock) {
|
||||||
value = inl(emu->port + i);
|
value = inl(emu->port + i);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
}
|
||||||
snd_iprintf(buffer, "Register %02X: %08lX\n", i, value);
|
snd_iprintf(buffer, "Register %02X: %08lX\n", i, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -316,13 +314,13 @@ static void snd_ca0106_proc_reg_read16(struct snd_info_entry *entry,
|
||||||
{
|
{
|
||||||
struct snd_ca0106 *emu = entry->private_data;
|
struct snd_ca0106 *emu = entry->private_data;
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
unsigned long flags;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
snd_iprintf(buffer, "Registers:\n\n");
|
snd_iprintf(buffer, "Registers:\n\n");
|
||||||
for(i = 0; i < 0x20; i+=2) {
|
for(i = 0; i < 0x20; i+=2) {
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
scoped_guard(spinlock_irqsave, &emu->emu_lock) {
|
||||||
value = inw(emu->port + i);
|
value = inw(emu->port + i);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
}
|
||||||
snd_iprintf(buffer, "Register %02X: %04X\n", i, value);
|
snd_iprintf(buffer, "Register %02X: %04X\n", i, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -332,13 +330,13 @@ static void snd_ca0106_proc_reg_read8(struct snd_info_entry *entry,
|
||||||
{
|
{
|
||||||
struct snd_ca0106 *emu = entry->private_data;
|
struct snd_ca0106 *emu = entry->private_data;
|
||||||
unsigned int value;
|
unsigned int value;
|
||||||
unsigned long flags;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
snd_iprintf(buffer, "Registers:\n\n");
|
snd_iprintf(buffer, "Registers:\n\n");
|
||||||
for(i = 0; i < 0x20; i+=1) {
|
for(i = 0; i < 0x20; i+=1) {
|
||||||
spin_lock_irqsave(&emu->emu_lock, flags);
|
scoped_guard(spinlock_irqsave, &emu->emu_lock) {
|
||||||
value = inb(emu->port + i);
|
value = inb(emu->port + i);
|
||||||
spin_unlock_irqrestore(&emu->emu_lock, flags);
|
}
|
||||||
snd_iprintf(buffer, "Register %02X: %02X\n", i, value);
|
snd_iprintf(buffer, "Register %02X: %02X\n", i, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,58 +45,54 @@ static void ca_midi_interrupt(struct snd_ca_midi *midi, unsigned int status)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock(&midi->input_lock);
|
scoped_guard(spinlock, &midi->input_lock) {
|
||||||
if ((status & midi->ipr_rx) && ca_midi_input_avail(midi)) {
|
if ((status & midi->ipr_rx) && ca_midi_input_avail(midi)) {
|
||||||
if (!(midi->midi_mode & CA_MIDI_MODE_INPUT)) {
|
if (!(midi->midi_mode & CA_MIDI_MODE_INPUT)) {
|
||||||
ca_midi_clear_rx(midi);
|
ca_midi_clear_rx(midi);
|
||||||
} else {
|
} else {
|
||||||
byte = ca_midi_read_data(midi);
|
byte = ca_midi_read_data(midi);
|
||||||
if(midi->substream_input)
|
if (midi->substream_input)
|
||||||
snd_rawmidi_receive(midi->substream_input, &byte, 1);
|
snd_rawmidi_receive(midi->substream_input, &byte, 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&midi->input_lock);
|
|
||||||
|
|
||||||
spin_lock(&midi->output_lock);
|
scoped_guard(spinlock, &midi->output_lock) {
|
||||||
if ((status & midi->ipr_tx) && ca_midi_output_ready(midi)) {
|
if ((status & midi->ipr_tx) && ca_midi_output_ready(midi)) {
|
||||||
if (midi->substream_output &&
|
if (midi->substream_output &&
|
||||||
snd_rawmidi_transmit(midi->substream_output, &byte, 1) == 1) {
|
snd_rawmidi_transmit(midi->substream_output, &byte, 1) == 1) {
|
||||||
ca_midi_write_data(midi, byte);
|
ca_midi_write_data(midi, byte);
|
||||||
} else {
|
} else {
|
||||||
midi->interrupt_disable(midi,midi->tx_enable);
|
midi->interrupt_disable(midi, midi->tx_enable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock(&midi->output_lock);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ca_midi_cmd(struct snd_ca_midi *midi, unsigned char cmd, int ack)
|
static void ca_midi_cmd(struct snd_ca_midi *midi, unsigned char cmd, int ack)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
|
||||||
int timeout, ok;
|
int timeout, ok;
|
||||||
|
|
||||||
spin_lock_irqsave(&midi->input_lock, flags);
|
scoped_guard(spinlock_irqsave, &midi->input_lock) {
|
||||||
ca_midi_write_data(midi, 0x00);
|
ca_midi_write_data(midi, 0x00);
|
||||||
/* ca_midi_clear_rx(midi); */
|
/* ca_midi_clear_rx(midi); */
|
||||||
|
|
||||||
ca_midi_write_cmd(midi, cmd);
|
ca_midi_write_cmd(midi, cmd);
|
||||||
if (ack) {
|
if (ack) {
|
||||||
ok = 0;
|
ok = 0;
|
||||||
timeout = 10000;
|
timeout = 10000;
|
||||||
while (!ok && timeout-- > 0) {
|
while (!ok && timeout-- > 0) {
|
||||||
if (ca_midi_input_avail(midi)) {
|
if (ca_midi_input_avail(midi)) {
|
||||||
if (ca_midi_read_data(midi) == midi->ack)
|
if (ca_midi_read_data(midi) == midi->ack)
|
||||||
ok = 1;
|
ok = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!ok && ca_midi_read_data(midi) == midi->ack)
|
||||||
if (!ok && ca_midi_read_data(midi) == midi->ack)
|
ok = 1;
|
||||||
|
} else {
|
||||||
ok = 1;
|
ok = 1;
|
||||||
} else {
|
}
|
||||||
ok = 1;
|
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&midi->input_lock, flags);
|
|
||||||
if (!ok)
|
if (!ok)
|
||||||
pr_err("ca_midi_cmd: 0x%x failed at 0x%x (status = 0x%x, data = 0x%x)!!!\n",
|
pr_err("ca_midi_cmd: 0x%x failed at 0x%x (status = 0x%x, data = 0x%x)!!!\n",
|
||||||
cmd,
|
cmd,
|
||||||
|
|
@ -108,83 +104,69 @@ static void ca_midi_cmd(struct snd_ca_midi *midi, unsigned char cmd, int ack)
|
||||||
static int ca_midi_input_open(struct snd_rawmidi_substream *substream)
|
static int ca_midi_input_open(struct snd_rawmidi_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (snd_BUG_ON(!midi->dev_id))
|
if (snd_BUG_ON(!midi->dev_id))
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
spin_lock_irqsave(&midi->open_lock, flags);
|
scoped_guard(spinlock_irqsave, &midi->open_lock) {
|
||||||
midi->midi_mode |= CA_MIDI_MODE_INPUT;
|
midi->midi_mode |= CA_MIDI_MODE_INPUT;
|
||||||
midi->substream_input = substream;
|
midi->substream_input = substream;
|
||||||
if (!(midi->midi_mode & CA_MIDI_MODE_OUTPUT)) {
|
if (midi->midi_mode & CA_MIDI_MODE_OUTPUT)
|
||||||
spin_unlock_irqrestore(&midi->open_lock, flags);
|
return 0;
|
||||||
ca_midi_cmd(midi, midi->reset, 1);
|
|
||||||
ca_midi_cmd(midi, midi->enter_uart, 1);
|
|
||||||
} else {
|
|
||||||
spin_unlock_irqrestore(&midi->open_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
ca_midi_cmd(midi, midi->reset, 1);
|
||||||
|
ca_midi_cmd(midi, midi->enter_uart, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ca_midi_output_open(struct snd_rawmidi_substream *substream)
|
static int ca_midi_output_open(struct snd_rawmidi_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (snd_BUG_ON(!midi->dev_id))
|
if (snd_BUG_ON(!midi->dev_id))
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
spin_lock_irqsave(&midi->open_lock, flags);
|
scoped_guard(spinlock_irqsave, &midi->open_lock) {
|
||||||
midi->midi_mode |= CA_MIDI_MODE_OUTPUT;
|
midi->midi_mode |= CA_MIDI_MODE_OUTPUT;
|
||||||
midi->substream_output = substream;
|
midi->substream_output = substream;
|
||||||
if (!(midi->midi_mode & CA_MIDI_MODE_INPUT)) {
|
if (midi->midi_mode & CA_MIDI_MODE_INPUT)
|
||||||
spin_unlock_irqrestore(&midi->open_lock, flags);
|
return 0;
|
||||||
ca_midi_cmd(midi, midi->reset, 1);
|
|
||||||
ca_midi_cmd(midi, midi->enter_uart, 1);
|
|
||||||
} else {
|
|
||||||
spin_unlock_irqrestore(&midi->open_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
ca_midi_cmd(midi, midi->reset, 1);
|
||||||
|
ca_midi_cmd(midi, midi->enter_uart, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ca_midi_input_close(struct snd_rawmidi_substream *substream)
|
static int ca_midi_input_close(struct snd_rawmidi_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (snd_BUG_ON(!midi->dev_id))
|
if (snd_BUG_ON(!midi->dev_id))
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
spin_lock_irqsave(&midi->open_lock, flags);
|
scoped_guard(spinlock_irqsave, &midi->open_lock) {
|
||||||
midi->interrupt_disable(midi,midi->rx_enable);
|
midi->interrupt_disable(midi, midi->rx_enable);
|
||||||
midi->midi_mode &= ~CA_MIDI_MODE_INPUT;
|
midi->midi_mode &= ~CA_MIDI_MODE_INPUT;
|
||||||
midi->substream_input = NULL;
|
midi->substream_input = NULL;
|
||||||
if (!(midi->midi_mode & CA_MIDI_MODE_OUTPUT)) {
|
if (midi->midi_mode & CA_MIDI_MODE_OUTPUT)
|
||||||
spin_unlock_irqrestore(&midi->open_lock, flags);
|
return 0;
|
||||||
ca_midi_cmd(midi, midi->reset, 0);
|
|
||||||
} else {
|
|
||||||
spin_unlock_irqrestore(&midi->open_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
ca_midi_cmd(midi, midi->reset, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
|
static int ca_midi_output_close(struct snd_rawmidi_substream *substream)
|
||||||
{
|
{
|
||||||
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (snd_BUG_ON(!midi->dev_id))
|
if (snd_BUG_ON(!midi->dev_id))
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
spin_lock_irqsave(&midi->open_lock, flags);
|
scoped_guard(spinlock_irqsave, &midi->open_lock) {
|
||||||
|
midi->interrupt_disable(midi, midi->tx_enable);
|
||||||
midi->interrupt_disable(midi,midi->tx_enable);
|
midi->midi_mode &= ~CA_MIDI_MODE_OUTPUT;
|
||||||
midi->midi_mode &= ~CA_MIDI_MODE_OUTPUT;
|
midi->substream_output = NULL;
|
||||||
midi->substream_output = NULL;
|
if (midi->midi_mode & CA_MIDI_MODE_INPUT)
|
||||||
|
return 0;
|
||||||
if (!(midi->midi_mode & CA_MIDI_MODE_INPUT)) {
|
|
||||||
spin_unlock_irqrestore(&midi->open_lock, flags);
|
|
||||||
ca_midi_cmd(midi, midi->reset, 0);
|
|
||||||
} else {
|
|
||||||
spin_unlock_irqrestore(&midi->open_lock, flags);
|
|
||||||
}
|
}
|
||||||
|
ca_midi_cmd(midi, midi->reset, 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,7 +187,6 @@ static void ca_midi_input_trigger(struct snd_rawmidi_substream *substream, int u
|
||||||
static void ca_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
|
static void ca_midi_output_trigger(struct snd_rawmidi_substream *substream, int up)
|
||||||
{
|
{
|
||||||
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
struct snd_ca_midi *midi = substream->rmidi->private_data;
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
if (snd_BUG_ON(!midi->dev_id))
|
if (snd_BUG_ON(!midi->dev_id))
|
||||||
return;
|
return;
|
||||||
|
|
@ -214,25 +195,23 @@ static void ca_midi_output_trigger(struct snd_rawmidi_substream *substream, int
|
||||||
int max = 4;
|
int max = 4;
|
||||||
unsigned char byte;
|
unsigned char byte;
|
||||||
|
|
||||||
spin_lock_irqsave(&midi->output_lock, flags);
|
scoped_guard(spinlock_irqsave, &midi->output_lock) {
|
||||||
|
|
||||||
/* try to send some amount of bytes here before interrupts */
|
/* try to send some amount of bytes here before interrupts */
|
||||||
while (max > 0) {
|
while (max > 0) {
|
||||||
if (ca_midi_output_ready(midi)) {
|
if (ca_midi_output_ready(midi)) {
|
||||||
if (!(midi->midi_mode & CA_MIDI_MODE_OUTPUT) ||
|
if (!(midi->midi_mode & CA_MIDI_MODE_OUTPUT) ||
|
||||||
snd_rawmidi_transmit(substream, &byte, 1) != 1) {
|
snd_rawmidi_transmit(substream, &byte, 1) != 1) {
|
||||||
/* no more data */
|
/* no more data */
|
||||||
spin_unlock_irqrestore(&midi->output_lock, flags);
|
return;
|
||||||
return;
|
}
|
||||||
|
ca_midi_write_data(midi, byte);
|
||||||
|
max--;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
ca_midi_write_data(midi, byte);
|
|
||||||
max--;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&midi->output_lock, flags);
|
|
||||||
midi->interrupt_enable(midi,midi->tx_enable);
|
midi->interrupt_enable(midi,midi->tx_enable);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue