mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
Merge branch 'topic/snd_card_new-err' into topic/cs423x-merge
This commit is contained in:
@@ -492,9 +492,9 @@
|
||||
}
|
||||
|
||||
/* (2) */
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
/* (3) */
|
||||
err = snd_mychip_create(card, pci, &chip);
|
||||
@@ -590,8 +590,9 @@
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
struct snd_card *card;
|
||||
int err;
|
||||
....
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
@@ -809,26 +810,28 @@
|
||||
|
||||
<para>
|
||||
As mentioned above, to create a card instance, call
|
||||
<function>snd_card_new()</function>.
|
||||
<function>snd_card_create()</function>.
|
||||
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
struct snd_card *card;
|
||||
card = snd_card_new(index, id, module, extra_size);
|
||||
int err;
|
||||
err = snd_card_create(index, id, module, extra_size, &card);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The function takes four arguments, the card-index number, the
|
||||
The function takes five arguments, the card-index number, the
|
||||
id string, the module pointer (usually
|
||||
<constant>THIS_MODULE</constant>),
|
||||
and the size of extra-data space. The last argument is used to
|
||||
the size of extra-data space, and the pointer to return the
|
||||
card instance. The extra_size argument is used to
|
||||
allocate card->private_data for the
|
||||
chip-specific data. Note that these data
|
||||
are allocated by <function>snd_card_new()</function>.
|
||||
are allocated by <function>snd_card_create()</function>.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
@@ -915,15 +918,16 @@
|
||||
</para>
|
||||
|
||||
<section id="card-management-chip-specific-snd-card-new">
|
||||
<title>1. Allocating via <function>snd_card_new()</function>.</title>
|
||||
<title>1. Allocating via <function>snd_card_create()</function>.</title>
|
||||
<para>
|
||||
As mentioned above, you can pass the extra-data-length
|
||||
to the 4th argument of <function>snd_card_new()</function>, i.e.
|
||||
to the 4th argument of <function>snd_card_create()</function>, i.e.
|
||||
|
||||
<informalexample>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct mychip));
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE,
|
||||
sizeof(struct mychip), &card);
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
@@ -952,8 +956,8 @@
|
||||
|
||||
<para>
|
||||
After allocating a card instance via
|
||||
<function>snd_card_new()</function> (with
|
||||
<constant>NULL</constant> on the 4th arg), call
|
||||
<function>snd_card_create()</function> (with
|
||||
<constant>0</constant> on the 4th arg), call
|
||||
<function>kzalloc()</function>.
|
||||
|
||||
<informalexample>
|
||||
@@ -961,7 +965,7 @@
|
||||
<![CDATA[
|
||||
struct snd_card *card;
|
||||
struct mychip *chip;
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, NULL);
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
.....
|
||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
]]>
|
||||
@@ -5750,8 +5754,9 @@ struct _snd_pcm_runtime {
|
||||
....
|
||||
struct snd_card *card;
|
||||
struct mychip *chip;
|
||||
int err;
|
||||
....
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, NULL);
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
....
|
||||
chip = kzalloc(sizeof(*chip), GFP_KERNEL);
|
||||
....
|
||||
@@ -5763,7 +5768,7 @@ struct _snd_pcm_runtime {
|
||||
</informalexample>
|
||||
|
||||
When you created the chip data with
|
||||
<function>snd_card_new()</function>, it's anyway accessible
|
||||
<function>snd_card_create()</function>, it's anyway accessible
|
||||
via <structfield>private_data</structfield> field.
|
||||
|
||||
<informalexample>
|
||||
@@ -5775,9 +5780,10 @@ struct _snd_pcm_runtime {
|
||||
....
|
||||
struct snd_card *card;
|
||||
struct mychip *chip;
|
||||
int err;
|
||||
....
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE,
|
||||
sizeof(struct mychip));
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE,
|
||||
sizeof(struct mychip), &card);
|
||||
....
|
||||
chip = card->private_data;
|
||||
....
|
||||
|
||||
@@ -803,9 +803,10 @@ static int __devinit cx88_audio_initdev(struct pci_dev *pci,
|
||||
return (-ENOENT);
|
||||
}
|
||||
|
||||
card = snd_card_new(index[devno], id[devno], THIS_MODULE, sizeof(snd_cx88_card_t));
|
||||
if (!card)
|
||||
return (-ENOMEM);
|
||||
err = snd_card_create(index[devno], id[devno], THIS_MODULE,
|
||||
sizeof(snd_cx88_card_t), &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
card->private_free = snd_cx88_dev_free;
|
||||
|
||||
|
||||
@@ -438,9 +438,10 @@ static int em28xx_audio_init(struct em28xx *dev)
|
||||
printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus "
|
||||
"Rechberger\n");
|
||||
|
||||
card = snd_card_new(index[devnr], "Em28xx Audio", THIS_MODULE, 0);
|
||||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index[devnr], "Em28xx Audio", THIS_MODULE, 0,
|
||||
&card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
spin_lock_init(&adev->slock);
|
||||
err = snd_pcm_new(card, "Em28xx Audio", 0, 0, 1, &pcm);
|
||||
|
||||
@@ -990,10 +990,10 @@ static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
|
||||
if (!enable[devnum])
|
||||
return -ENODEV;
|
||||
|
||||
card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, sizeof(snd_card_saa7134_t));
|
||||
|
||||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index[devnum], id[devnum], THIS_MODULE,
|
||||
sizeof(snd_card_saa7134_t), &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
strcpy(card->driver, "SAA7134");
|
||||
|
||||
|
||||
@@ -248,10 +248,11 @@ int go7007_snd_init(struct go7007 *go)
|
||||
spin_lock_init(&gosnd->lock);
|
||||
gosnd->hw_ptr = gosnd->w_idx = gosnd->avail = 0;
|
||||
gosnd->capturing = 0;
|
||||
gosnd->card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
if (gosnd->card == NULL) {
|
||||
ret = snd_card_create(index[dev], id[dev], THIS_MODULE, 0,
|
||||
&gosnd->card);
|
||||
if (ret < 0) {
|
||||
kfree(gosnd);
|
||||
return -ENOMEM;
|
||||
return ret;
|
||||
}
|
||||
ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go,
|
||||
&go7007_snd_device_ops);
|
||||
|
||||
@@ -1099,10 +1099,9 @@ static int gmidi_register_card(struct gmidi_device *dev)
|
||||
.dev_free = gmidi_snd_free,
|
||||
};
|
||||
|
||||
card = snd_card_new(index, id, THIS_MODULE, 0);
|
||||
if (!card) {
|
||||
ERROR(dev, "snd_card_new failed\n");
|
||||
err = -ENOMEM;
|
||||
err = snd_card_create(index, id, THIS_MODULE, 0, &card);
|
||||
if (err < 0) {
|
||||
ERROR(dev, "snd_card_create failed\n");
|
||||
goto fail;
|
||||
}
|
||||
dev->card = card;
|
||||
|
||||
@@ -296,8 +296,20 @@ int snd_card_locked(int card);
|
||||
extern int (*snd_mixer_oss_notify_callback)(struct snd_card *card, int cmd);
|
||||
#endif
|
||||
|
||||
int snd_card_create(int idx, const char *id,
|
||||
struct module *module, int extra_size,
|
||||
struct snd_card **card_ret);
|
||||
|
||||
static inline __deprecated
|
||||
struct snd_card *snd_card_new(int idx, const char *id,
|
||||
struct module *module, int extra_size);
|
||||
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;
|
||||
}
|
||||
|
||||
int snd_card_disconnect(struct snd_card *card);
|
||||
int snd_card_free(struct snd_card *card);
|
||||
int snd_card_free_when_closed(struct snd_card *card);
|
||||
|
||||
@@ -23,9 +23,10 @@ int aoa_alsa_init(char *name, struct module *mod, struct device *dev)
|
||||
/* cannot be EEXIST due to usage in aoa_fabric_register */
|
||||
return -EBUSY;
|
||||
|
||||
alsa_card = snd_card_new(index, name, mod, sizeof(struct aoa_card));
|
||||
if (!alsa_card)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index, name, mod, sizeof(struct aoa_card),
|
||||
&alsa_card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
aoa_card = alsa_card->private_data;
|
||||
aoa_card->alsa_card = alsa_card;
|
||||
alsa_card->dev = dev;
|
||||
|
||||
@@ -995,10 +995,11 @@ static struct aaci * __devinit aaci_init_card(struct amba_device *dev)
|
||||
{
|
||||
struct aaci *aaci;
|
||||
struct snd_card *card;
|
||||
int err;
|
||||
|
||||
card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
|
||||
THIS_MODULE, sizeof(struct aaci));
|
||||
if (card == NULL)
|
||||
err = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
|
||||
THIS_MODULE, sizeof(struct aaci), &card);
|
||||
if (err < 0)
|
||||
return NULL;
|
||||
|
||||
card->private_free = aaci_free_card;
|
||||
|
||||
@@ -173,10 +173,9 @@ static int __devinit pxa2xx_ac97_probe(struct platform_device *dev)
|
||||
struct snd_ac97_template ac97_template;
|
||||
int ret;
|
||||
|
||||
ret = -ENOMEM;
|
||||
card = snd_card_new(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
|
||||
THIS_MODULE, 0);
|
||||
if (!card)
|
||||
ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
|
||||
THIS_MODULE, 0, &card);
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
card->dev = &dev->dev;
|
||||
|
||||
@@ -887,9 +887,10 @@ static int __devinit sa11xx_uda1341_probe(struct platform_device *devptr)
|
||||
struct sa11xx_uda1341 *chip;
|
||||
|
||||
/* register the soundcard */
|
||||
card = snd_card_new(-1, id, THIS_MODULE, sizeof(struct sa11xx_uda1341));
|
||||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(-1, id, THIS_MODULE,
|
||||
sizeof(struct sa11xx_uda1341), &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
chip = card->private_data;
|
||||
spin_lock_init(&chip->s[0].dma_lock);
|
||||
|
||||
@@ -121,31 +121,44 @@ static inline int init_info_for_card(struct snd_card *card)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* snd_card_new - create and initialize a soundcard structure
|
||||
* snd_card_create - create and initialize a soundcard structure
|
||||
* @idx: card index (address) [0 ... (SNDRV_CARDS-1)]
|
||||
* @xid: card identification (ASCII string)
|
||||
* @module: top level module for locking
|
||||
* @extra_size: allocate this extra size after the main soundcard structure
|
||||
* @card_ret: the pointer to store the created card instance
|
||||
*
|
||||
* Creates and initializes a soundcard structure.
|
||||
*
|
||||
* Returns kmallocated snd_card structure. Creates the ALSA control interface
|
||||
* (which is blocked until snd_card_register function is called).
|
||||
* The function allocates snd_card instance via kzalloc with the given
|
||||
* space for the driver to use freely. The allocated struct is stored
|
||||
* in the given card_ret pointer.
|
||||
*
|
||||
* Returns zero if successful or a negative error code.
|
||||
*/
|
||||
struct snd_card *snd_card_new(int idx, const char *xid,
|
||||
struct module *module, int extra_size)
|
||||
int snd_card_create(int idx, const char *xid,
|
||||
struct module *module, int extra_size,
|
||||
struct snd_card **card_ret)
|
||||
{
|
||||
struct snd_card *card;
|
||||
int err, idx2;
|
||||
|
||||
if (snd_BUG_ON(!card_ret))
|
||||
return -EINVAL;
|
||||
*card_ret = NULL;
|
||||
|
||||
if (extra_size < 0)
|
||||
extra_size = 0;
|
||||
card = kzalloc(sizeof(*card) + extra_size, GFP_KERNEL);
|
||||
if (card == NULL)
|
||||
return NULL;
|
||||
if (!card)
|
||||
return -ENOMEM;
|
||||
if (xid) {
|
||||
if (!snd_info_check_reserved_words(xid))
|
||||
if (!snd_info_check_reserved_words(xid)) {
|
||||
snd_printk(KERN_ERR
|
||||
"given id string '%s' is reserved.\n", xid);
|
||||
err = -EBUSY;
|
||||
goto __error;
|
||||
}
|
||||
strlcpy(card->id, xid, sizeof(card->id));
|
||||
}
|
||||
err = 0;
|
||||
@@ -202,26 +215,28 @@ struct snd_card *snd_card_new(int idx, const char *xid,
|
||||
#endif
|
||||
/* the control interface cannot be accessed from the user space until */
|
||||
/* snd_cards_bitmask and snd_cards are set with snd_card_register */
|
||||
if ((err = snd_ctl_create(card)) < 0) {
|
||||
snd_printd("unable to register control minors\n");
|
||||
err = snd_ctl_create(card);
|
||||
if (err < 0) {
|
||||
snd_printk(KERN_ERR "unable to register control minors\n");
|
||||
goto __error;
|
||||
}
|
||||
if ((err = snd_info_card_create(card)) < 0) {
|
||||
snd_printd("unable to create card info\n");
|
||||
err = snd_info_card_create(card);
|
||||
if (err < 0) {
|
||||
snd_printk(KERN_ERR "unable to create card info\n");
|
||||
goto __error_ctl;
|
||||
}
|
||||
if (extra_size > 0)
|
||||
card->private_data = (char *)card + sizeof(struct snd_card);
|
||||
return card;
|
||||
*card_ret = card;
|
||||
return 0;
|
||||
|
||||
__error_ctl:
|
||||
snd_device_free_all(card, SNDRV_DEV_CMD_PRE);
|
||||
__error:
|
||||
kfree(card);
|
||||
return NULL;
|
||||
return err;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(snd_card_new);
|
||||
EXPORT_SYMBOL(snd_card_create);
|
||||
|
||||
/* return non-zero if a card is already locked */
|
||||
int snd_card_locked(int card)
|
||||
|
||||
@@ -588,10 +588,10 @@ static int __devinit snd_dummy_probe(struct platform_device *devptr)
|
||||
int idx, err;
|
||||
int dev = devptr->id;
|
||||
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE,
|
||||
sizeof(struct snd_dummy));
|
||||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE,
|
||||
sizeof(struct snd_dummy), &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
dummy = card->private_data;
|
||||
dummy->card = card;
|
||||
for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) {
|
||||
|
||||
@@ -1279,9 +1279,9 @@ static int __devinit snd_ml403_ac97cr_probe(struct platform_device *pfdev)
|
||||
if (!enable[dev])
|
||||
return -ENOENT;
|
||||
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
err = snd_ml403_ac97cr_create(card, pfdev, &ml403_ac97cr);
|
||||
if (err < 0) {
|
||||
PDEBUG(INIT_FAILURE, "probe(): create failed!\n");
|
||||
|
||||
@@ -73,9 +73,9 @@ static int snd_mpu401_create(int dev, struct snd_card **rcard)
|
||||
snd_printk(KERN_ERR "the uart_enter option is obsolete; remove it\n");
|
||||
|
||||
*rcard = NULL;
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
strcpy(card->driver, "MPU-401 UART");
|
||||
strcpy(card->shortname, card->driver);
|
||||
sprintf(card->longname, "%s at %#lx, ", card->shortname, port[dev]);
|
||||
|
||||
@@ -696,9 +696,9 @@ static int __devinit snd_mtpav_probe(struct platform_device *dev)
|
||||
int err;
|
||||
struct mtpav *mtp_card;
|
||||
|
||||
card = snd_card_new(index, id, THIS_MODULE, sizeof(*mtp_card));
|
||||
if (! card)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index, id, THIS_MODULE, sizeof(*mtp_card), &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
mtp_card = card->private_data;
|
||||
spin_lock_init(&mtp_card->spinlock);
|
||||
|
||||
@@ -957,10 +957,10 @@ static int __devinit snd_mts64_probe(struct platform_device *pdev)
|
||||
if ((err = snd_mts64_probe_port(p)) < 0)
|
||||
return err;
|
||||
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
if (card == NULL) {
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
if (err < 0) {
|
||||
snd_printd("Cannot create card\n");
|
||||
return -ENOMEM;
|
||||
return err;
|
||||
}
|
||||
strcpy(card->driver, DRIVER_NAME);
|
||||
strcpy(card->shortname, "ESI " CARD_NAME);
|
||||
|
||||
@@ -98,9 +98,9 @@ static int __devinit snd_card_pcsp_probe(int devnum, struct device *dev)
|
||||
hrtimer_init(&pcsp_chip.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
|
||||
pcsp_chip.timer.function = pcsp_do_timer;
|
||||
|
||||
card = snd_card_new(index, id, THIS_MODULE, 0);
|
||||
if (!card)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index, id, THIS_MODULE, 0, &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
err = snd_pcsp_create(card);
|
||||
if (err < 0) {
|
||||
|
||||
@@ -746,10 +746,10 @@ static int __devinit snd_portman_probe(struct platform_device *pdev)
|
||||
if ((err = snd_portman_probe_port(p)) < 0)
|
||||
return err;
|
||||
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
if (card == NULL) {
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
if (err < 0) {
|
||||
snd_printd("Cannot create card\n");
|
||||
return -ENOMEM;
|
||||
return err;
|
||||
}
|
||||
strcpy(card->driver, DRIVER_NAME);
|
||||
strcpy(card->shortname, CARD_NAME);
|
||||
|
||||
@@ -936,9 +936,9 @@ static int __devinit snd_serial_probe(struct platform_device *devptr)
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0);
|
||||
if (card == NULL)
|
||||
return -ENOMEM;
|
||||
err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
strcpy(card->driver, "Serial");
|
||||
strcpy(card->shortname, "Serial MIDI (UART16550A)");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user