All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/6 V2] kerneldoc: Annotate drivers/serial/serial.c
Date: Mon,  8 Oct 2012 22:58:54 +0200	[thread overview]
Message-ID: <1349729934-8502-1-git-send-email-marex@denx.de> (raw)
In-Reply-To: <1349568426-27219-6-git-send-email-marex@denx.de>

Add kerneldoc annotations into serial core.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Marek Vasut <marek.vasut@gmail.com>
Cc: Tom Rini <trini@ti.com>
---
 drivers/serial/serial.c |  164 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 164 insertions(+)

V2: Rewrap the documentation.

diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
index 57e3b75..51ddad7 100644
--- a/drivers/serial/serial.c
+++ b/drivers/serial/serial.c
@@ -33,10 +33,28 @@ DECLARE_GLOBAL_DATA_PTR;
 static struct serial_device *serial_devices;
 static struct serial_device *serial_current;
 
+/**
+ * serial_null() - Void registration routine of a serial driver
+ *
+ * This routine implements a void registration routine of a serial
+ * driver. The registration routine of a particular driver is aliased
+ * to this empty function in case the driver is not compiled into
+ * U-Boot.
+ */
 static void serial_null(void)
 {
 }
 
+/**
+ * serial_initfunc() - Forward declare of driver registration routine
+ * @name:	Name of the real driver registration routine.
+ *
+ * This macro expands onto forward declaration of a driver registration
+ * routine, which is then used below in serial_initialize() function.
+ * The declaration is made weak and aliases to serial_null() so in case
+ * the driver is not compiled in, the function is still declared and can
+ * be used, but aliases to serial_null() and thus is optimized away.
+ */
 #define serial_initfunc(name)					\
 	void name(void)						\
 		__attribute__((weak, alias("serial_null")));
@@ -94,6 +112,16 @@ serial_initfunc(s3c44b0_serial_initialize);
 serial_initfunc(sa1100_serial_initialize);
 serial_initfunc(sh_serial_initialize);
 
+/**
+ * serial_register() - Register serial driver with serial driver core
+ * @dev:	Pointer to the serial driver structure
+ *
+ * This function registers the serial driver supplied via @dev with
+ * serial driver core, thus making U-Boot aware of it and making it
+ * available for U-Boot to use. On platforms that still require manual
+ * relocation of constant variables, relocation of the supplied structure
+ * is performed.
+ */
 void serial_register(struct serial_device *dev)
 {
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
@@ -117,6 +145,15 @@ void serial_register(struct serial_device *dev)
 	serial_devices = dev;
 }
 
+/**
+ * serial_initialize() - Register all compiled-in serial port drivers
+ *
+ * This function registers all serial port drivers that are compiled
+ * into the U-Boot binary with the serial core, thus making them
+ * available to U-Boot to use. Lastly, this function assigns a default
+ * serial port to the serial core. That serial port is then used as a
+ * default output.
+ */
 void serial_initialize(void)
 {
 	mpc8xx_serial_initialize();
@@ -175,6 +212,13 @@ void serial_initialize(void)
 	serial_assign(default_serial_console()->name);
 }
 
+/**
+ * serial_stdio_init() - Register serial ports with STDIO core
+ *
+ * This function generates a proxy driver for each serial port driver.
+ * These proxy drivers then register with the STDIO core, making the
+ * serial drivers available as STDIO devices.
+ */
 void serial_stdio_init(void)
 {
 	struct stdio_dev dev;
@@ -199,6 +243,18 @@ void serial_stdio_init(void)
 	}
 }
 
+/**
+ * serial_assign() - Select the serial output device by name
+ * @name:	Name of the serial driver to be used as default output
+ *
+ * This function configures the serial output multiplexing by
+ * selecting which serial device will be used as default. In case
+ * the STDIO "serial" device is selected as stdin/stdout/stderr,
+ * the serial device previously configured by this function will be
+ * used for the particular operation.
+ *
+ * Returns 0 on success, negative on error.
+ */
 int serial_assign(const char *name)
 {
 	struct serial_device *s;
@@ -213,6 +269,12 @@ int serial_assign(const char *name)
 	return -EINVAL;
 }
 
+/**
+ * serial_reinit_all() - Reinitialize all compiled-in serial ports
+ *
+ * This function reinitializes all serial ports that are compiled
+ * into U-Boot by calling their serial_start() functions.
+ */
 void serial_reinit_all(void)
 {
 	struct serial_device *s;
@@ -221,6 +283,21 @@ void serial_reinit_all(void)
 		s->start();
 }
 
+/**
+ * get_current() - Return pointer to currently selected serial port
+ *
+ * This function returns a pointer to currently selected serial port.
+ * The currently selected serial port is altered by serial_assign()
+ * function.
+ *
+ * In case this function is called before relocation or before any serial
+ * port is configured, this function calls default_serial_console() to
+ * determine the serial port. Otherwise, the configured serial port is
+ * returned.
+ *
+ * Returns pointer to the currently selected serial port on success,
+ * NULL on error.
+ */
 static struct serial_device *get_current(void)
 {
 	struct serial_device *dev;
@@ -245,36 +322,112 @@ static struct serial_device *get_current(void)
 	return dev;
 }
 
+/**
+ * serial_init() - Initialize currently selected serial port
+ *
+ * This function initializes the currently selected serial port. This
+ * usually involves setting up the registers of that particular port,
+ * enabling clock and such. This function uses the get_current() call
+ * to determine which port is selected.
+ *
+ * Returns 0 on success, negative on error.
+ */
 int serial_init(void)
 {
 	return get_current()->start();
 }
 
+/**
+ * serial_setbrg() - Configure baud-rate of currently selected serial port
+ *
+ * This function configures the baud-rate of the currently selected
+ * serial port. The baud-rate is retrieved from global data within
+ * the serial port driver. This function uses the get_current() call
+ * to determine which port is selected.
+ *
+ * Returns 0 on success, negative on error.
+ */
 void serial_setbrg(void)
 {
 	get_current()->setbrg();
 }
 
+/**
+ * serial_getc() - Read single character from currently selected serial port
+ *
+ * This function retrieves a single character from currently selected
+ * serial port. In case there is no character in the serial port fifo,
+ * this function will block and wait for the character indefinitelly.
+ * This function uses the get_current() call to determine which port
+ * is selected.
+ *
+ * Returns the character on success, negative on error.
+ */
 int serial_getc(void)
 {
 	return get_current()->getc();
 }
 
+/**
+ * serial_tstc() - Test if data is available on currently selected serial port
+ *
+ * This function tests if a single character is available on currently
+ * selected serial port. In case there is no character in the serial
+ * port buffer, this function will not block. This function uses the
+ * get_current() call to determine which port is selected.
+ *
+ * Returns positive if character is available, zero otherwise.
+ */
 int serial_tstc(void)
 {
 	return get_current()->tstc();
 }
 
+/**
+ * serial_putc() - Output single character via currently selected serial port
+ * @c:	Single character to be output from the serial port.
+ *
+ * This function outputs a single character via currently selected
+ * serial port. This character is written into the fifo of the port
+ * and the function waits for the character to be emitted, therefore
+ * this function may block for a short amount of time. This function
+ * uses the get_current() call to determine which port is selected.
+ */
 void serial_putc(const char c)
 {
 	get_current()->putc(c);
 }
 
+/**
+ * serial_puts() - Output string via currently selected serial port
+ * @s:	Zero-terminated string to be output from the serial port.
+ *
+ * This function outputs a zero-terminated string via currently
+ * selected serial port. This function behaves as an accelerator
+ * in case the hardware has a larger fifo buffer. The whole string
+ * that is to be output is available to the function implementing
+ * the hardware manipulation. The function waits for the whole string
+ * to be emitted, therefore this function may block for a some amount
+ * of time. This function uses the get_current() call to determine
+ * which port is selected.
+ */
 void serial_puts(const char *s)
 {
 	get_current()->puts(s);
 }
 
+/**
+ * default_serial_puts() - Output string by calling serial_putc() in loop
+ * @s:	Zero-terminated string to be output from the serial port.
+ *
+ * This function outputs a zero-terminated string by calling serial_putc()
+ * in a loop. Most drivers do not fifo larger than one byte, thus this
+ * function precisely implements their serial_puts().
+ *
+ * To optimize the number of get_current() calls, this function only
+ * calls get_current() once and then directly accesses the putc() call
+ * of the &struct serial_device .
+ */
 void default_serial_puts(const char *s)
 {
 	struct serial_device *dev = get_current();
@@ -285,6 +438,17 @@ void default_serial_puts(const char *s)
 #if CONFIG_POST & CONFIG_SYS_POST_UART
 static const int bauds[] = CONFIG_SYS_BAUDRATE_TABLE;
 
+/**
+ * uart_post_test() - Test the currently selected serial port using POST
+ * @flags:	POST framework flags
+ *
+ * Do a loopback test of the currently selected serial port. This
+ * function is only useful in the context of the POST testing framwork.
+ * The serial port is firstly configured into loopback mode and then
+ * characters are sent through it.
+ *
+ * Returns 0 on success, value otherwise.
+ */
 /* Mark weak until post/cpu/.../uart.c migrate over */
 __weak
 int uart_post_test(int flags)
-- 
1.7.10.4

  parent reply	other threads:[~2012-10-08 20:58 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-07  0:07 [U-Boot] [PATCH 0/6] Serial cleanup series Marek Vasut
2012-10-07  0:07 ` [U-Boot] [PATCH 1/6] serial: Implement default_serial_puts() Marek Vasut
2012-10-17 14:59   ` [U-Boot] [U-Boot,1/6] " Tom Rini
2012-10-07  0:07 ` [U-Boot] [PATCH 2/6] serial: Use default_serial_puts() in drivers Marek Vasut
2012-10-07  0:07 ` [U-Boot] [PATCH 3/6] serial: Reorder serial_assign() Marek Vasut
2012-10-20  0:45   ` Allen Martin
2012-10-20  8:19     ` Marek Vasut
2012-10-22 17:23       ` Allen Martin
2012-10-25 18:09         ` Simon Glass
2012-10-25 19:03           ` Marek Vasut
2012-10-25 20:48             ` Allen Martin
2012-10-25 21:02             ` Simon Glass
2012-10-25 21:19               ` Allen Martin
2012-10-25 21:27                 ` Tom Rini
2012-10-25 21:31                   ` Allen Martin
2012-10-25 22:43                 ` Joe Hershberger
2012-10-26 10:22                   ` Marek Vasut
2012-10-26 17:34                     ` Allen Martin
2012-10-26 18:39                     ` Joe Hershberger
2012-10-26 21:55                       ` Allen Martin
2012-10-27 12:39                         ` Marek Vasut
2012-10-07  0:07 ` [U-Boot] [PATCH 4/6] serial: Reorder get_current() Marek Vasut
2012-10-07  0:07 ` [U-Boot] [PATCH 5/6] kerneldoc: Annotate drivers/serial/serial.c Marek Vasut
2012-10-08 19:37   ` Tom Rini
2012-10-08 22:56     ` Tom Rini
2012-10-08 23:26       ` Marek Vasut
2012-10-08 20:58   ` Marek Vasut [this message]
2012-10-08 21:36     ` [U-Boot] [PATCH 5/6 V3] " Marek Vasut
2012-10-07  0:07 ` [U-Boot] [PATCH 6/6] kerneldoc: stdio: tmpl: Add stdio template Marek Vasut

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=1349729934-8502-1-git-send-email-marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.