[PATCH 08/14] ALSA: wavefront: Use auto-cleanup for firmware loading
Takashi Iwai <[email protected]>
| Newsgroups | gmane.linux.sound |
|---|---|
| Message-ID | <[email protected]> |
Simplify the code to manage the firmware loading with __free(firmware) auto-cleanup. Only the code refactoring, no functional changes. Signed-off-by: Takashi Iwai <[email protected]> --- sound/isa/wavefront/wavefront_fx.c | 23 +++++++---------------- sound/isa/wavefront/wavefront_synth.c | 4 +--- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/sound/isa/wavefront/wavefront_fx.c b/sound/isa/wavefront/wavefront_fx.c index beca35ce04f3..6d95ea338ea9 100644 --- a/sound/isa/wavefront/wavefront_fx.c +++ b/sound/isa/wavefront/wavefront_fx.c @@ -232,41 +232,32 @@ snd_wavefront_fx_start (snd_wavefront_t *dev) { unsigned int i; int err; - const struct firmware *firmware = NULL; + const struct firmware *firmware __free(firmware) = NULL; if (dev->fx_initialized) return 0; err = request_firmware(&firmware, "yamaha/yss225_registers.bin", dev->card->dev); - if (err < 0) { - err = -1; - goto out; - } + if (err < 0) + return -1; for (i = 0; i + 1 < firmware->size; i += 2) { if (firmware->data[i] >= 8 && firmware->data[i] < 16) { outb(firmware->data[i + 1], dev->base + firmware->data[i]); } else if (firmware->data[i] == WAIT_IDLE) { - if (!wavefront_fx_idle(dev)) { - err = -1; - goto out; - } + if (!wavefront_fx_idle(dev)) + return -1; } else { dev_err(dev->card->dev, "invalid address in register data\n"); - err = -1; - goto out; + return -1; } } dev->fx_initialized = 1; - err = 0; - -out: - release_firmware(firmware); - return err; + return 0; } MODULE_FIRMWARE("yamaha/yss225_registers.bin"); diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c index 2f57a6795d22..0c8f5cf26455 100644 --- a/sound/isa/wavefront/wavefront_synth.c +++ b/sound/isa/wavefront/wavefront_synth.c @@ -2053,7 +2053,7 @@ wavefront_download_firmware (snd_wavefront_t *dev, char *path) const unsigned char *buf; int len, err; int section_cnt_downloaded = 0; - const struct firmware *firmware; + const struct firmware *firmware __free(firmware) = NULL; err = request_firmware(&firmware, path, dev->card->dev); if (err < 0) { @@ -2108,11 +2108,9 @@ wavefront_download_firmware (snd_wavefront_t *dev, char *path) section_cnt_downloaded++; } - release_firmware(firmware); return 0; failure: - release_firmware(firmware); dev_err(dev->card->dev, "firmware download failed!!!\n"); return 1; } -- 2.55.0