* [PATCH v3 0/2] two fixes on sprd serial driver
@ 2020-03-18 10:50 Chunyan Zhang
2020-03-18 10:50 ` [PATCH v3 1/2] serial: sprd: getting port index via serial aliases only Chunyan Zhang
2020-03-18 10:50 ` [PATCH v3 2/2] serial: sprd: remove redundant sprd_port cleanup Chunyan Zhang
0 siblings, 2 replies; 5+ messages in thread
From: Chunyan Zhang @ 2020-03-18 10:50 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, Orson Zhai, Baolin Wang,
Chunyan Zhang, Chunyan Zhang
From: Chunyan Zhang <chunyan.zhang@unisoc.com>
Changes from v2:
* Return -EINVAL for both kinds of errors for calling of_alias_get_id(),
to avoid return a positive value as error number if index is larger
than the array size;
* removed cleanup for sprd_port.
Chunyan Zhang (2):
serial: sprd: getting port index via serial alias only
serial: sprd: remove redundant sprd_port cleanup
drivers/tty/serial/sprd_serial.c | 40 +++++---------------------------
1 file changed, 6 insertions(+), 34 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/2] serial: sprd: getting port index via serial aliases only
2020-03-18 10:50 [PATCH v3 0/2] two fixes on sprd serial driver Chunyan Zhang
@ 2020-03-18 10:50 ` Chunyan Zhang
2020-03-18 10:54 ` Baolin Wang
2020-03-18 10:50 ` [PATCH v3 2/2] serial: sprd: remove redundant sprd_port cleanup Chunyan Zhang
1 sibling, 1 reply; 5+ messages in thread
From: Chunyan Zhang @ 2020-03-18 10:50 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, Orson Zhai, Baolin Wang,
Chunyan Zhang, Chunyan Zhang
From: Chunyan Zhang <chunyan.zhang@unisoc.com>
This patch simplifies the process of getting serial port number, with
this patch, serial devices must have aliases configured in devicetree.
The serial port searched out via sprd_port array maybe wrong if we don't
have serial alias defined in devicetree, and specify console with command
line, we would get the wrong port number if other serial ports probe
failed before console's. So using aliases is mandatory.
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
drivers/tty/serial/sprd_serial.c | 36 +++++---------------------------
1 file changed, 5 insertions(+), 31 deletions(-)
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index 914862844790..e9d148d47bec 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -1102,29 +1102,6 @@ static struct uart_driver sprd_uart_driver = {
.cons = SPRD_CONSOLE,
};
-static int sprd_probe_dt_alias(int index, struct device *dev)
-{
- struct device_node *np;
- int ret = index;
-
- if (!IS_ENABLED(CONFIG_OF))
- return ret;
-
- np = dev->of_node;
- if (!np)
- return ret;
-
- ret = of_alias_get_id(np, "serial");
- if (ret < 0)
- ret = index;
- else if (ret >= ARRAY_SIZE(sprd_port) || sprd_port[ret] != NULL) {
- dev_warn(dev, "requested serial port %d not available.\n", ret);
- ret = index;
- }
-
- return ret;
-}
-
static int sprd_remove(struct platform_device *dev)
{
struct sprd_uart_port *sup = platform_get_drvdata(dev);
@@ -1204,14 +1181,11 @@ static int sprd_probe(struct platform_device *pdev)
int index;
int ret;
- for (index = 0; index < ARRAY_SIZE(sprd_port); index++)
- if (sprd_port[index] == NULL)
- break;
-
- if (index == ARRAY_SIZE(sprd_port))
- return -EBUSY;
-
- index = sprd_probe_dt_alias(index, &pdev->dev);
+ index = of_alias_get_id(pdev->dev.of_node, "serial");
+ if (index < 0 || index >= ARRAY_SIZE(sprd_port)) {
+ dev_err(&pdev->dev, "got a wrong serial alias id %d\n", index);
+ return -EINVAL;
+ }
sprd_port[index] = devm_kzalloc(&pdev->dev, sizeof(*sprd_port[index]),
GFP_KERNEL);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] serial: sprd: remove redundant sprd_port cleanup
2020-03-18 10:50 [PATCH v3 0/2] two fixes on sprd serial driver Chunyan Zhang
2020-03-18 10:50 ` [PATCH v3 1/2] serial: sprd: getting port index via serial aliases only Chunyan Zhang
@ 2020-03-18 10:50 ` Chunyan Zhang
2020-03-18 10:55 ` Baolin Wang
1 sibling, 1 reply; 5+ messages in thread
From: Chunyan Zhang @ 2020-03-18 10:50 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, Orson Zhai, Baolin Wang,
Chunyan Zhang, Chunyan Zhang
From: Chunyan Zhang <chunyan.zhang@unisoc.com>
We don't need to cleanup sprd_port anymore, since we've dropped the way
of using the sprd_port[] array to get port index.
Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
---
drivers/tty/serial/sprd_serial.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
index e9d148d47bec..cefdd051b2d0 100644
--- a/drivers/tty/serial/sprd_serial.c
+++ b/drivers/tty/serial/sprd_serial.c
@@ -1237,10 +1237,8 @@ static int sprd_probe(struct platform_device *pdev)
sprd_ports_num++;
ret = uart_add_one_port(&sprd_uart_driver, up);
- if (ret) {
- sprd_port[index] = NULL;
+ if (ret)
sprd_remove(pdev);
- }
platform_set_drvdata(pdev, up);
--
2.20.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] serial: sprd: getting port index via serial aliases only
2020-03-18 10:50 ` [PATCH v3 1/2] serial: sprd: getting port index via serial aliases only Chunyan Zhang
@ 2020-03-18 10:54 ` Baolin Wang
0 siblings, 0 replies; 5+ messages in thread
From: Baolin Wang @ 2020-03-18 10:54 UTC (permalink / raw)
To: Chunyan Zhang
Cc: Greg Kroah-Hartman, Jiri Slaby, open list:SERIAL DRIVERS, LKML,
Orson Zhai, Chunyan Zhang
On Wed, Mar 18, 2020 at 6:51 PM Chunyan Zhang <zhang.lyra@gmail.com> wrote:
>
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
>
> This patch simplifies the process of getting serial port number, with
> this patch, serial devices must have aliases configured in devicetree.
>
> The serial port searched out via sprd_port array maybe wrong if we don't
> have serial alias defined in devicetree, and specify console with command
> line, we would get the wrong port number if other serial ports probe
> failed before console's. So using aliases is mandatory.
>
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Looks good to me.
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>
> ---
> drivers/tty/serial/sprd_serial.c | 36 +++++---------------------------
> 1 file changed, 5 insertions(+), 31 deletions(-)
>
> diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
> index 914862844790..e9d148d47bec 100644
> --- a/drivers/tty/serial/sprd_serial.c
> +++ b/drivers/tty/serial/sprd_serial.c
> @@ -1102,29 +1102,6 @@ static struct uart_driver sprd_uart_driver = {
> .cons = SPRD_CONSOLE,
> };
>
> -static int sprd_probe_dt_alias(int index, struct device *dev)
> -{
> - struct device_node *np;
> - int ret = index;
> -
> - if (!IS_ENABLED(CONFIG_OF))
> - return ret;
> -
> - np = dev->of_node;
> - if (!np)
> - return ret;
> -
> - ret = of_alias_get_id(np, "serial");
> - if (ret < 0)
> - ret = index;
> - else if (ret >= ARRAY_SIZE(sprd_port) || sprd_port[ret] != NULL) {
> - dev_warn(dev, "requested serial port %d not available.\n", ret);
> - ret = index;
> - }
> -
> - return ret;
> -}
> -
> static int sprd_remove(struct platform_device *dev)
> {
> struct sprd_uart_port *sup = platform_get_drvdata(dev);
> @@ -1204,14 +1181,11 @@ static int sprd_probe(struct platform_device *pdev)
> int index;
> int ret;
>
> - for (index = 0; index < ARRAY_SIZE(sprd_port); index++)
> - if (sprd_port[index] == NULL)
> - break;
> -
> - if (index == ARRAY_SIZE(sprd_port))
> - return -EBUSY;
> -
> - index = sprd_probe_dt_alias(index, &pdev->dev);
> + index = of_alias_get_id(pdev->dev.of_node, "serial");
> + if (index < 0 || index >= ARRAY_SIZE(sprd_port)) {
> + dev_err(&pdev->dev, "got a wrong serial alias id %d\n", index);
> + return -EINVAL;
> + }
>
> sprd_port[index] = devm_kzalloc(&pdev->dev, sizeof(*sprd_port[index]),
> GFP_KERNEL);
> --
> 2.20.1
>
--
Baolin Wang
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 2/2] serial: sprd: remove redundant sprd_port cleanup
2020-03-18 10:50 ` [PATCH v3 2/2] serial: sprd: remove redundant sprd_port cleanup Chunyan Zhang
@ 2020-03-18 10:55 ` Baolin Wang
0 siblings, 0 replies; 5+ messages in thread
From: Baolin Wang @ 2020-03-18 10:55 UTC (permalink / raw)
To: Chunyan Zhang
Cc: Greg Kroah-Hartman, Jiri Slaby, open list:SERIAL DRIVERS, LKML,
Orson Zhai, Chunyan Zhang
On Wed, Mar 18, 2020 at 6:51 PM Chunyan Zhang <zhang.lyra@gmail.com> wrote:
>
> From: Chunyan Zhang <chunyan.zhang@unisoc.com>
>
> We don't need to cleanup sprd_port anymore, since we've dropped the way
> of using the sprd_port[] array to get port index.
>
> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com>
Looks good to me.
Reviewed-by: Baolin Wang <baolin.wang7@gmail.com>
> ---
> drivers/tty/serial/sprd_serial.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c
> index e9d148d47bec..cefdd051b2d0 100644
> --- a/drivers/tty/serial/sprd_serial.c
> +++ b/drivers/tty/serial/sprd_serial.c
> @@ -1237,10 +1237,8 @@ static int sprd_probe(struct platform_device *pdev)
> sprd_ports_num++;
>
> ret = uart_add_one_port(&sprd_uart_driver, up);
> - if (ret) {
> - sprd_port[index] = NULL;
> + if (ret)
> sprd_remove(pdev);
> - }
>
> platform_set_drvdata(pdev, up);
>
> --
> 2.20.1
>
--
Baolin Wang
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-18 10:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-18 10:50 [PATCH v3 0/2] two fixes on sprd serial driver Chunyan Zhang
2020-03-18 10:50 ` [PATCH v3 1/2] serial: sprd: getting port index via serial aliases only Chunyan Zhang
2020-03-18 10:54 ` Baolin Wang
2020-03-18 10:50 ` [PATCH v3 2/2] serial: sprd: remove redundant sprd_port cleanup Chunyan Zhang
2020-03-18 10:55 ` Baolin Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).