diff mbox

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

Message ID 1414070772-19380-4-git-send-email-yamada.m@jp.panasonic.com
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Masahiro Yamada Oct. 23, 2014, 1:26 p.m. UTC
The type (void *) can be directly passed to a function that
takes a specific pointer type.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
---

Changes in v2:
  - Rebase

 drivers/serial/serial-uclass.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Simon Glass Oct. 23, 2014, 6:45 p.m. UTC | #1
Hi Masahiro,

On 23 October 2014 07:26, Masahiro Yamada <yamada.m@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@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
Simon Glass Oct. 23, 2014, 7:03 p.m. UTC | #2
Hi,

On 23 October 2014 12:45, Simon Glass <sjg@chromium.org> wrote:
> Hi Masahiro,
>
> On 23 October 2014 07:26, Masahiro Yamada <yamada.m@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@jp.panasonic.com>

Thinking a bit more we may as well take this, the value of the
explicit type is very small.

Acked-by: Simon Glass <sjg@chromium.org>

Regards,
Simon
Masahiro Yamada Oct. 23, 2014, 7:19 p.m. UTC | #3
Hi Simon,


2014-10-24 4:03 GMT+09:00 Simon Glass <sjg@chromium.org>:
> Hi,
>
> On 23 October 2014 12:45, Simon Glass <sjg@chromium.org> wrote:
>> Hi Masahiro,
>>
>> On 23 October 2014 07:26, Masahiro Yamada <yamada.m@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@jp.panasonic.com>
>
> Thinking a bit more we may as well take this, the value of the
> explicit type is very small.
>
> Acked-by: Simon Glass <sjg@chromium.org>


Setting aside my comments in the log, I like at least this code chage.

I admit the description was not nice as you pointed out.


If you like, you can rephrase the comments
or squash 3/8 and 4/8 into a single patch removing comments in this patch.
Of course, it is OK to leave it as is.
Up to you.
Simon Glass Oct. 24, 2014, 3:54 a.m. UTC | #4
On 23 October 2014 13:19, Masahiro YAMADA <yamada.m@jp.panasonic.com> wrote:
> Hi Simon,
>
>
> 2014-10-24 4:03 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> Hi,
>>
>> On 23 October 2014 12:45, Simon Glass <sjg@chromium.org> wrote:
>>> Hi Masahiro,
>>>
>>> On 23 October 2014 07:26, Masahiro Yamada <yamada.m@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@jp.panasonic.com>
>>
>> Thinking a bit more we may as well take this, the value of the
>> explicit type is very small.
>>
>> Acked-by: Simon Glass <sjg@chromium.org>
>
>
> Setting aside my comments in the log, I like at least this code chage.
>
> I admit the description was not nice as you pointed out.
>
>
> If you like, you can rephrase the comments
> or squash 3/8 and 4/8 into a single patch removing comments in this patch.
> Of course, it is OK to leave it as is.
> Up to you.

I think it is fairly clear what is going on.

Applied to u-boot-dm/master, thanks!
diff mbox

Patch

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);
 }
 
 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)