Commit d0ad13ef authored by Takashi Iwai's avatar Takashi Iwai

ALSA: serial: Fix assignment in if condition

A few ALSA serial drivers contain 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-63-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 9c78e803
...@@ -566,7 +566,8 @@ static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id) ...@@ -566,7 +566,8 @@ static irqreturn_t snd_mtpav_irqh(int irq, void *dev_id)
*/ */
static int snd_mtpav_get_ISA(struct mtpav *mcard) static int snd_mtpav_get_ISA(struct mtpav *mcard)
{ {
if ((mcard->res_port = request_region(port, 3, "MotuMTPAV MIDI")) == NULL) { mcard->res_port = request_region(port, 3, "MotuMTPAV MIDI");
if (!mcard->res_port) {
snd_printk(KERN_ERR "MTVAP port 0x%lx is busy\n", port); snd_printk(KERN_ERR "MTVAP port 0x%lx is busy\n", port);
return -EBUSY; return -EBUSY;
} }
...@@ -628,10 +629,11 @@ static int snd_mtpav_get_RAWMIDI(struct mtpav *mcard) ...@@ -628,10 +629,11 @@ static int snd_mtpav_get_RAWMIDI(struct mtpav *mcard)
hwports = 8; hwports = 8;
mcard->num_ports = hwports; mcard->num_ports = hwports;
if ((rval = snd_rawmidi_new(mcard->card, "MotuMIDI", 0, rval = snd_rawmidi_new(mcard->card, "MotuMIDI", 0,
mcard->num_ports * 2 + MTPAV_PIDX_BROADCAST + 1, mcard->num_ports * 2 + MTPAV_PIDX_BROADCAST + 1,
mcard->num_ports * 2 + MTPAV_PIDX_BROADCAST + 1, mcard->num_ports * 2 + MTPAV_PIDX_BROADCAST + 1,
&mcard->rmidi)) < 0) &mcard->rmidi);
if (rval < 0)
return rval; return rval;
rawmidi = mcard->rmidi; rawmidi = mcard->rmidi;
rawmidi->private_data = mcard; rawmidi->private_data = mcard;
...@@ -744,7 +746,8 @@ static int __init alsa_card_mtpav_init(void) ...@@ -744,7 +746,8 @@ static int __init alsa_card_mtpav_init(void)
{ {
int err; int err;
if ((err = platform_driver_register(&snd_mtpav_driver)) < 0) err = platform_driver_register(&snd_mtpav_driver);
if (err < 0)
return err; return err;
device = platform_device_register_simple(SND_MTPAV_DRIVER, -1, NULL, 0); device = platform_device_register_simple(SND_MTPAV_DRIVER, -1, NULL, 0);
......
...@@ -950,7 +950,8 @@ static int snd_mts64_probe(struct platform_device *pdev) ...@@ -950,7 +950,8 @@ static int snd_mts64_probe(struct platform_device *pdev)
goto free_pardev; goto free_pardev;
} }
if ((err = snd_mts64_create(card, pardev, &mts)) < 0) { err = snd_mts64_create(card, pardev, &mts);
if (err < 0) {
snd_printd("Cannot create main component\n"); snd_printd("Cannot create main component\n");
goto release_pardev; goto release_pardev;
} }
...@@ -963,19 +964,22 @@ static int snd_mts64_probe(struct platform_device *pdev) ...@@ -963,19 +964,22 @@ static int snd_mts64_probe(struct platform_device *pdev)
goto __err; goto __err;
} }
if ((err = snd_mts64_rawmidi_create(card)) < 0) { err = snd_mts64_rawmidi_create(card);
if (err < 0) {
snd_printd("Creating Rawmidi component failed\n"); snd_printd("Creating Rawmidi component failed\n");
goto __err; goto __err;
} }
/* init device */ /* init device */
if ((err = mts64_device_init(p)) < 0) err = mts64_device_init(p);
if (err < 0)
goto __err; goto __err;
platform_set_drvdata(pdev, card); platform_set_drvdata(pdev, card);
/* At this point card will be usable */ /* At this point card will be usable */
if ((err = snd_card_register(card)) < 0) { err = snd_card_register(card);
if (err < 0) {
snd_printd("Cannot register card\n"); snd_printd("Cannot register card\n");
goto __err; goto __err;
} }
...@@ -1031,7 +1035,8 @@ static int __init snd_mts64_module_init(void) ...@@ -1031,7 +1035,8 @@ static int __init snd_mts64_module_init(void)
{ {
int err; int err;
if ((err = platform_driver_register(&snd_mts64_driver)) < 0) err = platform_driver_register(&snd_mts64_driver);
if (err < 0)
return err; return err;
if (parport_register_driver(&mts64_parport_driver) != 0) { if (parport_register_driver(&mts64_parport_driver) != 0) {
......
...@@ -749,7 +749,8 @@ static int snd_portman_probe(struct platform_device *pdev) ...@@ -749,7 +749,8 @@ static int snd_portman_probe(struct platform_device *pdev)
goto free_pardev; goto free_pardev;
} }
if ((err = portman_create(card, pardev, &pm)) < 0) { err = portman_create(card, pardev, &pm);
if (err < 0) {
snd_printd("Cannot create main component\n"); snd_printd("Cannot create main component\n");
goto release_pardev; goto release_pardev;
} }
...@@ -762,19 +763,22 @@ static int snd_portman_probe(struct platform_device *pdev) ...@@ -762,19 +763,22 @@ static int snd_portman_probe(struct platform_device *pdev)
goto __err; goto __err;
} }
if ((err = snd_portman_rawmidi_create(card)) < 0) { err = snd_portman_rawmidi_create(card);
if (err < 0) {
snd_printd("Creating Rawmidi component failed\n"); snd_printd("Creating Rawmidi component failed\n");
goto __err; goto __err;
} }
/* init device */ /* init device */
if ((err = portman_device_init(pm)) < 0) err = portman_device_init(pm);
if (err < 0)
goto __err; goto __err;
platform_set_drvdata(pdev, card); platform_set_drvdata(pdev, card);
/* At this point card will be usable */ /* At this point card will be usable */
if ((err = snd_card_register(card)) < 0) { err = snd_card_register(card);
if (err < 0) {
snd_printd("Cannot register card\n"); snd_printd("Cannot register card\n");
goto __err; goto __err;
} }
...@@ -831,7 +835,8 @@ static int __init snd_portman_module_init(void) ...@@ -831,7 +835,8 @@ static int __init snd_portman_module_init(void)
{ {
int err; int err;
if ((err = platform_driver_register(&snd_portman_driver)) < 0) err = platform_driver_register(&snd_portman_driver);
if (err < 0)
return err; return err;
if (parport_register_driver(&portman_parport_driver) != 0) { if (parport_register_driver(&portman_parport_driver) != 0) {
......
...@@ -783,7 +783,8 @@ static int snd_uart16550_create(struct snd_card *card, ...@@ -783,7 +783,8 @@ static int snd_uart16550_create(struct snd_card *card,
int err; int err;
if ((uart = kzalloc(sizeof(*uart), GFP_KERNEL)) == NULL) uart = kzalloc(sizeof(*uart), GFP_KERNEL);
if (!uart)
return -ENOMEM; return -ENOMEM;
uart->adaptor = adaptor; uart->adaptor = adaptor;
uart->card = card; uart->card = card;
...@@ -792,7 +793,8 @@ static int snd_uart16550_create(struct snd_card *card, ...@@ -792,7 +793,8 @@ static int snd_uart16550_create(struct snd_card *card,
uart->base = iobase; uart->base = iobase;
uart->drop_on_full = droponfull; uart->drop_on_full = droponfull;
if ((err = snd_uart16550_detect(uart)) <= 0) { err = snd_uart16550_detect(uart);
if (err <= 0) {
printk(KERN_ERR "no UART detected at 0x%lx\n", iobase); printk(KERN_ERR "no UART detected at 0x%lx\n", iobase);
snd_uart16550_free(uart); snd_uart16550_free(uart);
return -ENODEV; return -ENODEV;
...@@ -818,7 +820,8 @@ static int snd_uart16550_create(struct snd_card *card, ...@@ -818,7 +820,8 @@ static int snd_uart16550_create(struct snd_card *card,
uart->timer_running = 0; uart->timer_running = 0;
/* Register device */ /* Register device */
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, uart, &ops)) < 0) { err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, uart, &ops);
if (err < 0) {
snd_uart16550_free(uart); snd_uart16550_free(uart);
return err; return err;
} }
...@@ -932,14 +935,10 @@ static int snd_serial_probe(struct platform_device *devptr) ...@@ -932,14 +935,10 @@ static int snd_serial_probe(struct platform_device *devptr)
strcpy(card->driver, "Serial"); strcpy(card->driver, "Serial");
strcpy(card->shortname, "Serial MIDI (UART16550A)"); strcpy(card->shortname, "Serial MIDI (UART16550A)");
if ((err = snd_uart16550_create(card, err = snd_uart16550_create(card, port[dev], irq[dev], speed[dev],
port[dev], base[dev], adaptor[dev], droponfull[dev],
irq[dev], &uart);
speed[dev], if (err < 0)
base[dev],
adaptor[dev],
droponfull[dev],
&uart)) < 0)
goto _err; goto _err;
err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi); err = snd_uart16550_rmidi(uart, 0, outs[dev], ins[dev], &uart->rmidi);
...@@ -952,7 +951,8 @@ static int snd_serial_probe(struct platform_device *devptr) ...@@ -952,7 +951,8 @@ static int snd_serial_probe(struct platform_device *devptr)
uart->base, uart->base,
uart->irq); uart->irq);
if ((err = snd_card_register(card)) < 0) err = snd_card_register(card);
if (err < 0)
goto _err; goto _err;
platform_set_drvdata(devptr, card); platform_set_drvdata(devptr, card);
...@@ -992,7 +992,8 @@ static int __init alsa_card_serial_init(void) ...@@ -992,7 +992,8 @@ static int __init alsa_card_serial_init(void)
{ {
int i, cards, err; int i, cards, err;
if ((err = platform_driver_register(&snd_serial_driver)) < 0) err = platform_driver_register(&snd_serial_driver);
if (err < 0)
return err; return err;
cards = 0; cards = 0;
......
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