Commit 4b3bd108 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: opl3sa2: Fix assignment in if condition

ISA OPL3SA2 driver code contains lots of assignments in if condition,
which is a bad coding style that may confuse readers and occasionally
lead to bugs.

This patch is merely for coding-style fixes, no functional changes.

Link: https://lore.kernel.org/r/20210608140540.17885-10-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 913ad3a3
...@@ -208,7 +208,8 @@ static int snd_opl3sa2_detect(struct snd_card *card) ...@@ -208,7 +208,8 @@ static int snd_opl3sa2_detect(struct snd_card *card)
char str[2]; char str[2];
port = chip->port; port = chip->port;
if ((chip->res_port = request_region(port, 2, "OPL3-SA control")) == NULL) { chip->res_port = request_region(port, 2, "OPL3-SA control");
if (!chip->res_port) {
snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port); snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port);
return -EBUSY; return -EBUSY;
} }
...@@ -239,14 +240,16 @@ static int snd_opl3sa2_detect(struct snd_card *card) ...@@ -239,14 +240,16 @@ static int snd_opl3sa2_detect(struct snd_card *card)
str[1] = 0; str[1] = 0;
strcat(card->shortname, str); strcat(card->shortname, str);
snd_opl3sa2_write(chip, OPL3SA2_MISC, tmp ^ 7); snd_opl3sa2_write(chip, OPL3SA2_MISC, tmp ^ 7);
if ((tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MISC)) != tmp) { tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MISC);
if (tmp1 != tmp) {
snd_printd("OPL3-SA [0x%lx] detect (1) = 0x%x (0x%x)\n", port, tmp, tmp1); snd_printd("OPL3-SA [0x%lx] detect (1) = 0x%x (0x%x)\n", port, tmp, tmp1);
return -ENODEV; return -ENODEV;
} }
/* try if the MIC register is accessible */ /* try if the MIC register is accessible */
tmp = snd_opl3sa2_read(chip, OPL3SA2_MIC); tmp = snd_opl3sa2_read(chip, OPL3SA2_MIC);
snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x8a); snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x8a);
if (((tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MIC)) & 0x9f) != 0x8a) { tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MIC);
if ((tmp1 & 0x9f) != 0x8a) {
snd_printd("OPL3-SA [0x%lx] detect (2) = 0x%x (0x%x)\n", port, tmp, tmp1); snd_printd("OPL3-SA [0x%lx] detect (2) = 0x%x (0x%x)\n", port, tmp, tmp1);
return -ENODEV; return -ENODEV;
} }
...@@ -489,32 +492,38 @@ static int snd_opl3sa2_mixer(struct snd_card *card) ...@@ -489,32 +492,38 @@ static int snd_opl3sa2_mixer(struct snd_card *card)
/* reassign AUX0 to CD */ /* reassign AUX0 to CD */
strcpy(id1.name, "Aux Playback Switch"); strcpy(id1.name, "Aux Playback Switch");
strcpy(id2.name, "CD Playback Switch"); strcpy(id2.name, "CD Playback Switch");
if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { err = snd_ctl_rename_id(card, &id1, &id2);
if (err < 0) {
snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
return err; return err;
} }
strcpy(id1.name, "Aux Playback Volume"); strcpy(id1.name, "Aux Playback Volume");
strcpy(id2.name, "CD Playback Volume"); strcpy(id2.name, "CD Playback Volume");
if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { err = snd_ctl_rename_id(card, &id1, &id2);
if (err < 0) {
snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
return err; return err;
} }
/* reassign AUX1 to FM */ /* reassign AUX1 to FM */
strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
strcpy(id2.name, "FM Playback Switch"); strcpy(id2.name, "FM Playback Switch");
if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { err = snd_ctl_rename_id(card, &id1, &id2);
if (err < 0) {
snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
return err; return err;
} }
strcpy(id1.name, "Aux Playback Volume"); strcpy(id1.name, "Aux Playback Volume");
strcpy(id2.name, "FM Playback Volume"); strcpy(id2.name, "FM Playback Volume");
if ((err = snd_ctl_rename_id(card, &id1, &id2)) < 0) { err = snd_ctl_rename_id(card, &id1, &id2);
if (err < 0) {
snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n");
return err; return err;
} }
/* add OPL3SA2 controls */ /* add OPL3SA2 controls */
for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) { for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) {
if ((err = snd_ctl_add(card, kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip))) < 0) kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip);
err = snd_ctl_add(card, kctl);
if (err < 0)
return err; return err;
switch (idx) { switch (idx) {
case 0: chip->master_switch = kctl; kctl->private_free = snd_opl3sa2_master_free; break; case 0: chip->master_switch = kctl; kctl->private_free = snd_opl3sa2_master_free; break;
...@@ -522,10 +531,12 @@ static int snd_opl3sa2_mixer(struct snd_card *card) ...@@ -522,10 +531,12 @@ static int snd_opl3sa2_mixer(struct snd_card *card)
} }
} }
if (chip->version > 2) { if (chip->version > 2) {
for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_tone_controls); idx++) for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_tone_controls); idx++) {
if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_opl3sa2_tone_controls[idx], chip))) < 0) err = snd_ctl_add(card, snd_ctl_new1(&snd_opl3sa2_tone_controls[idx], chip));
if (err < 0)
return err; return err;
} }
}
return 0; return 0;
} }
...@@ -677,20 +688,24 @@ static int snd_opl3sa2_probe(struct snd_card *card, int dev) ...@@ -677,20 +688,24 @@ static int snd_opl3sa2_probe(struct snd_card *card, int dev)
if (err < 0) if (err < 0)
return err; return err;
if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) { if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) {
if ((err = snd_opl3_create(card, fm_port[dev], err = snd_opl3_create(card, fm_port[dev],
fm_port[dev] + 2, fm_port[dev] + 2,
OPL3_HW_OPL3, 0, &opl3)) < 0) OPL3_HW_OPL3, 0, &opl3);
if (err < 0)
return err; return err;
if ((err = snd_opl3_timer_new(opl3, 1, 2)) < 0) err = snd_opl3_timer_new(opl3, 1, 2);
if (err < 0)
return err; return err;
if ((err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth)) < 0) err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth);
if (err < 0)
return err; return err;
} }
if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) { if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) {
if ((err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2, err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2,
midi_port[dev], midi_port[dev],
MPU401_INFO_IRQ_HOOK, -1, MPU401_INFO_IRQ_HOOK, -1,
&chip->rmidi)) < 0) &chip->rmidi);
if (err < 0)
return err; return err;
} }
sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d",
...@@ -721,11 +736,13 @@ static int snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, ...@@ -721,11 +736,13 @@ static int snd_opl3sa2_pnp_detect(struct pnp_dev *pdev,
err = snd_opl3sa2_card_new(&pdev->dev, dev, &card); err = snd_opl3sa2_card_new(&pdev->dev, dev, &card);
if (err < 0) if (err < 0)
return err; return err;
if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { err = snd_opl3sa2_pnp(dev, card->private_data, pdev);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
if ((err = snd_opl3sa2_probe(card, dev)) < 0) { err = snd_opl3sa2_probe(card, dev);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
...@@ -785,11 +802,13 @@ static int snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, ...@@ -785,11 +802,13 @@ static int snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard,
err = snd_opl3sa2_card_new(&pdev->dev, dev, &card); err = snd_opl3sa2_card_new(&pdev->dev, dev, &card);
if (err < 0) if (err < 0)
return err; return err;
if ((err = snd_opl3sa2_pnp(dev, card->private_data, pdev)) < 0) { err = snd_opl3sa2_pnp(dev, card->private_data, pdev);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
if ((err = snd_opl3sa2_probe(card, dev)) < 0) { err = snd_opl3sa2_probe(card, dev);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
...@@ -865,7 +884,8 @@ static int snd_opl3sa2_isa_probe(struct device *pdev, ...@@ -865,7 +884,8 @@ static int snd_opl3sa2_isa_probe(struct device *pdev,
err = snd_opl3sa2_card_new(pdev, dev, &card); err = snd_opl3sa2_card_new(pdev, dev, &card);
if (err < 0) if (err < 0)
return err; return err;
if ((err = snd_opl3sa2_probe(card, dev)) < 0) { err = snd_opl3sa2_probe(card, dev);
if (err < 0) {
snd_card_free(card); snd_card_free(card);
return err; return err;
} }
......
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