From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 04/29] stdio: Pass device pointer to stdio methods
Date: Fri, 11 Jul 2014 01:26:20 +0200 [thread overview]
Message-ID: <201407110126.20531.marex@denx.de> (raw)
In-Reply-To: <1404877099-7314-5-git-send-email-sjg@chromium.org>
On Wednesday, July 09, 2014 at 05:37:54 AM, Simon Glass wrote:
> At present stdio device functions do not get any clue as to which stdio
> device is being acted on. Some implementations go to great lengths to work
> around this, such as defining a whole separate set of functions for each
> possible device.
>
> For driver model we need to associate a stdio_dev with a device. It doesn't
> seem possible to continue with this work-around approach.
>
> Instead, add a stdio_dev pointer to each of the stdio member functions.
>
> Note: The serial drivers have the same problem, but it is not strictly
> necessary to fix that to get driver model running. Also, if we convert
> serial over to driver model the problem will go away.
>
> Code size increases by 244 bytes for Thumb2 and 428 for PowerPC.
>
> 22: stdio: Pass device pointer to stdio methods
> arm: (for 2/2 boards) all +244.0 bss -4.0 text +248.0
> powerpc: (for 1/1 boards) all +428.0 text +428.0
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Acked-by: Marek Vasut <marex@denx.de>
[...]
> diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c
> index fd61a5e..803d850 100644
> --- a/drivers/serial/serial.c
> +++ b/drivers/serial/serial.c
> @@ -254,6 +254,48 @@ void serial_initialize(void)
> serial_assign(default_serial_console()->name);
> }
>
> +int serial_stub_start(struct stdio_dev *sdev)
> +{
> + struct serial_device *dev = sdev->priv;
Are you sure this pointer derefference won't blow if $sdev is ever NULL? Can
$sdev be NULL (in some early stage for example) ?
> + return dev->start();
> +}
Reviewed-by: Marek Vasut <marex@denx.de>
I really like where this is going.
Best regards,
Marek Vasut
next prev parent reply other threads:[~2014-07-10 23:26 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-09 3:37 [U-Boot] [PATCH v2 0/29] Add additional core driver model features Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 01/29] dm: gpio: Don't use the driver model uclass for SPL Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 02/29] dm: Use an explicit expect value in core tests Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 03/29] stdio: Remove redundant code around stdio_register() calls Simon Glass
2014-07-10 23:23 ` Marek Vasut
2014-07-13 16:13 ` Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 04/29] stdio: Pass device pointer to stdio methods Simon Glass
2014-07-10 23:26 ` Marek Vasut [this message]
2014-07-11 4:29 ` Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 05/29] dm: Make sure that the root device is probed Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 06/29] dm: Provide a way to shut down driver model Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 07/29] sandbox: Remove all drivers before exit Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 08/29] dm: Allow drivers to be marked 'before relocation' Simon Glass
2014-07-10 23:29 ` Marek Vasut
2014-07-13 18:38 ` Simon Glass
2014-07-09 3:37 ` [U-Boot] [PATCH v2 09/29] dm: Support driver model prior to relocation Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 10/29] stdio: Provide functions to add/remove devices using stdio_dev Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 11/29] console: Remove vprintf() optimisation for sandbox Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 12/29] Add a flag indicating when the serial console is ready Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 13/29] dm: Move uclass error checking/probing into a function Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 14/29] fdt: Add a function to get the alias sequence of a node Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 15/29] dm: Move device display into its own function Simon Glass
2014-07-10 23:33 ` Marek Vasut
2014-07-11 4:27 ` Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 16/29] dm: Avoid activating devices in 'dm uclass' command Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 17/29] dm: Introduce device sequence numbering Simon Glass
2014-07-09 13:53 ` Jon Loeliger
2014-07-19 3:22 ` Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 18/29] dm: Display the sequence number for each device Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 19/29] dm: Allow a device to be found by its FDT offset Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 20/29] dm: Avoid accessing uclasses before they are ready Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 21/29] fdt: Add a function to get the node offset of an alias Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 22/29] dm: Tidy up some header file comments Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 23/29] dm: Provide a function to scan child FDT nodes Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 24/29] dm: Add functions to access a device's children Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 25/29] dm: Introduce per-child data for devices Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 26/29] dm: Add child_pre_probe() and child_post_remove() methods Simon Glass
2014-07-15 8:26 ` Pavel Herrmann
2014-07-17 5:41 ` Simon Glass
2014-07-17 7:09 ` Pavel Herrmann
2014-07-17 15:20 ` Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 27/29] dm: Improve errors and warnings in lists_bind_fdt() Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 28/29] dm: Add dm_scan_other() to locate board-specific devices Simon Glass
2014-07-09 3:38 ` [U-Boot] [PATCH v2 29/29] dm: Give the demo uclass a name Simon Glass
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=201407110126.20531.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox