Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 74c75c18 authored by Henrique de Moraes Holschuh's avatar Henrique de Moraes Holschuh Committed by Len Brown
Browse files

thinkpad-acpi: don't fail to load the entire module due to ALSA problems



If we cannot create the ALSA mixer, it is a good reason to fail to
load the volume subdriver, and not to fail to load the entire module.

While at it, add more debugging messages, as the error paths are being
used a lot more than I'd expect, and it is failing to set up the ALSA
mixer on a number of ThinkPads.

Reported-by: default avatarPeter Jordan <usernetwork@gmx.info>
Signed-off-by: default avatarHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent ead510ce
Loading
Loading
Loading
Loading
+18 −13
Original line number Original line Diff line number Diff line
@@ -6705,10 +6705,11 @@ static int __init volume_create_alsa_mixer(void)


	rc = snd_card_create(alsa_index, alsa_id, THIS_MODULE,
	rc = snd_card_create(alsa_index, alsa_id, THIS_MODULE,
			    sizeof(struct tpacpi_alsa_data), &card);
			    sizeof(struct tpacpi_alsa_data), &card);
	if (rc < 0)
	if (rc < 0 || !card) {
		return rc;
		printk(TPACPI_ERR
	if (!card)
			"Failed to create ALSA card structures: %d\n", rc);
		return -ENOMEM;
		return 1;
	}


	BUG_ON(!card->private_data);
	BUG_ON(!card->private_data);
	data = card->private_data;
	data = card->private_data;
@@ -6741,8 +6742,9 @@ static int __init volume_create_alsa_mixer(void)
		rc = snd_ctl_add(card, ctl_vol);
		rc = snd_ctl_add(card, ctl_vol);
		if (rc < 0) {
		if (rc < 0) {
			printk(TPACPI_ERR
			printk(TPACPI_ERR
				"Failed to create ALSA volume control\n");
				"Failed to create ALSA volume control: %d\n",
			goto err_out;
				rc);
			goto err_exit;
		}
		}
		data->ctl_vol_id = &ctl_vol->id;
		data->ctl_vol_id = &ctl_vol->id;
	}
	}
@@ -6750,22 +6752,25 @@ static int __init volume_create_alsa_mixer(void)
	ctl_mute = snd_ctl_new1(&volume_alsa_control_mute, NULL);
	ctl_mute = snd_ctl_new1(&volume_alsa_control_mute, NULL);
	rc = snd_ctl_add(card, ctl_mute);
	rc = snd_ctl_add(card, ctl_mute);
	if (rc < 0) {
	if (rc < 0) {
		printk(TPACPI_ERR "Failed to create ALSA mute control\n");
		printk(TPACPI_ERR "Failed to create ALSA mute control: %d\n",
		goto err_out;
			rc);
		goto err_exit;
	}
	}
	data->ctl_mute_id = &ctl_mute->id;
	data->ctl_mute_id = &ctl_mute->id;


	snd_card_set_dev(card, &tpacpi_pdev->dev);
	snd_card_set_dev(card, &tpacpi_pdev->dev);
	rc = snd_card_register(card);
	rc = snd_card_register(card);

err_out:
	if (rc < 0) {
	if (rc < 0) {
		snd_card_free(card);
		printk(TPACPI_ERR "Failed to register ALSA card: %d\n", rc);
		card = NULL;
		goto err_exit;
	}
	}


	alsa_card = card;
	alsa_card = card;
	return rc;
	return 0;

err_exit:
	snd_card_free(card);
	return 1;
}
}


#define TPACPI_VOL_Q_MUTEONLY	0x0001	/* Mute-only control available */
#define TPACPI_VOL_Q_MUTEONLY	0x0001	/* Mute-only control available */