]> err.no Git - linux-2.6/blobdiff - sound/ppc/pmac.c
[PATCH] Add missing overflow check in get_blkdev_list
[linux-2.6] / sound / ppc / pmac.c
index 32d94754acf814a243840bda4cdc1979d984f73c..c89e82eb06a6df91840c5863e8804d643db94e09 100644 (file)
@@ -36,7 +36,7 @@
 #include <asm/pci-bridge.h>
 
 
-#if defined(CONFIG_PM) && defined(CONFIG_PMAC_PBOOK)
+#ifdef CONFIG_PM
 static int snd_pmac_register_sleep_notifier(pmac_t *chip);
 static int snd_pmac_unregister_sleep_notifier(pmac_t *chip);
 static int snd_pmac_suspend(snd_card_t *card, pm_message_t state);
@@ -153,7 +153,7 @@ static pmac_stream_t *snd_pmac_get_stream(pmac_t *chip, int stream)
 /*
  * wait while run status is on
  */
-inline static void
+static inline void
 snd_pmac_wait_ack(pmac_stream_t *rec)
 {
        int timeout = 50000;
@@ -177,7 +177,7 @@ static void snd_pmac_pcm_set_format(pmac_t *chip)
 /*
  * stop the DMA transfer
  */
-inline static void snd_pmac_dma_stop(pmac_stream_t *rec)
+static inline void snd_pmac_dma_stop(pmac_stream_t *rec)
 {
        out_le32(&rec->dma->control, (RUN|WAKE|FLUSH|PAUSE) << 16);
        snd_pmac_wait_ack(rec);
@@ -186,7 +186,7 @@ inline static void snd_pmac_dma_stop(pmac_stream_t *rec)
 /*
  * set the command pointer address
  */
-inline static void snd_pmac_dma_set_command(pmac_stream_t *rec, pmac_dbdma_t *cmd)
+static inline void snd_pmac_dma_set_command(pmac_stream_t *rec, pmac_dbdma_t *cmd)
 {
        out_le32(&rec->dma->cmdptr, cmd->addr);
 }
@@ -194,7 +194,7 @@ inline static void snd_pmac_dma_set_command(pmac_stream_t *rec, pmac_dbdma_t *cm
 /*
  * start the DMA
  */
-inline static void snd_pmac_dma_run(pmac_stream_t *rec, int status)
+static inline void snd_pmac_dma_run(pmac_stream_t *rec, int status)
 {
        out_le32(&rec->dma->control, status | (status << 16));
 }
@@ -765,7 +765,8 @@ snd_pmac_ctrl_intr(int irq, void *devid, struct pt_regs *regs)
  */
 static void snd_pmac_sound_feature(pmac_t *chip, int enable)
 {
-       ppc_md.feature_call(PMAC_FTR_SOUND_CHIP_ENABLE, chip->node, 0, enable);
+       if (ppc_md.feature_call)
+               ppc_md.feature_call(PMAC_FTR_SOUND_CHIP_ENABLE, chip->node, 0, enable);
 }
 
 /*
@@ -782,7 +783,7 @@ static int snd_pmac_free(pmac_t *chip)
        }
 
        snd_pmac_sound_feature(chip, 0);
-#if defined(CONFIG_PM) && defined(CONFIG_PMAC_PBOOK)
+#ifdef CONFIG_PM
        snd_pmac_unregister_sleep_notifier(chip);
 #endif
 
@@ -876,7 +877,7 @@ static void __init detect_byte_swap(pmac_t *chip)
  */
 static int __init snd_pmac_detect(pmac_t *chip)
 {
-       struct device_node *sound;
+       struct device_node *sound = NULL;
        unsigned int *prop, l;
        struct macio_chip* macio;
 
@@ -906,20 +907,22 @@ static int __init snd_pmac_detect(pmac_t *chip)
                chip->is_pbook_G3 = 1;
        chip->node = find_devices("awacs");
        if (chip->node)
-               return 0; /* ok */
+               sound = chip->node;
 
        /*
         * powermac G3 models have a node called "davbus"
         * with a child called "sound".
         */
-       chip->node = find_devices("davbus");
+       if (!chip->node)
+               chip->node = find_devices("davbus");
        /*
         * if we didn't find a davbus device, try 'i2s-a' since
         * this seems to be what iBooks have
         */
        if (! chip->node) {
                chip->node = find_devices("i2s-a");
-               if (chip->node && chip->node->parent && chip->node->parent->parent) {
+               if (chip->node && chip->node->parent &&
+                   chip->node->parent->parent) {
                        if (device_is_compatible(chip->node->parent->parent,
                                                 "K2-Keylargo"))
                                chip->is_k2 = 1;
@@ -928,9 +931,11 @@ static int __init snd_pmac_detect(pmac_t *chip)
        if (! chip->node)
                return -ENODEV;
 
-       sound = find_devices("sound");
-       while (sound && sound->parent != chip->node)
-               sound = sound->next;
+       if (!sound) {
+               sound = find_devices("sound");
+               while (sound && sound->parent != chip->node)
+                       sound = sound->next;
+       }
        if (! sound)
                return -ENODEV;
        prop = (unsigned int *) get_property(sound, "sub-frame", NULL);
@@ -1019,7 +1024,8 @@ static int __init snd_pmac_detect(pmac_t *chip)
                }
        }
        if (chip->pdev == NULL)
-               printk(KERN_WARNING "snd-powermac: can't locate macio PCI device !\n");
+               printk(KERN_WARNING "snd-powermac: can't locate macio PCI"
+                      " device !\n");
 
        detect_byte_swap(chip);
 
@@ -1027,7 +1033,8 @@ static int __init snd_pmac_detect(pmac_t *chip)
           are available */
        prop = (unsigned int *) get_property(sound, "sample-rates", &l);
        if (! prop)
-               prop = (unsigned int *) get_property(sound, "output-frame-rates", &l);
+               prop = (unsigned int *) get_property(sound,
+                                                    "output-frame-rates", &l);
        if (prop) {
                int i;
                chip->freqs_ok = 0;
@@ -1054,7 +1061,8 @@ static int __init snd_pmac_detect(pmac_t *chip)
 /*
  * exported - boolean info callbacks for ease of programming
  */
-int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol,
+                                snd_ctl_elem_info_t *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        uinfo->count = 2;
@@ -1063,7 +1071,8 @@ int snd_pmac_boolean_stereo_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *
        return 0;
 }
 
-int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
+int snd_pmac_boolean_mono_info(snd_kcontrol_t *kcontrol,
+                              snd_ctl_elem_info_t *uinfo)
 {
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
        uinfo->count = 1;
@@ -1284,7 +1293,7 @@ int __init snd_pmac_new(snd_card_t *card, pmac_t **chip_return)
        /* Reset dbdma channels */
        snd_pmac_dbdma_reset(chip);
 
-#if defined(CONFIG_PM) && defined(CONFIG_PMAC_PBOOK)
+#ifdef CONFIG_PM
        /* add sleep notifier */
        if (! snd_pmac_register_sleep_notifier(chip))
                snd_card_set_pm_callback(chip->card, snd_pmac_suspend, snd_pmac_resume, chip);
@@ -1308,7 +1317,7 @@ int __init snd_pmac_new(snd_card_t *card, pmac_t **chip_return)
  * sleep notify for powerbook
  */
 
-#if defined(CONFIG_PM) && defined(CONFIG_PMAC_PBOOK)
+#ifdef CONFIG_PM
 
 /*
  * Save state when going to sleep, restore it afterwards.
@@ -1406,4 +1415,5 @@ static int snd_pmac_unregister_sleep_notifier(pmac_t *chip)
        return 0;
 }
 
-#endif /* CONFIG_PM && CONFIG_PMAC_PBOOK */
+#endif /* CONFIG_PM */
+