[U-Boot] [PATCH v2 3/8] dm: serial: remove unnecessary casting

Simon Glass sjg at chromium.org
Thu Oct 23 20:45:14 CEST 2014


Hi Masahiro,

On 23 October 2014 07:26, Masahiro Yamada <yamada.m at jp.panasonic.com> wrote:
> The type (void *) can be directly passed to a function that
> takes a specific pointer type.
>
> Signed-off-by: Masahiro Yamada <yamada.m at jp.panasonic.com>
> ---
>
> Changes in v2:
>   - Rebase
>
>  drivers/serial/serial-uclass.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index f2bc4d8..5767312 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -135,9 +135,7 @@ void serial_stdio_init(void)
>
>  static void serial_stub_putc(struct stdio_dev *sdev, const char ch)
>  {
> -       struct udevice *dev = sdev->priv;
> -
> -       serial_putc_dev(dev, ch);
> +       serial_putc_dev(sdev->priv, ch);
>  }

There isn't really any casting going on, at least not explicitly. The
purpose of the local variable is to show the type which would
otherwise not be obvious from the context.

I'm OK to take this patch if you really want it, but I'm also OK with
the code as it is. Let me know.

>
>  void serial_stub_puts(struct stdio_dev *sdev, const char *str)
> @@ -148,9 +146,7 @@ void serial_stub_puts(struct stdio_dev *sdev, const char *str)
>
>  int serial_stub_getc(struct stdio_dev *sdev)
>  {
> -       struct udevice *dev = sdev->priv;
> -
> -       return serial_getc_dev(dev);
> +       return serial_getc_dev(sdev->priv);
>  }
>
>  int serial_stub_tstc(struct stdio_dev *sdev)
> --
> 1.9.1
>

Regards,
Simon


More information about the U-Boot mailing list