ALSA: hdsp: check for iobox and upload firmware during ioctl

currently, the error message when trying to run hdspmixer or hdspconf
if the breakout box is not connected is somehow misleading, since it
asks the user to upload the firmware.

this patch adds a test, whether the breakout box is connected and
tries to upload the firmware in the case, that it is not present, e.g.
because of power failures of the breakout box.

[Minor coding-style fixes by tiwai]

Signed-off-by: Tim Blechmann <tim@klingt.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by Tim Blechmann and committed by Takashi Iwai 3ae7e2e2 00c9ddd1

+17 -4
+17 -4
sound/pci/rme9652/hdsp.c
··· 4548 4548 { 4549 4549 struct hdsp *hdsp = (struct hdsp *)hw->private_data; 4550 4550 void __user *argp = (void __user *)arg; 4551 + int err; 4551 4552 4552 4553 switch (cmd) { 4553 4554 case SNDRV_HDSP_IOCTL_GET_PEAK_RMS: { 4554 4555 struct hdsp_peak_rms __user *peak_rms = (struct hdsp_peak_rms __user *)arg; 4556 + 4557 + err = hdsp_check_for_iobox(hdsp); 4558 + if (err < 0) 4559 + return err; 4560 + 4561 + err = hdsp_check_for_firmware(hdsp, 1); 4562 + if (err < 0) 4563 + return err; 4555 4564 4556 4565 if (!(hdsp->state & HDSP_FirmwareLoaded)) { 4557 4566 snd_printk(KERN_ERR "Hammerfall-DSP: firmware needs to be uploaded to the card.\n"); ··· 4581 4572 unsigned long flags; 4582 4573 int i; 4583 4574 4584 - if (!(hdsp->state & HDSP_FirmwareLoaded)) { 4585 - snd_printk(KERN_ERR "Hammerfall-DSP: Firmware needs to be uploaded to the card.\n"); 4586 - return -EINVAL; 4587 - } 4575 + err = hdsp_check_for_iobox(hdsp); 4576 + if (err < 0) 4577 + return err; 4578 + 4579 + err = hdsp_check_for_firmware(hdsp, 1); 4580 + if (err < 0) 4581 + return err; 4582 + 4588 4583 spin_lock_irqsave(&hdsp->lock, flags); 4589 4584 info.pref_sync_ref = (unsigned char)hdsp_pref_sync_ref(hdsp); 4590 4585 info.wordclock_sync_check = (unsigned char)hdsp_wc_sync_check(hdsp);