From: Takashi Iwai Subject: Re: RFC: snd_card_create() function Date: Thu, 15 Jan 2009 14:05:08 +0100 Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (ns.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id 0FDE810381F for ; Thu, 15 Jan 2009 14:05:09 +0100 (CET) Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id DC4774597C for ; Thu, 15 Jan 2009 14:05:08 +0100 (CET) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Mon, 12 Jan 2009 15:35:19 +0100, I wrote: > > Hi, > > so far, we use snd_card_new() function to create a card instance. > A known problem regarding this API is that it doesn't return a proper > error code, thus the probe callback always returns -ENOMEM (or > whatever the driver defines) no matter which error occurred actually. > A typical case is the card slot conflict. Even in such a case, it > returns -ENOMEM, which may mislead the user. > > For fixing this situation, I'd like to convert from snd_card_new() to > a new function, snd_card_create(): > > int snd_card_create(int idx, const char *id, > struct module *module, int extra_size, > struct snd_card **card_ret); > > and provides snd_card_new() as a wrapper with deprecated flag: > > static inline __deprecated > struct snd_card *snd_card_new(int idx, const char *id, > struct module *module, int extra_size) > { > struct snd_card *card; > if (snd_card_create(idx, id, module, extra_size, &card) < 0) > return NULL; > return card; > } > > The merit of creating a new function is that the older and out-of-tree > codes (like xfi) work without modification. There is alternative > option, namely to use PTR_ERR() and keep the function as is. > But this has no advantage in practice -- it can't detect the old API > at build time, and it may Oops. > > The preliminary patches are found in test/snd_card_new-err branch > of sound git tree: > git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6.git test/snd_card_new-err > > If anyone finds problems with this, please let me know. Since no big issues came up, I merged that branch to master branch. Thanks for all your comments. Takashi