From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH 04/10] ALSA: core: Use standard printk helpers
Date: Wed, 12 Feb 2014 12:33:06 +0100 [thread overview]
Message-ID: <1392204792-12655-5-git-send-email-tiwai@suse.de> (raw)
In-Reply-To: <1392204792-12655-1-git-send-email-tiwai@suse.de>
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: Takashi Iwai <tiwai@suse.de>
---
sound/core/device.c | 19 ++++++++++++++-----
sound/core/info.c | 11 ++++++++---
sound/core/init.c | 20 ++++++++++----------
sound/core/isadma.c | 2 +-
sound/core/memalloc.c | 4 ++--
sound/core/sound.c | 4 ++--
sound/core/vmaster.c | 2 +-
7 files changed, 38 insertions(+), 24 deletions(-)
diff --git a/sound/core/device.c b/sound/core/device.c
index d622bcd4ff53..cbc7ded11a26 100644
--- a/sound/core/device.c
+++ b/sound/core/device.c
@@ -25,6 +25,13 @@
#include <linux/errno.h>
#include <sound/core.h>
+#define error(card, fmt, args...) do { \
+ if (card) \
+ dev_err((card)->dev, fmt, ##args); \
+ else \
+ pr_err(KERN_ERR "ALSA: " fmt, ##args); \
+ } while (0)
+
/**
* snd_device_new - create an ALSA device component
* @card: the card instance
@@ -51,7 +58,7 @@ int snd_device_new(struct snd_card *card, enum snd_device_type type,
return -ENXIO;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (dev == NULL) {
- snd_printk(KERN_ERR "Cannot allocate device\n");
+ error(dev->card, "Cannot allocate device, type=%d\n", type);
return -ENOMEM;
}
INIT_LIST_HEAD(&dev->list);
@@ -78,7 +85,8 @@ static int __snd_device_disconnect(struct snd_device *dev)
if (dev->state == SNDRV_DEV_REGISTERED) {
if (dev->ops->dev_disconnect &&
dev->ops->dev_disconnect(dev))
- snd_printk(KERN_ERR "device disconnect failure\n");
+ error(dev->card, "device disconnect failure, type=%d\n",
+ dev->type);
dev->state = SNDRV_DEV_DISCONNECTED;
}
return 0;
@@ -92,7 +100,8 @@ static int __snd_device_free(struct snd_device *dev)
__snd_device_disconnect(dev);
if (dev->ops->dev_free) {
if (dev->ops->dev_free(dev))
- snd_printk(KERN_ERR "device free failure\n");
+ error(dev->card, "device free failure, type=%d\n",
+ dev->type);
}
kfree(dev);
return 0;
@@ -130,8 +139,8 @@ int snd_device_free(struct snd_card *card, void *device_data)
dev = look_for_dev(card, device_data);
if (dev)
return __snd_device_free(dev);
- snd_printd("device free %p (from %pF), not found\n", device_data,
- __builtin_return_address(0));
+ dev_dbg(card->dev, "device free %p (from %pF), not found\n",
+ device_data, __builtin_return_address(0));
return -ENXIO;
}
EXPORT_SYMBOL(snd_device_free);
diff --git a/sound/core/info.c b/sound/core/info.c
index 7916c07b9324..051d55b05521 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -418,9 +418,14 @@ static int snd_info_entry_release(struct inode *inode, struct file *file)
if (entry->c.text.write) {
entry->c.text.write(entry, data->wbuffer);
if (data->wbuffer->error) {
- snd_printk(KERN_WARNING "data write error to %s (%i)\n",
- entry->name,
- data->wbuffer->error);
+ if (entry->card)
+ dev_warn(entry->card->dev, "info: data write error to %s (%i)\n",
+ 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);
diff --git a/sound/core/init.c b/sound/core/init.c
index 3fdb4e2ce5ea..ad7234a63a7b 100644
--- a/sound/core/init.c
+++ b/sound/core/init.c
@@ -113,11 +113,11 @@ static inline int init_info_for_card(struct snd_card *card)
struct snd_info_entry *entry;
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;
}
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;
}
entry->c.text.read = snd_card_id_read;
@@ -217,7 +217,7 @@ int snd_card_new(struct device *parent, int idx, const char *xid,
err = -ENODEV;
if (err < 0) {
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);
kfree(card);
return err;
@@ -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 */
err = snd_ctl_create(card);
if (err < 0) {
- snd_printk(KERN_ERR "unable to register control minors\n");
+ dev_err(parent, "unable to register control minors\n");
goto __error;
}
err = snd_info_card_create(card);
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;
}
*card_ret = card;
@@ -422,7 +422,7 @@ int snd_card_disconnect(struct snd_card *card)
/* notify all devices that we are disconnected */
err = snd_device_disconnect_all(card);
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);
if (card->registered) {
@@ -455,14 +455,14 @@ static int snd_card_do_free(struct snd_card *card)
snd_mixer_oss_notify_callback(card, SND_MIXER_OSS_NOTIFY_FREE);
#endif
if (snd_device_free_all(card) < 0) {
- snd_printk(KERN_ERR "unable to free all devices\n");
+ dev_err(card->dev, "unable to free all devices\n");
/* Fatal, but this situation should never occur */
}
if (card->private_free)
card->private_free(card);
snd_info_free_entry(card->proc_id);
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 */
}
if (card->release_completion)
@@ -588,7 +588,7 @@ static void snd_card_set_id_no_lock(struct snd_card *card, const char *src,
goto again;
}
/* 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)
strlcpy(card->id, card->proc_root->name, sizeof(card->id));
}
@@ -940,7 +940,7 @@ int snd_card_file_remove(struct snd_card *card, struct file *file)
}
spin_unlock(&card->files_lock);
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;
}
kfree(found);
diff --git a/sound/core/isadma.c b/sound/core/isadma.c
index e2b386156a4c..31e8544d7f2d 100644
--- a/sound/core/isadma.c
+++ b/sound/core/isadma.c
@@ -106,7 +106,7 @@ unsigned int snd_dma_pointer(unsigned long dma, unsigned int size)
result = result1;
#ifdef CONFIG_SND_DEBUG
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
if (result >= size || result == 0)
return 0;
diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c
index 4595f93d151e..082509eb805d 100644
--- a/sound/core/memalloc.c
+++ b/sound/core/memalloc.c
@@ -207,7 +207,7 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
break;
#endif
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->addr = 0;
return -ENXIO;
@@ -284,7 +284,7 @@ void snd_dma_free_pages(struct snd_dma_buffer *dmab)
break;
#endif
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);
}
}
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 4aaa53161644..60ab9b1f44b9 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -458,7 +458,7 @@ static int __init alsa_sound_init(void)
snd_major = major;
snd_ecards_limit = cards_limit;
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;
}
if (snd_info_init() < 0) {
@@ -467,7 +467,7 @@ static int __init alsa_sound_init(void)
}
snd_info_minor_register();
#ifndef MODULE
- printk(KERN_INFO "Advanced Linux Sound Architecture Driver Initialized.\n");
+ pr_info("Advanced Linux Sound Architecture Driver Initialized.\n");
#endif
return 0;
}
diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c
index 842a97d5fc3a..6c58e6f73a01 100644
--- a/sound/core/vmaster.c
+++ b/sound/core/vmaster.c
@@ -101,7 +101,7 @@ static int slave_init(struct link_slave *slave)
if (slave->info.count > 2 ||
(slave->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER &&
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);
return -EINVAL;
}
--
1.8.5.2
next prev parent reply other threads:[~2014-02-12 11:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-12 11:33 [PATCH RFC 00/10] Use standard printk helpers for ALSA core codes Takashi Iwai
2014-02-12 11:33 ` [PATCH 01/10] ALSA: seq_oss: Drop debug prints Takashi Iwai
2014-02-12 11:33 ` [PATCH 02/10] ALSA: control: Use standard printk helpers Takashi Iwai
2014-02-12 11:33 ` [PATCH 03/10] " Takashi Iwai
2014-02-12 18:56 ` Takashi Iwai
2014-02-12 11:33 ` Takashi Iwai [this message]
2014-02-12 18:57 ` [PATCH 04/10] ALSA: core: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 05/10] ALSA: rawmidi: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 06/10] ALSA: hwdep: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 07/10] ALSA: oss: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 08/10] ALSA: timer: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 09/10] ALSA: seq: " Takashi Iwai
2014-02-12 11:33 ` [PATCH 10/10] ALSA: seq_oss: " Takashi Iwai
2014-02-14 12:01 ` [PATCH RFC 00/10] Use standard printk helpers for ALSA core codes Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1392204792-12655-5-git-send-email-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).