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))
|
||||
return 0;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
pos = tascam->capture_frames_processed;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
pos = tascam->capture_frames_processed;
|
||||
}
|
||||
|
||||
if (runtime->buffer_size == 0)
|
||||
return 0;
|
||||
|
||||
u64 remainder = do_div(pos, runtime->buffer_size);
|
||||
|
||||
return runtime ? remainder : 0;
|
||||
return do_div(pos, runtime->buffer_size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -179,8 +179,8 @@ void tascam_capture_work_handler(struct work_struct *work)
|
|||
size_t write_ptr, read_ptr, available_data;
|
||||
bool can_process;
|
||||
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
write_ptr = tascam->capture_ring_buffer_write_ptr;
|
||||
read_ptr = tascam->capture_ring_buffer_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,
|
||||
routed_block);
|
||||
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
if (atomic_read(&tascam->capture_active)) {
|
||||
int f;
|
||||
|
||||
|
|
@ -280,13 +280,10 @@ void capture_urb_complete(struct urb *urb)
|
|||
goto out;
|
||||
|
||||
if (urb->actual_length > 0) {
|
||||
size_t write_ptr;
|
||||
size_t bytes_to_end;
|
||||
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
write_ptr = tascam->capture_ring_buffer_write_ptr;
|
||||
bytes_to_end = CAPTURE_RING_BUFFER_SIZE - write_ptr;
|
||||
size_t write_ptr = tascam->capture_ring_buffer_write_ptr;
|
||||
size_t bytes_to_end = CAPTURE_RING_BUFFER_SIZE - write_ptr;
|
||||
|
||||
if (urb->actual_length > bytes_to_end) {
|
||||
memcpy(tascam->capture_ring_buffer + write_ptr,
|
||||
|
|
@ -323,3 +320,4 @@ void capture_urb_complete(struct urb *urb)
|
|||
out:
|
||||
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 tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
||||
int val;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
val = tascam->line_out_source;
|
||||
ucontrol->value.enumerated.item[0] = val;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
ucontrol->value.enumerated.item[0] = tascam->line_out_source;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -81,10 +81,12 @@ static int tascam_line_out_put(struct snd_kcontrol *kcontrol,
|
|||
if (ucontrol->value.enumerated.item[0] > 1)
|
||||
return -EINVAL;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
if (tascam->line_out_source != ucontrol->value.enumerated.item[0]) {
|
||||
tascam->line_out_source = ucontrol->value.enumerated.item[0];
|
||||
changed = 1;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
if (tascam->line_out_source != ucontrol->value.enumerated.item[0]) {
|
||||
tascam->line_out_source = ucontrol->value.enumerated.item[0];
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
|
@ -122,11 +124,11 @@ static int tascam_digital_out_get(struct snd_kcontrol *kcontrol,
|
|||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
||||
int val;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
val = tascam->digital_out_source;
|
||||
ucontrol->value.enumerated.item[0] = val;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
ucontrol->value.enumerated.item[0] = tascam->digital_out_source;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -151,10 +153,12 @@ static int tascam_digital_out_put(struct snd_kcontrol *kcontrol,
|
|||
if (ucontrol->value.enumerated.item[0] > 1)
|
||||
return -EINVAL;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
if (tascam->digital_out_source != ucontrol->value.enumerated.item[0]) {
|
||||
tascam->digital_out_source = ucontrol->value.enumerated.item[0];
|
||||
changed = 1;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
if (tascam->digital_out_source != ucontrol->value.enumerated.item[0]) {
|
||||
tascam->digital_out_source = ucontrol->value.enumerated.item[0];
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
|
@ -210,11 +214,11 @@ static int tascam_capture_12_get(struct snd_kcontrol *kcontrol,
|
|||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
||||
int val;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
val = tascam->capture_12_source;
|
||||
ucontrol->value.enumerated.item[0] = val;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
ucontrol->value.enumerated.item[0] = tascam->capture_12_source;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -239,10 +243,12 @@ static int tascam_capture_12_put(struct snd_kcontrol *kcontrol,
|
|||
if (ucontrol->value.enumerated.item[0] > 1)
|
||||
return -EINVAL;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
if (tascam->capture_12_source != ucontrol->value.enumerated.item[0]) {
|
||||
tascam->capture_12_source = ucontrol->value.enumerated.item[0];
|
||||
changed = 1;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
if (tascam->capture_12_source != ucontrol->value.enumerated.item[0]) {
|
||||
tascam->capture_12_source = ucontrol->value.enumerated.item[0];
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
|
@ -281,11 +287,11 @@ static int tascam_capture_34_get(struct snd_kcontrol *kcontrol,
|
|||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
struct tascam_card *tascam = snd_kcontrol_chip(kcontrol);
|
||||
int val;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
val = tascam->capture_34_source;
|
||||
ucontrol->value.enumerated.item[0] = val;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
ucontrol->value.enumerated.item[0] = tascam->capture_34_source;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -310,10 +316,12 @@ static int tascam_capture_34_put(struct snd_kcontrol *kcontrol,
|
|||
if (ucontrol->value.enumerated.item[0] > 1)
|
||||
return -EINVAL;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
if (tascam->capture_34_source != ucontrol->value.enumerated.item[0]) {
|
||||
tascam->capture_34_source = ucontrol->value.enumerated.item[0];
|
||||
changed = 1;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
if (tascam->capture_34_source != ucontrol->value.enumerated.item[0]) {
|
||||
tascam->capture_34_source = ucontrol->value.enumerated.item[0];
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
|
@ -377,12 +385,13 @@ static int tascam_samplerate_get(struct snd_kcontrol *kcontrol,
|
|||
int err;
|
||||
u32 rate = 0;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
if (tascam->current_rate > 0) {
|
||||
ucontrol->value.integer.value[0] = tascam->current_rate;
|
||||
return 0;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
if (tascam->current_rate > 0) {
|
||||
ucontrol->value.integer.value[0] = tascam->current_rate;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// Lock is released here before kmalloc and usb_control_msg
|
||||
|
||||
buf = kmalloc(3, GFP_KERNEL);
|
||||
if (!buf)
|
||||
|
|
|
|||
|
|
@ -117,23 +117,23 @@ static void tascam_midi_in_trigger(struct snd_rawmidi_substream *substream,
|
|||
|
||||
if (up) {
|
||||
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);
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_MIDI_IN_URBS; i++) {
|
||||
usb_get_urb(tascam->midi_in_urbs[i]);
|
||||
usb_anchor_urb(tascam->midi_in_urbs[i],
|
||||
&tascam->midi_in_anchor);
|
||||
&tascam->midi_in_anchor);
|
||||
err = usb_submit_urb(tascam->midi_in_urbs[i],
|
||||
GFP_KERNEL);
|
||||
GFP_KERNEL);
|
||||
if (err < 0) {
|
||||
dev_err(tascam->card->dev,
|
||||
"Failed to submit MIDI IN URB %d: %d\n",
|
||||
i, err);
|
||||
usb_unanchor_urb(
|
||||
tascam->midi_in_urbs[i]);
|
||||
tascam->midi_in_urbs[i]);
|
||||
usb_put_urb(tascam->midi_in_urbs[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -189,8 +189,8 @@ void tascam_midi_out_urb_complete(struct urb *urb)
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
@ -227,9 +227,8 @@ static void tascam_midi_out_work_handler(struct work_struct *work)
|
|||
u8 *buf;
|
||||
int bytes_to_send;
|
||||
|
||||
scoped_guard(spinlock_irqsave, &tascam->midi_out_lock)
|
||||
{
|
||||
guard(spinlock_irqsave)(&tascam->midi_out_lock);
|
||||
|
||||
urb_index = -1;
|
||||
for (i = 0; i < NUM_MIDI_OUT_URBS; i++) {
|
||||
if (!test_bit(
|
||||
|
|
@ -265,11 +264,11 @@ static void tascam_midi_out_work_handler(struct work_struct *work)
|
|||
usb_anchor_urb(urb, &tascam->midi_out_anchor);
|
||||
if (usb_submit_urb(urb, GFP_KERNEL) < 0) {
|
||||
dev_err_ratelimited(
|
||||
tascam->card->dev,
|
||||
"Failed to submit MIDI OUT URB %d\n",
|
||||
urb_index);
|
||||
tascam->card->dev,
|
||||
"Failed to submit MIDI OUT URB %d\n",
|
||||
urb_index);
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* as evenly as possible.
|
||||
*/
|
||||
static void fpo_init_pattern(unsigned int size, unsigned int *pattern_array,
|
||||
unsigned int initial_value, int target_sum)
|
||||
unsigned int initial_value, int target_sum)
|
||||
{
|
||||
int diff, i;
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ fail:
|
|||
}
|
||||
|
||||
int tascam_pcm_hw_params(struct snd_pcm_substream *substream,
|
||||
struct snd_pcm_hw_params *params)
|
||||
struct snd_pcm_hw_params *params)
|
||||
{
|
||||
struct tascam_card *tascam = snd_pcm_substream_chip(substream);
|
||||
int err;
|
||||
|
|
@ -238,7 +238,7 @@ int tascam_pcm_hw_params(struct snd_pcm_substream *substream,
|
|||
int target_sum = tascam->fpo.sample_rate_khz -
|
||||
tascam->fpo.feedback_offset + i;
|
||||
fpo_init_pattern(8, tascam->fpo.full_frame_patterns[i],
|
||||
initial_value, target_sum);
|
||||
initial_value, target_sum);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ int tascam_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
|||
|
||||
if (do_start) {
|
||||
if (atomic_read(&tascam->active_urbs) > 0) {
|
||||
dev_WARN(tascam->card->dev,
|
||||
dev_warn(tascam->card->dev,
|
||||
"Cannot start, URBs still active.\n");
|
||||
return -EAGAIN;
|
||||
}
|
||||
|
|
@ -302,9 +302,9 @@ int tascam_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
|||
for (i = 0; i < NUM_FEEDBACK_URBS; i++) {
|
||||
usb_get_urb(tascam->feedback_urbs[i]);
|
||||
usb_anchor_urb(tascam->feedback_urbs[i],
|
||||
&tascam->feedback_anchor);
|
||||
&tascam->feedback_anchor);
|
||||
err = usb_submit_urb(tascam->feedback_urbs[i],
|
||||
GFP_ATOMIC);
|
||||
GFP_ATOMIC);
|
||||
if (err < 0) {
|
||||
usb_unanchor_urb(tascam->feedback_urbs[i]);
|
||||
usb_put_urb(tascam->feedback_urbs[i]);
|
||||
|
|
@ -316,9 +316,9 @@ int tascam_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
|
|||
for (i = 0; i < NUM_PLAYBACK_URBS; i++) {
|
||||
usb_get_urb(tascam->playback_urbs[i]);
|
||||
usb_anchor_urb(tascam->playback_urbs[i],
|
||||
&tascam->playback_anchor);
|
||||
&tascam->playback_anchor);
|
||||
err = usb_submit_urb(tascam->playback_urbs[i],
|
||||
GFP_ATOMIC);
|
||||
GFP_ATOMIC);
|
||||
if (err < 0) {
|
||||
usb_unanchor_urb(tascam->playback_urbs[i]);
|
||||
usb_put_urb(tascam->playback_urbs[i]);
|
||||
|
|
|
|||
|
|
@ -127,15 +127,15 @@ tascam_playback_pointer(struct snd_pcm_substream *substream)
|
|||
if (!atomic_read(&tascam->playback_active))
|
||||
return 0;
|
||||
|
||||
guard(spinlock_irqsave)(&tascam->lock);
|
||||
pos = tascam->playback_frames_consumed;
|
||||
scoped_guard(spinlock_irqsave, &tascam->lock)
|
||||
{
|
||||
pos = tascam->playback_frames_consumed;
|
||||
}
|
||||
|
||||
if (runtime->buffer_size == 0)
|
||||
return 0;
|
||||
|
||||
u64 remainder = do_div(pos, runtime->buffer_size);
|
||||
|
||||
return runtime ? remainder : 0;
|
||||
return do_div(pos, runtime->buffer_size);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue