Skip to content

Commit

Permalink
ALSA: opl3: Fix assignment in if condition
Browse files Browse the repository at this point in the history
OPL3 helper code contains a few 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/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jun 9, 2021
1 parent ed1567c commit 9c78e80
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
42 changes: 27 additions & 15 deletions sound/drivers/opl3/opl3_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ static int snd_opl3_timer1_init(struct snd_opl3 * opl3, int timer_no)
tid.card = opl3->card->number;
tid.device = timer_no;
tid.subdevice = 0;
if ((err = snd_timer_new(opl3->card, "AdLib timer #1", &tid, &timer)) >= 0) {
err = snd_timer_new(opl3->card, "AdLib timer #1", &tid, &timer);
if (err >= 0) {
strcpy(timer->name, "AdLib timer #1");
timer->private_data = opl3;
timer->hw = snd_opl3_timer1;
Expand All @@ -263,7 +264,8 @@ static int snd_opl3_timer2_init(struct snd_opl3 * opl3, int timer_no)
tid.card = opl3->card->number;
tid.device = timer_no;
tid.subdevice = 0;
if ((err = snd_timer_new(opl3->card, "AdLib timer #2", &tid, &timer)) >= 0) {
err = snd_timer_new(opl3->card, "AdLib timer #2", &tid, &timer);
if (err >= 0) {
strcpy(timer->name, "AdLib timer #2");
timer->private_data = opl3;
timer->hw = snd_opl3_timer2;
Expand Down Expand Up @@ -348,7 +350,8 @@ int snd_opl3_new(struct snd_card *card,
spin_lock_init(&opl3->reg_lock);
spin_lock_init(&opl3->timer_lock);

if ((err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops)) < 0) {
err = snd_device_new(card, SNDRV_DEV_CODEC, opl3, &ops);
if (err < 0) {
snd_opl3_free(opl3);
return err;
}
Expand Down Expand Up @@ -396,19 +399,23 @@ int snd_opl3_create(struct snd_card *card,
int err;

*ropl3 = NULL;
if ((err = snd_opl3_new(card, hardware, &opl3)) < 0)
err = snd_opl3_new(card, hardware, &opl3);
if (err < 0)
return err;
if (! integrated) {
if ((opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)")) == NULL) {
opl3->res_l_port = request_region(l_port, 2, "OPL2/3 (left)");
if (!opl3->res_l_port) {
snd_printk(KERN_ERR "opl3: can't grab left port 0x%lx\n", l_port);
snd_device_free(card, opl3);
return -EBUSY;
}
if (r_port != 0 &&
(opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)")) == NULL) {
snd_printk(KERN_ERR "opl3: can't grab right port 0x%lx\n", r_port);
snd_device_free(card, opl3);
return -EBUSY;
if (r_port != 0) {
opl3->res_r_port = request_region(r_port, 2, "OPL2/3 (right)");
if (!opl3->res_r_port) {
snd_printk(KERN_ERR "opl3: can't grab right port 0x%lx\n", r_port);
snd_device_free(card, opl3);
return -EBUSY;
}
}
}
opl3->l_port = l_port;
Expand All @@ -423,7 +430,8 @@ int snd_opl3_create(struct snd_card *card,
break;
default:
opl3->command = &snd_opl2_command;
if ((err = snd_opl3_detect(opl3)) < 0) {
err = snd_opl3_detect(opl3);
if (err < 0) {
snd_printd("OPL2/3 chip not detected at 0x%lx/0x%lx\n",
opl3->l_port, opl3->r_port);
snd_device_free(card, opl3);
Expand All @@ -449,11 +457,14 @@ int snd_opl3_timer_new(struct snd_opl3 * opl3, int timer1_dev, int timer2_dev)
{
int err;

if (timer1_dev >= 0)
if ((err = snd_opl3_timer1_init(opl3, timer1_dev)) < 0)
if (timer1_dev >= 0) {
err = snd_opl3_timer1_init(opl3, timer1_dev);
if (err < 0)
return err;
}
if (timer2_dev >= 0) {
if ((err = snd_opl3_timer2_init(opl3, timer2_dev)) < 0) {
err = snd_opl3_timer2_init(opl3, timer2_dev);
if (err < 0) {
snd_device_free(opl3->card, opl3->timer1);
opl3->timer1 = NULL;
return err;
Expand All @@ -477,7 +488,8 @@ int snd_opl3_hwdep_new(struct snd_opl3 * opl3,

/* create hardware dependent device (direct FM) */

if ((err = snd_hwdep_new(card, "OPL2/OPL3", device, &hw)) < 0) {
err = snd_hwdep_new(card, "OPL2/OPL3", device, &hw);
if (err < 0) {
snd_device_free(card, opl3);
return err;
}
Expand Down
6 changes: 4 additions & 2 deletions sound/drivers/opl3/opl3_oss.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,17 @@ static int snd_opl3_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
if (snd_BUG_ON(!arg))
return -ENXIO;

if ((err = snd_opl3_synth_setup(opl3)) < 0)
err = snd_opl3_synth_setup(opl3);
if (err < 0)
return err;

/* fill the argument data */
arg->private_data = opl3;
arg->addr.client = opl3->oss_chset->client;
arg->addr.port = opl3->oss_chset->port;

if ((err = snd_opl3_synth_use_inc(opl3)) < 0)
err = snd_opl3_synth_use_inc(opl3);
if (err < 0)
return err;

opl3->synth_mode = SNDRV_OPL3_MODE_SYNTH;
Expand Down
9 changes: 6 additions & 3 deletions sound/drivers/opl3/opl3_seq.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe
struct snd_opl3 *opl3 = private_data;
int err;

if ((err = snd_opl3_synth_setup(opl3)) < 0)
err = snd_opl3_synth_setup(opl3);
if (err < 0)
return err;

if (use_internal_drums) {
Expand All @@ -107,7 +108,8 @@ static int snd_opl3_synth_use(void *private_data, struct snd_seq_port_subscribe
}

if (info->sender.client != SNDRV_SEQ_CLIENT_SYSTEM) {
if ((err = snd_opl3_synth_use_inc(opl3)) < 0)
err = snd_opl3_synth_use_inc(opl3);
if (err < 0)
return err;
}
opl3->synth_mode = SNDRV_OPL3_MODE_SEQ;
Expand Down Expand Up @@ -227,7 +229,8 @@ static int snd_opl3_seq_probe(struct device *_dev)
if (client < 0)
return client;

if ((err = snd_opl3_synth_create_port(opl3)) < 0) {
err = snd_opl3_synth_create_port(opl3);
if (err < 0) {
snd_seq_delete_kernel_client(client);
opl3->seq_client = -1;
return err;
Expand Down

0 comments on commit 9c78e80

Please sign in to comment.