Skip to content

Commit

Permalink
thinkpad-acpi: don't fail to load the entire module due to ALSA problems
Browse files Browse the repository at this point in the history
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: Peter Jordan <usernetwork@gmx.info>
Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Henrique de Moraes Holschuh authored and Len Brown committed Dec 27, 2009
1 parent ead510c commit 74c75c1
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions drivers/platform/x86/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6705,10 +6705,11 @@ static int __init volume_create_alsa_mixer(void)

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

BUG_ON(!card->private_data);
data = card->private_data;
Expand Down Expand Up @@ -6741,31 +6742,35 @@ static int __init volume_create_alsa_mixer(void)
rc = snd_ctl_add(card, ctl_vol);
if (rc < 0) {
printk(TPACPI_ERR
"Failed to create ALSA volume control\n");
goto err_out;
"Failed to create ALSA volume control: %d\n",
rc);
goto err_exit;
}
data->ctl_vol_id = &ctl_vol->id;
}

ctl_mute = snd_ctl_new1(&volume_alsa_control_mute, NULL);
rc = snd_ctl_add(card, ctl_mute);
if (rc < 0) {
printk(TPACPI_ERR "Failed to create ALSA mute control\n");
goto err_out;
printk(TPACPI_ERR "Failed to create ALSA mute control: %d\n",
rc);
goto err_exit;
}
data->ctl_mute_id = &ctl_mute->id;

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

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

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 */
Expand Down

0 comments on commit 74c75c1

Please sign in to comment.