]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - sound/core/info.c
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[karo-tx-linux.git] / sound / core / info.c
index 3aa88640808e089a48d773b263902b3c3ca76ae1..e79baa11b60eb15526ba3679537720b2f29d0de6 100644 (file)
@@ -89,7 +89,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer,
        char *nbuf;
 
        nsize = PAGE_ALIGN(nsize);
-       nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL);
+       nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL | __GFP_ZERO);
        if (! nbuf)
                return -ENOMEM;
 
@@ -105,7 +105,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer,
  *
  * Outputs the string on the procfs buffer just like printf().
  *
- * Returns the size of output string.
+ * Return: The size of output string, or a negative error code.
  */
 int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...)
 {
@@ -153,13 +153,6 @@ EXPORT_SYMBOL(snd_seq_root);
 struct snd_info_entry *snd_oss_root;
 #endif
 
-static void snd_remove_proc_entry(struct proc_dir_entry *parent,
-                                 struct proc_dir_entry *de)
-{
-       if (de)
-               remove_proc_entry(de->name, parent);
-}
-
 static loff_t snd_info_entry_llseek(struct file *file, loff_t offset, int orig)
 {
        struct snd_info_private_data *data;
@@ -351,7 +344,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
                                goto __nomem;
                        data->rbuffer = buffer;
                        buffer->len = PAGE_SIZE;
-                       buffer->buffer = kmalloc(buffer->len, GFP_KERNEL);
+                       buffer->buffer = kzalloc(buffer->len, GFP_KERNEL);
                        if (buffer->buffer == NULL)
                                goto __nomem;
                }
@@ -580,7 +573,7 @@ int __exit snd_info_done(void)
 #ifdef CONFIG_SND_OSSEMUL
                snd_info_free_entry(snd_oss_root);
 #endif
-               snd_remove_proc_entry(NULL, snd_proc_root);
+               proc_remove(snd_proc_root);
        }
        return 0;
 }
@@ -642,7 +635,7 @@ void snd_info_card_id_change(struct snd_card *card)
 {
        mutex_lock(&info_mutex);
        if (card->proc_root_link) {
-               snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
+               proc_remove(card->proc_root_link);
                card->proc_root_link = NULL;
        }
        if (strcmp(card->id, card->proc_root->name))
@@ -661,10 +654,8 @@ void snd_info_card_disconnect(struct snd_card *card)
        if (!card)
                return;
        mutex_lock(&info_mutex);
-       if (card->proc_root_link) {
-               snd_remove_proc_entry(snd_proc_root, card->proc_root_link);
-               card->proc_root_link = NULL;
-       }
+       proc_remove(card->proc_root_link);
+       card->proc_root_link = NULL;
        if (card->proc_root)
                snd_info_disconnect(card->proc_root);
        mutex_unlock(&info_mutex);
@@ -692,32 +683,27 @@ int snd_info_card_free(struct snd_card *card)
  *
  * Reads one line from the buffer and stores the string.
  *
- * Returns zero if successful, or 1 if error or EOF.
+ * Return: Zero if successful, or 1 if error or EOF.
  */
 int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len)
 {
        int c = -1;
 
+       if (snd_BUG_ON(!buffer || !buffer->buffer))
+               return 1;
        if (len <= 0 || buffer->stop || buffer->error)
                return 1;
-       while (--len > 0) {
+       while (!buffer->stop) {
                c = buffer->buffer[buffer->curr++];
-               if (c == '\n') {
-                       if (buffer->curr >= buffer->size)
-                               buffer->stop = 1;
-                       break;
-               }
-               *line++ = c;
-               if (buffer->curr >= buffer->size) {
+               if (buffer->curr >= buffer->size)
                        buffer->stop = 1;
+               if (c == '\n')
                        break;
+               if (len) {
+                       len--;
+                       *line++ = c;
                }
        }
-       while (c != '\n' && !buffer->stop) {
-               c = buffer->buffer[buffer->curr++];
-               if (buffer->curr >= buffer->size)
-                       buffer->stop = 1;
-       }
        *line = '\0';
        return 0;
 }
@@ -733,7 +719,7 @@ EXPORT_SYMBOL(snd_info_get_line);
  * Parses the original string and copy a token to the given
  * string buffer.
  *
- * Returns the updated pointer of the original string so that
+ * Return: The updated pointer of the original string so that
  * it can be used for the next call.
  */
 const char *snd_info_get_str(char *dest, const char *src, int len)
@@ -772,7 +758,7 @@ EXPORT_SYMBOL(snd_info_get_str);
  * Usually called from other functions such as
  * snd_info_create_card_entry().
  *
- * Returns the pointer of the new instance, or NULL on failure.
+ * Return: The pointer of the new instance, or %NULL on failure.
  */
 static struct snd_info_entry *snd_info_create_entry(const char *name)
 {
@@ -801,7 +787,7 @@ static struct snd_info_entry *snd_info_create_entry(const char *name)
  *
  * Creates a new info entry and assigns it to the given module.
  *
- * Returns the pointer of the new instance, or NULL on failure.
+ * Return: The pointer of the new instance, or %NULL on failure.
  */
 struct snd_info_entry *snd_info_create_module_entry(struct module * module,
                                               const char *name,
@@ -825,7 +811,7 @@ EXPORT_SYMBOL(snd_info_create_module_entry);
  *
  * Creates a new info entry and assigns it to the given card.
  *
- * Returns the pointer of the new instance, or NULL on failure.
+ * Return: The pointer of the new instance, or %NULL on failure.
  */
 struct snd_info_entry *snd_info_create_card_entry(struct snd_card *card,
                                             const char *name,
@@ -856,7 +842,7 @@ static void snd_info_disconnect(struct snd_info_entry *entry)
        list_del_init(&entry->list);
        root = entry->parent == NULL ? snd_proc_root : entry->parent->p;
        snd_BUG_ON(!root);
-       snd_remove_proc_entry(root, entry->p);
+       proc_remove(entry->p);
        entry->p = NULL;
 }
 
@@ -891,7 +877,7 @@ static int snd_info_dev_register_entry(struct snd_device *device)
  * For releasing this entry, use snd_device_free() instead of
  * snd_info_free_entry(). 
  *
- * Returns zero if successful, or a negative error code on failure.
+ * Return: Zero if successful, or a negative error code on failure.
  */
 int snd_card_proc_new(struct snd_card *card, const char *name,
                      struct snd_info_entry **entryp)
@@ -947,7 +933,7 @@ EXPORT_SYMBOL(snd_info_free_entry);
  *
  * Registers the proc info entry.
  *
- * Returns zero if successful, or a negative error code on failure.
+ * Return: Zero if successful, or a negative error code on failure.
  */
 int snd_info_register(struct snd_info_entry * entry)
 {
@@ -970,7 +956,7 @@ int snd_info_register(struct snd_info_entry * entry)
                        mutex_unlock(&info_mutex);
                        return -ENOMEM;
                }
-               p->size = entry->size;
+               proc_set_size(p, entry->size);
        }
        entry->p = p;
        if (entry->parent)