diff mbox series

[02/13] hw/arm/fsl-imx*: Don't create "null" chardevs for serial devices

Message ID 20180420145249.32435-3-peter.maydell@linaro.org
State New
Headers show
Series Drop compile time limit on number of serial ports | expand

Commit Message

Peter Maydell April 20, 2018, 2:52 p.m. UTC
Following commit 12051d82f004024, UART devices should handle
being passed a NULL pointer chardev, so we don't need to
create "null" backends in board code. Remove the code that
does this and updates serial_hds[].

(fsl-imx7.c was already written this way.)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/fsl-imx25.c | 12 +-----------
 hw/arm/fsl-imx31.c | 12 +-----------
 hw/arm/fsl-imx6.c  | 13 +------------
 3 files changed, 3 insertions(+), 34 deletions(-)

Comments

Philippe Mathieu-Daudé April 20, 2018, 4:48 p.m. UTC | #1
On 04/20/2018 11:52 AM, Peter Maydell wrote:
> Following commit 12051d82f004024, UART devices should handle
> being passed a NULL pointer chardev, so we don't need to
> create "null" backends in board code. Remove the code that
> does this and updates serial_hds[].
> 
> (fsl-imx7.c was already written this way.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/arm/fsl-imx25.c | 12 +-----------
>  hw/arm/fsl-imx31.c | 12 +-----------
>  hw/arm/fsl-imx6.c  | 13 +------------
>  3 files changed, 3 insertions(+), 34 deletions(-)
> 
> diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
> index cb988a6c25..d7d064e5ce 100644
> --- a/hw/arm/fsl-imx25.c
> +++ b/hw/arm/fsl-imx25.c
> @@ -118,17 +118,7 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp)
>          };
>  
>          if (i < MAX_SERIAL_PORTS) {
> -            Chardev *chr;
> -
> -            chr = serial_hds[i];
> -
> -            if (!chr) {
> -                char label[20];
> -                snprintf(label, sizeof(label), "imx31.uart%d", i);
> -                chr = qemu_chr_new(label, "null");
> -            }
> -
> -            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
> +            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hds[i]);
>          }
>  
>          object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
> diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
> index 3eee83d547..e6c788049d 100644
> --- a/hw/arm/fsl-imx31.c
> +++ b/hw/arm/fsl-imx31.c
> @@ -107,17 +107,7 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp)
>          };
>  
>          if (i < MAX_SERIAL_PORTS) {
> -            Chardev *chr;
> -
> -            chr = serial_hds[i];
> -
> -            if (!chr) {
> -                char label[20];
> -                snprintf(label, sizeof(label), "imx31.uart%d", i);
> -                chr = qemu_chr_new(label, "null");
> -            }
> -
> -            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
> +            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hds[i]);
>          }
>  
>          object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
> diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
> index 9dfbc9a8c4..ea14de33c6 100644
> --- a/hw/arm/fsl-imx6.c
> +++ b/hw/arm/fsl-imx6.c
> @@ -189,18 +189,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
>          };
>  
>          if (i < MAX_SERIAL_PORTS) {
> -            Chardev *chr;
> -
> -            chr = serial_hds[i];
> -
> -            if (!chr) {
> -                char *label = g_strdup_printf("imx6.uart%d", i + 1);
> -                chr = qemu_chr_new(label, "null");
> -                g_free(label);
> -                serial_hds[i] = chr;
> -            }
> -
> -            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
> +            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hds[i]);
>          }
>  
>          object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);

Removing the now unneeded #include "chardev/char.h" from the 3 files:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Thomas Huth April 25, 2018, 2:34 p.m. UTC | #2
On 20.04.2018 16:52, Peter Maydell wrote:
> Following commit 12051d82f004024, UART devices should handle
> being passed a NULL pointer chardev, so we don't need to
> create "null" backends in board code. Remove the code that
> does this and updates serial_hds[].
> 
> (fsl-imx7.c was already written this way.)
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/arm/fsl-imx25.c | 12 +-----------
>  hw/arm/fsl-imx31.c | 12 +-----------
>  hw/arm/fsl-imx6.c  | 13 +------------
>  3 files changed, 3 insertions(+), 34 deletions(-)

Reviewed-by: Thomas Huth <thuth@redhat.com>
Thomas Huth April 25, 2018, 2:36 p.m. UTC | #3
On 20.04.2018 16:52, Peter Maydell wrote:
> Following commit 12051d82f004024, UART devices should handle
> being passed a NULL pointer chardev, so we don't need to
> create "null" backends in board code. Remove the code that
> does this and updates serial_hds[].

... maybe drop the "updates serial_hds" in this patch description since
serial_hds is not updated here?

 Thomas
Peter Maydell April 26, 2018, 12:53 p.m. UTC | #4
On 25 April 2018 at 15:36, Thomas Huth <thuth@redhat.com> wrote:
> On 20.04.2018 16:52, Peter Maydell wrote:
>> Following commit 12051d82f004024, UART devices should handle
>> being passed a NULL pointer chardev, so we don't need to
>> create "null" backends in board code. Remove the code that
>> does this and updates serial_hds[].
>
> ... maybe drop the "updates serial_hds" in this patch description since
> serial_hds is not updated here?

It is in the fsl-imx6 case:

-                serial_hds[i] = chr;

thanks
-- PMM
diff mbox series

Patch

diff --git a/hw/arm/fsl-imx25.c b/hw/arm/fsl-imx25.c
index cb988a6c25..d7d064e5ce 100644
--- a/hw/arm/fsl-imx25.c
+++ b/hw/arm/fsl-imx25.c
@@ -118,17 +118,7 @@  static void fsl_imx25_realize(DeviceState *dev, Error **errp)
         };
 
         if (i < MAX_SERIAL_PORTS) {
-            Chardev *chr;
-
-            chr = serial_hds[i];
-
-            if (!chr) {
-                char label[20];
-                snprintf(label, sizeof(label), "imx31.uart%d", i);
-                chr = qemu_chr_new(label, "null");
-            }
-
-            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
+            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hds[i]);
         }
 
         object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
diff --git a/hw/arm/fsl-imx31.c b/hw/arm/fsl-imx31.c
index 3eee83d547..e6c788049d 100644
--- a/hw/arm/fsl-imx31.c
+++ b/hw/arm/fsl-imx31.c
@@ -107,17 +107,7 @@  static void fsl_imx31_realize(DeviceState *dev, Error **errp)
         };
 
         if (i < MAX_SERIAL_PORTS) {
-            Chardev *chr;
-
-            chr = serial_hds[i];
-
-            if (!chr) {
-                char label[20];
-                snprintf(label, sizeof(label), "imx31.uart%d", i);
-                chr = qemu_chr_new(label, "null");
-            }
-
-            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
+            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hds[i]);
         }
 
         object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 9dfbc9a8c4..ea14de33c6 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -189,18 +189,7 @@  static void fsl_imx6_realize(DeviceState *dev, Error **errp)
         };
 
         if (i < MAX_SERIAL_PORTS) {
-            Chardev *chr;
-
-            chr = serial_hds[i];
-
-            if (!chr) {
-                char *label = g_strdup_printf("imx6.uart%d", i + 1);
-                chr = qemu_chr_new(label, "null");
-                g_free(label);
-                serial_hds[i] = chr;
-            }
-
-            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", chr);
+            qdev_prop_set_chr(DEVICE(&s->uart[i]), "chardev", serial_hds[i]);
         }
 
         object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err);