Exemplo n.º 1
0
static int oxfw_probe(struct fw_unit *unit,
		      const struct ieee1394_device_id *entry)
{
	struct snd_oxfw *oxfw;

	if (entry->vendor_id == VENDOR_LOUD && !detect_loud_models(unit))
		return -ENODEV;

	/* Allocate this independent of sound card instance. */
	oxfw = kzalloc(sizeof(struct snd_oxfw), GFP_KERNEL);
	if (oxfw == NULL)
		return -ENOMEM;

	oxfw->entry = entry;
	oxfw->unit = fw_unit_get(unit);
	dev_set_drvdata(&unit->device, oxfw);

	mutex_init(&oxfw->mutex);
	spin_lock_init(&oxfw->lock);
	init_waitqueue_head(&oxfw->hwdep_wait);

	/* Allocate and register this sound card later. */
	INIT_DEFERRABLE_WORK(&oxfw->dwork, do_registration);
	snd_fw_schedule_registration(unit, &oxfw->dwork);

	return 0;
}
Exemplo n.º 2
0
Arquivo: oxfw.c Projeto: 19Dan01/linux
static int oxfw_probe(struct fw_unit *unit,
		       const struct ieee1394_device_id *id)
{
	struct snd_card *card;
	struct snd_oxfw *oxfw;
	int err;

	if ((id->vendor_id == VENDOR_LOUD) && !detect_loud_models(unit))
		return -ENODEV;

	err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
			   sizeof(*oxfw), &card);
	if (err < 0)
		return err;

	card->private_free = oxfw_card_free;
	oxfw = card->private_data;
	oxfw->card = card;
	mutex_init(&oxfw->mutex);
	oxfw->unit = fw_unit_get(unit);
	oxfw->device_info = (const struct device_info *)id->driver_data;
	spin_lock_init(&oxfw->lock);
	init_waitqueue_head(&oxfw->hwdep_wait);

	err = snd_oxfw_stream_discover(oxfw);
	if (err < 0)
		goto error;

	err = name_card(oxfw);
	if (err < 0)
		goto error;

	err = snd_oxfw_create_pcm(oxfw);
	if (err < 0)
		goto error;

	if (oxfw->device_info) {
		err = snd_oxfw_create_mixer(oxfw);
		if (err < 0)
			goto error;
	}

	snd_oxfw_proc_init(oxfw);

	err = snd_oxfw_create_midi(oxfw);
	if (err < 0)
		goto error;

	err = snd_oxfw_create_hwdep(oxfw);
	if (err < 0)
		goto error;

	err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->rx_stream);
	if (err < 0)
		goto error;
	if (oxfw->has_output) {
		err = snd_oxfw_stream_init_simplex(oxfw, &oxfw->tx_stream);
		if (err < 0)
			goto error;
	}

	err = snd_card_register(card);
	if (err < 0) {
		snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->rx_stream);
		if (oxfw->has_output)
			snd_oxfw_stream_destroy_simplex(oxfw, &oxfw->tx_stream);
		goto error;
	}
	dev_set_drvdata(&unit->device, oxfw);

	return 0;
error:
	snd_card_free(card);
	return err;
}