Commit f2f9307a authored by Takashi Iwai's avatar Takashi Iwai

ALSA: core: Use standard printk helpers

Use dev_err() & co as much as possible.  If not available (no device
assigned at the calling point), use pr_xxx() helpers instead.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 09e56df8
...@@ -50,7 +50,7 @@ int snd_device_new(struct snd_card *card, snd_device_type_t type, ...@@ -50,7 +50,7 @@ int snd_device_new(struct snd_card *card, snd_device_type_t type,
return -ENXIO; return -ENXIO;
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) { if (dev == NULL) {
snd_printk(KERN_ERR "Cannot allocate device\n"); dev_err(card->dev, "Cannot allocate device, type=%d\n", type);
return -ENOMEM; return -ENOMEM;
} }
dev->card = card; dev->card = card;
...@@ -90,17 +90,17 @@ int snd_device_free(struct snd_card *card, void *device_data) ...@@ -90,17 +90,17 @@ int snd_device_free(struct snd_card *card, void *device_data)
if (dev->state == SNDRV_DEV_REGISTERED && if (dev->state == SNDRV_DEV_REGISTERED &&
dev->ops->dev_disconnect) dev->ops->dev_disconnect)
if (dev->ops->dev_disconnect(dev)) if (dev->ops->dev_disconnect(dev))
snd_printk(KERN_ERR dev_err(card->dev,
"device disconnect failure\n"); "device disconnect failure\n");
if (dev->ops->dev_free) { if (dev->ops->dev_free) {
if (dev->ops->dev_free(dev)) if (dev->ops->dev_free(dev))
snd_printk(KERN_ERR "device free failure\n"); dev_err(card->dev, "device free failure\n");
} }
kfree(dev); kfree(dev);
return 0; return 0;
} }
snd_printd("device free %p (from %pF), not found\n", device_data, dev_dbg(card->dev, "device free %p (from %pF), not found\n",
__builtin_return_address(0)); device_data, __builtin_return_address(0));
return -ENXIO; return -ENXIO;
} }
...@@ -131,13 +131,14 @@ int snd_device_disconnect(struct snd_card *card, void *device_data) ...@@ -131,13 +131,14 @@ int snd_device_disconnect(struct snd_card *card, void *device_data)
if (dev->state == SNDRV_DEV_REGISTERED && if (dev->state == SNDRV_DEV_REGISTERED &&
dev->ops->dev_disconnect) { dev->ops->dev_disconnect) {
if (dev->ops->dev_disconnect(dev)) if (dev->ops->dev_disconnect(dev))
snd_printk(KERN_ERR "device disconnect failure\n"); dev_err(card->dev,
"device disconnect failure\n");
dev->state = SNDRV_DEV_DISCONNECTED; dev->state = SNDRV_DEV_DISCONNECTED;
} }
return 0; return 0;
} }
snd_printd("device disconnect %p (from %pF), not found\n", device_data, dev_dbg(card->dev, "device disconnect %p (from %pF), not found\n",
__builtin_return_address(0)); device_data, __builtin_return_address(0));
return -ENXIO; return -ENXIO;
} }
...@@ -170,7 +171,7 @@ int snd_device_register(struct snd_card *card, void *device_data) ...@@ -170,7 +171,7 @@ int snd_device_register(struct snd_card *card, void *device_data)
dev->state = SNDRV_DEV_REGISTERED; dev->state = SNDRV_DEV_REGISTERED;
return 0; return 0;
} }
snd_printd("snd_device_register busy\n"); dev_dbg(card->dev, "snd_device_register busy\n");
return -EBUSY; return -EBUSY;
} }
snd_BUG(); snd_BUG();
......
...@@ -418,9 +418,14 @@ static int snd_info_entry_release(struct inode *inode, struct file *file) ...@@ -418,9 +418,14 @@ static int snd_info_entry_release(struct inode *inode, struct file *file)
if (entry->c.text.write) { if (entry->c.text.write) {
entry->c.text.write(entry, data->wbuffer); entry->c.text.write(entry, data->wbuffer);
if (data->wbuffer->error) { if (data->wbuffer->error) {
snd_printk(KERN_WARNING "data write error to %s (%i)\n", if (entry->card)
entry->name, dev_warn(entry->card->dev, "info: data write error to %s (%i)\n",
data->wbuffer->error); entry->name,
data->wbuffer->error);
else
pr_warn("ALSA: info: data write error to %s (%i)\n",
entry->name,
data->wbuffer->error);
} }
} }
kfree(data->wbuffer->buffer); kfree(data->wbuffer->buffer);
......
...@@ -113,11 +113,11 @@ static inline int init_info_for_card(struct snd_card *card) ...@@ -113,11 +113,11 @@ static inline int init_info_for_card(struct snd_card *card)
struct snd_info_entry *entry; struct snd_info_entry *entry;
if ((err = snd_info_card_register(card)) < 0) { if ((err = snd_info_card_register(card)) < 0) {
snd_printd("unable to create card info\n"); dev_dbg(card->dev, "unable to create card info\n");
return err; return err;
} }
if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) { if ((entry = snd_info_create_card_entry(card, "id", card->proc_root)) == NULL) {
snd_printd("unable to create card entry\n"); dev_dbg(card->dev, "unable to create card entry\n");
return err; return err;
} }
entry->c.text.read = snd_card_id_read; entry->c.text.read = snd_card_id_read;
...@@ -217,7 +217,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid, ...@@ -217,7 +217,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
err = -ENODEV; err = -ENODEV;
if (err < 0) { if (err < 0) {
mutex_unlock(&snd_card_mutex); mutex_unlock(&snd_card_mutex);
snd_printk(KERN_ERR "cannot find the slot for index %d (range 0-%i), error: %d\n", dev_err(parent, "cannot find the slot for index %d (range 0-%i), error: %d\n",
idx, snd_ecards_limit - 1, err); idx, snd_ecards_limit - 1, err);
kfree(card); kfree(card);
return err; return err;
...@@ -254,12 +254,12 @@ int snd_card_new(struct device *parent, int idx, const char *xid, ...@@ -254,12 +254,12 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
/* snd_cards_bitmask and snd_cards are set with snd_card_register */ /* snd_cards_bitmask and snd_cards are set with snd_card_register */
err = snd_ctl_create(card); err = snd_ctl_create(card);
if (err < 0) { if (err < 0) {
snd_printk(KERN_ERR "unable to register control minors\n"); dev_err(parent, "unable to register control minors\n");
goto __error; goto __error;
} }
err = snd_info_card_create(card); err = snd_info_card_create(card);
if (err < 0) { if (err < 0) {
snd_printk(KERN_ERR "unable to create card info\n"); dev_err(parent, "unable to create card info\n");
goto __error_ctl; goto __error_ctl;
} }
*card_ret = card; *card_ret = card;
...@@ -422,7 +422,7 @@ int snd_card_disconnect(struct snd_card *card) ...@@ -422,7 +422,7 @@ int snd_card_disconnect(struct snd_card *card)
/* notify all devices that we are disconnected */ /* notify all devices that we are disconnected */
err = snd_device_disconnect_all(card); err = snd_device_disconnect_all(card);
if (err < 0) if (err < 0)
snd_printk(KERN_ERR "not all devices for card %i can be disconnected\n", card->number); dev_err(card->dev, "not all devices for card %i can be disconnected\n", card->number);
snd_info_card_disconnect(card); snd_info_card_disconnect(card);
if (card->registered) { if (card->registered) {
...@@ -455,22 +455,22 @@ static int snd_card_do_free(struct snd_card *card) ...@@ -455,22 +455,22 @@ static int snd_card_do_free(struct snd_card *card)
snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE); snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE);
#endif #endif
if (snd_device_free_all(card, SNDRV_DEV_CMD_PRE) < 0) { if (snd_device_free_all(card, SNDRV_DEV_CMD_PRE) < 0) {
snd_printk(KERN_ERR "unable to free all devices (pre)\n"); dev_err(card->dev, "unable to free all devices (pre)\n");
/* Fatal, but this situation should never occur */ /* Fatal, but this situation should never occur */
} }
if (snd_device_free_all(card, SNDRV_DEV_CMD_NORMAL) < 0) { if (snd_device_free_all(card, SNDRV_DEV_CMD_NORMAL) < 0) {
snd_printk(KERN_ERR "unable to free all devices (normal)\n"); dev_err(card->dev, "unable to free all devices (normal)\n");
/* Fatal, but this situation should never occur */ /* Fatal, but this situation should never occur */
} }
if (snd_device_free_all(card, SNDRV_DEV_CMD_POST) < 0) { if (snd_device_free_all(card, SNDRV_DEV_CMD_POST) < 0) {
snd_printk(KERN_ERR "unable to free all devices (post)\n"); dev_err(card->dev, "unable to free all devices (post)\n");
/* Fatal, but this situation should never occur */ /* Fatal, but this situation should never occur */
} }
if (card->private_free) if (card->private_free)
card->private_free(card); card->private_free(card);
snd_info_free_entry(card->proc_id); snd_info_free_entry(card->proc_id);
if (snd_info_card_free(card) < 0) { if (snd_info_card_free(card) < 0) {
snd_printk(KERN_WARNING "unable to free card info\n"); dev_warn(card->dev, "unable to free card info\n");
/* Not fatal error */ /* Not fatal error */
} }
if (card->release_completion) if (card->release_completion)
...@@ -596,7 +596,7 @@ static void snd_card_set_id_no_lock(struct snd_card *card, const char *src, ...@@ -596,7 +596,7 @@ static void snd_card_set_id_no_lock(struct snd_card *card, const char *src,
goto again; goto again;
} }
/* last resort... */ /* last resort... */
snd_printk(KERN_ERR "unable to set card id (%s)\n", id); dev_err(card->dev, "unable to set card id (%s)\n", id);
if (card->proc_root->name) if (card->proc_root->name)
strlcpy(card->id, card->proc_root->name, sizeof(card->id)); strlcpy(card->id, card->proc_root->name, sizeof(card->id));
} }
...@@ -948,7 +948,7 @@ int snd_card_file_remove(struct snd_card *card, struct file *file) ...@@ -948,7 +948,7 @@ int snd_card_file_remove(struct snd_card *card, struct file *file)
} }
spin_unlock(&card->files_lock); spin_unlock(&card->files_lock);
if (!found) { if (!found) {
snd_printk(KERN_ERR "ALSA card file remove problem (%p)\n", file); dev_err(card->dev, "card file remove problem (%p)\n", file);
return -ENOENT; return -ENOENT;
} }
kfree(found); kfree(found);
......
...@@ -106,7 +106,7 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size) ...@@ -106,7 +106,7 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size)
result = result1; result = result1;
#ifdef CONFIG_SND_DEBUG #ifdef CONFIG_SND_DEBUG
if (result > size) if (result > size)
snd_printk(KERN_ERR "pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size); pr_err("ALSA: pointer (0x%x) for DMA #%ld is greater than transfer size (0x%x)\n", result, dma, size);
#endif #endif
if (result >= size || result == 0) if (result >= size || result == 0)
return 0; return 0;
......
...@@ -207,7 +207,7 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size, ...@@ -207,7 +207,7 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
break; break;
#endif #endif
default: default:
printk(KERN_ERR "snd-malloc: invalid device type %d\n", type); pr_err("snd-malloc: invalid device type %d\n", type);
dmab->area = NULL; dmab->area = NULL;
dmab->addr = 0; dmab->addr = 0;
return -ENXIO; return -ENXIO;
...@@ -284,7 +284,7 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab) ...@@ -284,7 +284,7 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
break; break;
#endif #endif
default: default:
printk(KERN_ERR "snd-malloc: invalid device type %d\n", dmab->dev.type); pr_err("snd-malloc: invalid device type %d\n", dmab->dev.type);
} }
} }
......
...@@ -168,7 +168,7 @@ void snd_seq_device_load_drivers(void) ...@@ -168,7 +168,7 @@ void snd_seq_device_load_drivers(void)
/* /*
* register a sequencer device * register a sequencer device
* card = card info (NULL allowed) * card = card info
* device = device number (if any) * device = device number (if any)
* id = id of driver * id = id of driver
* result = return pointer (NULL allowed if unnecessary) * result = return pointer (NULL allowed if unnecessary)
......
...@@ -458,7 +458,7 @@ static int __init alsa_sound_init(void) ...@@ -458,7 +458,7 @@ static int __init alsa_sound_init(void)
snd_major = major; snd_major = major;
snd_ecards_limit = cards_limit; snd_ecards_limit = cards_limit;
if (register_chrdev(major, "alsa", &snd_fops)) { if (register_chrdev(major, "alsa", &snd_fops)) {
snd_printk(KERN_ERR "unable to register native major device number %d\n", major); pr_err("ALSA core: unable to register native major device number %d\n", major);
return -EIO; return -EIO;
} }
if (snd_info_init() < 0) { if (snd_info_init() < 0) {
...@@ -467,7 +467,7 @@ static int __init alsa_sound_init(void) ...@@ -467,7 +467,7 @@ static int __init alsa_sound_init(void)
} }
snd_info_minor_register(); snd_info_minor_register();
#ifndef MODULE #ifndef MODULE
printk(KERN_INFO "Advanced Linux Sound Architecture Driver Initialized.\n"); pr_info("Advanced Linux Sound Architecture Driver Initialized.\n");
#endif #endif
return 0; return 0;
} }
......
...@@ -101,7 +101,7 @@ static int slave_init(struct link_slave *slave) ...@@ -101,7 +101,7 @@ static int slave_init(struct link_slave *slave)
if (slave->info.count > 2 || if (slave->info.count > 2 ||
(slave->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER && (slave->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER &&
slave->info.type != SNDRV_CTL_ELEM_TYPE_BOOLEAN)) { slave->info.type != SNDRV_CTL_ELEM_TYPE_BOOLEAN)) {
snd_printk(KERN_ERR "invalid slave element\n"); pr_err("ALSA: vmaster: invalid slave element\n");
kfree(uinfo); kfree(uinfo);
return -EINVAL; return -EINVAL;
} }
......
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