OSDN Git Service

serial: sh-sci: Add support for dynamic instances
authorGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 5 Mar 2018 17:17:40 +0000 (18:17 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Apr 2018 08:08:18 +0000 (10:08 +0200)
commit7678f4c20fa7670fcc23e2537a26543c5c6a7772
tree33a235c27d572c9322a353f4cfea9daeb1d9c3e9
parent394e835145414f8633303b46fe938e10fda697c4
serial: sh-sci: Add support for dynamic instances

On DT platforms, the sh-sci driver requires the presence of "serialN"
aliases in DT, from which instance IDs are derived.  If a DT alias is
missing, the drivers fails to probe the corresponding serial port.

This becomes cumbersome when considering DT overlays, as currently
there is no upstream support for dynamically updating the /aliases node
in DT.  Furthermore, even in the presence of such support, hardcoded
instance IDs in independent overlays are prone to conflicts.

Hence add support for dynamic instance IDs, to be used in the absence of
a DT alias.  This makes serial ports behave similar to I2C and SPI
buses, which already support dynamic instances.

Ports in use are tracked using a simple bitmask of type unsigned long,
which is sufficient to handle all current hardware (max. 18 ports).
The maximum number of serial ports is still fixed, and configurable
through Kconfig.  Range validation is done through both Kconfig and a
compile-time check.

Due to the fixed maximum number of serial ports, dynamic and static
instances share the same ID space.  Static instances added later are
rejected when conflicting with dynamic instances registered earlier.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/Kconfig
drivers/tty/serial/sh-sci.c