From 21be3d162651f11e422275aad62a4bb06292ef4f Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 16 Sep 2005 19:18:56 +0200 Subject: [ALSA] Add description for ALC260 codec Modules: Documentation Added description for ALC260 codec models in hda-intel driver section. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/ALSA-Configuration.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Documentation') diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 13cba955cb5a..09340cb4e18d 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -663,6 +663,10 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. adjusted. Appearing only when compiled with $CONFIG_SND_DEBUG=y + ALC260 + hp HP machines + fujitsu Fujitsu S7020 + CMI9880 minimal 3-jack in back min_fp 3-jack in back, 2-jack in front -- cgit v1.2.3-59-g8ed1b From b7fe46220487f684abc858865cff817389af5c76 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 4 Oct 2005 08:46:51 +0200 Subject: [ALSA] highlanderize motherboard AC97/HDA drivers Remove the code for supporting eight cards from the integrated controller drivers because There Can Be Only One controller of each type per mainboard. Signed-off-by: Clemens Ladisch --- Documentation/sound/alsa/ALSA-Configuration.txt | 14 ++-- sound/pci/atiixp.c | 42 ++++------ sound/pci/atiixp_modem.c | 28 ++----- sound/pci/hda/hda_intel.c | 34 +++----- sound/pci/intel8x0.c | 58 +++++-------- sound/pci/intel8x0m.c | 28 ++----- sound/pci/via82xx.c | 103 +++++++++++------------- sound/pci/via82xx_modem.c | 29 +++---- 8 files changed, 126 insertions(+), 210 deletions(-) (limited to 'Documentation') diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 09340cb4e18d..46a125003b0a 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -206,7 +206,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. See "AC97 Quirk Option" section below. spdif_aclink - S/PDIF transfer over AC-link (default = 1) - This module supports up to 8 cards and autoprobe. + This module supports one card and autoprobe. ATI IXP has two different methods to control SPDIF output. One is over AC-link and another is over the "direct" SPDIF output. The @@ -218,7 +218,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. Module for ATI IXP 150/200/250 AC97 modem controllers. - Module supports up to 8 cards. + This module supports one card and autoprobe. Note: The default index value of this module is -2, i.e. the first slot is excluded. @@ -637,7 +637,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. model - force the model name position_fix - Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size) - Module supports up to 8 cards. + This module supports one card and autoprobe. Each codec may have a model table for different configurations. If your machine isn't listed there, the default (usually minimal) @@ -815,7 +815,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. semaphores (e.g. on some ASUS laptops) (default off) - Module supports autoprobe and multiple bus-master chips (max 8). + This module supports one chip and autoprobe. Note: the latest driver supports auto-detection of chip clock. if you still encounter too fast playback, specify the clock @@ -834,7 +834,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ac97_clock - AC'97 codec clock base (0 = auto-detect) - This module supports up to 8 cards and autoprobe. + This module supports one card and autoprobe. Note: The default index value of this module is -2, i.e. the first slot is excluded. @@ -1314,7 +1314,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ac97_quirk - AC'97 workaround for strange hardware See "AC97 Quirk Option" section below. - Module supports autoprobe and multiple bus-master chips (max 8). + This module supports one chip and autoprobe. Note: on some SMP motherboards like MSI 694D the interrupts might not be generated properly. In such a case, please try to @@ -1356,7 +1356,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. ac97_clock - AC'97 codec clock base (default 48000Hz) - Module supports up to 8 cards. + This module supports one card and autoprobe. Note: The default index value of this module is -2, i.e. the first slot is excluded. diff --git a/sound/pci/atiixp.c b/sound/pci/atiixp.c index cb1741102bbc..332a71de9673 100644 --- a/sound/pci/atiixp.c +++ b/sound/pci/atiixp.c @@ -39,24 +39,21 @@ MODULE_DESCRIPTION("ATI IXP AC97 controller"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250/300/400}}"); -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ -static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000}; -static char *ac97_quirk[SNDRV_CARDS]; -static int spdif_aclink[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; - -module_param_array(index, int, NULL, 0444); +static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static int ac97_clock = 48000; +static char *ac97_quirk; +static int spdif_aclink = 1; + +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for ATI IXP controller."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for ATI IXP controller."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable audio part of ATI IXP controller."); -module_param_array(ac97_clock, int, NULL, 0444); +module_param(ac97_clock, int, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); -module_param_array(ac97_quirk, charp, NULL, 0444); +module_param(ac97_quirk, charp, 0444); MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); -module_param_array(spdif_aclink, bool, NULL, 0444); +module_param(spdif_aclink, bool, 0444); MODULE_PARM_DESC(spdif_aclink, "S/PDIF over AC-link."); @@ -1578,26 +1575,18 @@ static int __devinit snd_atiixp_create(snd_card_t *card, static int __devinit snd_atiixp_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; atiixp_t *chip; unsigned char revision; int err; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (!enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; pci_read_config_byte(pci, PCI_REVISION_ID, &revision); - strcpy(card->driver, spdif_aclink[dev] ? "ATIIXP" : "ATIIXP-SPDMA"); + strcpy(card->driver, spdif_aclink ? "ATIIXP" : "ATIIXP-SPDMA"); strcpy(card->shortname, "ATI IXP"); if ((err = snd_atiixp_create(card, pci, &chip)) < 0) goto __error; @@ -1605,9 +1594,9 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, if ((err = snd_atiixp_aclink_reset(chip)) < 0) goto __error; - chip->spdif_over_aclink = spdif_aclink[dev]; + chip->spdif_over_aclink = spdif_aclink; - if ((err = snd_atiixp_mixer_new(chip, ac97_clock[dev], ac97_quirk[dev])) < 0) + if ((err = snd_atiixp_mixer_new(chip, ac97_clock, ac97_quirk)) < 0) goto __error; if ((err = snd_atiixp_pcm_new(chip)) < 0) @@ -1628,7 +1617,6 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, goto __error; pci_set_drvdata(pci, card); - dev++; return 0; __error: diff --git a/sound/pci/atiixp_modem.c b/sound/pci/atiixp_modem.c index a88a6f372050..a4778d373cdf 100644 --- a/sound/pci/atiixp_modem.c +++ b/sound/pci/atiixp_modem.c @@ -39,18 +39,15 @@ MODULE_DESCRIPTION("ATI IXP MC97 controller"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{ATI,IXP150/200/250}}"); -static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ -static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000}; +static int index = -2; /* Exclude the first card */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static int ac97_clock = 48000; -module_param_array(index, int, NULL, 0444); +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for ATI IXP controller."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for ATI IXP controller."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable audio part of ATI IXP controller."); -module_param_array(ac97_clock, int, NULL, 0444); +module_param(ac97_clock, int, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); @@ -1256,20 +1253,12 @@ static int __devinit snd_atiixp_create(snd_card_t *card, static int __devinit snd_atiixp_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; atiixp_t *chip; unsigned char revision; int err; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (!enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; @@ -1283,7 +1272,7 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, if ((err = snd_atiixp_aclink_reset(chip)) < 0) goto __error; - if ((err = snd_atiixp_mixer_new(chip, ac97_clock[dev])) < 0) + if ((err = snd_atiixp_mixer_new(chip, ac97_clock)) < 0) goto __error; if ((err = snd_atiixp_pcm_new(chip)) < 0) @@ -1302,7 +1291,6 @@ static int __devinit snd_atiixp_probe(struct pci_dev *pci, goto __error; pci_set_drvdata(pci, card); - dev++; return 0; __error: diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c index faf9dd00ba6c..d9e88dfe8171 100644 --- a/sound/pci/hda/hda_intel.c +++ b/sound/pci/hda/hda_intel.c @@ -47,21 +47,18 @@ #include "hda_codec.h" -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; -static char *model[SNDRV_CARDS]; -static int position_fix[SNDRV_CARDS]; +static int index = SNDRV_DEFAULT_IDX1; +static char *id = SNDRV_DEFAULT_STR1; +static char *model; +static int position_fix; -module_param_array(index, int, NULL, 0444); +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for Intel HD audio interface."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for Intel HD audio interface."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable Intel HD audio interface."); -module_param_array(model, charp, NULL, 0444); +module_param(model, charp, 0444); MODULE_PARM_DESC(model, "Use the given board model."); -module_param_array(position_fix, int, NULL, 0444); +module_param(position_fix, int, 0444); MODULE_PARM_DESC(position_fix, "Fix DMA pointer (0 = auto, 1 = none, 2 = POSBUF, 3 = FIFO size)."); MODULE_LICENSE("GPL"); @@ -1544,32 +1541,24 @@ static int __devinit azx_create(snd_card_t *card, struct pci_dev *pci, static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; azx_t *chip; int err = 0; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (! enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (NULL == card) { snd_printk(KERN_ERR SFX "Error creating card!\n"); return -ENOMEM; } - if ((err = azx_create(card, pci, position_fix[dev], pci_id->driver_data, + if ((err = azx_create(card, pci, position_fix, pci_id->driver_data, &chip)) < 0) { snd_card_free(card); return err; } /* create codec instances */ - if ((err = azx_codec_create(chip, model[dev])) < 0) { + if ((err = azx_codec_create(chip, model)) < 0) { snd_card_free(card); return err; } @@ -1595,7 +1584,6 @@ static int __devinit azx_probe(struct pci_dev *pci, const struct pci_device_id * } pci_set_drvdata(pci, card); - dev++; return err; } diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c index 0d11cf7d569a..bd9563c8b11e 100644 --- a/sound/pci/intel8x0.c +++ b/sound/pci/intel8x0.c @@ -64,34 +64,27 @@ MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH}," "{AMD,AMD8111}," "{ALI,M5455}}"); -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ -static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; -static char *ac97_quirk[SNDRV_CARDS]; -static int buggy_semaphore[SNDRV_CARDS]; -static int buggy_irq[SNDRV_CARDS]; -static int xbox[SNDRV_CARDS]; - -#ifdef SUPPORT_MIDI -static int mpu_port[SNDRV_CARDS]; /* disabled */ -#endif - -module_param_array(index, int, NULL, 0444); +static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static int ac97_clock = 0; +static char *ac97_quirk; +static int buggy_semaphore; +static int buggy_irq; +static int xbox; + +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for Intel i8x0 soundcard."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for Intel i8x0 soundcard."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable Intel i8x0 soundcard."); -module_param_array(ac97_clock, int, NULL, 0444); +module_param(ac97_clock, int, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect)."); -module_param_array(ac97_quirk, charp, NULL, 0444); +module_param(ac97_quirk, charp, 0444); MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); -module_param_array(buggy_semaphore, bool, NULL, 0444); +module_param(buggy_semaphore, bool, 0444); MODULE_PARM_DESC(buggy_semaphore, "Enable workaround for hardwares with problematic codec semaphores."); -module_param_array(buggy_irq, bool, NULL, 0444); +module_param(buggy_irq, bool, 0444); MODULE_PARM_DESC(buggy_irq, "Enable workaround for buggy interrupts on some motherboards."); -module_param_array(xbox, bool, NULL, 0444); +module_param(xbox, bool, 0444); MODULE_PARM_DESC(xbox, "Set to 1 for Xbox, if you have problems with the AC'97 codec detection."); /* @@ -2781,20 +2774,12 @@ static struct shortname_table { static int __devinit snd_intel8x0_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; intel8x0_t *chip; int err; struct shortname_table *name; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (!enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; @@ -2819,16 +2804,16 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci, } if ((err = snd_intel8x0_create(card, pci, pci_id->driver_data, - buggy_semaphore[dev], &chip)) < 0) { + buggy_semaphore, &chip)) < 0) { snd_card_free(card); return err; } - if (buggy_irq[dev]) + if (buggy_irq) chip->buggy_irq = 1; - if (xbox[dev]) + if (xbox) chip->xbox = 1; - if ((err = snd_intel8x0_mixer(chip, ac97_clock[dev], ac97_quirk[dev])) < 0) { + if ((err = snd_intel8x0_mixer(chip, ac97_clock, ac97_quirk)) < 0) { snd_card_free(card); return err; } @@ -2843,7 +2828,7 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci, "%s with %s at %#lx, irq %i", card->shortname, snd_ac97_get_short_name(chip->ac97[0]), chip->addr, chip->irq); - if (! ac97_clock[dev]) + if (! ac97_clock) intel8x0_measure_ac97_clock(chip); if ((err = snd_card_register(card)) < 0) { @@ -2851,7 +2836,6 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci, return err; } pci_set_drvdata(pci, card); - dev++; return 0; } diff --git a/sound/pci/intel8x0m.c b/sound/pci/intel8x0m.c index 15364d27804d..be604bb8445d 100644 --- a/sound/pci/intel8x0m.c +++ b/sound/pci/intel8x0m.c @@ -56,18 +56,15 @@ MODULE_SUPPORTED_DEVICE("{{Intel,82801AA-ICH}," "{NVidia,NForce3 Modem}," "{AMD,AMD768}}"); -static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ -static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; +static int index = -2; /* Exclude the first card */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static int ac97_clock = 0; -module_param_array(index, int, NULL, 0444); +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for Intel i8x0 modemcard."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for Intel i8x0 modemcard."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable Intel i8x0 modemcard."); -module_param_array(ac97_clock, int, NULL, 0444); +module_param(ac97_clock, int, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect)."); /* @@ -1263,20 +1260,12 @@ static struct shortname_table { static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; intel8x0_t *chip; int err; struct shortname_table *name; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (!enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; @@ -1295,7 +1284,7 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, return err; } - if ((err = snd_intel8x0_mixer(chip, ac97_clock[dev])) < 0) { + if ((err = snd_intel8x0_mixer(chip, ac97_clock)) < 0) { snd_card_free(card); return err; } @@ -1314,7 +1303,6 @@ static int __devinit snd_intel8x0m_probe(struct pci_dev *pci, return err; } pci_set_drvdata(pci, card); - dev++; return 0; } diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index ecc4836ba8de..4545208ee460 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -73,34 +73,31 @@ MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C,pci},{VIA,VT8233A/C,8235}}"); #define SUPPORT_JOYSTICK 1 #endif -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ -static long mpu_port[SNDRV_CARDS]; +static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static long mpu_port; #ifdef SUPPORT_JOYSTICK -static int joystick[SNDRV_CARDS]; +static int joystick; #endif -static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000}; -static char *ac97_quirk[SNDRV_CARDS]; -static int dxs_support[SNDRV_CARDS]; +static int ac97_clock = 48000; +static char *ac97_quirk; +static int dxs_support; -module_param_array(index, int, NULL, 0444); +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable audio part of VIA 82xx bridge."); -module_param_array(mpu_port, long, NULL, 0444); +module_param(mpu_port, long, 0444); MODULE_PARM_DESC(mpu_port, "MPU-401 port. (VT82C686x only)"); #ifdef SUPPORT_JOYSTICK -module_param_array(joystick, bool, NULL, 0444); +module_param(joystick, bool, 0444); MODULE_PARM_DESC(joystick, "Enable joystick. (VT82C686x only)"); #endif -module_param_array(ac97_clock, int, NULL, 0444); +module_param(ac97_clock, int, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); -module_param_array(ac97_quirk, charp, NULL, 0444); +module_param(ac97_quirk, charp, 0444); MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware."); -module_param_array(dxs_support, int, NULL, 0444); +module_param(dxs_support, int, 0444); MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA, 5 = enable any sample rate)"); @@ -1637,12 +1634,12 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip, const char *quirk_ov #ifdef SUPPORT_JOYSTICK #define JOYSTICK_ADDR 0x200 -static int __devinit snd_via686_create_gameport(via82xx_t *chip, int dev, unsigned char *legacy) +static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char *legacy) { struct gameport *gp; struct resource *r; - if (!joystick[dev]) + if (!joystick) return -ENODEV; r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport"); @@ -1686,7 +1683,7 @@ static void snd_via686_free_gameport(via82xx_t *chip) } } #else -static inline int snd_via686_create_gameport(via82xx_t *chip, int dev, unsigned char *legacy) +static inline int snd_via686_create_gameport(via82xx_t *chip, unsigned char *legacy) { return -ENOSYS; } @@ -1698,7 +1695,7 @@ static inline void snd_via686_free_gameport(via82xx_t *chip) { } * */ -static int __devinit snd_via8233_init_misc(via82xx_t *chip, int dev) +static int __devinit snd_via8233_init_misc(via82xx_t *chip) { int i, err, caps; unsigned char val; @@ -1739,7 +1736,7 @@ static int __devinit snd_via8233_init_misc(via82xx_t *chip, int dev) return 0; } -static int __devinit snd_via686_init_misc(via82xx_t *chip, int dev) +static int __devinit snd_via686_init_misc(via82xx_t *chip) { unsigned char legacy, legacy_cfg; int rev_h = 0; @@ -1750,32 +1747,33 @@ static int __devinit snd_via686_init_misc(via82xx_t *chip, int dev) legacy &= ~VIA_FUNC_ENABLE_GAME; /* disable joystick */ if (chip->revision >= VIA_REV_686_H) { rev_h = 1; - if (mpu_port[dev] >= 0x200) { /* force MIDI */ - mpu_port[dev] &= 0xfffc; - pci_write_config_dword(chip->pci, 0x18, mpu_port[dev] | 0x01); + if (mpu_port >= 0x200) { /* force MIDI */ + mpu_port &= 0xfffc; + pci_write_config_dword(chip->pci, 0x18, mpu_port | 0x01); #ifdef CONFIG_PM - chip->mpu_port_saved = mpu_port[dev]; + chip->mpu_port_saved = mpu_port; #endif } else { - mpu_port[dev] = pci_resource_start(chip->pci, 2); + mpu_port = pci_resource_start(chip->pci, 2); } } else { - switch (mpu_port[dev]) { /* force MIDI */ + switch (mpu_port) { /* force MIDI */ case 0x300: case 0x310: case 0x320: case 0x330: legacy_cfg &= ~(3 << 2); - legacy_cfg |= (mpu_port[dev] & 0x0030) >> 2; + legacy_cfg |= (mpu_port & 0x0030) >> 2; break; default: /* no, use BIOS settings */ if (legacy & VIA_FUNC_ENABLE_MIDI) - mpu_port[dev] = 0x300 + ((legacy_cfg & 0x000c) << 2); + mpu_port = 0x300 + ((legacy_cfg & 0x000c) << 2); break; } } - if (mpu_port[dev] >= 0x200 && - (chip->mpu_res = request_region(mpu_port[dev], 2, "VIA82xx MPU401")) != NULL) { + if (mpu_port >= 0x200 && + (chip->mpu_res = request_region(mpu_port, 2, "VIA82xx MPU401")) + != NULL) { if (rev_h) legacy |= VIA_FUNC_MIDI_PNP; /* enable PCI I/O 2 */ legacy |= VIA_FUNC_ENABLE_MIDI; @@ -1783,16 +1781,17 @@ static int __devinit snd_via686_init_misc(via82xx_t *chip, int dev) if (rev_h) legacy &= ~VIA_FUNC_MIDI_PNP; /* disable PCI I/O 2 */ legacy &= ~VIA_FUNC_ENABLE_MIDI; - mpu_port[dev] = 0; + mpu_port = 0; } pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, legacy_cfg); if (chip->mpu_res) { if (snd_mpu401_uart_new(chip->card, 0, MPU401_HW_VIA686A, - mpu_port[dev], 1, + mpu_port, 1, chip->irq, 0, &chip->rmidi) < 0) { - printk(KERN_WARNING "unable to initialize MPU-401 at 0x%lx, skipping\n", mpu_port[dev]); + printk(KERN_WARNING "unable to initialize MPU-401" + " at 0x%lx, skipping\n", mpu_port); legacy &= ~VIA_FUNC_ENABLE_MIDI; } else { legacy &= ~VIA_FUNC_MIDI_IRQMASK; /* enable MIDI interrupt */ @@ -1800,7 +1799,7 @@ static int __devinit snd_via686_init_misc(via82xx_t *chip, int dev) pci_write_config_byte(chip->pci, VIA_FUNC_ENABLE, legacy); } - snd_via686_create_gameport(chip, dev, &legacy); + snd_via686_create_gameport(chip, &legacy); #ifdef CONFIG_PM chip->legacy_saved = legacy; @@ -2221,7 +2220,6 @@ static int __devinit check_dxs_list(struct pci_dev *pci) static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; via82xx_t *chip; unsigned char revision; @@ -2229,14 +2227,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, unsigned int i; int err; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (!enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; @@ -2259,12 +2250,12 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, } } if (chip_type != TYPE_VIA8233A) { - if (dxs_support[dev] == VIA_DXS_AUTO) - dxs_support[dev] = check_dxs_list(pci); + if (dxs_support == VIA_DXS_AUTO) + dxs_support = check_dxs_list(pci); /* force to use VIA8233 or 8233A model according to * dxs_support module option */ - if (dxs_support[dev] == VIA_DXS_DISABLE) + if (dxs_support == VIA_DXS_DISABLE) chip_type = TYPE_VIA8233A; else chip_type = TYPE_VIA8233; @@ -2282,14 +2273,15 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, goto __error; } - if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock[dev], &chip)) < 0) + if ((err = snd_via82xx_create(card, pci, chip_type, revision, + ac97_clock, &chip)) < 0) goto __error; - if ((err = snd_via82xx_mixer_new(chip, ac97_quirk[dev])) < 0) + if ((err = snd_via82xx_mixer_new(chip, ac97_quirk)) < 0) goto __error; if (chip_type == TYPE_VIA686) { if ((err = snd_via686_pcm_new(chip)) < 0 || - (err = snd_via686_init_misc(chip, dev)) < 0) + (err = snd_via686_init_misc(chip)) < 0) goto __error; } else { if (chip_type == TYPE_VIA8233A) { @@ -2299,16 +2291,16 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, } else { if ((err = snd_via8233_pcm_new(chip)) < 0) goto __error; - if (dxs_support[dev] == VIA_DXS_48K) + if (dxs_support == VIA_DXS_48K) chip->dxs_fixed = 1; - else if (dxs_support[dev] == VIA_DXS_NO_VRA) + else if (dxs_support == VIA_DXS_NO_VRA) chip->no_vra = 1; - else if (dxs_support[dev] == VIA_DXS_SRC) { + else if (dxs_support == VIA_DXS_SRC) { chip->no_vra = 1; chip->dxs_src = 1; } } - if ((err = snd_via8233_init_misc(chip, dev)) < 0) + if ((err = snd_via8233_init_misc(chip)) < 0) goto __error; } @@ -2329,7 +2321,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, return err; } pci_set_drvdata(pci, card); - dev++; return 0; __error: diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index c3ab8fbf582c..a7a60d837c85 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c @@ -55,18 +55,15 @@ MODULE_DESCRIPTION("VIA VT82xx modem"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{VIA,VT82C686A/B/C modem,pci}}"); -static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ -static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000}; +static int index = -2; /* Exclude the first card */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static int ac97_clock = 48000; -module_param_array(index, int, NULL, 0444); +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for VIA 82xx bridge."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for VIA 82xx bridge."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable modem part of VIA 82xx bridge."); -module_param_array(ac97_clock, int, NULL, 0444); +module_param(ac97_clock, int, 0444); MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz)."); @@ -1135,7 +1132,6 @@ static int __devinit snd_via82xx_create(snd_card_t * card, static int __devinit snd_via82xx_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; via82xx_t *chip; unsigned char revision; @@ -1143,14 +1139,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, unsigned int i; int err; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (!enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; @@ -1167,7 +1156,8 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, goto __error; } - if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock[dev], &chip)) < 0) + if ((err = snd_via82xx_create(card, pci, chip_type, revision, + ac97_clock, &chip)) < 0) goto __error; if ((err = snd_via82xx_mixer_new(chip)) < 0) goto __error; @@ -1191,7 +1181,6 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci, return err; } pci_set_drvdata(pci, card); - dev++; return 0; __error: -- cgit v1.2.3-59-g8ed1b From 7c22f1aaa23370bf9ba2dd3abbccbed70dced216 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 10 Oct 2005 11:46:31 +0200 Subject: [ALSA] Remove snd_runtime_check() macro Remove snd_runtime_check() macro. This macro worsens the readability of codes. They should be either normal if() or removable asserts. Also, the assert displays stack-dump, instead of only the last caller pointer. Signed-off-by: Takashi Iwai --- .../sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 33 +++++------- include/sound/core.h | 34 ++++--------- sound/core/control.c | 18 +++---- sound/core/init.c | 5 +- sound/core/oss/mixer_oss.c | 59 +++++++++++++++------- sound/core/pcm.c | 3 +- sound/core/pcm_lib.c | 3 +- sound/core/pcm_native.c | 3 +- sound/core/seq/seq_midi.c | 2 - sound/core/timer.c | 3 +- sound/isa/cs423x/cs4236_lib.c | 5 +- sound/pci/ac97/ac97_codec.c | 1 - sound/pci/ac97/ac97_patch.c | 3 +- sound/pci/emu10k1/emufx.c | 34 +++++++++---- sound/pci/emu10k1/emupcm.c | 3 +- sound/pci/trident/trident_main.c | 3 +- sound/ppc/pmac.c | 16 +++--- 17 files changed, 126 insertions(+), 102 deletions(-) (limited to 'Documentation') diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index 24e85520890b..f3a2fdca9ad2 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -18,8 +18,8 @@ - March 6, 2005 - 0.3.4 + October 6, 2005 + 0.3.5 @@ -30,7 +30,7 @@ - Copyright (c) 2002-2004 Takashi Iwai tiwai@suse.de + Copyright (c) 2002-2005 Takashi Iwai tiwai@suse.de @@ -5998,32 +5998,23 @@ struct _snd_pcm_runtime { The first argument is the expression to evaluate, and the second argument is the action if it fails. When CONFIG_SND_DEBUG, is set, it will show an - error message such as BUG? (xxx) (called from - yyy). When no debug flag is set, this is - ignored. + error message such as BUG? (xxx) + together with stack trace. - - -
- <function>snd_runtime_check()</function> - This macro is quite similar with - snd_assert(). Unlike - snd_assert(), the expression is always - evaluated regardless of - CONFIG_SND_DEBUG. When - CONFIG_SND_DEBUG is set, the macro will - show a message like ERROR (xx) (called from - yyy). + When no debug flag is set, this macro is ignored.
<function>snd_BUG()</function> - It calls snd_assert(0,) -- that is, just - prints the error message at the point. It's useful to show that - a fatal error happens there. + It shows BUG? message and + stack trace as well as snd_assert at the point. + It's useful to show that a fatal error happens there. + + + When no debug flag is set, this macro is ignored.
diff --git a/include/sound/core.h b/include/sound/core.h index 6d971a4c4ca0..f0f54407fe5c 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -429,34 +429,24 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) * When CONFIG_SND_DEBUG is not set, the expression is executed but * not checked. */ -#define snd_assert(expr, args...) do {\ - if (unlikely(!(expr))) { \ - snd_printk(KERN_ERR "BUG? (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\ - args;\ - }\ +#define snd_assert(expr, args...) do { \ + if (unlikely(!(expr))) { \ + snd_printk(KERN_ERR "BUG? (%s)\n", __ASTRING__(expr)); \ + dump_stack(); \ + args; \ + } \ } while (0) -/** - * snd_runtime_check - run-time assertion macro - * @expr: expression - * @args...: the action - * - * This macro checks the expression in run-time and invokes the commands - * given in the rest arguments if the assertion is failed. - * Unlike snd_assert(), the action commands are executed even if - * CONFIG_SND_DEBUG is not set but without any error messages. - */ -#define snd_runtime_check(expr, args...) do {\ - if (unlikely(!(expr))) { \ - snd_printk(KERN_ERR "ERROR (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\ - args;\ - }\ + +#define snd_BUG() do { \ + snd_printk(KERN_ERR "BUG?\n"); \ + dump_stack(); \ } while (0) #else /* !CONFIG_SND_DEBUG */ #define snd_printd(fmt, args...) /* nothing */ #define snd_assert(expr, args...) (void)(expr) -#define snd_runtime_check(expr, args...) do { if (!(expr)) { args; } } while (0) +#define snd_BUG() /* nothing */ #endif /* CONFIG_SND_DEBUG */ @@ -473,8 +463,6 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) #define snd_printdd(format, args...) /* nothing */ #endif -#define snd_BUG() snd_assert(0, ) - static inline void snd_timestamp_now(struct timespec *tstamp, int timespec) { diff --git a/sound/core/control.c b/sound/core/control.c index 736edf358e05..212c46a94376 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -144,7 +144,7 @@ void snd_ctl_notify(snd_card_t *card, unsigned int mask, snd_ctl_elem_id_t *id) snd_ctl_file_t *ctl; snd_kctl_event_t *ev; - snd_runtime_check(card != NULL && id != NULL, return); + snd_assert(card != NULL && id != NULL, return); read_lock(&card->ctl_files_rwlock); #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) card->mixer_oss_change_count++; @@ -193,8 +193,8 @@ snd_kcontrol_t *snd_ctl_new(snd_kcontrol_t * control, unsigned int access) snd_kcontrol_t *kctl; unsigned int idx; - snd_runtime_check(control != NULL, return NULL); - snd_runtime_check(control->count > 0, return NULL); + snd_assert(control != NULL, return NULL); + snd_assert(control->count > 0, return NULL); kctl = kzalloc(sizeof(*kctl) + sizeof(snd_kcontrol_volatile_t) * control->count, GFP_KERNEL); if (kctl == NULL) return NULL; @@ -220,7 +220,7 @@ snd_kcontrol_t *snd_ctl_new1(const snd_kcontrol_new_t * ncontrol, void *private_ snd_kcontrol_t kctl; unsigned int access; - snd_runtime_check(ncontrol != NULL, return NULL); + snd_assert(ncontrol != NULL, return NULL); snd_assert(ncontrol->info != NULL, return NULL); memset(&kctl, 0, sizeof(kctl)); kctl.id.iface = ncontrol->iface; @@ -309,7 +309,7 @@ int snd_ctl_add(snd_card_t * card, snd_kcontrol_t * kcontrol) snd_ctl_elem_id_t id; unsigned int idx; - snd_runtime_check(card != NULL && kcontrol != NULL, return -EINVAL); + snd_assert(card != NULL && kcontrol != NULL, return -EINVAL); snd_assert(kcontrol->info != NULL, return -EINVAL); id = kcontrol->id; down_write(&card->controls_rwsem); @@ -355,7 +355,7 @@ int snd_ctl_remove(snd_card_t * card, snd_kcontrol_t * kcontrol) snd_ctl_elem_id_t id; unsigned int idx; - snd_runtime_check(card != NULL && kcontrol != NULL, return -EINVAL); + snd_assert(card != NULL && kcontrol != NULL, return -EINVAL); list_del(&kcontrol->list); card->controls_count -= kcontrol->count; id = kcontrol->id; @@ -468,7 +468,7 @@ snd_kcontrol_t *snd_ctl_find_numid(snd_card_t * card, unsigned int numid) struct list_head *list; snd_kcontrol_t *kctl; - snd_runtime_check(card != NULL && numid != 0, return NULL); + snd_assert(card != NULL && numid != 0, return NULL); list_for_each(list, &card->controls) { kctl = snd_kcontrol(list); if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) @@ -494,7 +494,7 @@ snd_kcontrol_t *snd_ctl_find_id(snd_card_t * card, snd_ctl_elem_id_t *id) struct list_head *list; snd_kcontrol_t *kctl; - snd_runtime_check(card != NULL && id != NULL, return NULL); + snd_assert(card != NULL && id != NULL, return NULL); if (id->numid != 0) return snd_ctl_find_numid(card, id->numid); list_for_each(list, &card->controls) { @@ -1215,7 +1215,7 @@ static int _snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn, struct list_head struct list_head *list; snd_kctl_ioctl_t *p; - snd_runtime_check(fcn != NULL, return -EINVAL); + snd_assert(fcn != NULL, return -EINVAL); down_write(&snd_ioctl_rwsem); list_for_each(list, lists) { p = list_entry(list, snd_kctl_ioctl_t, list); diff --git a/sound/core/init.c b/sound/core/init.c index 41e224986f35..b98f7c6310c5 100644 --- a/sound/core/init.c +++ b/sound/core/init.c @@ -420,7 +420,7 @@ int snd_card_register(snd_card_t * card) int err; snd_info_entry_t *entry; - snd_runtime_check(card != NULL, return -EINVAL); + snd_assert(card != NULL, return -EINVAL); if ((err = snd_device_register_all(card)) < 0) return err; write_lock(&snd_card_rwlock); @@ -524,7 +524,8 @@ int __init snd_card_info_init(void) snd_info_entry_t *entry; entry = snd_info_create_module_entry(THIS_MODULE, "cards", NULL); - snd_runtime_check(entry != NULL, return -ENOMEM); + if (! entry) + return -ENOMEM; entry->c.text.read_size = PAGE_SIZE; entry->c.text.read = snd_card_info_read; if (snd_info_register(entry) < 0) { diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c index 69e1059112d1..b2497cec2079 100644 --- a/sound/core/oss/mixer_oss.c +++ b/sound/core/oss/mixer_oss.c @@ -521,9 +521,13 @@ static void snd_mixer_oss_get_volume1_vol(snd_mixer_oss_file_t *fmixer, uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; - snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); - snd_runtime_check(!kctl->get(kctl, uctl), goto __unalloc); - snd_runtime_check(uinfo->type != SNDRV_CTL_ELEM_TYPE_BOOLEAN || uinfo->value.integer.min != 0 || uinfo->value.integer.max != 1, goto __unalloc); + if (kctl->info(kctl, uinfo)) + goto __unalloc; + if (kctl->get(kctl, uctl)) + goto __unalloc; + if (uinfo->type == SNDRV_CTL_ELEM_TYPE_BOOLEAN && + uinfo->value.integer.min == 0 && uinfo->value.integer.max == 1) + goto __unalloc; *left = snd_mixer_oss_conv1(uctl->value.integer.value[0], uinfo->value.integer.min, uinfo->value.integer.max, &pslot->volume[0]); if (uinfo->count > 1) *right = snd_mixer_oss_conv1(uctl->value.integer.value[1], uinfo->value.integer.min, uinfo->value.integer.max, &pslot->volume[1]); @@ -555,8 +559,10 @@ static void snd_mixer_oss_get_volume1_sw(snd_mixer_oss_file_t *fmixer, uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; - snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); - snd_runtime_check(!kctl->get(kctl, uctl), goto __unalloc); + if (kctl->info(kctl, uinfo)) + goto __unalloc; + if (kctl->get(kctl, uctl)) + goto __unalloc; if (!uctl->value.integer.value[0]) { *left = 0; if (uinfo->count == 1) @@ -616,12 +622,16 @@ static void snd_mixer_oss_put_volume1_vol(snd_mixer_oss_file_t *fmixer, uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; - snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); - snd_runtime_check(uinfo->type != SNDRV_CTL_ELEM_TYPE_BOOLEAN || uinfo->value.integer.min != 0 || uinfo->value.integer.max != 1, goto __unalloc); + if (kctl->info(kctl, uinfo)) + goto __unalloc; + if (uinfo->type == SNDRV_CTL_ELEM_TYPE_BOOLEAN && + uinfo->value.integer.min == 0 && uinfo->value.integer.max == 1) + goto __unalloc; uctl->value.integer.value[0] = snd_mixer_oss_conv2(left, uinfo->value.integer.min, uinfo->value.integer.max); if (uinfo->count > 1) uctl->value.integer.value[1] = snd_mixer_oss_conv2(right, uinfo->value.integer.min, uinfo->value.integer.max); - snd_runtime_check((res = kctl->put(kctl, uctl)) >= 0, goto __unalloc); + if ((res = kctl->put(kctl, uctl)) < 0) + goto __unalloc; if (res > 0) snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); __unalloc: @@ -653,7 +663,8 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer, uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); if (uinfo == NULL || uctl == NULL) goto __unalloc; - snd_runtime_check(!kctl->info(kctl, uinfo), goto __unalloc); + if (kctl->info(kctl, uinfo)) + goto __unalloc; if (uinfo->count > 1) { uctl->value.integer.value[0] = left > 0 ? 1 : 0; uctl->value.integer.value[route ? 3 : 1] = right > 0 ? 1 : 0; @@ -664,7 +675,8 @@ static void snd_mixer_oss_put_volume1_sw(snd_mixer_oss_file_t *fmixer, } else { uctl->value.integer.value[0] = (left > 0 || right > 0) ? 1 : 0; } - snd_runtime_check((res = kctl->put(kctl, uctl)) >= 0, goto __unalloc); + if ((res = kctl->put(kctl, uctl)) < 0) + goto __unalloc; if (res > 0) snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); __unalloc: @@ -776,9 +788,14 @@ static int snd_mixer_oss_get_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int } down_read(&card->controls_rwsem); kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0); - snd_runtime_check(kctl != NULL, err = -ENOENT; goto __unlock); - snd_runtime_check(!(err = kctl->info(kctl, uinfo)), goto __unlock); - snd_runtime_check(!(err = kctl->get(kctl, uctl)), goto __unlock); + if (! kctl) { + err = -ENOENT; + goto __unlock; + } + if ((err = kctl->info(kctl, uinfo)) < 0) + goto __unlock; + if ((err = kctl->get(kctl, uctl)) < 0) + goto __unlock; for (idx = 0; idx < 32; idx++) { if (!(mixer->mask_recsrc & (1 << idx))) continue; @@ -821,8 +838,12 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int } down_read(&card->controls_rwsem); kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0); - snd_runtime_check(kctl != NULL, err = -ENOENT; goto __unlock); - snd_runtime_check(!(err = kctl->info(kctl, uinfo)), goto __unlock); + if (! kctl) { + err = -ENOENT; + goto __unlock; + } + if ((err = kctl->info(kctl, uinfo)) < 0) + goto __unlock; for (idx = 0; idx < 32; idx++) { if (!(mixer->mask_recsrc & (1 << idx))) continue; @@ -836,10 +857,11 @@ static int snd_mixer_oss_put_recsrc2(snd_mixer_oss_file_t *fmixer, unsigned int break; slot = NULL; } - snd_runtime_check(slot != NULL, goto __unlock); + if (! slot) + goto __unlock; for (idx = 0; idx < uinfo->count; idx++) uctl->value.enumerated.item[idx] = slot->capture_item; - snd_runtime_check((err = kctl->put(kctl, uctl)) >= 0, ); + err = kctl->put(kctl, uctl); if (err > 0) snd_ctl_notify(fmixer->card, SNDRV_CTL_EVENT_MASK_VALUE, &kctl->id); err = 0; @@ -1008,7 +1030,8 @@ static int snd_mixer_oss_build_input(snd_mixer_oss_t *mixer, struct snd_mixer_os up_read(&mixer->card->controls_rwsem); if (slot.present != 0) { pslot = (struct slot *)kmalloc(sizeof(slot), GFP_KERNEL); - snd_runtime_check(pslot != NULL, return -ENOMEM); + if (! pslot) + return -ENOMEM; *pslot = slot; pslot->signature = SNDRV_MIXER_OSS_SIGNATURE; pslot->assigned = ptr; diff --git a/sound/core/pcm.c b/sound/core/pcm.c index 1be470e942ef..184e74b75ba9 100644 --- a/sound/core/pcm.c +++ b/sound/core/pcm.c @@ -273,7 +273,8 @@ static void snd_pcm_proc_info_read(snd_pcm_substream_t *substream, snd_info_buff snd_pcm_info_t *info; int err; - snd_runtime_check(substream, return); + if (! substream) + return; info = kmalloc(sizeof(*info), GFP_KERNEL); if (! info) { diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 0503980c23d9..dfc5f45f2748 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -156,9 +156,8 @@ static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(snd_pcm_substream_t *s #ifdef CONFIG_SND_DEBUG if (pos >= runtime->buffer_size) { snd_printk(KERN_ERR "BUG: stream = %i, pos = 0x%lx, buffer size = 0x%lx, period size = 0x%lx\n", substream->stream, pos, runtime->buffer_size, runtime->period_size); - } else + } #endif - snd_runtime_check(pos < runtime->buffer_size, return 0); pos -= pos % runtime->min_align; return pos; } diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index e97b2d162cc7..e6e2b70314c0 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2053,7 +2053,8 @@ static int snd_pcm_open(struct inode *inode, struct file *file) snd_pcm_file_t *pcm_file; wait_queue_t wait; - snd_runtime_check(device >= SNDRV_MINOR_PCM_PLAYBACK && device < SNDRV_MINOR_DEVICES, return -ENXIO); + if (device < SNDRV_MINOR_PCM_PLAYBACK || device >= SNDRV_MINOR_DEVICES) + return -ENXIO; pcm = snd_pcm_devices[(cardnum * SNDRV_PCM_DEVICES) + (device % SNDRV_MINOR_PCMS)]; if (pcm == NULL) { err = -ENODEV; diff --git a/sound/core/seq/seq_midi.c b/sound/core/seq/seq_midi.c index b4674ae3bc30..f89f40f44876 100644 --- a/sound/core/seq/seq_midi.c +++ b/sound/core/seq/seq_midi.c @@ -449,11 +449,9 @@ snd_seq_midisynth_unregister_port(snd_seq_device_t *dev) client->ports_per_device[device] = 0; msynth = client->ports[device]; client->ports[device] = NULL; - snd_runtime_check(msynth != NULL || ports <= 0, goto __skip); for (p = 0; p < ports; p++) snd_seq_midisynth_delete(&msynth[p]); kfree(msynth); - __skip: client->num_ports--; if (client->num_ports <= 0) { snd_seq_delete_kernel_client(client->seq_client); diff --git a/sound/core/timer.c b/sound/core/timer.c index 22b104624084..128916c66085 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -879,7 +879,8 @@ void snd_timer_notify(snd_timer_t *timer, enum sndrv_timer_event event, struct t snd_timer_instance_t *ti, *ts; struct list_head *p, *n; - snd_runtime_check(timer->hw.flags & SNDRV_TIMER_HW_SLAVE, return); + if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) + return; snd_assert(event >= SNDRV_TIMER_EVENT_MSTART && event <= SNDRV_TIMER_EVENT_MRESUME, return); spin_lock_irqsave(&timer->lock, flags); if (event == SNDRV_TIMER_EVENT_MSTART || diff --git a/sound/isa/cs423x/cs4236_lib.c b/sound/isa/cs423x/cs4236_lib.c index 2128d4bdef41..1adb88d5f8f4 100644 --- a/sound/isa/cs423x/cs4236_lib.c +++ b/sound/isa/cs423x/cs4236_lib.c @@ -173,7 +173,10 @@ static unsigned char divisor_to_rate_register(unsigned int divisor) case 2117: return 6; case 2558: return 7; default: - snd_runtime_check(divisor >= 21 && divisor <= 192, return 192); + if (divisor < 21 || divisor > 192) { + snd_BUG(); + return 192; + } return divisor; } } diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 56549add80a8..bbc409ae7ee9 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -1127,7 +1127,6 @@ snd_kcontrol_t *snd_ac97_cnew(const snd_kcontrol_new_t *_template, ac97_t * ac97 { snd_kcontrol_new_t template; memcpy(&template, _template, sizeof(template)); - snd_runtime_check(!template.index, return NULL); template.index = ac97->num; return snd_ctl_new1(&template, ac97); } diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c index b24beb32961e..de1c72ad2c6b 100644 --- a/sound/pci/ac97/ac97_patch.c +++ b/sound/pci/ac97/ac97_patch.c @@ -1460,7 +1460,8 @@ int patch_ad1881(ac97_t * ac97) codecs[1] = patch_ad1881_unchained(ac97, 1, (1<<14)); codecs[2] = patch_ad1881_unchained(ac97, 2, (1<<13)); - snd_runtime_check(codecs[0] | codecs[1] | codecs[2], goto __end); + if (! (codecs[0] || codecs[1] || codecs[2])) + goto __end; for (idx = 0; idx < 3; idx++) if (ac97->spec.ad18xx.unchained[idx]) diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index 20db3ac6cd61..177c4ad0f778 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c @@ -364,12 +364,18 @@ static int snd_emu10k1_gpr_ctl_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]); break; case EMU10K1_GPR_TRANSLATION_BASS: - snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error); + if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { + change = -EIO; + goto __error; + } for (j = 0; j < 5; j++) snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]); break; case EMU10K1_GPR_TRANSLATION_TREBLE: - snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error); + if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) { + change = -EIO; + goto __error; + } for (j = 0; j < 5; j++) snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]); break; @@ -412,8 +418,6 @@ int snd_emu10k1_fx8010_register_irq_handler(emu10k1_t *emu, snd_emu10k1_fx8010_irq_t *irq; unsigned long flags; - snd_runtime_check(emu, return -EINVAL); - snd_runtime_check(handler, return -EINVAL); irq = kmalloc(sizeof(*irq), GFP_ATOMIC); if (irq == NULL) return -ENOMEM; @@ -442,7 +446,6 @@ int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu, snd_emu10k1_fx8010_irq_t *tmp; unsigned long flags; - snd_runtime_check(irq, return -EINVAL); spin_lock_irqsave(&emu->fx8010.irq_lock, flags); if ((tmp = emu->fx8010.irq_handlers) == irq) { emu->fx8010.irq_handlers = tmp->next; @@ -717,9 +720,15 @@ static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode err = -EFAULT; goto __error; } - snd_runtime_check(gctl->id.iface == SNDRV_CTL_ELEM_IFACE_MIXER || - gctl->id.iface == SNDRV_CTL_ELEM_IFACE_PCM, err = -EINVAL; goto __error); - snd_runtime_check(gctl->id.name[0] != '\0', err = -EINVAL; goto __error); + if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER && + gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) { + err = -EINVAL; + goto __error; + } + if (! gctl->id.name[0]) { + err = -EINVAL; + goto __error; + } ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); memset(&knew, 0, sizeof(knew)); knew.iface = gctl->id.iface; @@ -783,7 +792,8 @@ static int snd_emu10k1_del_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode for (i = 0, _id = icode->gpr_del_controls; i < icode->gpr_del_control_count; i++, _id++) { - snd_runtime_check(copy_from_user(&id, _id, sizeof(id)) == 0, return -EFAULT); + if (copy_from_user(&id, _id, sizeof(id))) + return -EFAULT; down_write(&card->controls_rwsem); ctl = snd_emu10k1_look_for_ctl(emu, &id); if (ctl) @@ -2075,14 +2085,16 @@ void snd_emu10k1_free_efx(emu10k1_t *emu) #if 0 // FIXME: who use them? int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output) { - snd_runtime_check(output >= 0 && output < 6, return -EINVAL); + if (output < 0 || output >= 6) + return -EINVAL; snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1); return 0; } int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output) { - snd_runtime_check(output >= 0 && output < 6, return -EINVAL); + if (output < 0 || output >= 6) + return -EINVAL; snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0); return 0; } diff --git a/sound/pci/emu10k1/emupcm.c b/sound/pci/emu10k1/emupcm.c index 66ba27afe962..bf7490dae09b 100644 --- a/sound/pci/emu10k1/emupcm.c +++ b/sound/pci/emu10k1/emupcm.c @@ -965,7 +965,8 @@ static void snd_emu10k1_pcm_mixer_notify1(emu10k1_t *emu, snd_kcontrol_t *kctl, { snd_ctl_elem_id_t id; - snd_runtime_check(kctl != NULL, return); + if (! kctl) + return; if (activate) kctl->vd[idx].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; else diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index 777da9a7298b..dda62955b4fe 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c @@ -2893,7 +2893,8 @@ static void snd_trident_notify_pcm_change1(snd_card_t * card, snd_kcontrol_t *kc { snd_ctl_elem_id_t id; - snd_runtime_check(kctl != NULL, return); + if (! kctl) + return; if (activate) kctl->vd[num].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; else diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c index 392b2abd9f13..db2f1815fc30 100644 --- a/sound/ppc/pmac.c +++ b/sound/ppc/pmac.c @@ -220,7 +220,8 @@ static int snd_pmac_pcm_prepare(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substr /* set up constraints */ astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); - snd_runtime_check(astr, return -EINVAL); + if (! astr) + return -EINVAL; astr->cur_freqs = 1 << rate_index; astr->cur_formats = 1 << runtime->format; chip->rate_index = rate_index; @@ -467,7 +468,8 @@ static int snd_pmac_hw_rule_rate(snd_pcm_hw_params_t *params, pmac_stream_t *rec = snd_pmac_get_stream(chip, rule->deps[0]); int i, freq_table[8], num_freqs; - snd_runtime_check(rec, return -EINVAL); + if (! rec) + return -EINVAL; num_freqs = 0; for (i = chip->num_freqs - 1; i >= 0; i--) { if (rec->cur_freqs & (1 << i)) @@ -484,7 +486,8 @@ static int snd_pmac_hw_rule_format(snd_pcm_hw_params_t *params, pmac_t *chip = rule->private; pmac_stream_t *rec = snd_pmac_get_stream(chip, rule->deps[0]); - snd_runtime_check(rec, return -EINVAL); + if (! rec) + return -EINVAL; return snd_mask_refine_set(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), rec->cur_formats); } @@ -569,7 +572,8 @@ static int snd_pmac_pcm_close(pmac_t *chip, pmac_stream_t *rec, snd_pcm_substrea snd_pmac_dma_stop(rec); astr = snd_pmac_get_stream(chip, another_stream(rec->stream)); - snd_runtime_check(astr, return -EINVAL); + if (! astr) + return -EINVAL; /* reset constraints */ astr->cur_freqs = chip->freqs_ok; @@ -1158,7 +1162,6 @@ int __init snd_pmac_new(snd_card_t *card, pmac_t **chip_return) .dev_free = snd_pmac_dev_free, }; - snd_runtime_check(chip_return, return -EINVAL); *chip_return = NULL; chip = kzalloc(sizeof(*chip), GFP_KERNEL); @@ -1382,7 +1385,8 @@ static int snd_pmac_sleep_notify(struct pmu_sleep_notifier *self, int when) pmac_t *chip; chip = sleeping_pmac; - snd_runtime_check(chip, return 0); + if (! chip) + return 0; switch (when) { case PBOOK_SLEEP_NOW: -- cgit v1.2.3-59-g8ed1b From 07799e756c76ecd52cb01a812ba48b7d8ac67633 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 10 Oct 2005 11:49:49 +0200 Subject: [ALSA] Use getnstimeofday() Modules: Documentation,PCM Midlevel,Timer Midlevel,ALSA Core Use the standard getnstimeofday() function instead of ALSA's own one. Signed-off-by: Takashi Iwai --- .../sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 3 +-- include/sound/core.h | 23 ---------------------- include/sound/pcm.h | 3 +-- sound/core/pcm_lib.c | 2 +- sound/core/pcm_native.c | 14 ++++--------- sound/core/timer.c | 6 +++--- 6 files changed, 10 insertions(+), 41 deletions(-) (limited to 'Documentation') diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index f3a2fdca9ad2..ab3dfe074fb1 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -2190,8 +2190,7 @@ struct _snd_pcm_runtime { unsigned int rate_den; /* -- SW params -- */ - int tstamp_timespec; /* use timeval (0) or timespec (1) */ - snd_pcm_tstamp_t tstamp_mode; /* mmap timestamp is updated */ + struct timespec tstamp_mode; /* mmap timestamp is updated */ unsigned int period_step; unsigned int sleep_min; /* min ticks to sleep */ snd_pcm_uframes_t xfer_align; /* xfer size need to be a multiple */ diff --git a/include/sound/core.h b/include/sound/core.h index f0f54407fe5c..fa8f4c9492cc 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -29,7 +29,6 @@ #include /* pm_message_t */ /* Typedef's */ -typedef struct timespec snd_timestamp_t; typedef struct sndrv_interval snd_interval_t; typedef enum sndrv_card_type snd_card_type; typedef struct sndrv_xferi snd_xferi_t; @@ -464,28 +463,6 @@ void snd_verbose_printd(const char *file, int line, const char *format, ...) #endif -static inline void snd_timestamp_now(struct timespec *tstamp, int timespec) -{ - struct timeval val; - /* FIXME: use a linear time source */ - do_gettimeofday(&val); - tstamp->tv_sec = val.tv_sec; - tstamp->tv_nsec = val.tv_usec; - if (timespec) - tstamp->tv_nsec *= 1000L; -} - -static inline void snd_timestamp_zero(struct timespec *tstamp) -{ - tstamp->tv_sec = 0; - tstamp->tv_nsec = 0; -} - -static inline int snd_timestamp_null(struct timespec *tstamp) -{ - return tstamp->tv_sec == 0 && tstamp->tv_nsec == 0; -} - #define SNDRV_OSS_VERSION ((3<<16)|(8<<8)|(1<<4)|(0)) /* 3.8.1a */ /* for easier backward-porting */ diff --git a/include/sound/pcm.h b/include/sound/pcm.h index 2b23a5967071..acc4fa9d5abe 100644 --- a/include/sound/pcm.h +++ b/include/sound/pcm.h @@ -281,7 +281,7 @@ typedef struct { struct _snd_pcm_runtime { /* -- Status -- */ snd_pcm_substream_t *trigger_master; - snd_timestamp_t trigger_tstamp; /* trigger timestamp */ + struct timespec trigger_tstamp; /* trigger timestamp */ int overrange; snd_pcm_uframes_t avail_max; snd_pcm_uframes_t hw_ptr_base; /* Position at buffer restart */ @@ -306,7 +306,6 @@ struct _snd_pcm_runtime { unsigned int rate_den; /* -- SW params -- */ - int tstamp_timespec; /* use timeval (0) or timespec (1) */ snd_pcm_tstamp_t tstamp_mode; /* mmap timestamp is updated */ unsigned int period_step; unsigned int sleep_min; /* min ticks to sleep */ diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index dfc5f45f2748..3dbf9bf2ac16 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -152,7 +152,7 @@ static inline snd_pcm_uframes_t snd_pcm_update_hw_ptr_pos(snd_pcm_substream_t *s if (pos == SNDRV_PCM_POS_XRUN) return pos; /* XRUN */ if (runtime->tstamp_mode & SNDRV_PCM_TSTAMP_MMAP) - snd_timestamp_now((snd_timestamp_t*)&runtime->status->tstamp, runtime->tstamp_timespec); + getnstimeofday((struct timespec *)&runtime->status->tstamp); #ifdef CONFIG_SND_DEBUG if (pos >= runtime->buffer_size) { snd_printk(KERN_ERR "BUG: stream = %i, pos = 0x%lx, buffer size = 0x%lx, period size = 0x%lx\n", substream->stream, pos, runtime->buffer_size, runtime->period_size); diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index e6e2b70314c0..a1924f12d8fc 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -565,9 +565,9 @@ int snd_pcm_status(snd_pcm_substream_t *substream, if (runtime->tstamp_mode & SNDRV_PCM_TSTAMP_MMAP) status->tstamp = runtime->status->tstamp; else - snd_timestamp_now(&status->tstamp, runtime->tstamp_timespec); + getnstimeofday(&status->tstamp); } else - snd_timestamp_now(&status->tstamp, runtime->tstamp_timespec); + getnstimeofday(&status->tstamp); status->appl_ptr = runtime->control->appl_ptr; status->hw_ptr = runtime->status->hw_ptr; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { @@ -652,7 +652,7 @@ static void snd_pcm_trigger_tstamp(snd_pcm_substream_t *substream) if (runtime->trigger_master == NULL) return; if (runtime->trigger_master == substream) { - snd_timestamp_now(&runtime->trigger_tstamp, runtime->tstamp_timespec); + getnstimeofday(&runtime->trigger_tstamp); } else { snd_pcm_trigger_tstamp(runtime->trigger_master); runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; @@ -2446,14 +2446,8 @@ static int snd_pcm_common_ioctl1(snd_pcm_substream_t *substream, return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0; case SNDRV_PCM_IOCTL_INFO: return snd_pcm_info_user(substream, arg); - case SNDRV_PCM_IOCTL_TSTAMP: - { - int xarg; - if (get_user(xarg, (int __user *)arg)) - return -EFAULT; - substream->runtime->tstamp_timespec = xarg ? 1 : 0; + case SNDRV_PCM_IOCTL_TSTAMP: /* just for compatibility */ return 0; - } case SNDRV_PCM_IOCTL_HW_REFINE: return snd_pcm_hw_refine_user(substream, arg); case SNDRV_PCM_IOCTL_HW_PARAMS: diff --git a/sound/core/timer.c b/sound/core/timer.c index 128916c66085..8ecec9134acd 100644 --- a/sound/core/timer.c +++ b/sound/core/timer.c @@ -385,7 +385,7 @@ static void snd_timer_notify1(snd_timer_instance_t *ti, enum sndrv_timer_event e struct list_head *n; struct timespec tstamp; - snd_timestamp_now(&tstamp, 1); + getnstimeofday(&tstamp); snd_assert(event >= SNDRV_TIMER_EVENT_START && event <= SNDRV_TIMER_EVENT_PAUSE, return); if (event == SNDRV_TIMER_EVENT_START || event == SNDRV_TIMER_EVENT_CONTINUE) resolution = snd_timer_resolution(ti); @@ -1156,14 +1156,14 @@ static void snd_timer_user_tinterrupt(snd_timer_instance_t *timeri, struct timespec tstamp; int prev, append = 0; - snd_timestamp_zero(&tstamp); + memset(&tstamp, 0, sizeof(tstamp)); spin_lock(&tu->qlock); if ((tu->filter & ((1 << SNDRV_TIMER_EVENT_RESOLUTION)|(1 << SNDRV_TIMER_EVENT_TICK))) == 0) { spin_unlock(&tu->qlock); return; } if (tu->last_resolution != resolution || ticks > 0) - snd_timestamp_now(&tstamp, 1); + getnstimeofday(&tstamp); if ((tu->filter & (1 << SNDRV_TIMER_EVENT_RESOLUTION)) && tu->last_resolution != resolution) { r1.event = SNDRV_TIMER_EVENT_RESOLUTION; r1.tstamp = tstamp; -- cgit v1.2.3-59-g8ed1b From b1d5776d865951c213a1caaab5d8bf5de7615dbd Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 10 Oct 2005 11:56:31 +0200 Subject: [ALSA] Remove vmalloc wrapper, kfree_nocheck() - Remove vmalloc wrapper - Add release_and_free_resource() to remove kfree_nocheck() from each driver and simplify the code Signed-off-by: Takashi Iwai --- .../sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 17 +------ include/sound/core.h | 9 +--- include/sound/driver.h | 4 -- sound/core/memory.c | 53 ---------------------- sound/core/misc.c | 9 ++++ sound/core/sound.c | 5 +- sound/core/wrappers.c | 10 ---- sound/drivers/mpu401/mpu401_uart.c | 5 +- sound/drivers/mtpav.c | 5 +- sound/drivers/opl3/opl3_lib.c | 10 +--- sound/drivers/opl4/opl4_lib.c | 10 +--- sound/drivers/serial-u16550.c | 5 +- sound/drivers/vx/vx_pcm.c | 4 +- sound/isa/ad1816a/ad1816a_lib.c | 5 +- sound/isa/ad1848/ad1848_lib.c | 5 +- sound/isa/cs423x/cs4231_lib.c | 10 +--- sound/isa/cs423x/cs4236.c | 8 +--- sound/isa/es1688/es1688_lib.c | 3 +- sound/isa/es18xx.c | 15 ++---- sound/isa/gus/gus_main.c | 10 +--- sound/isa/gus/interwave.c | 5 +- sound/isa/opl3sa2.c | 5 +- sound/isa/opti9xx/opti92x-ad1848.c | 25 +++------- sound/isa/sb/emu8000.c | 15 ++---- sound/isa/sb/sb16.c | 5 +- sound/isa/sb/sb8.c | 5 +- sound/isa/sb/sb_common.c | 6 +-- sound/isa/sscape.c | 6 +-- sound/isa/wavefront/wavefront.c | 5 +- sound/mips/au1x00.c | 3 +- sound/pci/als4000.c | 6 +-- sound/pci/azt3328.c | 6 +-- sound/pci/ca0106/ca0106_main.c | 6 +-- sound/pci/cmipci.c | 6 +-- sound/pci/cs46xx/cs46xx_lib.c | 5 +- sound/pci/emu10k1/emu10k1x.c | 6 +-- sound/pci/es1968.c | 6 +-- sound/pci/nm256/nm256.c | 10 +--- sound/pci/sonicvibes.c | 10 +--- sound/pci/via82xx.c | 11 ++--- sound/pci/ymfpci/ymfpci.c | 16 ++----- sound/pci/ymfpci/ymfpci_main.c | 15 ++---- sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c | 6 +-- sound/usb/usbaudio.c | 6 +-- 44 files changed, 86 insertions(+), 311 deletions(-) (limited to 'Documentation') diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index ab3dfe074fb1..05ae29ac898c 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -1433,25 +1433,10 @@ res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + release_and_free_resource(chip->res_port); ]]> - - As you can see, the resource pointer is also to be freed - via kfree_nocheck() after - release_resource() is called. You - cannot use kfree() here, because on ALSA, - kfree() may be a wrapper to its own - allocator with the memory debugging. Since the resource pointer - is allocated externally outside the ALSA, it must be released - via the native - kfree(). - kfree_nocheck() is used for that; it calls - the native kfree() without wrapper.
diff --git a/include/sound/core.h b/include/sound/core.h index af314205635d..0a14885fb1d7 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -293,19 +293,13 @@ void *snd_hidden_kmalloc(size_t size, gfp_t flags); void *snd_hidden_kzalloc(size_t size, gfp_t flags); void *snd_hidden_kcalloc(size_t n, size_t size, gfp_t flags); void snd_hidden_kfree(const void *obj); -void *snd_hidden_vmalloc(unsigned long size); -void snd_hidden_vfree(void *obj); char *snd_hidden_kstrdup(const char *s, gfp_t flags); #define kmalloc(size, flags) snd_hidden_kmalloc(size, flags) #define kzalloc(size, flags) snd_hidden_kzalloc(size, flags) #define kcalloc(n, size, flags) snd_hidden_kcalloc(n, size, flags) #define kfree(obj) snd_hidden_kfree(obj) -#define vmalloc(size) snd_hidden_vmalloc(size) -#define vfree(obj) snd_hidden_vfree(obj) #define kmalloc_nocheck(size, flags) snd_wrapper_kmalloc(size, flags) -#define vmalloc_nocheck(size) snd_wrapper_vmalloc(size) #define kfree_nocheck(obj) snd_wrapper_kfree(obj) -#define vfree_nocheck(obj) snd_wrapper_vfree(obj) #define kstrdup(s, flags) snd_hidden_kstrdup(s, flags) #else #define snd_memory_init() /*NOP*/ @@ -313,9 +307,7 @@ char *snd_hidden_kstrdup(const char *s, gfp_t flags); #define snd_memory_info_init() /*NOP*/ #define snd_memory_info_done() /*NOP*/ #define kmalloc_nocheck(size, flags) kmalloc(size, flags) -#define vmalloc_nocheck(size) vmalloc(size) #define kfree_nocheck(obj) kfree(obj) -#define vfree_nocheck(obj) vfree(obj) #endif int copy_to_user_fromio(void __user *dst, const volatile void __iomem *src, size_t count); int copy_from_user_toio(volatile void __iomem *dst, const void __user *src, size_t count); @@ -372,6 +364,7 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size); #endif /* misc.c */ +void release_and_free_resource(struct resource *res); #ifdef CONFIG_SND_VERBOSE_PRINTK void snd_verbose_printk(const char *file, int line, const char *format, ...) diff --git a/include/sound/driver.h b/include/sound/driver.h index 1ec2fae050a6..7973e0c05ae3 100644 --- a/include/sound/driver.h +++ b/include/sound/driver.h @@ -55,10 +55,6 @@ void *snd_wrapper_kmalloc(size_t, gfp_t); #undef kmalloc void snd_wrapper_kfree(const void *); #undef kfree -void *snd_wrapper_vmalloc(size_t); -#undef vmalloc -void snd_wrapper_vfree(void *); -#undef vfree #endif #endif /* __SOUND_DRIVER_H */ diff --git a/sound/core/memory.c b/sound/core/memory.c index 7d8e2eebba51..b99343616f81 100644 --- a/sound/core/memory.c +++ b/sound/core/memory.c @@ -47,19 +47,14 @@ struct snd_alloc_track { #define snd_alloc_track_entry(obj) (struct snd_alloc_track *)((char*)obj - (unsigned long)((struct snd_alloc_track *)0)->data) static long snd_alloc_kmalloc; -static long snd_alloc_vmalloc; static LIST_HEAD(snd_alloc_kmalloc_list); -static LIST_HEAD(snd_alloc_vmalloc_list); static DEFINE_SPINLOCK(snd_alloc_kmalloc_lock); -static DEFINE_SPINLOCK(snd_alloc_vmalloc_lock); #define KMALLOC_MAGIC 0x87654321 -#define VMALLOC_MAGIC 0x87654320 static snd_info_entry_t *snd_memory_info_entry; void __init snd_memory_init(void) { snd_alloc_kmalloc = 0; - snd_alloc_vmalloc = 0; } void snd_memory_done(void) @@ -69,8 +64,6 @@ void snd_memory_done(void) if (snd_alloc_kmalloc > 0) snd_printk(KERN_ERR "Not freed snd_alloc_kmalloc = %li\n", snd_alloc_kmalloc); - if (snd_alloc_vmalloc > 0) - snd_printk(KERN_ERR "Not freed snd_alloc_vmalloc = %li\n", snd_alloc_vmalloc); list_for_each_prev(head, &snd_alloc_kmalloc_list) { t = list_entry(head, struct snd_alloc_track, list); if (t->magic != KMALLOC_MAGIC) { @@ -79,14 +72,6 @@ void snd_memory_done(void) } snd_printk(KERN_ERR "kmalloc(%ld) from %p not freed\n", (long) t->size, t->caller); } - list_for_each_prev(head, &snd_alloc_vmalloc_list) { - t = list_entry(head, struct snd_alloc_track, list); - if (t->magic != VMALLOC_MAGIC) { - snd_printk(KERN_ERR "Corrupted vmalloc\n"); - break; - } - snd_printk(KERN_ERR "vmalloc(%ld) from %p not freed\n", (long) t->size, t->caller); - } } static void *__snd_kmalloc(size_t size, gfp_t flags, void *caller) @@ -153,43 +138,6 @@ void snd_hidden_kfree(const void *obj) snd_wrapper_kfree(obj); } -void *snd_hidden_vmalloc(unsigned long size) -{ - void *ptr; - ptr = snd_wrapper_vmalloc(size + sizeof(struct snd_alloc_track)); - if (ptr) { - struct snd_alloc_track *t = (struct snd_alloc_track *)ptr; - t->magic = VMALLOC_MAGIC; - t->caller = __builtin_return_address(0); - spin_lock(&snd_alloc_vmalloc_lock); - list_add_tail(&t->list, &snd_alloc_vmalloc_list); - spin_unlock(&snd_alloc_vmalloc_lock); - t->size = size; - snd_alloc_vmalloc += size; - ptr = t->data; - } - return ptr; -} - -void snd_hidden_vfree(void *obj) -{ - struct snd_alloc_track *t; - if (obj == NULL) - return; - t = snd_alloc_track_entry(obj); - if (t->magic != VMALLOC_MAGIC) { - snd_printk(KERN_ERR "bad vfree (called from %p)\n", __builtin_return_address(0)); - return; - } - spin_lock(&snd_alloc_vmalloc_lock); - list_del(&t->list); - spin_unlock(&snd_alloc_vmalloc_lock); - t->magic = 0; - snd_alloc_vmalloc -= t->size; - obj = t; - snd_wrapper_vfree(obj); -} - char *snd_hidden_kstrdup(const char *s, gfp_t flags) { int len; @@ -207,7 +155,6 @@ char *snd_hidden_kstrdup(const char *s, gfp_t flags) static void snd_memory_info_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) { snd_iprintf(buffer, "kmalloc: %li bytes\n", snd_alloc_kmalloc); - snd_iprintf(buffer, "vmalloc: %li bytes\n", snd_alloc_vmalloc); } int __init snd_memory_info_init(void) diff --git a/sound/core/misc.c b/sound/core/misc.c index 11a7675b719b..3eddfdede9f3 100644 --- a/sound/core/misc.c +++ b/sound/core/misc.c @@ -23,8 +23,17 @@ #include #include #include +#include #include +void release_and_free_resource(struct resource *res) +{ + if (res) { + release_resource(res); + kfree_nocheck(res); + } +} + #ifdef CONFIG_SND_VERBOSE_PRINTK void snd_verbose_printk(const char *file, int line, const char *format, ...) { diff --git a/sound/core/sound.c b/sound/core/sound.c index bc8ad0017984..e94eebd8ad6f 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c @@ -407,8 +407,6 @@ EXPORT_SYMBOL(snd_unregister_oss_device); EXPORT_SYMBOL(snd_hidden_kmalloc); EXPORT_SYMBOL(snd_hidden_kcalloc); EXPORT_SYMBOL(snd_hidden_kfree); -EXPORT_SYMBOL(snd_hidden_vmalloc); -EXPORT_SYMBOL(snd_hidden_vfree); EXPORT_SYMBOL(snd_hidden_kstrdup); #endif EXPORT_SYMBOL(copy_to_user_fromio); @@ -487,6 +485,7 @@ EXPORT_SYMBOL(snd_ctl_unregister_ioctl_compat); EXPORT_SYMBOL(snd_ctl_elem_read); EXPORT_SYMBOL(snd_ctl_elem_write); /* misc.c */ +EXPORT_SYMBOL(release_and_free_resource); #ifdef CONFIG_SND_VERBOSE_PRINTK EXPORT_SYMBOL(snd_verbose_printk); #endif @@ -497,6 +496,4 @@ EXPORT_SYMBOL(snd_verbose_printd); #ifdef CONFIG_SND_DEBUG_MEMORY EXPORT_SYMBOL(snd_wrapper_kmalloc); EXPORT_SYMBOL(snd_wrapper_kfree); -EXPORT_SYMBOL(snd_wrapper_vmalloc); -EXPORT_SYMBOL(snd_wrapper_vfree); #endif diff --git a/sound/core/wrappers.c b/sound/core/wrappers.c index 296b716f1376..19e899089cb3 100644 --- a/sound/core/wrappers.c +++ b/sound/core/wrappers.c @@ -36,15 +36,5 @@ void snd_wrapper_kfree(const void *obj) { kfree(obj); } - -void *snd_wrapper_vmalloc(unsigned long size) -{ - return vmalloc(size); -} - -void snd_wrapper_vfree(void *obj) -{ - vfree(obj); -} #endif diff --git a/sound/drivers/mpu401/mpu401_uart.c b/sound/drivers/mpu401/mpu401_uart.c index fe3f921ffbe3..bdeb2c00dac5 100644 --- a/sound/drivers/mpu401/mpu401_uart.c +++ b/sound/drivers/mpu401/mpu401_uart.c @@ -423,10 +423,7 @@ static void snd_mpu401_uart_free(snd_rawmidi_t *rmidi) mpu401_t *mpu = rmidi->private_data; if (mpu->irq_flags && mpu->irq >= 0) free_irq(mpu->irq, (void *) mpu); - if (mpu->res) { - release_resource(mpu->res); - kfree_nocheck(mpu->res); - } + release_and_free_resource(mpu->res); kfree(mpu); } diff --git a/sound/drivers/mtpav.c b/sound/drivers/mtpav.c index 3a25c89d2983..e9d52c668edc 100644 --- a/sound/drivers/mtpav.c +++ b/sound/drivers/mtpav.c @@ -717,10 +717,7 @@ static void free_mtpav(mtpav_t * crd) spin_unlock_irqrestore(&crd->spinlock, flags); if (crd->irq >= 0) free_irq(crd->irq, (void *)crd); - if (crd->res_port) { - release_resource(crd->res_port); - kfree_nocheck(crd->res_port); - } + release_and_free_resource(crd->res_port); kfree(crd); } diff --git a/sound/drivers/opl3/opl3_lib.c b/sound/drivers/opl3/opl3_lib.c index 1f84d78260de..06246503083c 100644 --- a/sound/drivers/opl3/opl3_lib.c +++ b/sound/drivers/opl3/opl3_lib.c @@ -325,14 +325,8 @@ static int snd_opl3_free(opl3_t *opl3) snd_assert(opl3 != NULL, return -ENXIO); if (opl3->private_free) opl3->private_free(opl3); - if (opl3->res_l_port) { - release_resource(opl3->res_l_port); - kfree_nocheck(opl3->res_l_port); - } - if (opl3->res_r_port) { - release_resource(opl3->res_r_port); - kfree_nocheck(opl3->res_r_port); - } + release_and_free_resource(opl3->res_l_port); + release_and_free_resource(opl3->res_r_port); kfree(opl3); return 0; } diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c index 380c2c704c54..4ae5dd8f011e 100644 --- a/sound/drivers/opl4/opl4_lib.c +++ b/sound/drivers/opl4/opl4_lib.c @@ -169,14 +169,8 @@ static void snd_opl4_free(opl4_t *opl4) #ifdef CONFIG_PROC_FS snd_opl4_free_proc(opl4); #endif - if (opl4->res_fm_port) { - release_resource(opl4->res_fm_port); - kfree_nocheck(opl4->res_fm_port); - } - if (opl4->res_pcm_port) { - release_resource(opl4->res_pcm_port); - kfree_nocheck(opl4->res_pcm_port); - } + release_and_free_resource(opl4->res_fm_port); + release_and_free_resource(opl4->res_pcm_port); kfree(opl4); } diff --git a/sound/drivers/serial-u16550.c b/sound/drivers/serial-u16550.c index 416172ea1f47..1ed58df42671 100644 --- a/sound/drivers/serial-u16550.c +++ b/sound/drivers/serial-u16550.c @@ -749,10 +749,7 @@ static int snd_uart16550_free(snd_uart16550_t *uart) { if (uart->irq >= 0) free_irq(uart->irq, (void *)uart); - if (uart->res_base) { - release_resource(uart->res_base); - kfree_nocheck(uart->res_base); - } + release_and_free_resource(uart->res_base); kfree(uart); return 0; }; diff --git a/sound/drivers/vx/vx_pcm.c b/sound/drivers/vx/vx_pcm.c index c2312d912fc7..2b46758fe86f 100644 --- a/sound/drivers/vx/vx_pcm.c +++ b/sound/drivers/vx/vx_pcm.c @@ -79,7 +79,7 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) /* already allocated */ if (runtime->dma_bytes >= size) return 0; /* already enough large */ - vfree_nocheck(runtime->dma_area); /* bypass the memory wrapper */ + vfree(runtime->dma_area); } runtime->dma_area = vmalloc_32(size); if (! runtime->dma_area) @@ -98,7 +98,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) { snd_pcm_runtime_t *runtime = subs->runtime; if (runtime->dma_area) { - vfree_nocheck(runtime->dma_area); /* bypass the memory wrapper */ + vfree(runtime->dma_area); runtime->dma_area = NULL; } return 0; diff --git a/sound/isa/ad1816a/ad1816a_lib.c b/sound/isa/ad1816a/ad1816a_lib.c index 27a9dcfbba00..7ae02396cae2 100644 --- a/sound/isa/ad1816a/ad1816a_lib.c +++ b/sound/isa/ad1816a/ad1816a_lib.c @@ -542,10 +542,7 @@ static int snd_ad1816a_probe(ad1816a_t *chip) static int snd_ad1816a_free(ad1816a_t *chip) { - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + release_and_free_resource(chip->res_port); if (chip->irq >= 0) free_irq(chip->irq, (void *) chip); if (chip->dma1 >= 0) { diff --git a/sound/isa/ad1848/ad1848_lib.c b/sound/isa/ad1848/ad1848_lib.c index 303861cd03cd..0c2924dfefaf 100644 --- a/sound/isa/ad1848/ad1848_lib.c +++ b/sound/isa/ad1848/ad1848_lib.c @@ -846,10 +846,7 @@ static int snd_ad1848_capture_close(snd_pcm_substream_t * substream) static int snd_ad1848_free(ad1848_t *chip) { - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + release_and_free_resource(chip->res_port); if (chip->irq >= 0) free_irq(chip->irq, (void *) chip); if (chip->dma >= 0) { diff --git a/sound/isa/cs423x/cs4231_lib.c b/sound/isa/cs423x/cs4231_lib.c index 32318258cd8e..4af769030beb 100644 --- a/sound/isa/cs423x/cs4231_lib.c +++ b/sound/isa/cs423x/cs4231_lib.c @@ -1417,14 +1417,8 @@ static int snd_cs4231_pm_resume(snd_card_t *card) static int snd_cs4231_free(cs4231_t *chip) { - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } - if (chip->res_cport) { - release_resource(chip->res_cport); - kfree_nocheck(chip->res_cport); - } + release_and_free_resource(chip->res_port); + release_and_free_resource(chip->res_cport); if (chip->irq >= 0) { disable_irq(chip->irq); if (!(chip->hwshare & CS4231_HWSHARE_IRQ)) diff --git a/sound/isa/cs423x/cs4236.c b/sound/isa/cs423x/cs4236.c index d28315dc72f7..d60a55e6a0b1 100644 --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -379,12 +379,8 @@ static void snd_card_cs4236_free(snd_card_t *card) { struct snd_card_cs4236 *acard = (struct snd_card_cs4236 *)card->private_data; - if (acard) { - if (acard->res_sb_port) { - release_resource(acard->res_sb_port); - kfree_nocheck(acard->res_sb_port); - } - } + if (acard) + release_and_free_resource(acard->res_sb_port); } #ifdef CONFIG_PNP diff --git a/sound/isa/es1688/es1688_lib.c b/sound/isa/es1688/es1688_lib.c index aac898765c02..2edc9c9f0445 100644 --- a/sound/isa/es1688/es1688_lib.c +++ b/sound/isa/es1688/es1688_lib.c @@ -606,8 +606,7 @@ static int snd_es1688_free(es1688_t *chip) { if (chip->res_port) { snd_es1688_init(chip, 0); - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); + release_and_free_resource(chip->res_port); } if (chip->irq >= 0) free_irq(chip->irq, (void *) chip); diff --git a/sound/isa/es18xx.c b/sound/isa/es18xx.c index d0ea19f42703..f0f8505cd1a5 100644 --- a/sound/isa/es18xx.c +++ b/sound/isa/es18xx.c @@ -1640,18 +1640,9 @@ static int snd_es18xx_resume(snd_card_t *card) static int snd_es18xx_free(es18xx_t *chip) { - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } - if (chip->res_ctrl_port) { - release_resource(chip->res_ctrl_port); - kfree_nocheck(chip->res_ctrl_port); - } - if (chip->res_mpu_port) { - release_resource(chip->res_mpu_port); - kfree_nocheck(chip->res_mpu_port); - } + release_and_free_resource(chip->res_port); + release_and_free_resource(chip->res_ctrl_port); + release_and_free_resource(chip->res_mpu_port); if (chip->irq >= 0) free_irq(chip->irq, (void *) chip); if (chip->dma1 >= 0) { diff --git a/sound/isa/gus/gus_main.c b/sound/isa/gus/gus_main.c index 8f2872f8e8f6..5fd374f052ec 100644 --- a/sound/isa/gus/gus_main.c +++ b/sound/isa/gus/gus_main.c @@ -113,14 +113,8 @@ static int snd_gus_free(snd_gus_card_t *gus) snd_gf1_stop(gus); snd_gus_init_dma_irq(gus, 0); __hw_end: - if (gus->gf1.res_port1) { - release_resource(gus->gf1.res_port1); - kfree_nocheck(gus->gf1.res_port1); - } - if (gus->gf1.res_port2) { - release_resource(gus->gf1.res_port2); - kfree_nocheck(gus->gf1.res_port2); - } + release_and_free_resource(gus->gf1.res_port1); + release_and_free_resource(gus->gf1.res_port2); if (gus->gf1.irq >= 0) free_irq(gus->gf1.irq, (void *) gus); if (gus->gf1.dma1 >= 0) { diff --git a/sound/isa/gus/interwave.c b/sound/isa/gus/interwave.c index 358cba9d738f..b101ab0a0dbf 100644 --- a/sound/isa/gus/interwave.c +++ b/sound/isa/gus/interwave.c @@ -638,10 +638,7 @@ static void snd_interwave_free(snd_card_t *card) if (iwcard == NULL) return; #ifdef SNDRV_STB - if (iwcard->i2c_res) { - release_resource(iwcard->i2c_res); - kfree_nocheck(iwcard->i2c_res); - } + release_and_free_resource(iwcard->i2c_res); #endif if (iwcard->irq >= 0) free_irq(iwcard->irq, (void *)iwcard); diff --git a/sound/isa/opl3sa2.c b/sound/isa/opl3sa2.c index 4ba268f251e3..47cabda792b6 100644 --- a/sound/isa/opl3sa2.c +++ b/sound/isa/opl3sa2.c @@ -656,10 +656,7 @@ static int snd_opl3sa2_free(opl3sa2_t *chip) { if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + release_and_free_resource(chip->res_port); kfree(chip); return 0; } diff --git a/sound/isa/opti9xx/opti92x-ad1848.c b/sound/isa/opti9xx/opti92x-ad1848.c index 73573cb1db6a..b94339f8306f 100644 --- a/sound/isa/opti9xx/opti92x-ad1848.c +++ b/sound/isa/opti9xx/opti92x-ad1848.c @@ -299,10 +299,8 @@ static char * snd_opti9xx_names[] = { static long snd_legacy_find_free_ioport(long *port_table, long size) { while (*port_table != -1) { - struct resource *res; - if ((res = request_region(*port_table, size, "ALSA test")) != NULL) { - release_resource(res); - kfree_nocheck(res); + if (request_region(*port_table, size, "ALSA test")) { + release_region(*port_table, size); return *port_table; } port_table++; @@ -1227,10 +1225,7 @@ static int snd_opti93x_probe(opti93x_t *chip) static int snd_opti93x_free(opti93x_t *chip) { - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + release_and_free_resource(chip->res_port); if (chip->dma1 >= 0) { disable_dma(chip->dma1); free_dma(chip->dma1); @@ -1656,8 +1651,7 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip) if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1))) return 1; - release_resource(chip->res_mc_base); - kfree_nocheck(chip->res_mc_base); + release_and_free_resource(chip->res_mc_base); chip->res_mc_base = NULL; } @@ -1683,8 +1677,7 @@ static int __devinit snd_card_opti9xx_detect(snd_card_t *card, opti9xx_t *chip) if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value) return 1; - release_resource(chip->res_mc_base); - kfree_nocheck(chip->res_mc_base); + release_and_free_resource(chip->res_mc_base); chip->res_mc_base = NULL; } #endif /* OPTi93X */ @@ -1886,12 +1879,8 @@ static void snd_card_opti9xx_free(snd_card_t *card) { opti9xx_t *chip = (opti9xx_t *)card->private_data; - if (chip) { - if (chip->res_mc_base) { - release_resource(chip->res_mc_base); - kfree_nocheck(chip->res_mc_base); - } - } + if (chip) + release_and_free_resource(chip->res_mc_base); } static int snd_card_opti9xx_probe(struct pnp_card_link *pcard, diff --git a/sound/isa/sb/emu8000.c b/sound/isa/sb/emu8000.c index 5375705c054b..95540f133199 100644 --- a/sound/isa/sb/emu8000.c +++ b/sound/isa/sb/emu8000.c @@ -1054,18 +1054,9 @@ __error: */ static int snd_emu8000_free(emu8000_t *hw) { - if (hw->res_port1) { - release_resource(hw->res_port1); - kfree_nocheck(hw->res_port1); - } - if (hw->res_port2) { - release_resource(hw->res_port2); - kfree_nocheck(hw->res_port2); - } - if (hw->res_port3) { - release_resource(hw->res_port3); - kfree_nocheck(hw->res_port3); - } + release_and_free_resource(hw->res_port1); + release_and_free_resource(hw->res_port2); + release_and_free_resource(hw->res_port3); kfree(hw); return 0; } diff --git a/sound/isa/sb/sb16.c b/sound/isa/sb/sb16.c index 7888783d68f5..c2fa451bc8f0 100644 --- a/sound/isa/sb/sb16.c +++ b/sound/isa/sb/sb16.c @@ -345,10 +345,7 @@ static void snd_sb16_free(snd_card_t *card) if (acard == NULL) return; - if (acard->fm_res) { - release_resource(acard->fm_res); - kfree_nocheck(acard->fm_res); - } + release_and_free_resource(acard->fm_res); } #ifdef CONFIG_PNP diff --git a/sound/isa/sb/sb8.c b/sound/isa/sb/sb8.c index c41ac25e85ca..0bc0a3afdabc 100644 --- a/sound/isa/sb/sb8.c +++ b/sound/isa/sb/sb8.c @@ -78,10 +78,7 @@ static void snd_sb8_free(snd_card_t *card) if (acard == NULL) return; - if (acard->fm_res) { - release_resource(acard->fm_res); - kfree_nocheck(acard->fm_res); - } + release_and_free_resource(acard->fm_res); } static int __init snd_sb8_probe(int dev) diff --git a/sound/isa/sb/sb_common.c b/sound/isa/sb/sb_common.c index f0f205ae425f..46b9480669f9 100644 --- a/sound/isa/sb/sb_common.c +++ b/sound/isa/sb/sb_common.c @@ -178,10 +178,8 @@ static int snd_sbdsp_probe(sb_t * chip) static int snd_sbdsp_free(sb_t *chip) { - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + if (chip->res_port) + release_and_free_resource(chip->res_port); if (chip->irq >= 0) free_irq(chip->irq, (void *) chip); #ifdef CONFIG_ISA diff --git a/sound/isa/sscape.c b/sound/isa/sscape.c index 9f6b58c79209..1036876146c4 100644 --- a/sound/isa/sscape.c +++ b/sound/isa/sscape.c @@ -338,8 +338,7 @@ static inline void activate_ad1845_unsafe(unsigned io_base) static void soundscape_free(snd_card_t * c) { register struct soundscape *sscape = get_card_soundscape(c); - release_resource(sscape->io_res); - kfree_nocheck(sscape->io_res); + release_and_free_resource(sscape->io_res); free_dma(sscape->chip->dma1); } @@ -1288,8 +1287,7 @@ static int __devinit create_sscape(const struct params *params, snd_card_t **rca free_dma(params->dma1); _release_region: - release_resource(io_res); - kfree_nocheck(io_res); + release_and_free_resource(io_res); return err; } diff --git a/sound/isa/wavefront/wavefront.c b/sound/isa/wavefront/wavefront.c index 0a572e0a47e6..1818f1013c3f 100644 --- a/sound/isa/wavefront/wavefront.c +++ b/sound/isa/wavefront/wavefront.c @@ -379,10 +379,7 @@ snd_wavefront_free(snd_card_t *card) snd_wavefront_card_t *acard = (snd_wavefront_card_t *)card->private_data; if (acard) { - if (acard->wavefront.res_base != NULL) { - release_resource(acard->wavefront.res_base); - kfree_nocheck(acard->wavefront.res_base); - } + release_and_free_resource(acard->wavefront.res_base); if (acard->wavefront.irq > 0) free_irq(acard->wavefront.irq, (void *)acard); } diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index 3f9684f1d1d2..b7af85f5bfb4 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -606,8 +606,7 @@ snd_au1000_free(snd_card_t *card) /* put internal AC97 block into reset */ au1000->ac97_ioport->cntrl = AC97C_RS; au1000->ac97_ioport = NULL; - release_resource(au1000->ac97_res_port); - kfree_nocheck(au1000->ac97_res_port); + release_and_free_resource(au1000->ac97_res_port); } if (au1000->stream[PLAYBACK]->dma >= 0) diff --git a/sound/pci/als4000.c b/sound/pci/als4000.c index 196ec1c61bb4..8a32cd92f62a 100644 --- a/sound/pci/als4000.c +++ b/sound/pci/als4000.c @@ -594,8 +594,7 @@ static int __devinit snd_als4000_create_gameport(snd_card_als4000_t *acard, int acard->gameport = gp = gameport_allocate_port(); if (!gp) { printk(KERN_ERR "als4000: cannot allocate memory for gameport\n"); - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); return -ENOMEM; } @@ -622,8 +621,7 @@ static void snd_als4000_free_gameport(snd_card_als4000_t *acard) acard->gameport = NULL; snd_als4000_set_addr(acard->gcr, 0, 0, 0, 0); /* disable joystick */ - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); } } #else diff --git a/sound/pci/azt3328.c b/sound/pci/azt3328.c index d5261bdec583..dc638f395c02 100644 --- a/sound/pci/azt3328.c +++ b/sound/pci/azt3328.c @@ -1238,8 +1238,7 @@ static int __devinit snd_azf3328_config_joystick(azf3328_t *chip, int dev) chip->gameport = gp = gameport_allocate_port(); if (!gp) { printk(KERN_ERR "azt3328: cannot allocate memory for gameport\n"); - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); return -ENOMEM; } @@ -1267,8 +1266,7 @@ static void snd_azf3328_free_joystick(azf3328_t *chip) /* disable gameport */ snd_azf3328_io2_write(chip, IDX_IO2_LEGACY_ADDR, snd_azf3328_io2_read(chip, IDX_IO2_LEGACY_ADDR) & ~LEGACY_JOY); - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); } } #else diff --git a/sound/pci/ca0106/ca0106_main.c b/sound/pci/ca0106/ca0106_main.c index ba07960921d8..0d9d8923fbbb 100644 --- a/sound/pci/ca0106/ca0106_main.c +++ b/sound/pci/ca0106/ca0106_main.c @@ -969,10 +969,8 @@ static int snd_ca0106_free(ca0106_t *chip) #endif // release the i/o port - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + release_and_free_resource(chip->res_port); + // release the irq if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); diff --git a/sound/pci/cmipci.c b/sound/pci/cmipci.c index 316afb78488d..db093bca2cd0 100644 --- a/sound/pci/cmipci.c +++ b/sound/pci/cmipci.c @@ -2683,8 +2683,7 @@ static int __devinit snd_cmipci_create_gameport(cmipci_t *cm, int dev) cm->gameport = gp = gameport_allocate_port(); if (!gp) { printk(KERN_ERR "cmipci: cannot allocate memory for gameport\n"); - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); return -ENOMEM; } gameport_set_name(gp, "C-Media Gameport"); @@ -2709,8 +2708,7 @@ static void snd_cmipci_free_gameport(cmipci_t *cm) cm->gameport = NULL; snd_cmipci_clear_bit(cm, CM_REG_FUNCTRL1, CM_JYSTK_EN); - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); } } #else diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index 6e3855b8b33d..147836f09dcf 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -2906,10 +2906,7 @@ static int snd_cs46xx_free(cs46xx_t *chip) snd_cs46xx_region_t *region = &chip->region.idx[idx]; if (region->remap_addr) iounmap(region->remap_addr); - if (region->resource) { - release_resource(region->resource); - kfree_nocheck(region->resource); - } + release_and_free_resource(region->resource); } if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); diff --git a/sound/pci/emu10k1/emu10k1x.c b/sound/pci/emu10k1/emu10k1x.c index ad15755a63c3..cbb689474e7d 100644 --- a/sound/pci/emu10k1/emu10k1x.c +++ b/sound/pci/emu10k1/emu10k1x.c @@ -759,10 +759,8 @@ static int snd_emu10k1x_free(emu10k1x_t *chip) outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); // release the i/o port - if (chip->res_port) { - release_resource(chip->res_port); - kfree_nocheck(chip->res_port); - } + release_and_free_resource(chip->res_port); + // release the irq if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c index ecdcada90ca2..1bf094b67469 100644 --- a/sound/pci/es1968.c +++ b/sound/pci/es1968.c @@ -2461,8 +2461,7 @@ static int __devinit snd_es1968_create_gameport(es1968_t *chip, int dev) chip->gameport = gp = gameport_allocate_port(); if (!gp) { printk(KERN_ERR "es1968: cannot allocate memory for gameport\n"); - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); return -ENOMEM; } @@ -2488,8 +2487,7 @@ static void snd_es1968_free_gameport(es1968_t *chip) gameport_unregister_port(chip->gameport); chip->gameport = NULL; - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); } } #else diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index 5c55a3b1d121..ebfa38b51128 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -1347,14 +1347,8 @@ static int snd_nm256_free(nm256_t *chip) iounmap(chip->cport); if (chip->buffer) iounmap(chip->buffer); - if (chip->res_cport) { - release_resource(chip->res_cport); - kfree_nocheck(chip->res_cport); - } - if (chip->res_buffer) { - release_resource(chip->res_buffer); - kfree_nocheck(chip->res_buffer); - } + release_and_free_resource(chip->res_cport); + release_and_free_resource(chip->res_buffer); if (chip->irq >= 0) free_irq(chip->irq, (void*)chip); diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index 1f6c2bfd43fd..4f64814dfef0 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1205,14 +1205,8 @@ static int snd_sonicvibes_free(sonicvibes_t *sonic) pci_write_config_dword(sonic->pci, 0x48, sonic->dmac_port); if (sonic->irq >= 0) free_irq(sonic->irq, (void *)sonic); - if (sonic->res_dmaa) { - release_resource(sonic->res_dmaa); - kfree_nocheck(sonic->res_dmaa); - } - if (sonic->res_dmac) { - release_resource(sonic->res_dmac); - kfree_nocheck(sonic->res_dmac); - } + release_and_free_resource(sonic->res_dmaa); + release_and_free_resource(sonic->res_dmac); pci_release_regions(sonic->pci); pci_disable_device(sonic->pci); kfree(sonic); diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index b2779fb7d1a9..b0302c369c3d 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1655,8 +1655,7 @@ static int __devinit snd_via686_create_gameport(via82xx_t *chip, unsigned char * chip->gameport = gp = gameport_allocate_port(); if (!gp) { printk(KERN_ERR "via82xx: cannot allocate memory for gameport\n"); - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); return -ENOMEM; } @@ -1682,8 +1681,7 @@ static void snd_via686_free_gameport(via82xx_t *chip) gameport_unregister_port(chip->gameport); chip->gameport = NULL; - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); } } #else @@ -2023,10 +2021,7 @@ static int snd_via82xx_free(via82xx_t *chip) __end_hw: if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); - if (chip->mpu_res) { - release_resource(chip->mpu_res); - kfree_nocheck(chip->mpu_res); - } + release_and_free_resource(chip->mpu_res); pci_release_regions(chip->pci); if (chip->chip_type == TYPE_VIA686) { diff --git a/sound/pci/ymfpci/ymfpci.c b/sound/pci/ymfpci/ymfpci.c index 2e69abe51aa9..e50d744ae706 100644 --- a/sound/pci/ymfpci/ymfpci.c +++ b/sound/pci/ymfpci/ymfpci.c @@ -130,8 +130,7 @@ static int __devinit snd_ymfpci_create_gameport(ymfpci_t *chip, int dev, chip->gameport = gp = gameport_allocate_port(); if (!gp) { printk(KERN_ERR "ymfpci: cannot allocate memory for gameport\n"); - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); return -ENOMEM; } @@ -161,8 +160,7 @@ void snd_ymfpci_free_gameport(ymfpci_t *chip) gameport_unregister_port(chip->gameport); chip->gameport = NULL; - release_resource(r); - kfree_nocheck(r); + release_and_free_resource(r); } } #else @@ -267,14 +265,8 @@ static int __devinit snd_card_ymfpci_probe(struct pci_dev *pci, old_legacy_ctrl, &chip)) < 0) { snd_card_free(card); - if (mpu_res) { - release_resource(mpu_res); - kfree_nocheck(mpu_res); - } - if (fm_res) { - release_resource(fm_res); - kfree_nocheck(fm_res); - } + release_and_free_resource(mpu_res); + release_and_free_resource(fm_res); return err; } chip->fm_res = fm_res; diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 2e671ee438c6..c0aaade772d4 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -2151,14 +2151,8 @@ static int snd_ymfpci_free(ymfpci_t *chip) #ifdef CONFIG_PM vfree(chip->saved_regs); #endif - if (chip->mpu_res) { - release_resource(chip->mpu_res); - kfree_nocheck(chip->mpu_res); - } - if (chip->fm_res) { - release_resource(chip->fm_res); - kfree_nocheck(chip->fm_res); - } + release_and_free_resource(chip->mpu_res); + release_and_free_resource(chip->fm_res); snd_ymfpci_free_gameport(chip); if (chip->reg_area_virt) iounmap(chip->reg_area_virt); @@ -2167,10 +2161,7 @@ static int snd_ymfpci_free(ymfpci_t *chip) if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); - if (chip->res_reg_area) { - release_resource(chip->res_reg_area); - kfree_nocheck(chip->res_reg_area); - } + release_and_free_resource(chip->res_reg_area); pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c index 0a954dc11b73..20b86d8df7a3 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf_pcm.c @@ -50,9 +50,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) if (runtime->dma_area) { if (runtime->dma_bytes >= size) return 0; /* already enough large */ - vfree_nocheck(runtime->dma_area); + vfree(runtime->dma_area); } - runtime->dma_area = vmalloc_nocheck(size); + runtime->dma_area = vmalloc_32(size); if (! runtime->dma_area) return -ENOMEM; runtime->dma_bytes = size; @@ -67,7 +67,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) { snd_pcm_runtime_t *runtime = subs->runtime; if (runtime->dma_area) { - vfree_nocheck(runtime->dma_area); + vfree(runtime->dma_area); runtime->dma_area = NULL; } return 0; diff --git a/sound/usb/usbaudio.c b/sound/usb/usbaudio.c index 5429b169877a..4589c637a25e 100644 --- a/sound/usb/usbaudio.c +++ b/sound/usb/usbaudio.c @@ -692,9 +692,9 @@ static int snd_pcm_alloc_vmalloc_buffer(snd_pcm_substream_t *subs, size_t size) if (runtime->dma_area) { if (runtime->dma_bytes >= size) return 0; /* already large enough */ - vfree_nocheck(runtime->dma_area); + vfree(runtime->dma_area); } - runtime->dma_area = vmalloc_nocheck(size); + runtime->dma_area = vmalloc(size); if (! runtime->dma_area) return -ENOMEM; runtime->dma_bytes = size; @@ -706,7 +706,7 @@ static int snd_pcm_free_vmalloc_buffer(snd_pcm_substream_t *subs) { snd_pcm_runtime_t *runtime = subs->runtime; if (runtime->dma_area) { - vfree_nocheck(runtime->dma_area); + vfree(runtime->dma_area); runtime->dma_area = NULL; } return 0; -- cgit v1.2.3-59-g8ed1b From 063859c854fcb42a04eec4e20c71885dc121edce Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 14 Oct 2005 17:17:02 +0200 Subject: [ALSA] Remove obsolete chip_t Modules: Documentation,MIPS AU1x00 driver,PPC Beep,SPARC DBRI driver Removed the use of chip_t, which was obsoleted. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl | 3 +-- sound/mips/au1x00.c | 2 -- sound/ppc/beep.c | 2 -- sound/sparc/dbri.c | 5 +---- 4 files changed, 2 insertions(+), 10 deletions(-) (limited to 'Documentation') diff --git a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl index 05ae29ac898c..260334c98d95 100644 --- a/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/sound/alsa/DocBook/writing-an-alsa-driver.tmpl @@ -3693,8 +3693,7 @@ struct _snd_pcm_runtime { Here, the chip instance is retrieved via snd_kcontrol_chip() macro. This macro - converts from kcontrol->private_data to the type defined by - chip_t. The + just accesses to kcontrol->private_data. The kcontrol->private_data field is given as the argument of snd_ctl_new() (see the later subsection diff --git a/sound/mips/au1x00.c b/sound/mips/au1x00.c index b7af85f5bfb4..2df78a64c7f2 100644 --- a/sound/mips/au1x00.c +++ b/sound/mips/au1x00.c @@ -57,8 +57,6 @@ MODULE_CLASSES("{sound}"); MODULE_DEVICES("{{AMD,Au1000 AC'97}}"); #endif -#define chip_t au1000_t - #define PLAYBACK 0 #define CAPTURE 1 #define AC97_SLOT_3 0x01 diff --git a/sound/ppc/beep.c b/sound/ppc/beep.c index 1681ee13efbb..d4ec6cc3f1c5 100644 --- a/sound/ppc/beep.c +++ b/sound/ppc/beep.c @@ -171,8 +171,6 @@ static int snd_pmac_beep_event(struct input_dev *dev, unsigned int type, unsigne * beep volume mixer */ -#define chip_t pmac_t - static int snd_pmac_info_beep(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo) { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; diff --git a/sound/sparc/dbri.c b/sound/sparc/dbri.c index b5c4c15ae7f0..59a771294709 100644 --- a/sound/sparc/dbri.c +++ b/sound/sparc/dbri.c @@ -343,9 +343,6 @@ typedef struct snd_dbri { struct snd_dbri *next; } snd_dbri_t; -/* Needed for the ALSA macros to work */ -#define chip_t snd_dbri_t - #define DBRI_MAX_VOLUME 63 /* Output volume */ #define DBRI_MAX_GAIN 15 /* Input gain */ #define DBRI_RIGHT_BALANCE 255 @@ -1767,7 +1764,7 @@ play: spin_unlock_irqrestore(&dbri->lock, flags); } -DECLARE_TASKLET(xmit_descs_task, xmit_descs, 0); +static DECLARE_TASKLET(xmit_descs_task, xmit_descs, 0); /* transmission_complete_intr() * -- cgit v1.2.3-59-g8ed1b From d1f38cf9f8fcb486a027bb5adc214558d7830f45 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 19 Oct 2005 16:04:27 +0200 Subject: [ALSA] Add description about a new option of nm256 driver Modules: Documentation Add description about a new option of nm256 driver. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/ALSA-Configuration.txt | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Documentation') diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 46a125003b0a..9342846c7c48 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -954,6 +954,8 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. use_cache - 0 or 1 (disabled by default) vaio_hack - alias buffer_top=0x25a800 reset_workaround - enable AC97 RESET workaround for some laptops + reset_workaround2 - enable extended AC97 RESET workaround for some + other laptops Module supports autoprobe and multiple chips (max 8). @@ -984,6 +986,11 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. workaround is enabled automatically. For other laptops with a hard freeze, you can try reset_workaround=1 option. + Note: Dell Latitude CSx laptops have another problem regarding + AC97 RESET. On these laptops, reset_workaround2 option is + turned on as default. This option is worth to try if the + previous reset_workaround option doesn't help. + Note: This driver is really crappy. It's a porting from the OSS driver, which is a result of black-magic reverse engineering. The detection of codec will fail if the driver is loaded *after* -- cgit v1.2.3-59-g8ed1b From 8a3fb4d0ce5cc37a765d59b65a3b3714e5806dc9 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 20 Oct 2005 17:10:49 +0200 Subject: [ALSA] Remove multi-card support for ali5451 and nm256 Modules: Documentation,ALI5451 driver,NM256 driver Removed multi-card supports for ali5451 and nm256 drivers. They are supposed to be a single device. Signed-off-by: Takashi Iwai --- Documentation/sound/alsa/ALSA-Configuration.txt | 4 +- sound/pci/ali5451/ali5451.c | 37 ++++----- sound/pci/nm256/nm256.c | 100 +++++++++++------------- 3 files changed, 64 insertions(+), 77 deletions(-) (limited to 'Documentation') diff --git a/Documentation/sound/alsa/ALSA-Configuration.txt b/Documentation/sound/alsa/ALSA-Configuration.txt index 9342846c7c48..2f27f391c7cc 100644 --- a/Documentation/sound/alsa/ALSA-Configuration.txt +++ b/Documentation/sound/alsa/ALSA-Configuration.txt @@ -167,7 +167,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. spdif - Support SPDIF I/O - Default: disabled - Module supports autoprobe and multiple chips (max 8). + This module supports one chip and autoprobe. The power-management is supported. @@ -957,7 +957,7 @@ Prior to version 0.9.0rc4 options had a 'snd_' prefix. This was removed. reset_workaround2 - enable extended AC97 RESET workaround for some other laptops - Module supports autoprobe and multiple chips (max 8). + This module supports one chip and autoprobe. The power-management is supported. diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c index 01d971c89e43..1f747c3034fe 100644 --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -45,23 +45,25 @@ MODULE_DESCRIPTION("ALI M5451"); MODULE_LICENSE("GPL"); MODULE_SUPPORTED_DEVICE("{{ALI,M5451,pci},{ALI,M5451}}"); -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; -static int pcm_channels[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 32}; -static int spdif[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; +static int index = SNDRV_DEFAULT_IDX1; /* Index */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static int pcm_channels = 32; +static int spdif = 0; -module_param_array(index, int, NULL, 0444); +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for ALI M5451 PCI Audio."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for ALI M5451 PCI Audio."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable ALI 5451 PCI Audio."); -module_param_array(pcm_channels, int, NULL, 0444); +module_param(pcm_channels, int, 0444); MODULE_PARM_DESC(pcm_channels, "PCM Channels"); -module_param_array(spdif, bool, NULL, 0444); +module_param(spdif, bool, 0444); MODULE_PARM_DESC(spdif, "Support SPDIF I/O"); +/* just for backward compatibility */ +static int enable; +module_param(enable, bool, 0444); + + /* * Debug part definitions */ @@ -2353,25 +2355,17 @@ static int __devinit snd_ali_create(snd_card_t * card, static int __devinit snd_ali_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; ali_t *codec; int err; snd_ali_printk("probe ...\n"); - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (!enable[dev]) { - dev++; - return -ENOENT; - } - - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; - if ((err = snd_ali_create(card, pci, pcm_channels[dev], spdif[dev], &codec)) < 0) { + if ((err = snd_ali_create(card, pci, pcm_channels, spdif, &codec)) < 0) { snd_card_free(card); return err; } @@ -2402,7 +2396,6 @@ static int __devinit snd_ali_probe(struct pci_dev *pci, return err; } pci_set_drvdata(pci, card); - dev++; return 0; } diff --git a/sound/pci/nm256/nm256.c b/sound/pci/nm256/nm256.c index d0da9a53de03..cccdc576b8a3 100644 --- a/sound/pci/nm256/nm256.c +++ b/sound/pci/nm256/nm256.c @@ -52,41 +52,44 @@ MODULE_SUPPORTED_DEVICE("{{NeoMagic,NM256AV}," * some compile conditions. */ -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; -static int playback_bufsize[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 16}; -static int capture_bufsize[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 16}; -static int force_ac97[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; /* disabled as default */ -static int buffer_top[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; /* not specified */ -static int use_cache[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; /* disabled */ -static int vaio_hack[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0}; /* disabled */ -static int reset_workaround[SNDRV_CARDS]; -static int reset_workaround_2[SNDRV_CARDS]; - -module_param_array(index, int, NULL, 0444); +static int index = SNDRV_DEFAULT_IDX1; /* Index */ +static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ +static int playback_bufsize = 16; +static int capture_bufsize = 16; +static int force_ac97; /* disabled as default */ +static int buffer_top; /* not specified */ +static int use_cache; /* disabled */ +static int vaio_hack; /* disabled */ +static int reset_workaround; +static int reset_workaround_2; + +module_param(index, int, 0444); MODULE_PARM_DESC(index, "Index value for " CARD_NAME " soundcard."); -module_param_array(id, charp, NULL, 0444); +module_param(id, charp, 0444); MODULE_PARM_DESC(id, "ID string for " CARD_NAME " soundcard."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable this soundcard."); -module_param_array(playback_bufsize, int, NULL, 0444); +module_param(playback_bufsize, int, 0444); MODULE_PARM_DESC(playback_bufsize, "DAC frame size in kB for " CARD_NAME " soundcard."); -module_param_array(capture_bufsize, int, NULL, 0444); +module_param(capture_bufsize, int, 0444); MODULE_PARM_DESC(capture_bufsize, "ADC frame size in kB for " CARD_NAME " soundcard."); -module_param_array(force_ac97, bool, NULL, 0444); +module_param(force_ac97, bool, 0444); MODULE_PARM_DESC(force_ac97, "Force to use AC97 codec for " CARD_NAME " soundcard."); -module_param_array(buffer_top, int, NULL, 0444); +module_param(buffer_top, int, 0444); MODULE_PARM_DESC(buffer_top, "Set the top address of audio buffer for " CARD_NAME " soundcard."); -module_param_array(use_cache, bool, NULL, 0444); +module_param(use_cache, bool, 0444); MODULE_PARM_DESC(use_cache, "Enable the cache for coefficient table access."); -module_param_array(vaio_hack, bool, NULL, 0444); +module_param(vaio_hack, bool, 0444); MODULE_PARM_DESC(vaio_hack, "Enable workaround for Sony VAIO notebooks."); -module_param_array(reset_workaround, bool, NULL, 0444); +module_param(reset_workaround, bool, 0444); MODULE_PARM_DESC(reset_workaround, "Enable AC97 RESET workaround for some laptops."); -module_param_array(reset_workaround_2, bool, NULL, 0444); +module_param(reset_workaround_2, bool, 0444); MODULE_PARM_DESC(reset_workaround_2, "Enable extended AC97 RESET workaround for some other laptops."); +/* just for backward compatibility */ +static int enable; +module_param(enable, bool, 0444); + + + /* * hw definitions */ @@ -1561,7 +1564,6 @@ static struct nm256_quirk nm256_quirks[] __devinitdata = { static int __devinit snd_nm256_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { - static int dev; snd_card_t *card; nm256_t *chip; int err; @@ -1569,13 +1571,6 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, struct nm256_quirk *q; u16 subsystem_vendor, subsystem_device; - if (dev >= SNDRV_CARDS) - return -ENODEV; - if (!enable[dev]) { - dev++; - return -ENOENT; - } - pci_read_config_word(pci, PCI_SUBSYSTEM_VENDOR_ID, &subsystem_vendor); pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &subsystem_device); @@ -1586,16 +1581,16 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, printk(KERN_INFO "nm256: The device is blacklisted. Loading stopped\n"); return -ENODEV; case NM_RESET_WORKAROUND_2: - reset_workaround_2[dev] = 1; + reset_workaround_2 = 1; /* Fall-through */ case NM_RESET_WORKAROUND: - reset_workaround[dev] = 1; + reset_workaround = 1; break; } } } - card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); + card = snd_card_new(index, id, THIS_MODULE, 0); if (card == NULL) return -ENOMEM; @@ -1615,36 +1610,36 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, return -EINVAL; } - if (vaio_hack[dev]) + if (vaio_hack) xbuffer_top = 0x25a800; /* this avoids conflicts with XFree86 server */ else - xbuffer_top = buffer_top[dev]; - - if (playback_bufsize[dev] < 4) - playback_bufsize[dev] = 4; - if (playback_bufsize[dev] > 128) - playback_bufsize[dev] = 128; - if (capture_bufsize[dev] < 4) - capture_bufsize[dev] = 4; - if (capture_bufsize[dev] > 128) - capture_bufsize[dev] = 128; + xbuffer_top = buffer_top; + + if (playback_bufsize < 4) + playback_bufsize = 4; + if (playback_bufsize > 128) + playback_bufsize = 128; + if (capture_bufsize < 4) + capture_bufsize = 4; + if (capture_bufsize > 128) + capture_bufsize = 128; if ((err = snd_nm256_create(card, pci, - playback_bufsize[dev] * 1024, /* in bytes */ - capture_bufsize[dev] * 1024, /* in bytes */ - force_ac97[dev], + playback_bufsize * 1024, /* in bytes */ + capture_bufsize * 1024, /* in bytes */ + force_ac97, xbuffer_top, - use_cache[dev], + use_cache, &chip)) < 0) { snd_card_free(card); return err; } - if (reset_workaround[dev]) { + if (reset_workaround) { snd_printdd(KERN_INFO "nm256: reset_workaround activated\n"); chip->reset_workaround = 1; } - if (reset_workaround_2[dev]) { + if (reset_workaround_2) { snd_printdd(KERN_INFO "nm256: reset_workaround_2 activated\n"); chip->reset_workaround_2 = 1; } @@ -1666,7 +1661,6 @@ static int __devinit snd_nm256_probe(struct pci_dev *pci, } pci_set_drvdata(pci, card); - dev++; return 0; } -- cgit v1.2.3-59-g8ed1b