Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-serial
[powerpc.git] / sound / sparc / cs4231.c
index e9086e9..b3efc9a 100644 (file)
@@ -69,13 +69,14 @@ struct sbus_dma_info {
 };
 #endif
 
+struct snd_cs4231;
 struct cs4231_dma_control {
         void           (*prepare)(struct cs4231_dma_control *dma_cont, int dir);
         void           (*enable)(struct cs4231_dma_control *dma_cont, int on);
         int            (*request)(struct cs4231_dma_control *dma_cont, dma_addr_t bus_addr, size_t len);
         unsigned int   (*address)(struct cs4231_dma_control *dma_cont);
         void           (*reset)(struct snd_cs4231 *chip); 
-        void           (*preallocate)(struct snd_cs4231 *chip, struct snd_snd_pcm *pcm); 
+        void           (*preallocate)(struct snd_cs4231 *chip, struct snd_pcm *pcm); 
 #ifdef EBUS_SUPPORT
        struct          ebus_dma_info   ebus_info;
 #endif
@@ -114,8 +115,8 @@ struct snd_cs4231 {
        unsigned char           image[32];      /* registers image */
        int                     mce_bit;
        int                     calibrate_mute;
-       struct semaphore        mce_mutex;
-       struct semaphore        open_mutex;
+       struct mutex            mce_mutex;
+       struct mutex            open_mutex;
 
        union {
 #ifdef SBUS_SUPPORT
@@ -610,8 +611,7 @@ static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont,
                unsigned int period_size = snd_pcm_lib_period_bytes(substream);
                unsigned int offset = period_size * (*periods_sent);
 
-               if (period_size >= (1 << 24))
-                       BUG();
+               BUG_ON(period_size >= (1 << 24));
 
                if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size))
                        return;
@@ -774,7 +774,7 @@ static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_h
 {
        unsigned long flags;
 
-       down(&chip->mce_mutex);
+       mutex_lock(&chip->mce_mutex);
        snd_cs4231_calibrate_mute(chip, 1);
 
        snd_cs4231_mce_up(chip);
@@ -789,7 +789,7 @@ static void snd_cs4231_playback_format(struct snd_cs4231 *chip, struct snd_pcm_h
        snd_cs4231_mce_down(chip);
 
        snd_cs4231_calibrate_mute(chip, 0);
-       up(&chip->mce_mutex);
+       mutex_unlock(&chip->mce_mutex);
 }
 
 static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw_params *params,
@@ -797,7 +797,7 @@ static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw
 {
        unsigned long flags;
 
-       down(&chip->mce_mutex);
+       mutex_lock(&chip->mce_mutex);
        snd_cs4231_calibrate_mute(chip, 1);
 
        snd_cs4231_mce_up(chip);
@@ -818,7 +818,7 @@ static void snd_cs4231_capture_format(struct snd_cs4231 *chip, struct snd_pcm_hw
        snd_cs4231_mce_down(chip);
 
        snd_cs4231_calibrate_mute(chip, 0);
-       up(&chip->mce_mutex);
+       mutex_unlock(&chip->mce_mutex);
 }
 
 /*
@@ -932,14 +932,14 @@ static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode)
 {
        unsigned long flags;
 
-       down(&chip->open_mutex);
+       mutex_lock(&chip->open_mutex);
        if ((chip->mode & mode)) {
-               up(&chip->open_mutex);
+               mutex_unlock(&chip->open_mutex);
                return -EAGAIN;
        }
        if (chip->mode & CS4231_MODE_OPEN) {
                chip->mode |= mode;
-               up(&chip->open_mutex);
+               mutex_unlock(&chip->open_mutex);
                return 0;
        }
        /* ok. now enable and ack CODEC IRQ */
@@ -959,7 +959,7 @@ static int snd_cs4231_open(struct snd_cs4231 *chip, unsigned int mode)
        spin_unlock_irqrestore(&chip->lock, flags);
 
        chip->mode = mode;
-       up(&chip->open_mutex);
+       mutex_unlock(&chip->open_mutex);
        return 0;
 }
 
@@ -967,10 +967,10 @@ static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode)
 {
        unsigned long flags;
 
-       down(&chip->open_mutex);
+       mutex_lock(&chip->open_mutex);
        chip->mode &= ~mode;
        if (chip->mode & CS4231_MODE_OPEN) {
-               up(&chip->open_mutex);
+               mutex_unlock(&chip->open_mutex);
                return;
        }
        snd_cs4231_calibrate_mute(chip, 1);
@@ -1007,7 +1007,7 @@ static void snd_cs4231_close(struct snd_cs4231 *chip, unsigned int mode)
        snd_cs4231_calibrate_mute(chip, 0);
 
        chip->mode = 0;
-       up(&chip->open_mutex);
+       mutex_unlock(&chip->open_mutex);
 }
 
 /*
@@ -1078,8 +1078,7 @@ static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream)
        chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE |
                                            CS4231_PLAYBACK_PIO);
 
-       if (runtime->period_size > 0xffff + 1)
-               BUG();
+       BUG_ON(runtime->period_size > 0xffff + 1);
 
        chip->p_periods_sent = 0;
        spin_unlock_irqrestore(&chip->lock, flags);
@@ -1968,8 +1967,8 @@ static int __init snd_cs4231_sbus_create(struct snd_card *card,
        spin_lock_init(&chip->lock);
        spin_lock_init(&chip->c_dma.sbus_info.lock);
        spin_lock_init(&chip->p_dma.sbus_info.lock);
-       init_MUTEX(&chip->mce_mutex);
-       init_MUTEX(&chip->open_mutex);
+       mutex_init(&chip->mce_mutex);
+       mutex_init(&chip->open_mutex);
        chip->card = card;
        chip->dev_u.sdev = sdev;
        chip->regs_size = sdev->reg_addrs[0].reg_size;
@@ -2004,9 +2003,8 @@ static int __init snd_cs4231_sbus_create(struct snd_card *card,
 
        if (request_irq(sdev->irqs[0], snd_cs4231_sbus_interrupt,
                        SA_SHIRQ, "cs4231", chip)) {
-               snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %s\n",
-                          dev,
-                          __irq_itoa(sdev->irqs[0]));
+               snd_printdd("cs4231-%d: Unable to grab SBUS IRQ %d\n",
+                           dev, sdev->irqs[0]);
                snd_cs4231_sbus_free(chip);
                return -EBUSY;
        }
@@ -2039,11 +2037,11 @@ static int __init cs4231_sbus_attach(struct sbus_dev *sdev)
        if (err)
                return err;
 
-       sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %s",
+       sprintf(card->longname, "%s at 0x%02lx:0x%08lx, irq %d",
                card->shortname,
                rp->flags & 0xffL,
                rp->start,
-               __irq_itoa(sdev->irqs[0]));
+               sdev->irqs[0]);
 
        if ((err = snd_cs4231_sbus_create(card, sdev, dev, &cp)) < 0) {
                snd_card_free(card);
@@ -2156,8 +2154,8 @@ static int __init snd_cs4231_ebus_create(struct snd_card *card,
        spin_lock_init(&chip->lock);
        spin_lock_init(&chip->c_dma.ebus_info.lock);
        spin_lock_init(&chip->p_dma.ebus_info.lock);
-       init_MUTEX(&chip->mce_mutex);
-       init_MUTEX(&chip->open_mutex);
+       mutex_init(&chip->mce_mutex);
+       mutex_init(&chip->open_mutex);
        chip->flags |= CS4231_FLAG_EBUS;
        chip->card = card;
        chip->dev_u.pdev = edev->bus->self;
@@ -2245,10 +2243,10 @@ static int __init cs4231_ebus_attach(struct linux_ebus_device *edev)
        if (err)
                return err;
 
-       sprintf(card->longname, "%s at 0x%lx, irq %s",
+       sprintf(card->longname, "%s at 0x%lx, irq %d",
                card->shortname,
                edev->resource[0].start,
-               __irq_itoa(edev->irqs[0]));
+               edev->irqs[0]);
 
        if ((err = snd_cs4231_ebus_create(card, edev, dev, &chip)) < 0) {
                snd_card_free(card);