Skip to content

Commit

Permalink
ALSA: 6fire: Use standard printk helpers
Browse files Browse the repository at this point in the history
Convert with dev_err() and co from snd_printk(), etc.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
tiwai committed Feb 26, 2014
1 parent 0ba41d9 commit e3b3757
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 72 deletions.
8 changes: 4 additions & 4 deletions sound/usb/6fire/chip.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,
}
if (regidx < 0) {
mutex_unlock(&register_mutex);
snd_printk(KERN_ERR PREFIX "too many cards registered.\n");
dev_err(&intf->dev, "too many cards registered.\n");
return -ENODEV;
}
devices[regidx] = device;
Expand All @@ -121,13 +121,13 @@ static int usb6fire_chip_probe(struct usb_interface *intf,

/* if we are here, card can be registered in alsa. */
if (usb_set_interface(device, 0, 0) != 0) {
snd_printk(KERN_ERR PREFIX "can't set first interface.\n");
dev_err(&intf->dev, "can't set first interface.\n");
return -EIO;
}
ret = snd_card_new(&intf->dev, index[regidx], id[regidx],
THIS_MODULE, sizeof(struct sfire_chip), &card);
if (ret < 0) {
snd_printk(KERN_ERR PREFIX "cannot create alsa card.\n");
dev_err(&intf->dev, "cannot create alsa card.\n");
return ret;
}
strcpy(card->driver, "6FireUSB");
Expand Down Expand Up @@ -168,7 +168,7 @@ static int usb6fire_chip_probe(struct usb_interface *intf,

ret = snd_card_register(card);
if (ret < 0) {
snd_printk(KERN_ERR PREFIX "cannot register card.");
dev_err(&intf->dev, "cannot register card.");
usb6fire_chip_destroy(chip);
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions sound/usb/6fire/comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static void usb6fire_comm_receiver_handler(struct urb *urb)
urb->status = 0;
urb->actual_length = 0;
if (usb_submit_urb(urb, GFP_ATOMIC) < 0)
snd_printk(KERN_WARNING PREFIX
dev_warn(&urb->dev->dev,
"comm data receiver aborted.\n");
}
}
Expand Down Expand Up @@ -179,7 +179,7 @@ int usb6fire_comm_init(struct sfire_chip *chip)
if (ret < 0) {
kfree(rt->receiver_buffer);
kfree(rt);
snd_printk(KERN_ERR PREFIX "cannot create comm data receiver.");
dev_err(&chip->dev->dev, "cannot create comm data receiver.");
return ret;
}
chip->comm = rt;
Expand Down
18 changes: 11 additions & 7 deletions sound/usb/6fire/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ static int usb6fire_control_output_vol_put(struct snd_kcontrol *kcontrol,
int changed = 0;

if (ch > 4) {
snd_printk(KERN_ERR PREFIX "Invalid channel in volume control.");
dev_err(&rt->chip->dev->dev,
"Invalid channel in volume control.");
return -EINVAL;
}

Expand Down Expand Up @@ -222,7 +223,8 @@ static int usb6fire_control_output_vol_get(struct snd_kcontrol *kcontrol,
unsigned int ch = kcontrol->private_value;

if (ch > 4) {
snd_printk(KERN_ERR PREFIX "Invalid channel in volume control.");
dev_err(&rt->chip->dev->dev,
"Invalid channel in volume control.");
return -EINVAL;
}

Expand All @@ -240,7 +242,8 @@ static int usb6fire_control_output_mute_put(struct snd_kcontrol *kcontrol,
u8 value = 0;

if (ch > 4) {
snd_printk(KERN_ERR PREFIX "Invalid channel in volume control.");
dev_err(&rt->chip->dev->dev,
"Invalid channel in volume control.");
return -EINVAL;
}

Expand All @@ -265,7 +268,8 @@ static int usb6fire_control_output_mute_get(struct snd_kcontrol *kcontrol,
u8 value = rt->output_mute >> ch;

if (ch > 4) {
snd_printk(KERN_ERR PREFIX "Invalid channel in volume control.");
dev_err(&rt->chip->dev->dev,
"Invalid channel in volume control.");
return -EINVAL;
}

Expand Down Expand Up @@ -594,14 +598,14 @@ int usb6fire_control_init(struct sfire_chip *chip)
ret = usb6fire_control_add_virtual(rt, chip->card,
"Master Playback Volume", vol_elements);
if (ret) {
snd_printk(KERN_ERR PREFIX "cannot add control.\n");
dev_err(&chip->dev->dev, "cannot add control.\n");
kfree(rt);
return ret;
}
ret = usb6fire_control_add_virtual(rt, chip->card,
"Master Playback Switch", mute_elements);
if (ret) {
snd_printk(KERN_ERR PREFIX "cannot add control.\n");
dev_err(&chip->dev->dev, "cannot add control.\n");
kfree(rt);
return ret;
}
Expand All @@ -611,7 +615,7 @@ int usb6fire_control_init(struct sfire_chip *chip)
ret = snd_ctl_add(chip->card, snd_ctl_new1(&elements[i], rt));
if (ret < 0) {
kfree(rt);
snd_printk(KERN_ERR PREFIX "cannot add control.\n");
dev_err(&chip->dev->dev, "cannot add control.\n");
return ret;
}
i++;
Expand Down
70 changes: 37 additions & 33 deletions sound/usb/6fire/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,16 @@ static int usb6fire_fw_ezusb_upload(
ret = request_firmware(&fw, fwname, &device->dev);
if (ret < 0) {
kfree(rec);
snd_printk(KERN_ERR PREFIX "error requesting ezusb "
"firmware %s.\n", fwname);
dev_err(&intf->dev,
"error requesting ezusb firmware %s.\n", fwname);
return ret;
}
ret = usb6fire_fw_ihex_init(fw, rec);
if (ret < 0) {
kfree(rec);
release_firmware(fw);
snd_printk(KERN_ERR PREFIX "error validating ezusb "
"firmware %s.\n", fwname);
dev_err(&intf->dev,
"error validating ezusb firmware %s.\n", fwname);
return ret;
}
/* upload firmware image */
Expand All @@ -237,8 +237,9 @@ static int usb6fire_fw_ezusb_upload(
if (ret < 0) {
kfree(rec);
release_firmware(fw);
snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
"firmware %s: begin message.\n", fwname);
dev_err(&intf->dev,
"unable to upload ezusb firmware %s: begin message.\n",
fwname);
return ret;
}

Expand All @@ -248,8 +249,9 @@ static int usb6fire_fw_ezusb_upload(
if (ret < 0) {
kfree(rec);
release_firmware(fw);
snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
"firmware %s: data urb.\n", fwname);
dev_err(&intf->dev,
"unable to upload ezusb firmware %s: data urb.\n",
fwname);
return ret;
}
}
Expand All @@ -260,17 +262,19 @@ static int usb6fire_fw_ezusb_upload(
ret = usb6fire_fw_ezusb_write(device, 0xa0, postaddr,
postdata, postlen);
if (ret < 0) {
snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
"firmware %s: post urb.\n", fwname);
dev_err(&intf->dev,
"unable to upload ezusb firmware %s: post urb.\n",
fwname);
return ret;
}
}

data = 0x00; /* resume ezusb cpu */
ret = usb6fire_fw_ezusb_write(device, 0xa0, 0xe600, &data, 1);
if (ret < 0) {
snd_printk(KERN_ERR PREFIX "unable to upload ezusb "
"firmware %s: end message.\n", fwname);
dev_err(&intf->dev,
"unable to upload ezusb firmware %s: end message.\n",
fwname);
return ret;
}
return 0;
Expand All @@ -292,7 +296,7 @@ static int usb6fire_fw_fpga_upload(

ret = request_firmware(&fw, fwname, &device->dev);
if (ret < 0) {
snd_printk(KERN_ERR PREFIX "unable to get fpga firmware %s.\n",
dev_err(&intf->dev, "unable to get fpga firmware %s.\n",
fwname);
kfree(buffer);
return -EIO;
Expand All @@ -305,8 +309,8 @@ static int usb6fire_fw_fpga_upload(
if (ret < 0) {
kfree(buffer);
release_firmware(fw);
snd_printk(KERN_ERR PREFIX "unable to upload fpga firmware: "
"begin urb.\n");
dev_err(&intf->dev,
"unable to upload fpga firmware: begin urb.\n");
return ret;
}

Expand All @@ -318,8 +322,8 @@ static int usb6fire_fw_fpga_upload(
if (ret < 0) {
release_firmware(fw);
kfree(buffer);
snd_printk(KERN_ERR PREFIX "unable to upload fpga "
"firmware: fw urb.\n");
dev_err(&intf->dev,
"unable to upload fpga firmware: fw urb.\n");
return ret;
}
}
Expand All @@ -328,8 +332,8 @@ static int usb6fire_fw_fpga_upload(

ret = usb6fire_fw_ezusb_write(device, 9, 0, NULL, 0);
if (ret < 0) {
snd_printk(KERN_ERR PREFIX "unable to upload fpga firmware: "
"end urb.\n");
dev_err(&intf->dev,
"unable to upload fpga firmware: end urb.\n");
return ret;
}
return 0;
Expand All @@ -338,15 +342,15 @@ static int usb6fire_fw_fpga_upload(
/* check, if the firmware version the devices has currently loaded
* is known by this driver. 'version' needs to have 4 bytes version
* info data. */
static int usb6fire_fw_check(u8 *version)
static int usb6fire_fw_check(struct usb_interface *intf, const u8 *version)
{
int i;

for (i = 0; i < ARRAY_SIZE(known_fw_versions); i++)
if (!memcmp(version, known_fw_versions + i, 2))
return 0;

snd_printk(KERN_ERR PREFIX "invalid fimware version in device: %4ph. "
dev_err(&intf->dev, "invalid fimware version in device: %4ph. "
"please reconnect to power. if this failure "
"still happens, check your firmware installation.",
version);
Expand All @@ -364,16 +368,16 @@ int usb6fire_fw_init(struct usb_interface *intf)

ret = usb6fire_fw_ezusb_read(device, 1, 0, buffer, 8);
if (ret < 0) {
snd_printk(KERN_ERR PREFIX "unable to receive device "
"firmware state.\n");
dev_err(&intf->dev,
"unable to receive device firmware state.\n");
return ret;
}
if (buffer[0] != 0xeb || buffer[1] != 0xaa || buffer[2] != 0x55) {
snd_printk(KERN_ERR PREFIX "unknown device firmware state "
"received from device: ");
dev_err(&intf->dev,
"unknown device firmware state received from device:");
for (i = 0; i < 8; i++)
snd_printk("%02x ", buffer[i]);
snd_printk("\n");
printk(KERN_CONT "%02x ", buffer[i]);
printk(KERN_CONT "\n");
return -EIO;
}
/* do we need fpga loader ezusb firmware? */
Expand All @@ -386,7 +390,7 @@ int usb6fire_fw_init(struct usb_interface *intf)
}
/* do we need fpga firmware and application ezusb firmware? */
else if (buffer[3] == 0x02) {
ret = usb6fire_fw_check(buffer + 4);
ret = usb6fire_fw_check(intf, buffer + 4);
if (ret < 0)
return ret;
ret = usb6fire_fw_fpga_upload(intf, "6fire/dmx6firecf.bin");
Expand All @@ -402,14 +406,14 @@ int usb6fire_fw_init(struct usb_interface *intf)
}
/* all fw loaded? */
else if (buffer[3] == 0x03)
return usb6fire_fw_check(buffer + 4);
return usb6fire_fw_check(intf, buffer + 4);
/* unknown data? */
else {
snd_printk(KERN_ERR PREFIX "unknown device firmware state "
"received from device: ");
dev_err(&intf->dev,
"unknown device firmware state received from device: ");
for (i = 0; i < 8; i++)
snd_printk("%02x ", buffer[i]);
snd_printk("\n");
printk(KERN_CONT "%02x ", buffer[i]);
printk(KERN_CONT "\n");
return -EIO;
}
return 0;
Expand Down
12 changes: 7 additions & 5 deletions sound/usb/6fire/midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ static void usb6fire_midi_out_handler(struct urb *urb)

ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret < 0)
snd_printk(KERN_ERR PREFIX "midi out urb "
"submit failed: %d\n", ret);
dev_err(&urb->dev->dev,
"midi out urb submit failed: %d\n",
ret);
} else /* no more data to transmit */
rt->out = NULL;
}
Expand Down Expand Up @@ -94,8 +95,9 @@ static void usb6fire_midi_out_trigger(

ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret < 0)
snd_printk(KERN_ERR PREFIX "midi out urb "
"submit failed: %d\n", ret);
dev_err(&urb->dev->dev,
"midi out urb submit failed: %d\n",
ret);
else
rt->out = alsa_sub;
}
Expand Down Expand Up @@ -181,7 +183,7 @@ int usb6fire_midi_init(struct sfire_chip *chip)
if (ret < 0) {
kfree(rt->out_buffer);
kfree(rt);
snd_printk(KERN_ERR PREFIX "unable to create midi.\n");
dev_err(&chip->dev->dev, "unable to create midi.\n");
return ret;
}
rt->instance->private_data = rt;
Expand Down
Loading

0 comments on commit e3b3757

Please sign in to comment.