v5 patch series fixes
This commit is contained in:
parent
beaa28b590
commit
a3f45537b6
|
|
@ -81,15 +81,15 @@ tascam_capture_pointer(struct snd_pcm_substream *substream)
|
||||||
if (!atomic_read(&tascam->capture_active))
|
if (!atomic_read(&tascam->capture_active))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
|
{
|
||||||
pos = tascam->capture_frames_processed;
|
pos = tascam->capture_frames_processed;
|
||||||
|
}
|
||||||
|
|
||||||
if (runtime->buffer_size == 0)
|
if (runtime->buffer_size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
u64 remainder = do_div(pos, runtime->buffer_size);
|
return do_div(pos, runtime->buffer_size);
|
||||||
|
|
||||||
return runtime ? remainder : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -179,8 +179,8 @@ void tascam_capture_work_handler(struct work_struct *work)
|
||||||
size_t write_ptr, read_ptr, available_data;
|
size_t write_ptr, read_ptr, available_data;
|
||||||
bool can_process;
|
bool can_process;
|
||||||
|
|
||||||
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
{
|
{
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
|
||||||
write_ptr = tascam->capture_ring_buffer_write_ptr;
|
write_ptr = tascam->capture_ring_buffer_write_ptr;
|
||||||
read_ptr = tascam->capture_ring_buffer_read_ptr;
|
read_ptr = tascam->capture_ring_buffer_read_ptr;
|
||||||
available_data = (write_ptr >= read_ptr) ?
|
available_data = (write_ptr >= read_ptr) ?
|
||||||
|
|
@ -223,8 +223,8 @@ void tascam_capture_work_handler(struct work_struct *work)
|
||||||
process_capture_routing_us144mkii(tascam, decoded_block,
|
process_capture_routing_us144mkii(tascam, decoded_block,
|
||||||
routed_block);
|
routed_block);
|
||||||
|
|
||||||
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
{
|
{
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
|
||||||
if (atomic_read(&tascam->capture_active)) {
|
if (atomic_read(&tascam->capture_active)) {
|
||||||
int f;
|
int f;
|
||||||
|
|
||||||
|
|
@ -280,13 +280,10 @@ void capture_urb_complete(struct urb *urb)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (urb->actual_length > 0) {
|
if (urb->actual_length > 0) {
|
||||||
size_t write_ptr;
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
size_t bytes_to_end;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
size_t write_ptr = tascam->capture_ring_buffer_write_ptr;
|
||||||
write_ptr = tascam->capture_ring_buffer_write_ptr;
|
size_t bytes_to_end = CAPTURE_RING_BUFFER_SIZE - write_ptr;
|
||||||
bytes_to_end = CAPTURE_RING_BUFFER_SIZE - write_ptr;
|
|
||||||
|
|
||||||
if (urb->actual_length > bytes_to_end) {
|
if (urb->actual_length > bytes_to_end) {
|
||||||
memcpy(tascam->capture_ring_buffer + write_ptr,
|
memcpy(tascam->capture_ring_buffer + write_ptr,
|
||||||
|
|
@ -323,3 +320,4 @@ void capture_urb_complete(struct urb *urb)
|
||||||
out:
|
out:
|
||||||
usb_put_urb(urb);
|
usb_put_urb(urb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,11 @@ static int tascam_line_out_get(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
struct snd_ctl_elem_value *ucontrol)
|
||||||
{
|
{
|
||||||
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
||||||
int val;
|
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
val = tascam->line_out_source;
|
{
|
||||||
ucontrol->value.enumerated.item[0] = val;
|
ucontrol->value.enumerated.item[0] = tascam->line_out_source;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,11 +81,13 @@ static int tascam_line_out_put(struct snd_kcontrol *kcontrol,
|
||||||
if (ucontrol->value.enumerated.item[0] > 1)
|
if (ucontrol->value.enumerated.item[0] > 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
|
{
|
||||||
if (tascam->line_out_source != ucontrol->value.enumerated.item[0]) {
|
if (tascam->line_out_source != ucontrol->value.enumerated.item[0]) {
|
||||||
tascam->line_out_source = ucontrol->value.enumerated.item[0];
|
tascam->line_out_source = ucontrol->value.enumerated.item[0];
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -122,11 +124,11 @@ static int tascam_digital_out_get(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
struct snd_ctl_elem_value *ucontrol)
|
||||||
{
|
{
|
||||||
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
||||||
int val;
|
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
val = tascam->digital_out_source;
|
{
|
||||||
ucontrol->value.enumerated.item[0] = val;
|
ucontrol->value.enumerated.item[0] = tascam->digital_out_source;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -151,11 +153,13 @@ static int tascam_digital_out_put(struct snd_kcontrol *kcontrol,
|
||||||
if (ucontrol->value.enumerated.item[0] > 1)
|
if (ucontrol->value.enumerated.item[0] > 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
|
{
|
||||||
if (tascam->digital_out_source != ucontrol->value.enumerated.item[0]) {
|
if (tascam->digital_out_source != ucontrol->value.enumerated.item[0]) {
|
||||||
tascam->digital_out_source = ucontrol->value.enumerated.item[0];
|
tascam->digital_out_source = ucontrol->value.enumerated.item[0];
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -210,11 +214,11 @@ static int tascam_capture_12_get(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
struct snd_ctl_elem_value *ucontrol)
|
||||||
{
|
{
|
||||||
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
||||||
int val;
|
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
val = tascam->capture_12_source;
|
{
|
||||||
ucontrol->value.enumerated.item[0] = val;
|
ucontrol->value.enumerated.item[0] = tascam->capture_12_source;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -239,11 +243,13 @@ static int tascam_capture_12_put(struct snd_kcontrol *kcontrol,
|
||||||
if (ucontrol->value.enumerated.item[0] > 1)
|
if (ucontrol->value.enumerated.item[0] > 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
|
{
|
||||||
if (tascam->capture_12_source != ucontrol->value.enumerated.item[0]) {
|
if (tascam->capture_12_source != ucontrol->value.enumerated.item[0]) {
|
||||||
tascam->capture_12_source = ucontrol->value.enumerated.item[0];
|
tascam->capture_12_source = ucontrol->value.enumerated.item[0];
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -281,11 +287,11 @@ static int tascam_capture_34_get(struct snd_kcontrol *kcontrol,
|
||||||
struct snd_ctl_elem_value *ucontrol)
|
struct snd_ctl_elem_value *ucontrol)
|
||||||
{
|
{
|
||||||
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
||||||
int val;
|
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
val = tascam->capture_34_source;
|
{
|
||||||
ucontrol->value.enumerated.item[0] = val;
|
ucontrol->value.enumerated.item[0] = tascam->capture_34_source;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,11 +316,13 @@ static int tascam_capture_34_put(struct snd_kcontrol *kcontrol,
|
||||||
if (ucontrol->value.enumerated.item[0] > 1)
|
if (ucontrol->value.enumerated.item[0] > 1)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
|
{
|
||||||
if (tascam->capture_34_source != ucontrol->value.enumerated.item[0]) {
|
if (tascam->capture_34_source != ucontrol->value.enumerated.item[0]) {
|
||||||
tascam->capture_34_source = ucontrol->value.enumerated.item[0];
|
tascam->capture_34_source = ucontrol->value.enumerated.item[0];
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -377,12 +385,13 @@ static int tascam_samplerate_get(struct snd_kcontrol *kcontrol,
|
||||||
int err;
|
int err;
|
||||||
u32 rate = 0;
|
u32 rate = 0;
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
|
{
|
||||||
if (tascam->current_rate > 0) {
|
if (tascam->current_rate > 0) {
|
||||||
ucontrol->value.integer.value[0] = tascam->current_rate;
|
ucontrol->value.integer.value[0] = tascam->current_rate;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// Lock is released here before kmalloc and usb_control_msg
|
}
|
||||||
|
|
||||||
buf = kmalloc(3, GFP_KERNEL);
|
buf = kmalloc(3, GFP_KERNEL);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
|
|
|
||||||
|
|
@ -117,8 +117,8 @@ static void tascam_midi_in_trigger(struct snd_rawmidi_substream *substream,
|
||||||
|
|
||||||
if (up) {
|
if (up) {
|
||||||
if (atomic_xchg(&tascam->midi_in_active, 1) == 0) {
|
if (atomic_xchg(&tascam->midi_in_active, 1) == 0) {
|
||||||
|
scoped_guard(spinlock_irqsave, &tascam->midi_in_lock)
|
||||||
{
|
{
|
||||||
guard(spinlock_irqsave)(&tascam->midi_in_lock);
|
|
||||||
kfifo_reset(&tascam->midi_in_fifo);
|
kfifo_reset(&tascam->midi_in_fifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,8 +189,8 @@ void tascam_midi_out_urb_complete(struct urb *urb)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scoped_guard(spinlock_irqsave, &tascam->midi_out_lock)
|
||||||
{
|
{
|
||||||
guard(spinlock_irqsave)(&tascam->midi_out_lock);
|
|
||||||
clear_bit(urb_index, &tascam->midi_out_urbs_in_flight);
|
clear_bit(urb_index, &tascam->midi_out_urbs_in_flight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,9 +227,8 @@ static void tascam_midi_out_work_handler(struct work_struct *work)
|
||||||
u8 *buf;
|
u8 *buf;
|
||||||
int bytes_to_send;
|
int bytes_to_send;
|
||||||
|
|
||||||
|
scoped_guard(spinlock_irqsave, &tascam->midi_out_lock)
|
||||||
{
|
{
|
||||||
guard(spinlock_irqsave)(&tascam->midi_out_lock);
|
|
||||||
|
|
||||||
urb_index = -1;
|
urb_index = -1;
|
||||||
for (i = 0; i < NUM_MIDI_OUT_URBS; i++) {
|
for (i = 0; i < NUM_MIDI_OUT_URBS; i++) {
|
||||||
if (!test_bit(
|
if (!test_bit(
|
||||||
|
|
@ -268,8 +267,8 @@ static void tascam_midi_out_work_handler(struct work_struct *work)
|
||||||
tascam->card->dev,
|
tascam->card->dev,
|
||||||
"Failed to submit MIDI OUT URB %d\n",
|
"Failed to submit MIDI OUT URB %d\n",
|
||||||
urb_index);
|
urb_index);
|
||||||
|
scoped_guard(spinlock_irqsave, &tascam->midi_out_lock)
|
||||||
{
|
{
|
||||||
guard(spinlock_irqsave)(&tascam->midi_out_lock);
|
|
||||||
clear_bit(urb_index,
|
clear_bit(urb_index,
|
||||||
&tascam->midi_out_urbs_in_flight);
|
&tascam->midi_out_urbs_in_flight);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,7 @@ int tascam_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
||||||
|
|
||||||
if (do_start) {
|
if (do_start) {
|
||||||
if (atomic_read(&tascam->active_urbs) > 0) {
|
if (atomic_read(&tascam->active_urbs) > 0) {
|
||||||
dev_WARN(tascam->card->dev,
|
dev_warn(tascam->card->dev,
|
||||||
"Cannot start, URBs still active.\n");
|
"Cannot start, URBs still active.\n");
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,15 +127,15 @@ tascam_playback_pointer(struct snd_pcm_substream *substream)
|
||||||
if (!atomic_read(&tascam->playback_active))
|
if (!atomic_read(&tascam->playback_active))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
guard(spinlock_irqsave)(&tascam->lock);
|
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||||
|
{
|
||||||
pos = tascam->playback_frames_consumed;
|
pos = tascam->playback_frames_consumed;
|
||||||
|
}
|
||||||
|
|
||||||
if (runtime->buffer_size == 0)
|
if (runtime->buffer_size == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
u64 remainder = do_div(pos, runtime->buffer_size);
|
return do_div(pos, runtime->buffer_size);
|
||||||
|
|
||||||
return runtime ? remainder : 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue