Merge branch 'topic/bkl' into topic/core-cleanup
[safe/jmp/linux-2.6] / sound / ppc / burgundy.c
index f0c12a9..00e2d51 100644 (file)
@@ -21,7 +21,6 @@
 
 #include <asm/io.h>
 #include <linux/init.h>
-#include <linux/slab.h>
 #include <linux/delay.h>
 #include <sound/core.h>
 #include "pmac.h"
@@ -35,7 +34,7 @@ snd_pmac_burgundy_busy_wait(struct snd_pmac *chip)
        int timeout = 50;
        while ((in_le32(&chip->awacs->codec_ctrl) & MASK_NEWECMD) && timeout--)
                udelay(1);
-       if (! timeout)
+       if (timeout < 0)
                printk(KERN_DEBUG "burgundy_busy_wait: timeout\n");
 }
 
@@ -46,12 +45,12 @@ snd_pmac_burgundy_extend_wait(struct snd_pmac *chip)
        timeout = 50;
        while (!(in_le32(&chip->awacs->codec_stat) & MASK_EXTEND) && timeout--)
                udelay(1);
-       if (! timeout)
+       if (timeout < 0)
                printk(KERN_DEBUG "burgundy_extend_wait: timeout #1\n");
        timeout = 50;
        while ((in_le32(&chip->awacs->codec_stat) & MASK_EXTEND) && timeout--)
                udelay(1);
-       if (! timeout)
+       if (timeout < 0)
                printk(KERN_DEBUG "burgundy_extend_wait: timeout #2\n");
 }
 
@@ -102,7 +101,8 @@ snd_pmac_burgundy_rcw(struct snd_pmac *chip, unsigned addr)
 }
 
 static void
-snd_pmac_burgundy_wcb(struct snd_pmac *chip, unsigned int addr, unsigned int val)
+snd_pmac_burgundy_wcb(struct snd_pmac *chip, unsigned int addr,
+                     unsigned int val)
 {
        out_le32(&chip->awacs->codec_ctrl, addr + 0x300000 + (val & 0xff));
        snd_pmac_burgundy_busy_wait(chip);
@@ -126,8 +126,11 @@ snd_pmac_burgundy_rcb(struct snd_pmac *chip, unsigned int addr)
        return val;
 }
 
+#define BASE2ADDR(base)        ((base) << 12)
+#define ADDR2BASE(addr)        ((addr) >> 12)
+
 /*
- * Burgundy volume: 0 - 100, stereo
+ * Burgundy volume: 0 - 100, stereo, word reg
  */
 static void
 snd_pmac_burgundy_write_volume(struct snd_pmac *chip, unsigned int address,
@@ -168,13 +171,6 @@ snd_pmac_burgundy_read_volume(struct snd_pmac *chip, unsigned int address,
                volume[1] = 0;
 }
 
-
-/*
- */
-
-#define BASE2ADDR(base)        ((base) << 12)
-#define ADDR2BASE(addr)        ((addr) >> 12)
-
 static int snd_pmac_burgundy_info_volume(struct snd_kcontrol *kcontrol,
                                         struct snd_ctl_elem_info *uinfo)
 {
@@ -191,8 +187,8 @@ static int snd_pmac_burgundy_get_volume(struct snd_kcontrol *kcontrol,
        struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
        unsigned int addr = BASE2ADDR(kcontrol->private_value & 0xff);
        int shift = (kcontrol->private_value >> 8) & 0xff;
-       snd_pmac_burgundy_read_volume(chip, addr, ucontrol->value.integer.value,
-                                     shift);
+       snd_pmac_burgundy_read_volume(chip, addr,
+                                     ucontrol->value.integer.value, shift);
        return 0;
 }
 
@@ -204,8 +200,8 @@ static int snd_pmac_burgundy_put_volume(struct snd_kcontrol *kcontrol,
        int shift = (kcontrol->private_value >> 8) & 0xff;
        long nvoices[2];
 
-       snd_pmac_burgundy_write_volume(chip, addr, ucontrol->value.integer.value,
-                                      shift);
+       snd_pmac_burgundy_write_volume(chip, addr,
+                                      ucontrol->value.integer.value, shift);
        snd_pmac_burgundy_read_volume(chip, addr, nvoices, shift);
        return (nvoices[0] != ucontrol->value.integer.value[0] ||
                nvoices[1] != ucontrol->value.integer.value[1]);
@@ -471,7 +467,7 @@ static int snd_pmac_burgundy_put_switch_b(struct snd_kcontrol *kcontrol,
 /*
  * Burgundy mixers
  */
-static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = {
+static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __devinitdata = {
        BURGUNDY_VOLUME_W("Master Playback Volume", 0,
                        MASK_ADDR_BURGUNDY_MASTER_VOLUME, 8),
        BURGUNDY_VOLUME_W("CD Capture Volume", 0,
@@ -499,7 +495,7 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers[] __initdata = {
  */    BURGUNDY_SWITCH_B("PCM Capture Switch", 0,
                        MASK_ADDR_BURGUNDY_HOSTIFEH, 0x01, 0, 0)
 };
-static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __initdata = {
+static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __devinitdata = {
        BURGUNDY_VOLUME_W("Line in Capture Volume", 0,
                        MASK_ADDR_BURGUNDY_VOLLINE, 16),
        BURGUNDY_VOLUME_W("Mic Capture Volume", 0,
@@ -508,7 +504,7 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __initdata = {
                        MASK_ADDR_BURGUNDY_GAINLINE, 1, 0),
        BURGUNDY_VOLUME_B("Mic Gain Capture Volume", 0,
                        MASK_ADDR_BURGUNDY_GAINMIC, 1, 0),
-       BURGUNDY_VOLUME_B("PC Speaker Playback Volume", 0,
+       BURGUNDY_VOLUME_B("Speaker Playback Volume", 0,
                        MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1),
        BURGUNDY_VOLUME_B("Line out Playback Volume", 0,
                        MASK_ADDR_BURGUNDY_ATTENLINEOUT, 1, 1),
@@ -525,12 +521,12 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_imac[] __initdata = {
        BURGUNDY_SWITCH_B("Mic Boost Capture Switch", 0,
                        MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1)
 };
-static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __initdata = {
+static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __devinitdata = {
        BURGUNDY_VOLUME_W("Line in Capture Volume", 0,
                        MASK_ADDR_BURGUNDY_VOLMIC, 16),
        BURGUNDY_VOLUME_B("Line in Gain Capture Volume", 0,
                        MASK_ADDR_BURGUNDY_GAINMIC, 1, 0),
-       BURGUNDY_VOLUME_B("PC Speaker Playback Volume", 0,
+       BURGUNDY_VOLUME_B("Speaker Playback Volume", 0,
                        MASK_ADDR_BURGUNDY_ATTENMONO, 0, 1),
        BURGUNDY_VOLUME_B("Line out Playback Volume", 0,
                        MASK_ADDR_BURGUNDY_ATTENSPEAKER, 1, 1),
@@ -541,33 +537,33 @@ static struct snd_kcontrol_new snd_pmac_burgundy_mixers_pmac[] __initdata = {
 /*     BURGUNDY_SWITCH_B("Line in Boost Capture Switch", 0,
  *             MASK_ADDR_BURGUNDY_INPBOOST, 0x40, 0x80, 1) */
 };
-static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac __initdata =
+static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_imac __devinitdata =
 BURGUNDY_SWITCH_B("Master Playback Switch", 0,
        MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
        BURGUNDY_OUTPUT_LEFT | BURGUNDY_LINEOUT_LEFT | BURGUNDY_HP_LEFT,
        BURGUNDY_OUTPUT_RIGHT | BURGUNDY_LINEOUT_RIGHT | BURGUNDY_HP_RIGHT, 1);
-static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac __initdata =
+static struct snd_kcontrol_new snd_pmac_burgundy_master_sw_pmac __devinitdata =
 BURGUNDY_SWITCH_B("Master Playback Switch", 0,
        MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
        BURGUNDY_OUTPUT_INTERN
        | BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
-static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __initdata =
-BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0,
+static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_imac __devinitdata =
+BURGUNDY_SWITCH_B("Speaker Playback Switch", 0,
        MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
        BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
-static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __initdata =
-BURGUNDY_SWITCH_B("PC Speaker Playback Switch", 0,
+static struct snd_kcontrol_new snd_pmac_burgundy_speaker_sw_pmac __devinitdata =
+BURGUNDY_SWITCH_B("Speaker Playback Switch", 0,
        MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
        BURGUNDY_OUTPUT_INTERN, 0, 0);
-static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __initdata =
+static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_imac __devinitdata =
 BURGUNDY_SWITCH_B("Line out Playback Switch", 0,
        MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
        BURGUNDY_LINEOUT_LEFT, BURGUNDY_LINEOUT_RIGHT, 1);
-static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac __initdata =
+static struct snd_kcontrol_new snd_pmac_burgundy_line_sw_pmac __devinitdata =
 BURGUNDY_SWITCH_B("Line out Playback Switch", 0,
        MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
        BURGUNDY_OUTPUT_LEFT, BURGUNDY_OUTPUT_RIGHT, 1);
-static struct snd_kcontrol_new snd_pmac_burgundy_hp_sw_imac __initdata =
+static struct snd_kcontrol_new snd_pmac_burgundy_hp_sw_imac __devinitdata =
 BURGUNDY_SWITCH_B("Headphone Playback Switch", 0,
        MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES,
        BURGUNDY_HP_LEFT, BURGUNDY_HP_RIGHT, 1);
@@ -585,7 +581,7 @@ static int snd_pmac_burgundy_detect_headphone(struct snd_pmac *chip)
 static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_notify)
 {
        if (chip->auto_mute) {
-               int imac = machine_is_compatible("iMac");
+               int imac = of_machine_is_compatible("iMac");
                int reg, oreg;
                reg = oreg = snd_pmac_burgundy_rcb(chip,
                                MASK_ADDR_BURGUNDY_MORE_OUTPUTENABLES);
@@ -621,9 +617,9 @@ static void snd_pmac_burgundy_update_automute(struct snd_pmac *chip, int do_noti
 /*
  * initialize burgundy
  */
-int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
+int __devinit snd_pmac_burgundy_init(struct snd_pmac *chip)
 {
-       int imac = machine_is_compatible("iMac");
+       int imac = of_machine_is_compatible("iMac");
        int i, err;
 
        /* Checks to see the chip is alive and kicking */
@@ -700,7 +696,8 @@ int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
        chip->master_sw_ctl = snd_ctl_new1(imac
                        ? &snd_pmac_burgundy_master_sw_imac
                        : &snd_pmac_burgundy_master_sw_pmac, chip);
-       if ((err = snd_ctl_add(chip->card, chip->master_sw_ctl)) < 0)
+       err = snd_ctl_add(chip->card, chip->master_sw_ctl);
+       if (err < 0)
                return err;
        chip->master_sw_ctl = snd_ctl_new1(imac
                        ? &snd_pmac_burgundy_line_sw_imac
@@ -718,10 +715,12 @@ int __init snd_pmac_burgundy_init(struct snd_pmac *chip)
        chip->speaker_sw_ctl = snd_ctl_new1(imac
                        ? &snd_pmac_burgundy_speaker_sw_imac
                        : &snd_pmac_burgundy_speaker_sw_pmac, chip);
-       if ((err = snd_ctl_add(chip->card, chip->speaker_sw_ctl)) < 0)
+       err = snd_ctl_add(chip->card, chip->speaker_sw_ctl);
+       if (err < 0)
                return err;
 #ifdef PMAC_SUPPORT_AUTOMUTE
-       if ((err = snd_pmac_add_automute(chip)) < 0)
+       err = snd_pmac_add_automute(chip);
+       if (err < 0)
                return err;
 
        chip->detect_headphone = snd_pmac_burgundy_detect_headphone;