Commit 3c76b4d6 authored by Krzysztof Helt's avatar Krzysztof Helt Committed by Takashi Iwai

ALSA: es18xx: remove snd_card pointer from snd_es18xx structure

The snd_card pointer is redundant and code can be easily
changed to work without it.
Signed-off-by: default avatarKrzysztof Helt <krzysztof.h1@wp.pl>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent b7d5d946
...@@ -121,7 +121,6 @@ struct snd_es18xx { ...@@ -121,7 +121,6 @@ struct snd_es18xx {
unsigned int dma1_shift; unsigned int dma1_shift;
unsigned int dma2_shift; unsigned int dma2_shift;
struct snd_card *card;
struct snd_pcm *pcm; struct snd_pcm *pcm;
struct snd_pcm_substream *playback_a_substream; struct snd_pcm_substream *playback_a_substream;
struct snd_pcm_substream *capture_a_substream; struct snd_pcm_substream *capture_a_substream;
...@@ -755,7 +754,9 @@ static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream, ...@@ -755,7 +754,9 @@ static int snd_es18xx_playback_trigger(struct snd_pcm_substream *substream,
static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id)
{ {
struct snd_es18xx *chip = dev_id; struct snd_card *card = dev_id;
struct snd_audiodrive *acard = card->private_data;
struct snd_es18xx *chip = acard->chip;
unsigned char status; unsigned char status;
if (chip->caps & ES18XX_CONTROL) { if (chip->caps & ES18XX_CONTROL) {
...@@ -805,12 +806,16 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id) ...@@ -805,12 +806,16 @@ static irqreturn_t snd_es18xx_interrupt(int irq, void *dev_id)
int split = 0; int split = 0;
if (chip->caps & ES18XX_HWV) { if (chip->caps & ES18XX_HWV) {
split = snd_es18xx_mixer_read(chip, 0x64) & 0x80; split = snd_es18xx_mixer_read(chip, 0x64) & 0x80;
snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_switch->id); snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->hw_volume->id); &chip->hw_switch->id);
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
&chip->hw_volume->id);
} }
if (!split) { if (!split) {
snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_switch->id); snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE, &chip->master_volume->id); &chip->master_switch->id);
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
&chip->master_volume->id);
} }
/* ack interrupt */ /* ack interrupt */
snd_es18xx_mixer_write(chip, 0x66, 0x00); snd_es18xx_mixer_write(chip, 0x66, 0x00);
...@@ -1691,8 +1696,11 @@ static struct snd_pcm_ops snd_es18xx_capture_ops = { ...@@ -1691,8 +1696,11 @@ static struct snd_pcm_ops snd_es18xx_capture_ops = {
.pointer = snd_es18xx_capture_pointer, .pointer = snd_es18xx_capture_pointer,
}; };
static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct snd_pcm ** rpcm) static int __devinit snd_es18xx_pcm(struct snd_card *card, int device,
struct snd_pcm **rpcm)
{ {
struct snd_audiodrive *acard = card->private_data;
struct snd_es18xx *chip = acard->chip;
struct snd_pcm *pcm; struct snd_pcm *pcm;
char str[16]; char str[16];
int err; int err;
...@@ -1701,9 +1709,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct ...@@ -1701,9 +1709,9 @@ static int __devinit snd_es18xx_pcm(struct snd_es18xx *chip, int device, struct
*rpcm = NULL; *rpcm = NULL;
sprintf(str, "ES%x", chip->version); sprintf(str, "ES%x", chip->version);
if (chip->caps & ES18XX_PCM2) if (chip->caps & ES18XX_PCM2)
err = snd_pcm_new(chip->card, str, device, 2, 1, &pcm); err = snd_pcm_new(card, str, device, 2, 1, &pcm);
else else
err = snd_pcm_new(chip->card, str, device, 1, 1, &pcm); err = snd_pcm_new(card, str, device, 1, 1, &pcm);
if (err < 0) if (err < 0)
return err; return err;
...@@ -1737,7 +1745,7 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state) ...@@ -1737,7 +1745,7 @@ static int snd_es18xx_suspend(struct snd_card *card, pm_message_t state)
struct snd_audiodrive *acard = card->private_data; struct snd_audiodrive *acard = card->private_data;
struct snd_es18xx *chip = acard->chip; struct snd_es18xx *chip = acard->chip;
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot); snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
snd_pcm_suspend_all(chip->pcm); snd_pcm_suspend_all(chip->pcm);
...@@ -1758,18 +1766,21 @@ static int snd_es18xx_resume(struct snd_card *card) ...@@ -1758,18 +1766,21 @@ static int snd_es18xx_resume(struct snd_card *card)
/* restore PM register, we won't wake till (not 0x07) i/o activity though */ /* restore PM register, we won't wake till (not 0x07) i/o activity though */
snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM); snd_es18xx_write(chip, ES18XX_PM, chip->pm_reg ^= ES18XX_PM_FM);
snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); snd_power_change_state(card, SNDRV_CTL_POWER_D0);
return 0; return 0;
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
static int snd_es18xx_free(struct snd_es18xx *chip) static int snd_es18xx_free(struct snd_card *card)
{ {
struct snd_audiodrive *acard = card->private_data;
struct snd_es18xx *chip = acard->chip;
release_and_free_resource(chip->res_port); release_and_free_resource(chip->res_port);
release_and_free_resource(chip->res_ctrl_port); release_and_free_resource(chip->res_ctrl_port);
release_and_free_resource(chip->res_mpu_port); release_and_free_resource(chip->res_mpu_port);
if (chip->irq >= 0) if (chip->irq >= 0)
free_irq(chip->irq, (void *) chip); free_irq(chip->irq, (void *) card);
if (chip->dma1 >= 0) { if (chip->dma1 >= 0) {
disable_dma(chip->dma1); disable_dma(chip->dma1);
free_dma(chip->dma1); free_dma(chip->dma1);
...@@ -1784,8 +1795,7 @@ static int snd_es18xx_free(struct snd_es18xx *chip) ...@@ -1784,8 +1795,7 @@ static int snd_es18xx_free(struct snd_es18xx *chip)
static int snd_es18xx_dev_free(struct snd_device *device) static int snd_es18xx_dev_free(struct snd_device *device)
{ {
struct snd_es18xx *chip = device->device_data; return snd_es18xx_free(device->card);
return snd_es18xx_free(chip);
} }
static int __devinit snd_es18xx_new_device(struct snd_card *card, static int __devinit snd_es18xx_new_device(struct snd_card *card,
...@@ -1808,7 +1818,6 @@ static int __devinit snd_es18xx_new_device(struct snd_card *card, ...@@ -1808,7 +1818,6 @@ static int __devinit snd_es18xx_new_device(struct snd_card *card,
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
spin_lock_init(&chip->mixer_lock); spin_lock_init(&chip->mixer_lock);
spin_lock_init(&chip->ctrl_lock); spin_lock_init(&chip->ctrl_lock);
chip->card = card;
chip->port = port; chip->port = port;
chip->mpu_port = mpu_port; chip->mpu_port = mpu_port;
chip->fm_port = fm_port; chip->fm_port = fm_port;
...@@ -1818,53 +1827,55 @@ static int __devinit snd_es18xx_new_device(struct snd_card *card, ...@@ -1818,53 +1827,55 @@ static int __devinit snd_es18xx_new_device(struct snd_card *card,
chip->audio2_vol = 0x00; chip->audio2_vol = 0x00;
chip->active = 0; chip->active = 0;
if ((chip->res_port = request_region(port, 16, "ES18xx")) == NULL) { chip->res_port = request_region(port, 16, "ES18xx");
snd_es18xx_free(chip); if (chip->res_port == NULL) {
snd_es18xx_free(card);
snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1); snd_printk(KERN_ERR PFX "unable to grap ports 0x%lx-0x%lx\n", port, port + 16 - 1);
return -EBUSY; return -EBUSY;
} }
if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx", (void *) chip)) { if (request_irq(irq, snd_es18xx_interrupt, IRQF_DISABLED, "ES18xx",
snd_es18xx_free(chip); (void *) card)) {
snd_es18xx_free(card);
snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq); snd_printk(KERN_ERR PFX "unable to grap IRQ %d\n", irq);
return -EBUSY; return -EBUSY;
} }
chip->irq = irq; chip->irq = irq;
if (request_dma(dma1, "ES18xx DMA 1")) { if (request_dma(dma1, "ES18xx DMA 1")) {
snd_es18xx_free(chip); snd_es18xx_free(card);
snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1); snd_printk(KERN_ERR PFX "unable to grap DMA1 %d\n", dma1);
return -EBUSY; return -EBUSY;
} }
chip->dma1 = dma1; chip->dma1 = dma1;
if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) { if (dma2 != dma1 && request_dma(dma2, "ES18xx DMA 2")) {
snd_es18xx_free(chip); snd_es18xx_free(card);
snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2); snd_printk(KERN_ERR PFX "unable to grap DMA2 %d\n", dma2);
return -EBUSY; return -EBUSY;
} }
chip->dma2 = dma2; chip->dma2 = dma2;
if (snd_es18xx_probe(chip) < 0) { if (snd_es18xx_probe(chip) < 0) {
snd_es18xx_free(chip); snd_es18xx_free(card);
return -ENODEV; return -ENODEV;
} }
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, NULL, &ops);
snd_es18xx_free(chip); if (err < 0) {
snd_es18xx_free(card);
return err; return err;
} }
*rchip = chip; *rchip = chip;
return 0; return 0;
} }
static int __devinit snd_es18xx_mixer(struct snd_es18xx *chip) static int __devinit snd_es18xx_mixer(struct snd_card *card)
{ {
struct snd_card *card; struct snd_audiodrive *acard = card->private_data;
struct snd_es18xx *chip = acard->chip;
int err; int err;
unsigned int idx; unsigned int idx;
card = chip->card;
strcpy(card->mixername, chip->pcm->name); strcpy(card->mixername, chip->pcm->name);
for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) { for (idx = 0; idx < ARRAY_SIZE(snd_es18xx_base_controls); idx++) {
...@@ -2161,10 +2172,12 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev) ...@@ -2161,10 +2172,12 @@ static int __devinit snd_audiodrive_probe(struct snd_card *card, int dev)
chip->port, chip->port,
irq[dev], dma1[dev]); irq[dev], dma1[dev]);
if ((err = snd_es18xx_pcm(chip, 0, NULL)) < 0) err = snd_es18xx_pcm(card, 0, NULL);
if (err < 0)
return err; return err;
if ((err = snd_es18xx_mixer(chip)) < 0) err = snd_es18xx_mixer(card);
if (err < 0)
return err; return err;
if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) { if (fm_port[dev] > 0 && fm_port[dev] != SNDRV_AUTO_PORT) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment