From: Takashi Iwai <tiwai@suse.de>
To: Wesley Cheng <quic_wcheng@quicinc.com>
Cc: <srinivas.kandagatla@linaro.org>, <mathias.nyman@intel.com>,
<perex@perex.cz>, <lgirdwood@gmail.com>, <andersson@kernel.org>,
<krzysztof.kozlowski+dt@linaro.org>, <gregkh@linuxfoundation.org>,
<Thinh.Nguyen@synopsys.com>, <broonie@kernel.org>,
<bgoswami@quicinc.com>, <tiwai@suse.com>, <robh+dt@kernel.org>,
<agross@kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-msm@vger.kernel.org>, <alsa-devel@alsa-project.org>,
<devicetree@vger.kernel.org>, <linux-usb@vger.kernel.org>,
<quic_jackp@quicinc.com>, <quic_plai@quicinc.com>
Subject: Re: [PATCH v5 11/32] sound: usb: card: Introduce USB SND platform op callbacks
Date: Thu, 07 Sep 2023 17:36:55 +0200 [thread overview]
Message-ID: <875y4matbc.wl-tiwai@suse.de> (raw)
In-Reply-To: <20230829210657.9904-12-quic_wcheng@quicinc.com>
On Tue, 29 Aug 2023 23:06:36 +0200,
Wesley Cheng wrote:
>
> Allow for different platforms to be notified on USB SND connect/disconnect
> seqeunces. This allows for platform USB SND modules to properly initialize
> and populate internal structures with references to the USB SND chip
> device.
>
> Signed-off-by: Wesley Cheng <quic_wcheng@quicinc.com>
> ---
> sound/usb/card.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> sound/usb/card.h | 9 +++++++++
> 2 files changed, 54 insertions(+)
>
> diff --git a/sound/usb/card.c b/sound/usb/card.c
> index 1b2edc0fd2e9..067a1e82f4bf 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
> @@ -118,6 +118,34 @@ MODULE_PARM_DESC(skip_validation, "Skip unit descriptor validation (default: no)
> static DEFINE_MUTEX(register_mutex);
> static struct snd_usb_audio *usb_chip[SNDRV_CARDS];
> static struct usb_driver usb_audio_driver;
> +static struct snd_usb_platform_ops *platform_ops;
> +
> +int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops)
> +{
> + int ret;
> +
> + mutex_lock(®ister_mutex);
> + if (platform_ops) {
> + ret = -EEXIST;
> + goto out;
> + }
> +
> + platform_ops = ops;
> +out:
> + mutex_unlock(®ister_mutex);
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(snd_usb_register_platform_ops);
For adding this kind of API, please give the proper comment.
Especially this API is special and need a caution, to mention that it
can be used only for a single instance.
Also, it should be mentioned that all callbacks are exclusive under
the global register_mutex.
> @@ -910,7 +938,11 @@ static int usb_audio_probe(struct usb_interface *intf,
> chip->num_interfaces++;
> usb_set_intfdata(intf, chip);
> atomic_dec(&chip->active);
> +
> + if (platform_ops && platform_ops->connect_cb)
> + platform_ops->connect_cb(chip);
> mutex_unlock(®ister_mutex);
One uncertain thing is the argument for connect_cb and disconnect_cb.
Those take snd_usb_audio object, but the callback gets called per
interface at each probe and disconnect. How does the callee handle
multiple calls?
Last but not least, the patch subject should be with "ALSA:" prefix,
and in this case, at best "ALSA: usb-audio: xxx".
thanks,
Takashi
next prev parent reply other threads:[~2023-09-07 15:46 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-29 21:06 [PATCH v5 00/32] Introduce QC USB SND audio offloading support Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 01/32] xhci: add support to allocate several interrupters Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 02/32] xhci: add helper to stop endpoint and wait for completion Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 03/32] xhci: sideband: add initial api to register a sideband entity Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 04/32] usb: host: xhci-mem: Cleanup pending secondary event ring events Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 05/32] usb: host: xhci-mem: Allow for interrupter clients to choose specific index Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 06/32] ASoC: Add SOC USB APIs for adding an USB backend Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 07/32] ASoC: dt-bindings: qcom,q6dsp-lpass-ports: Add USB_RX port Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 08/32] ASoC: qcom: qdsp6: Introduce USB AFE port to q6dsp Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 09/32] ASoC: qdsp6: q6afe: Increase APR timeout Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 10/32] ASoC: qcom: Add USB backend ASoC driver for Q6 Wesley Cheng
2023-08-30 12:50 ` Amadeusz Sławiński
2023-08-31 19:34 ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 11/32] sound: usb: card: Introduce USB SND platform op callbacks Wesley Cheng
2023-09-07 15:36 ` Takashi Iwai [this message]
2023-09-11 17:57 ` Wesley Cheng
2023-09-12 22:36 ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 12/32] sound: usb: Export USB SND APIs for modules Wesley Cheng
2023-08-30 12:50 ` Amadeusz Sławiński
2023-08-31 19:36 ` Wesley Cheng
2023-09-07 15:38 ` Takashi Iwai
2023-09-11 17:58 ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 13/32] dt-bindings: usb: dwc3: Add snps,num-hc-interrupters definition Wesley Cheng
2023-08-31 17:24 ` Rob Herring
2023-08-31 19:25 ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 14/32] dt-bindings: usb: xhci: Add num-hc-interrupters definition Wesley Cheng
2023-08-31 17:22 ` Rob Herring
2023-08-29 21:06 ` [PATCH v5 15/32] usb: dwc3: Add DT parameter to specify maximum number of interrupters Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 16/32] usb: host: xhci-plat: Set XHCI max interrupters if property is present Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 17/32] sound: usb: qcom: Add USB QMI definitions Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 18/32] sound: usb: Introduce QC USB SND offloading support Wesley Cheng
2023-09-07 15:51 ` Takashi Iwai
2023-09-11 17:59 ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 19/32] sound: usb: card: Check for support for requested audio format Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 20/32] sound: soc: soc-usb: Add PCM format check API for USB backend Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 21/32] sound: soc: qcom: qusb6: Ensure PCM format is supported by USB audio device Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 22/32] sound: usb: Prevent starting of audio stream if in use Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 23/32] ASoC: dt-bindings: Add Q6USB backend Wesley Cheng
2023-08-31 17:29 ` Rob Herring
2023-08-31 19:32 ` Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 24/32] ASoC: dt-bindings: Update example for enabling USB offload on SM8250 Wesley Cheng
2023-08-31 17:29 ` Rob Herring
2023-08-29 21:06 ` [PATCH v5 25/32] ASoC: qcom: qdsp6: q6afe: Split USB AFE dev_token param into separate API Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 26/32] sound: Pass USB SND card and PCM information to SOC USB Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 27/32] sound: soc: qdsp6: Add SND kcontrol to select offload device Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 28/32] sound: soc: qdsp6: Add SND kcontrol for fetching offload status Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 29/32] sound: soc: qcom: q6usb: Add headphone jack for offload connection status Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 30/32] sound: usb: qc_audio_offload: Use card and PCM index from QMI request Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 31/32] sound: usb: card: Allow for rediscovery of connected USB SND devices Wesley Cheng
2023-08-29 21:06 ` [PATCH v5 32/32] sound: soc: soc-usb: Rediscover USB SND devices on USB port add Wesley Cheng
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=875y4matbc.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=Thinh.Nguyen@synopsys.com \
--cc=agross@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=andersson@kernel.org \
--cc=bgoswami@quicinc.com \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=perex@perex.cz \
--cc=quic_jackp@quicinc.com \
--cc=quic_plai@quicinc.com \
--cc=quic_wcheng@quicinc.com \
--cc=robh+dt@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=tiwai@suse.com \
/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;
as well as URLs for NNTP newsgroup(s).