ALSA: sscape: coding style fixes

Fix coding style errors in the driver.

Also, add missing argument for CMD_XXX_MIDI_VOL command.

Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Krzysztof Helt 2009-10-10 10:27:58 +02:00 committed by Takashi Iwai
parent ed76f652d5
commit 6fcfa3959a

View file

@ -166,10 +166,12 @@ static inline struct soundscape *get_card_soundscape(struct snd_card *c)
* I think this means that the memory has to map to
* contiguous pages of physical memory.
*/
static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf, unsigned long size)
static struct snd_dma_buffer *get_dmabuf(struct snd_dma_buffer *buf,
unsigned long size)
{
if (buf) {
if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV, snd_dma_isa_data(),
if (snd_dma_alloc_pages_fallback(SNDRV_DMA_TYPE_DEV,
snd_dma_isa_data(),
size, buf) < 0) {
snd_printk(KERN_ERR "sscape: Failed to allocate "
"%lu bytes for DMA\n",
@ -190,13 +192,13 @@ static void free_dmabuf(struct snd_dma_buffer *buf)
snd_dma_free_pages(buf);
}
/*
* This function writes to the SoundScape's control registers,
* but doesn't do any locking. It's up to the caller to do that.
* This is why this function is "unsafe" ...
*/
static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsigned char val)
static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg,
unsigned char val)
{
outb(reg, ODIE_ADDR_IO(io_base));
outb(val, ODIE_DATA_IO(io_base));
@ -206,7 +208,8 @@ static inline void sscape_write_unsafe(unsigned io_base, enum GA_REG reg, unsign
* Write to the SoundScape's control registers, and do the
* necessary locking ...
*/
static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char val)
static void sscape_write(struct soundscape *s, enum GA_REG reg,
unsigned char val)
{
unsigned long flags;
@ -219,7 +222,8 @@ static void sscape_write(struct soundscape *s, enum GA_REG reg, unsigned char va
* Read from the SoundScape's control registers, but leave any
* locking to the caller. This is why the function is "unsafe" ...
*/
static inline unsigned char sscape_read_unsafe(unsigned io_base, enum GA_REG reg)
static inline unsigned char sscape_read_unsafe(unsigned io_base,
enum GA_REG reg)
{
outb(reg, ODIE_ADDR_IO(io_base));
return inb(ODIE_DATA_IO(io_base));
@ -248,9 +252,8 @@ static inline void set_midi_mode_unsafe(unsigned io_base)
static inline int host_read_unsafe(unsigned io_base)
{
int data = -1;
if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0) {
if ((inb(HOST_CTRL_IO(io_base)) & RX_READY) != 0)
data = inb(HOST_DATA_IO(io_base));
}
return data;
}
@ -329,9 +332,10 @@ static inline void initialise_mpu401(const struct snd_mpu401 * mpu)
* The AD1845 detection fails if we *don't* do this, so I
* think that this is a good idea ...
*/
static inline void activate_ad1845_unsafe(unsigned io_base)
static void activate_ad1845_unsafe(unsigned io_base)
{
sscape_write_unsafe(io_base, GA_HMCTL_REG, (sscape_read_unsafe(io_base, GA_HMCTL_REG) & 0xcf) | 0x10);
unsigned char val = sscape_read_unsafe(io_base, GA_HMCTL_REG);
sscape_write_unsafe(io_base, GA_HMCTL_REG, (val & 0xcf) | 0x10);
sscape_write_unsafe(io_base, GA_CDCFG_REG, 0x80);
}
@ -350,24 +354,27 @@ static void soundscape_free(struct snd_card *c)
* Tell the SoundScape to begin a DMA tranfer using the given channel.
* All locking issues are left to the caller.
*/
static inline void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg)
static void sscape_start_dma_unsafe(unsigned io_base, enum GA_REG reg)
{
sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) | 0x01);
sscape_write_unsafe(io_base, reg, sscape_read_unsafe(io_base, reg) & 0xfe);
sscape_write_unsafe(io_base, reg,
sscape_read_unsafe(io_base, reg) | 0x01);
sscape_write_unsafe(io_base, reg,
sscape_read_unsafe(io_base, reg) & 0xfe);
}
/*
* Wait for a DMA transfer to complete. This is a "limited busy-wait",
* and all locking issues are left to the caller.
*/
static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg, unsigned timeout)
static int sscape_wait_dma_unsafe(unsigned io_base, enum GA_REG reg,
unsigned timeout)
{
while (!(sscape_read_unsafe(io_base, reg) & 0x01) && (timeout != 0)) {
udelay(100);
--timeout;
} /* while */
return (sscape_read_unsafe(io_base, reg) & 0x01);
return sscape_read_unsafe(io_base, reg) & 0x01;
}
/*
@ -427,13 +434,13 @@ static int host_startup_ack(struct soundscape *s, unsigned timeout)
/*
* Upload a byte-stream into the SoundScape using DMA channel A.
*/
static int upload_dma_data(struct soundscape *s,
const unsigned char *data,
static int upload_dma_data(struct soundscape *s, const unsigned char *data,
size_t size)
{
unsigned long flags;
struct snd_dma_buffer dma;
int ret;
unsigned char val;
if (!get_dmabuf(&dma, PAGE_ALIGN(32 * 1024)))
return -ENOMEM;
@ -443,18 +450,21 @@ static int upload_dma_data(struct soundscape *s,
/*
* Reset the board ...
*/
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f);
val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val & 0x3f);
/*
* Enable the DMA channels and configure them ...
*/
sscape_write_unsafe(s->io_base, GA_DMAA_REG, (s->chip->dma1 << 4) | DMA_8BIT);
val = (s->chip->dma1 << 4) | DMA_8BIT;
sscape_write_unsafe(s->io_base, GA_DMAA_REG, val);
sscape_write_unsafe(s->io_base, GA_DMAB_REG, 0x20);
/*
* Take the board out of reset ...
*/
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x80);
val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x80);
/*
* Upload the firmware to the SoundScape
@ -472,7 +482,7 @@ static int upload_dma_data(struct soundscape *s,
sscape_start_dma_unsafe(s->io_base, GA_DMAA_REG);
if (!sscape_wait_dma_unsafe(s->io_base, GA_DMAA_REG, 5000)) {
/*
* Don't forget to release this spinlock we're holding ...
* Don't forget to release this spinlock we're holding
*/
spin_unlock_irqrestore(&s->lock, flags);
@ -489,7 +499,8 @@ static int upload_dma_data(struct soundscape *s,
/*
* Boot the board ... (I think)
*/
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, sscape_read_unsafe(s->io_base, GA_HMCTL_REG) | 0x40);
val = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, val | 0x40);
spin_unlock_irqrestore(&s->lock, flags);
/*
@ -619,12 +630,14 @@ static int sscape_midi_put(struct snd_kcontrol *kctl,
{
struct snd_wss *chip = snd_kcontrol_chip(kctl);
struct snd_card *card = chip->card;
register struct soundscape *s = get_card_soundscape(card);
struct soundscape *s = get_card_soundscape(card);
unsigned long flags;
int change;
unsigned char new_val;
spin_lock_irqsave(&s->lock, flags);
new_val = uctl->value.integer.value[0] & 127;
/*
* We need to put the board into HOST mode before we
* can send any volume-changing HOST commands ...
@ -637,14 +650,15 @@ static int sscape_midi_put(struct snd_kcontrol *kctl,
* and then perform another volume-related command. Perhaps the
* first command is an "open" and the second command is a "close"?
*/
if (s->midi_vol == ((unsigned char) uctl->value.integer. value[0] & 127)) {
if (s->midi_vol == new_val) {
change = 0;
goto __skip_change;
}
change = (host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100)
&& host_write_ctrl_unsafe(s->io_base, ((unsigned char) uctl->value.integer. value[0]) & 127, 100)
&& host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100));
s->midi_vol = (unsigned char) uctl->value.integer.value[0] & 127;
change = host_write_ctrl_unsafe(s->io_base, CMD_SET_MIDI_VOL, 100)
&& host_write_ctrl_unsafe(s->io_base, new_val, 100)
&& host_write_ctrl_unsafe(s->io_base, CMD_XXX_MIDI_VOL, 100)
&& host_write_ctrl_unsafe(s->io_base, new_val, 100);
s->midi_vol = new_val;
__skip_change:
/*
@ -738,7 +752,7 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io)
if (s->type == SSCAPE_VIVO)
wss_io += 4;
d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f;
d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
/* wait for WSS codec */
@ -762,7 +776,7 @@ static int __devinit detect_sscape(struct soundscape *s, long wss_io)
if ((inb(wss_io) & 0x80) != 0)
s->type = MEDIA_FX;
d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG) & 0x3f;
d = sscape_read_unsafe(s->io_base, GA_HMCTL_REG);
sscape_write_unsafe(s->io_base, GA_HMCTL_REG, d | 0xc0);
/* wait for WSS codec */
for (d = 0; d < 500; d++) {
@ -803,18 +817,18 @@ static int mpu401_open(struct snd_mpu401 * mpu)
/*
* Initialse an MPU-401 subdevice for MIDI support on the SoundScape.
*/
static int __devinit create_mpu401(struct snd_card *card, int devnum, unsigned long port, int irq)
static int __devinit create_mpu401(struct snd_card *card, int devnum,
unsigned long port, int irq)
{
struct soundscape *sscape = get_card_soundscape(card);
struct snd_rawmidi *rawmidi;
int err;
if ((err = snd_mpu401_uart_new(card, devnum,
MPU401_HW_MPU401,
port, MPU401_INFO_INTEGRATED,
irq, IRQF_DISABLED,
&rawmidi)) == 0) {
struct snd_mpu401 *mpu = (struct snd_mpu401 *) rawmidi->private_data;
err = snd_mpu401_uart_new(card, devnum, MPU401_HW_MPU401, port,
MPU401_INFO_INTEGRATED, irq, IRQF_DISABLED,
&rawmidi);
if (err == 0) {
struct snd_mpu401 *mpu = rawmidi->private_data;
mpu->open_input = mpu401_open;
mpu->open_output = mpu401_open;
mpu->private_data = sscape;
@ -866,19 +880,6 @@ static int __devinit create_ad1845(struct snd_card *card, unsigned port,
unsigned long flags;
struct snd_pcm *pcm;
/*
* It turns out that the PLAYBACK_ENABLE bit is set
* by the lowlevel driver ...
*
#define AD1845_IFACE_CONFIG \
(CS4231_AUTOCALIB | CS4231_RECORD_ENABLE | CS4231_PLAYBACK_ENABLE)
snd_wss_mce_up(chip);
spin_lock_irqsave(&chip->reg_lock, flags);
snd_wss_out(chip, CS4231_IFACE_CTRL, AD1845_IFACE_CONFIG);
spin_unlock_irqrestore(&chip->reg_lock, flags);
snd_wss_mce_down(chip);
*/
if (sscape->type != SSCAPE_VIVO) {
/*
* The input clock frequency on the SoundScape must
@ -1034,7 +1035,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
*/
spin_lock_irqsave(&sscape->lock, flags);
sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x00); /* disable */
sscape_write_unsafe(sscape->io_base, GA_SMCFGA_REG, 0x2e);
sscape_write_unsafe(sscape->io_base, GA_SMCFGB_REG, 0x00);
@ -1055,6 +1055,10 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
sscape_write_unsafe(sscape->io_base,
GA_CDCFG_REG, 0x09 | DMA_8BIT
| (dma[dev] << 4) | (irq_cfg << 1));
/*
* Enable the master IRQ ...
*/
sscape_write_unsafe(sscape->io_base, GA_INTENA_REG, 0x80);
spin_unlock_irqrestore(&sscape->lock, flags);
@ -1093,11 +1097,6 @@ static int __devinit create_sscape(int dev, struct snd_card *card)
goto _release_dma;
}
/*
* Enable the master IRQ ...
*/
sscape_write(sscape, GA_INTENA_REG, 0x80);
/*
* Initialize mixer
*/
@ -1155,7 +1154,8 @@ static int __devinit snd_sscape_match(struct device *pdev, unsigned int i)
mpu_irq[i] == SNDRV_AUTO_IRQ ||
dma[i] == SNDRV_AUTO_DMA) {
printk(KERN_INFO
"sscape: insufficient parameters, need IO, IRQ, MPU-IRQ and DMA\n");
"sscape: insufficient parameters, "
"need IO, IRQ, MPU-IRQ and DMA\n");
return 0;
}
@ -1183,7 +1183,8 @@ static int __devinit snd_sscape_probe(struct device *pdev, unsigned int dev)
if (ret < 0)
goto _release_card;
if ((ret = snd_card_register(card)) < 0) {
ret = snd_card_register(card);
if (ret < 0) {
snd_printk(KERN_ERR "sscape: Failed to register sound card\n");
goto _release_card;
}
@ -1236,15 +1237,10 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
* Allow this function to fail *quietly* if all the ISA PnP
* devices were configured using module parameters instead.
*/
if ((idx = get_next_autoindex(idx)) >= SNDRV_CARDS)
idx = get_next_autoindex(idx);
if (idx >= SNDRV_CARDS)
return -ENOSPC;
/*
* We have found a candidate ISA PnP card. Now we
* have to check that it has the devices that we
* expect it to have.
*/
/*
* Check that we still have room for another sound card ...
*/
@ -1298,7 +1294,8 @@ static int __devinit sscape_pnp_detect(struct pnp_card_link *pcard,
if (ret < 0)
goto _release_card;
if ((ret = snd_card_register(card)) < 0) {
ret = snd_card_register(card);
if (ret < 0) {
snd_printk(KERN_ERR "sscape: Failed to register sound card\n");
goto _release_card;
}