]> 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 3c9bd6b10a961e6d430d044a69fe643c0cdc07ba..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, ...)
 {
@@ -344,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;
                }
@@ -683,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;
 }
@@ -724,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)
@@ -763,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)
 {
@@ -792,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,
@@ -816,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,
@@ -882,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)
@@ -938,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)
 {