From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, En-Shuo Hsu <enshuo@chromium.org>,
Yu-Hsuan Hsu <yuhsuan@chromium.org>, Takashi Iwai <tiwai@suse.de>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.14 06/30] ALSA: usb-audio: Unify mixer resume and reset_resume procedure
Date: Thu, 14 Oct 2021 16:54:11 +0200 [thread overview]
Message-ID: <20211014145209.731464673@linuxfoundation.org> (raw)
In-Reply-To: <20211014145209.520017940@linuxfoundation.org>
From: Takashi Iwai <tiwai@suse.de>
[ Upstream commit 7b9cf9036609428e845dc300aec13822ba2c4ab3 ]
USB-audio driver assumes that the normal resume would preserve the
device configuration while reset_resume wouldn't, and tries to restore
the mixer elements only at reset_resume callback. However, this seems
too naive, and some devices do behave differently, resetting the
volume at the normal resume; this resulted in the inconsistent volume
that surprised users.
This patch changes the mixer resume code to handle both the normal and
reset resume in the same way, always restoring the original mixer
element values. This allows us to unify the both callbacks as well as
dropping the no longer used reset_resume field, which ends up with a
good code reduction.
A slight behavior change by this patch is that now we assign
restore_mixer_value() as the default resume callback, and the function
is no longer called at reset-resume when the resume callback is
overridden by the quirk function. That is, if needed, the quirk
resume function would have to handle similarly as
restore_mixer_value() by itself.
Reported-by: En-Shuo Hsu <enshuo@chromium.org>
Cc: Yu-Hsuan Hsu <yuhsuan@chromium.org>
Link: https://lore.kernel.org/r/CADDZ45UPsbpAAqP6=ZkTT8BE-yLii4Y7xSDnjK550G2DhQsMew@mail.gmail.com
Link: https://lore.kernel.org/r/20210910105155.12862-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/usb/card.c | 18 ++++--------------
sound/usb/mixer.c | 26 ++++----------------------
sound/usb/mixer.h | 3 +--
sound/usb/mixer_quirks.c | 2 +-
4 files changed, 10 insertions(+), 39 deletions(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 6abfc9d079e7..fa75b7e72ad1 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -1020,7 +1020,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message)
return 0;
}
-static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
+static int usb_audio_resume(struct usb_interface *intf)
{
struct snd_usb_audio *chip = usb_get_intfdata(intf);
struct snd_usb_stream *as;
@@ -1046,7 +1046,7 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume)
* we just notify and restart the mixers
*/
list_for_each_entry(mixer, &chip->mixer_list, list) {
- err = snd_usb_mixer_resume(mixer, reset_resume);
+ err = snd_usb_mixer_resume(mixer);
if (err < 0)
goto err_out;
}
@@ -1066,20 +1066,10 @@ err_out:
atomic_dec(&chip->active); /* allow autopm after this point */
return err;
}
-
-static int usb_audio_resume(struct usb_interface *intf)
-{
- return __usb_audio_resume(intf, false);
-}
-
-static int usb_audio_reset_resume(struct usb_interface *intf)
-{
- return __usb_audio_resume(intf, true);
-}
#else
#define usb_audio_suspend NULL
#define usb_audio_resume NULL
-#define usb_audio_reset_resume NULL
+#define usb_audio_resume NULL
#endif /* CONFIG_PM */
static const struct usb_device_id usb_audio_ids [] = {
@@ -1101,7 +1091,7 @@ static struct usb_driver usb_audio_driver = {
.disconnect = usb_audio_disconnect,
.suspend = usb_audio_suspend,
.resume = usb_audio_resume,
- .reset_resume = usb_audio_reset_resume,
+ .reset_resume = usb_audio_resume,
.id_table = usb_audio_ids,
.supports_autosuspend = 1,
};
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index 9b713b4a5ec4..fa7cf982d39e 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -3655,33 +3655,16 @@ static int restore_mixer_value(struct usb_mixer_elem_list *list)
return 0;
}
-static int default_mixer_reset_resume(struct usb_mixer_elem_list *list)
-{
- int err;
-
- if (list->resume) {
- err = list->resume(list);
- if (err < 0)
- return err;
- }
- return restore_mixer_value(list);
-}
-
-int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume)
+int snd_usb_mixer_resume(struct usb_mixer_interface *mixer)
{
struct usb_mixer_elem_list *list;
- usb_mixer_elem_resume_func_t f;
int id, err;
/* restore cached mixer values */
for (id = 0; id < MAX_ID_ELEMS; id++) {
for_each_mixer_elem(list, mixer, id) {
- if (reset_resume)
- f = list->reset_resume;
- else
- f = list->resume;
- if (f) {
- err = f(list);
+ if (list->resume) {
+ err = list->resume(list);
if (err < 0)
return err;
}
@@ -3702,7 +3685,6 @@ void snd_usb_mixer_elem_init_std(struct usb_mixer_elem_list *list,
list->id = unitid;
list->dump = snd_usb_mixer_dump_cval;
#ifdef CONFIG_PM
- list->resume = NULL;
- list->reset_resume = default_mixer_reset_resume;
+ list->resume = restore_mixer_value;
#endif
}
diff --git a/sound/usb/mixer.h b/sound/usb/mixer.h
index ea41e7a1f7bf..16567912b998 100644
--- a/sound/usb/mixer.h
+++ b/sound/usb/mixer.h
@@ -70,7 +70,6 @@ struct usb_mixer_elem_list {
bool is_std_info;
usb_mixer_elem_dump_func_t dump;
usb_mixer_elem_resume_func_t resume;
- usb_mixer_elem_resume_func_t reset_resume;
};
/* iterate over mixer element list of the given unit id */
@@ -122,7 +121,7 @@ int snd_usb_mixer_vol_tlv(struct snd_kcontrol *kcontrol, int op_flag,
#ifdef CONFIG_PM
int snd_usb_mixer_suspend(struct usb_mixer_interface *mixer);
-int snd_usb_mixer_resume(struct usb_mixer_interface *mixer, bool reset_resume);
+int snd_usb_mixer_resume(struct usb_mixer_interface *mixer);
#endif
int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,
diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 0a3cb8fd7d00..4a4d3361ac04 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -151,7 +151,7 @@ static int add_single_ctl_with_resume(struct usb_mixer_interface *mixer,
*listp = list;
list->mixer = mixer;
list->id = id;
- list->reset_resume = resume;
+ list->resume = resume;
kctl = snd_ctl_new1(knew, list);
if (!kctl) {
kfree(list);
--
2.33.0
next prev parent reply other threads:[~2021-10-14 15:05 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-14 14:54 [PATCH 5.14 00/30] 5.14.13-rc1 review Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 01/30] ext4: check and update i_disksize properly Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 02/30] ext4: correct the error path of ext4_write_inline_data_end() Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 03/30] ASoC: Intel: sof_sdw: tag SoundWire BEs as non-atomic Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 04/30] ALSA: oxfw: fix transmission method for Loud models based on OXFW971 Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 05/30] interconnect: qcom: sdm660: Add missing a2noc qos clocks Greg Kroah-Hartman
2021-10-15 11:24 ` Georgi Djakov
2021-10-15 11:31 ` Greg Kroah-Hartman
2021-10-14 14:54 ` Greg Kroah-Hartman [this message]
2021-10-14 14:54 ` [PATCH 5.14 07/30] HID: apple: Fix logical maximum and usage maximum of Magic Keyboard JIS Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 08/30] netfilter: ip6_tables: zero-initialize fragment offset Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 09/30] HID: wacom: Add new Intuos BT (CTL-4100WL/CTL-6100WL) device IDs Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 10/30] ASoC: SOF: loader: release_firmware() on load failure to avoid batching Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 11/30] KVM: arm64: nvhe: Fix missing FORCE for hyp-reloc.S build rule Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 12/30] netfilter: nf_nat_masquerade: make async masq_inet6_event handling generic Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 13/30] netfilter: nf_nat_masquerade: defer conntrack walk to work queue Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 14/30] mac80211: Drop frames from invalid MAC address in ad-hoc mode Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 15/30] pinctrl: qcom: sc7280: Add PM suspend callbacks Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 16/30] m68k: Handle arrivals of multiple signals correctly Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 17/30] hwmon: (ltc2947) Properly handle errors when looking for the external clock Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 18/30] net: prevent user from passing illegal stab size Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 19/30] mac80211: check return value of rhashtable_init Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 20/30] net: bgmac-platform: handle mac-address deferral Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 21/30] vboxfs: fix broken legacy mount signature checking Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 22/30] net: sun: SUNVNET_COMMON should depend on INET Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 23/30] drm/amdgpu: fix gart.bo pin_count leak Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 24/30] scsi: ses: Fix unsigned comparison with less than zero Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 25/30] scsi: virtio_scsi: Fix spelling mistake "Unsupport" -> "Unsupported" Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 26/30] scsi: qla2xxx: Fix excessive messages during device logout Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 27/30] perf/core: fix userpage->time_enabled of inactive events Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 28/30] sched: Always inline is_percpu_thread() Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 29/30] io_uring: kill fasync Greg Kroah-Hartman
2021-10-14 14:54 ` [PATCH 5.14 30/30] hwmon: (pmbus/ibm-cffps) max_power_out swap changes Greg Kroah-Hartman
2021-10-14 20:24 ` [PATCH 5.14 00/30] 5.14.13-rc1 review Fox Chen
2021-10-14 22:23 ` Florian Fainelli
2021-10-14 22:38 ` Shuah Khan
2021-10-15 15:48 ` Daniel Díaz
2021-10-15 20:24 ` Justin Forbes
2021-10-15 22:07 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211014145209.731464673@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=enshuo@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.de \
--cc=yuhsuan@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox