From 5a23994ca3be73858d64b004001a8588cece9f60 Mon Sep 17 00:00:00 2001 From: Hridya Valsaraju Date: Tue, 21 Apr 2020 11:17:01 -0700 Subject: [PATCH] ANDROID: GKI: Resolve ABI diff for struct snd_usb_audio Adds member 'struct mutex dev_lock' to struct snd_usb_audio. Test: build Bug: 151372815 Signed-off-by: Hemant Kumar Change-Id: I9aafd93924025e71ef1362ea225396593cd64872 (cherry picked from commit f055b3843f78a67497bbab7da5ea6405823bb861) [hridya: partial cherry-pick from snapshot change] Signed-off-by: Hridya Valsaraju --- sound/usb/card.c | 2 ++ sound/usb/stream.c | 5 +++++ sound/usb/usbaudio.h | 1 + 3 files changed, 8 insertions(+) diff --git a/sound/usb/card.c b/sound/usb/card.c index e0ef5c29bd69..424450923061 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -430,6 +430,7 @@ static void snd_usb_audio_free(struct snd_card *card) list_for_each_entry_safe(ep, n, &chip->ep_list, list) snd_usb_endpoint_free(ep); + mutex_destroy(&chip->dev_lock); mutex_destroy(&chip->mutex); if (!atomic_read(&chip->shutdown)) dev_set_drvdata(&chip->dev->dev, NULL); @@ -557,6 +558,7 @@ static int snd_usb_audio_create(struct usb_interface *intf, chip = card->private_data; mutex_init(&chip->mutex); + mutex_init(&chip->dev_lock); init_waitqueue_head(&chip->shutdown_wait); chip->index = idx; chip->dev = dev; diff --git a/sound/usb/stream.c b/sound/usb/stream.c index 9d020bd0de17..c414dffa55f0 100644 --- a/sound/usb/stream.c +++ b/sound/usb/stream.c @@ -72,9 +72,14 @@ static void snd_usb_audio_stream_free(struct snd_usb_stream *stream) static void snd_usb_audio_pcm_free(struct snd_pcm *pcm) { struct snd_usb_stream *stream = pcm->private_data; + struct snd_usb_audio *chip; + if (stream) { + mutex_lock(&stream->chip->dev_lock); + chip = stream->chip; stream->pcm = NULL; snd_usb_audio_stream_free(stream); + mutex_unlock(&chip->dev_lock); } } diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h index d41098e84880..e6f0db7dc0fd 100644 --- a/sound/usb/usbaudio.h +++ b/sound/usb/usbaudio.h @@ -66,6 +66,7 @@ struct snd_usb_audio { */ struct usb_host_interface *ctrl_intf; /* the audio control interface */ + struct mutex dev_lock; /* to protect any race with disconnect */ int card_num; /* cache pcm card number to use upon disconnect */ void (*disconnect_cb)(struct snd_usb_audio *chip); /* callback to cleanup on disconnect */ };