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 A67A4C04A94 for ; Tue, 25 Jul 2023 06:55:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbjGYGzf (ORCPT ); Tue, 25 Jul 2023 02:55:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229678AbjGYGzc (ORCPT ); Tue, 25 Jul 2023 02:55:32 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7B99BD; Mon, 24 Jul 2023 23:55:30 -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 707511F460; Tue, 25 Jul 2023 06:55:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690268129; 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=FW60ca4OfmtA62jqaIvoPbHSo4Qh3qo4WXB3S+Vrgbg=; b=RZouMMWpjtWvn4VUwfWniFkz9SA46/V7OpupxU74R0sZRCwWfDhtV9qG2oGbe6ibtI8wgx aFmnmxlI3cAWTNPlSbVLdz+WjjelmEWNl4j4T8wPFzW6MYni53WJG3Fqf2gGoT91mTVTgk Qgyc5usSL1Pgh7vPxPXjR7XfnBoLMH0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690268129; 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=FW60ca4OfmtA62jqaIvoPbHSo4Qh3qo4WXB3S+Vrgbg=; b=7PZKUyQ/sM07QOcCpimwJFlHEZx/sF7OB5wGCJmkjX2zQulgpyjxLuXGlhicSzNi245L8S YAsRblS8+/EeTnCA== 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 CF46313487; Tue, 25 Jul 2023 06:55:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id I+3HMeBxv2RyBQAAMHmgww (envelope-from ); Tue, 25 Jul 2023 06:55:28 +0000 Date: Tue, 25 Jul 2023 08:55:28 +0200 Message-ID: <87edkwv5sv.wl-tiwai@suse.de> From: Takashi Iwai To: Wesley Cheng Cc: , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v4 11/32] sound: usb: card: Introduce USB SND platform op callbacks In-Reply-To: <20230725023416.11205-12-quic_wcheng@quicinc.com> References: <20230725023416.11205-1-quic_wcheng@quicinc.com> <20230725023416.11205-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, 25 Jul 2023 04:33:55 +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 | 36 ++++++++++++++++++++++++++++++++++++ > sound/usb/card.h | 20 ++++++++++++++++++++ > 2 files changed, 56 insertions(+) > > diff --git a/sound/usb/card.c b/sound/usb/card.c > index f6e99ced8068..9365d1e17836 100644 > --- a/sound/usb/card.c > +++ b/sound/usb/card.c > @@ -117,6 +117,30 @@ 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) > +{ > + if (platform_ops) > + return -EEXIST; > + mutex_lock(®ister_mutex); > + platform_ops = ops; > + mutex_unlock(®ister_mutex); The check should be inside register_mutex lock, too. Otherwise it's racy. > --- a/sound/usb/card.h > +++ b/sound/usb/card.h > @@ -207,4 +207,24 @@ struct snd_usb_stream { > struct list_head list; > }; > > +struct snd_usb_platform_ops { > + void (*connect_cb)(struct snd_usb_audio *chip); > + void (*disconnect_cb)(struct snd_usb_audio *chip); > + void (*suspend_cb)(struct usb_interface *intf, pm_message_t message); > +}; Don't we need resume_cb? Even if it's unused for your platform, it'd make sense to be a pair. > +#if IS_ENABLED(CONFIG_SND_USB_AUDIO) > +int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops); > +int snd_usb_unregister_platform_ops(void); > +#else > +static int snd_usb_register_platform_ops(struct snd_usb_platform_ops *ops) > +{ > + return -EOPNOTSUPP; > +} > + > +static int snd_usb_unregister_platform_ops(void) > +{ > + return -EOPNOTSUPP; > +} > +#endif /* IS_ENABLED(CONFIG_SND_USB_AUDIO) */ Any need for dummy function definitions? I thought those exported functions are always with CONFIG_SND_USB_AUDIO enabled? IOW, are they use of those functions without USB audio driver? thanks, Takashi