* [U-Boot] [PATCH] dm: serial: Add a REQUIRE_SERIAL_CONSOLE option for boards with no serial port
@ 2015-07-25 9:58 Hans de Goede
2015-08-01 16:05 ` Simon Glass
0 siblings, 1 reply; 4+ messages in thread
From: Hans de Goede @ 2015-07-25 9:58 UTC (permalink / raw)
To: u-boot
Currently the serial code assumes that there is always at least one serial
port (and panics / crashes due to null pointer dereferences when there is
none).
This makes it impossible to use u-boot on boards where there is no (debug)
serial port, because e.g. all uart pins are muxed to another function.
This commit adds a CONFIG_REQUIRE_SERIAL_CONSOLE Kconfig option, which
defaults to y (preserving existing behavior), which can be set to n on
such boards to make them work.
This commit only implements this for CONFIG_DM_SERIAL=y configs, as allowing
running without a serial port for CONFIG_DM_SERIAL=n configs is non trivial,
and is not necessary at this moment.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/serial/Kconfig | 11 +++++++++++
drivers/serial/serial-uclass.c | 20 +++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 4829284..89d01d5 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -1,3 +1,14 @@
+config REQUIRE_SERIAL_CONSOLE
+ bool "Require a serial port for console"
+ # Running without a serial console is not supported by the
+ # non dm serial code
+ depends on DM_SERIAL
+ default y
+ help
+ Require a serial port for the console, and panic of none is found
+ during serial port initialization (default y). Set this to n on
+ boards which have no debug serial port what so ever.
+
config DM_SERIAL
bool "Enable Driver Model for serial drivers"
depends on DM
diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
index 815fec3..df0f183 100644
--- a/drivers/serial/serial-uclass.c
+++ b/drivers/serial/serial-uclass.c
@@ -78,7 +78,9 @@ static void serial_find_console_or_panic(void)
#undef INDEX
}
+#ifdef CONFIG_REQUIRE_SERIAL_CONSOLE
panic_str("No serial driver found");
+#endif
}
/* Called prior to relocation */
@@ -140,28 +142,40 @@ static int _serial_tstc(struct udevice *dev)
void serial_putc(char ch)
{
- _serial_putc(gd->cur_serial_dev, ch);
+ if (gd->cur_serial_dev)
+ _serial_putc(gd->cur_serial_dev, ch);
}
void serial_puts(const char *str)
{
- _serial_puts(gd->cur_serial_dev, str);
+ if (gd->cur_serial_dev)
+ _serial_puts(gd->cur_serial_dev, str);
}
int serial_getc(void)
{
+ if (!gd->cur_serial_dev)
+ return 0;
+
return _serial_getc(gd->cur_serial_dev);
}
int serial_tstc(void)
{
+ if (!gd->cur_serial_dev)
+ return 0;
+
return _serial_tstc(gd->cur_serial_dev);
}
void serial_setbrg(void)
{
- struct dm_serial_ops *ops = serial_get_ops(gd->cur_serial_dev);
+ struct dm_serial_ops *ops;
+
+ if (!gd->cur_serial_dev)
+ return;
+ ops = serial_get_ops(gd->cur_serial_dev);
if (ops->setbrg)
ops->setbrg(gd->cur_serial_dev, gd->baudrate);
}
--
2.4.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] dm: serial: Add a REQUIRE_SERIAL_CONSOLE option for boards with no serial port
2015-07-25 9:58 [U-Boot] [PATCH] dm: serial: Add a REQUIRE_SERIAL_CONSOLE option for boards with no serial port Hans de Goede
@ 2015-08-01 16:05 ` Simon Glass
2015-08-06 16:10 ` Simon Glass
0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2015-08-01 16:05 UTC (permalink / raw)
To: u-boot
Hi Hans,
On 25 July 2015 at 03:58, Hans de Goede <hdegoede@redhat.com> wrote:
> Currently the serial code assumes that there is always at least one serial
> port (and panics / crashes due to null pointer dereferences when there is
> none).
>
> This makes it impossible to use u-boot on boards where there is no (debug)
> serial port, because e.g. all uart pins are muxed to another function.
>
> This commit adds a CONFIG_REQUIRE_SERIAL_CONSOLE Kconfig option, which
> defaults to y (preserving existing behavior), which can be set to n on
> such boards to make them work.
>
> This commit only implements this for CONFIG_DM_SERIAL=y configs, as allowing
> running without a serial port for CONFIG_DM_SERIAL=n configs is non trivial,
> and is not necessary at this moment.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/serial/Kconfig | 11 +++++++++++
> drivers/serial/serial-uclass.c | 20 +++++++++++++++++---
> 2 files changed, 28 insertions(+), 3 deletions(-)
Acked-by: Simon Glass <sjg@chromium.org>
A few nits below.
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 4829284..89d01d5 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -1,3 +1,14 @@
> +config REQUIRE_SERIAL_CONSOLE
> + bool "Require a serial port for console"
> + # Running without a serial console is not supported by the
> + # non dm serial code
non-dm
> + depends on DM_SERIAL
> + default y
> + help
> + Require a serial port for the console, and panic of none is found
s/of/if/
> + during serial port initialization (default y). Set this to n on
> + boards which have no debug serial port what so ever.
whatsoever
> +
> config DM_SERIAL
> bool "Enable Driver Model for serial drivers"
> depends on DM
> diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c
> index 815fec3..df0f183 100644
> --- a/drivers/serial/serial-uclass.c
> +++ b/drivers/serial/serial-uclass.c
> @@ -78,7 +78,9 @@ static void serial_find_console_or_panic(void)
> #undef INDEX
> }
>
> +#ifdef CONFIG_REQUIRE_SERIAL_CONSOLE
> panic_str("No serial driver found");
> +#endif
> }
>
> /* Called prior to relocation */
> @@ -140,28 +142,40 @@ static int _serial_tstc(struct udevice *dev)
>
> void serial_putc(char ch)
> {
> - _serial_putc(gd->cur_serial_dev, ch);
> + if (gd->cur_serial_dev)
> + _serial_putc(gd->cur_serial_dev, ch);
> }
>
> void serial_puts(const char *str)
> {
> - _serial_puts(gd->cur_serial_dev, str);
> + if (gd->cur_serial_dev)
> + _serial_puts(gd->cur_serial_dev, str);
> }
>
> int serial_getc(void)
> {
> + if (!gd->cur_serial_dev)
> + return 0;
> +
> return _serial_getc(gd->cur_serial_dev);
> }
>
> int serial_tstc(void)
> {
> + if (!gd->cur_serial_dev)
> + return 0;
> +
> return _serial_tstc(gd->cur_serial_dev);
> }
>
> void serial_setbrg(void)
> {
> - struct dm_serial_ops *ops = serial_get_ops(gd->cur_serial_dev);
> + struct dm_serial_ops *ops;
> +
> + if (!gd->cur_serial_dev)
> + return;
>
> + ops = serial_get_ops(gd->cur_serial_dev);
> if (ops->setbrg)
> ops->setbrg(gd->cur_serial_dev, gd->baudrate);
> }
> --
> 2.4.3
>
Regards,
Simon
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] dm: serial: Add a REQUIRE_SERIAL_CONSOLE option for boards with no serial port
2015-08-01 16:05 ` Simon Glass
@ 2015-08-06 16:10 ` Simon Glass
2015-08-06 18:27 ` Hans de Goede
0 siblings, 1 reply; 4+ messages in thread
From: Simon Glass @ 2015-08-06 16:10 UTC (permalink / raw)
To: u-boot
hi Hans,
On 1 August 2015 at 10:05, Simon Glass <sjg@chromium.org> wrote:
> Hi Hans,
>
> On 25 July 2015 at 03:58, Hans de Goede <hdegoede@redhat.com> wrote:
>> Currently the serial code assumes that there is always at least one serial
>> port (and panics / crashes due to null pointer dereferences when there is
>> none).
>>
>> This makes it impossible to use u-boot on boards where there is no (debug)
>> serial port, because e.g. all uart pins are muxed to another function.
>>
>> This commit adds a CONFIG_REQUIRE_SERIAL_CONSOLE Kconfig option, which
>> defaults to y (preserving existing behavior), which can be set to n on
>> such boards to make them work.
>>
>> This commit only implements this for CONFIG_DM_SERIAL=y configs, as allowing
>> running without a serial port for CONFIG_DM_SERIAL=n configs is non trivial,
>> and is not necessary at this moment.
>>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>> drivers/serial/Kconfig | 11 +++++++++++
>> drivers/serial/serial-uclass.c | 20 +++++++++++++++++---
>> 2 files changed, 28 insertions(+), 3 deletions(-)
>
> Acked-by: Simon Glass <sjg@chromium.org>
>
> A few nits below.
Are you OK with me fixing the nits when I apply it or would you like to resent?
Regards,
Simon
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] dm: serial: Add a REQUIRE_SERIAL_CONSOLE option for boards with no serial port
2015-08-06 16:10 ` Simon Glass
@ 2015-08-06 18:27 ` Hans de Goede
0 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2015-08-06 18:27 UTC (permalink / raw)
To: u-boot
Hi,
On 06-08-15 18:10, Simon Glass wrote:
> hi Hans,
>
> On 1 August 2015 at 10:05, Simon Glass <sjg@chromium.org> wrote:
>> Hi Hans,
>>
>> On 25 July 2015 at 03:58, Hans de Goede <hdegoede@redhat.com> wrote:
>>> Currently the serial code assumes that there is always at least one serial
>>> port (and panics / crashes due to null pointer dereferences when there is
>>> none).
>>>
>>> This makes it impossible to use u-boot on boards where there is no (debug)
>>> serial port, because e.g. all uart pins are muxed to another function.
>>>
>>> This commit adds a CONFIG_REQUIRE_SERIAL_CONSOLE Kconfig option, which
>>> defaults to y (preserving existing behavior), which can be set to n on
>>> such boards to make them work.
>>>
>>> This commit only implements this for CONFIG_DM_SERIAL=y configs, as allowing
>>> running without a serial port for CONFIG_DM_SERIAL=n configs is non trivial,
>>> and is not necessary at this moment.
>>>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>> drivers/serial/Kconfig | 11 +++++++++++
>>> drivers/serial/serial-uclass.c | 20 +++++++++++++++++---
>>> 2 files changed, 28 insertions(+), 3 deletions(-)
>>
>> Acked-by: Simon Glass <sjg@chromium.org>
>>
>> A few nits below.
>
> Are you OK with me fixing the nits when I apply it or would you like to resent?
I was planning on doing a v2, but I have not found the time to do
so yet. So your offer to fix the nits sounds good. Please go ahead
and fix them.
Thanks & Regards,
Hans
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-08-06 18:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-25 9:58 [U-Boot] [PATCH] dm: serial: Add a REQUIRE_SERIAL_CONSOLE option for boards with no serial port Hans de Goede
2015-08-01 16:05 ` Simon Glass
2015-08-06 16:10 ` Simon Glass
2015-08-06 18:27 ` Hans de Goede
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.