Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EF78C07E9B for ; Tue, 20 Jul 2021 22:18:23 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 707846120D for ; Tue, 20 Jul 2021 22:18:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 707846120D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5AD13168D; Wed, 21 Jul 2021 00:17:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5AD13168D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1626819500; bh=M5sCuUpe4NXSXCjMGXao/bf5+SYqmQ3S+F10TohfPdk=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jgRgT+wNQK4LogXNODejhZ15ss2XCgcVR1yAoFaEq1c6UXkSCkk3BR4f6RIk7D/BY +9iqx7giDWzpHMiq3TXoPQbm/sRldRbJRhOycJZH0RfpliC9bf5Zv14zJQALJ1cA9W 4HAaENkiilhYwXlgiUcNumLF7H3uag1chsW+6n6I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id E9C26F8020D; Wed, 21 Jul 2021 00:17:29 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 287B1F80218; Wed, 21 Jul 2021 00:17:29 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E52D2F80169 for ; Wed, 21 Jul 2021 00:17:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E52D2F80169 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Ju4An0+J"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="Iv3vLw5E" Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id BAFF42242E; Tue, 20 Jul 2021 22:17:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626819440; 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=6k4rnWTIoQFHr8KfEedpi5HrJLTJfNixgTosCLenHo4=; b=Ju4An0+J79iFwCG6oe+DMZntGrAinqjLUcZ7hItz64lmYGG/sxHMAQajCuf7LzDwisHbKy VCk8O6Q51DAow+Uhq6sD0B0+nAdbJkt2Kgtwgub8xp8z/m2MrT5BCdqpha/BGqzCl7Z0av WP58CykAkEGgQmQnjySnQkD6SRpo0WM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626819440; 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=6k4rnWTIoQFHr8KfEedpi5HrJLTJfNixgTosCLenHo4=; b=Iv3vLw5E/1HqZotECg9atb1t9IjkFYLiHBpdFJAyOGHvU1GIbWhMBBlGLFj1VB6T/y9Koi 1lBjHvAHUCvuHlCw== Received: from alsa1.suse.de (alsa1.suse.de [10.160.4.42]) by relay2.suse.de (Postfix) with ESMTP id AA9AFA3B83; Tue, 20 Jul 2021 22:17:20 +0000 (UTC) Date: Wed, 21 Jul 2021 00:17:20 +0200 Message-ID: From: Takashi Iwai To: Nathan Chancellor Subject: Re: [PATCH v2 14/79] ALSA: cs4281: Allocate resources with device-managed APIs In-Reply-To: References: <20210715075941.23332-1-tiwai@suse.de> <20210715075941.23332-15-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: alsa-devel@alsa-project.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Tue, 20 Jul 2021 21:46:47 +0200, Nathan Chancellor wrote: > > On Thu, Jul 15, 2021 at 09:58:36AM +0200, Takashi Iwai wrote: > > This patch converts the resource management in PCI cs4281 driver with > > devres as a clean up. Each manual resource management is converted > > with the corresponding devres helper, and the card object release is > > managed now via card->private_free instead of a lowlevel snd_device. > > > > This should give no user-visible functional changes. > > > > Signed-off-by: Takashi Iwai > > --- > > sound/pci/cs4281.c | 112 ++++++++++----------------------------------- > > 1 file changed, 24 insertions(+), 88 deletions(-) > > > > diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c > > index e122a168c148..f338caf98354 100644 > > --- a/sound/pci/cs4281.c > > +++ b/sound/pci/cs4281.c > > @@ -1268,8 +1268,10 @@ static inline int snd_cs4281_create_gameport(struct cs4281 *chip) { return -ENOS > > static inline void snd_cs4281_free_gameport(struct cs4281 *chip) { } > > #endif /* IS_REACHABLE(CONFIG_GAMEPORT) */ > > > > -static int snd_cs4281_free(struct cs4281 *chip) > > +static void snd_cs4281_free(struct snd_card *card) > > { > > + struct cs4281 *chip = card->private_data; > > + > > snd_cs4281_free_gameport(chip); > > > > /* Mask interrupts */ > > @@ -1278,49 +1280,20 @@ static int snd_cs4281_free(struct cs4281 *chip) > > snd_cs4281_pokeBA0(chip, BA0_CLKCR1, 0); > > /* Sound System Power Management - Turn Everything OFF */ > > snd_cs4281_pokeBA0(chip, BA0_SSPM, 0); > > - /* PCI interface - D3 state */ > > - pci_set_power_state(chip->pci, PCI_D3hot); > > - > > - if (chip->irq >= 0) > > - free_irq(chip->irq, chip); > > - iounmap(chip->ba0); > > - iounmap(chip->ba1); > > - pci_release_regions(chip->pci); > > - pci_disable_device(chip->pci); > > - > > - kfree(chip); > > - return 0; > > -} > > - > > -static int snd_cs4281_dev_free(struct snd_device *device) > > -{ > > - struct cs4281 *chip = device->device_data; > > - return snd_cs4281_free(chip); > > } > > > > static int snd_cs4281_chip_init(struct cs4281 *chip); /* defined below */ > > > > static int snd_cs4281_create(struct snd_card *card, > > struct pci_dev *pci, > > - struct cs4281 **rchip, > > int dual_codec) > > { > > struct cs4281 *chip; > > - unsigned int tmp; > > int err; > > - static const struct snd_device_ops ops = { > > - .dev_free = snd_cs4281_dev_free, > > - }; > > > > - *rchip = NULL; > > - err = pci_enable_device(pci); > > + err = pcim_enable_device(pci); > > if (err < 0) > > return err; > > - chip = kzalloc(sizeof(*chip), GFP_KERNEL); > > - if (chip == NULL) { > > - pci_disable_device(pci); > > - return -ENOMEM; > > - } > > spin_lock_init(&chip->reg_lock); > > chip->card = card; > > clang warns: > > sound/pci/cs4281.c:1298:2: error: variable 'chip' is uninitialized when used here [-Werror,-Wuninitialized] > chip->card = card; > ^~~~ > sound/pci/cs4281.c:1291:21: note: initialize the variable 'chip' to silence this warning > struct cs4281 *chip; > ^ > = NULL > 1 error generated. Thanks! The fix patch is below. I'll queue it up. Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] ALSA: cs4281: Fix missing chip initialization The chip variable was forgotten to be initialized properly while changing the object creation from the own malloc to card->private_data. This patch fixes it. Fixes: 99041fea70d0 ("ALSA: cs4281: Allocate resources with device-managed APIs") Reported-by: Nathan Chancellor Signed-off-by: Takashi Iwai --- sound/pci/cs4281.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/cs4281.c b/sound/pci/cs4281.c index f338caf98354..e7367402b84a 100644 --- a/sound/pci/cs4281.c +++ b/sound/pci/cs4281.c @@ -1288,7 +1288,7 @@ static int snd_cs4281_create(struct snd_card *card, struct pci_dev *pci, int dual_codec) { - struct cs4281 *chip; + struct cs4281 *chip = card->private_data; int err; err = pcim_enable_device(pci); -- 2.26.2