Skip to content
Snippets Groups Projects
Select Git revision
  • 20424d85f8a07090fd32c6fad343f91b63c730b0
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

leon_kernel.c

Blame
  • seq_buf.c 9.90 KiB
    // SPDX-License-Identifier: GPL-2.0
    /*
     * seq_buf.c
     *
     * Copyright (C) 2014 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
     *
     * The seq_buf is a handy tool that allows you to pass a descriptor around
     * to a buffer that other functions can write to. It is similar to the
     * seq_file functionality but has some differences.
     *
     * To use it, the seq_buf must be initialized with seq_buf_init().
     * This will set up the counters within the descriptor. You can call
     * seq_buf_init() more than once to reset the seq_buf to start
     * from scratch.
     */
    #include <linux/uaccess.h>
    #include <linux/seq_file.h>
    #include <linux/seq_buf.h>
    
    /**
     * seq_buf_can_fit - can the new data fit in the current buffer?
     * @s: the seq_buf descriptor
     * @len: The length to see if it can fit in the current buffer
     *
     * Returns true if there's enough unused space in the seq_buf buffer
     * to fit the amount of new data according to @len.
     */
    static bool seq_buf_can_fit(struct seq_buf *s, size_t len)
    {
    	return s->len + len <= s->size;
    }
    
    /**
     * seq_buf_print_seq - move the contents of seq_buf into a seq_file
     * @m: the seq_file descriptor that is the destination
     * @s: the seq_buf descriptor that is the source.
     *
     * Returns zero on success, non zero otherwise
     */
    int seq_buf_print_seq(struct seq_file *m, struct seq_buf *s)
    {
    	unsigned int len = seq_buf_used(s);
    
    	return seq_write(m, s->buffer, len);
    }
    
    /**
     * seq_buf_vprintf - sequence printing of information.
     * @s: seq_buf descriptor
     * @fmt: printf format string
     * @args: va_list of arguments from a printf() type function
     *
     * Writes a vnprintf() format into the sequencce buffer.
     *
     * Returns zero on success, -1 on overflow.
     */
    int seq_buf_vprintf(struct seq_buf *s, const char *fmt, va_list args)
    {
    	int len;
    
    	WARN_ON(s->size == 0);
    
    	if (s->len < s->size) {
    		len = vsnprintf(s->buffer + s->len, s->size - s->len, fmt, args);
    		if (s->len + len < s->size) {
    			s->len += len;
    			return 0;
    		}
    	}
    	seq_buf_set_overflow(s);