From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BFFEEC8741 for ; Thu, 7 Sep 2023 15:53:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239961AbjIGPxK (ORCPT ); Thu, 7 Sep 2023 11:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236232AbjIGPlX (ORCPT ); Thu, 7 Sep 2023 11:41:23 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42A8A2D6D; Thu, 7 Sep 2023 08:37:46 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9A8A31F86B; Thu, 7 Sep 2023 15:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1694101016; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=M0FCyN160pcl7/vGE/G6WlHC7elSb7flkJCyP5XdT5E=; b=S9MltvvWBQJ3S+InPcTpe0WnVoyXnKqaDKeu+BwDHvZj60OrGXEDSShbYcomd3GtxyIZTT TcrhM7Ol5ShXOYypjd7CzP+FglED+dodU3VRZtRK2n8dDSp9vOAhBBX+1HhEJDMdWIFsxf Ffq7xN4Ng5kkEE+uf8/WHH9t2J3hfAY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1694101016; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=M0FCyN160pcl7/vGE/G6WlHC7elSb7flkJCyP5XdT5E=; b=T7q/lXXghXAYZb3Ca5uIQsgLsYKDnlp9Dc3cyQRlMyyfjSjbLjxzbrNKR7PTjsz4yycOR4 OtzAVhoZN7Cz7wAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 231E5138FA; Thu, 7 Sep 2023 15:36:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kmOwBxju+WTgAgAAMHmgww (envelope-from ); Thu, 07 Sep 2023 15:36:56 +0000 Date: Thu, 07 Sep 2023 17:36:55 +0200 Message-ID: <875y4matbc.wl-tiwai@suse.de> From: Takashi Iwai To: Wesley Cheng Cc: , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v5 11/32] sound: usb: card: Introduce USB SND platform op callbacks In-Reply-To: <20230829210657.9904-12-quic_wcheng@quicinc.com> References: <20230829210657.9904-1-quic_wcheng@quicinc.com> <20230829210657.9904-12-quic_wcheng@quicinc.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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