Skip to contentSkip to conversation

serial: sccnxp: Improve verify_port

PATCH In review Alexander Shiyan 2 participants 5 messages May 14, 2013 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 serial: sccnxp: Improve verify_port

The patch improves verify_port procedure by comparing the type of port and IRQ numbers simultaneously. This can be important in the case of multiple drivers SCCNXP in the system that are different IRQs.

---
 drivers/tty/serial/sccnxp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/sccnxp.c +2 -2
index c773041..92e6195 100644
@@ -713,8 +713,8 @@ static void sccnxp_config_port(struct uart_port *port, int flags)
 
 static int sccnxp_verify_port(struct uart_port *port, struct serial_struct *s)
 {
-	if ((s->type == PORT_UNKNOWN) || (s->type == PORT_SC26XX))
-		return 0;
+	if ((s->type != PORT_UNKNOWN) && (s->type != PORT_SC26XX))
+		return -EINVAL;
 	if (s->irq == port->irq)
 		return 0;
 
Signature · 1 line
1.8.1.5
#1 lore raw
Quoted 3 lines · Alexander Shiyan

The patch improves verify_port procedure by comparing the type of port and IRQ numbers simultaneously. This can be important in the case of multiple drivers SCCNXP in the system that are different IRQs.

So this fixes a bug? Really?

Quoted 10 lines
---
 drivers/tty/serial/sccnxp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/sccnxp.c +0 -0
index c773041..92e6195 100644

drivers/tty/serial/sccnxp.c static void sccnxp_config_port(struct uart_port *port, int flags) · line 717

Quoted 7 lines
drivers/tty/serial/sccnxp.c +2 -2
@@ -713,8 +713,8 @@ static void sccnxp_config_port(struct uart_port *port, int flags)
 
 static int sccnxp_verify_port(struct uart_port *port, struct serial_struct *s)
 {
-	if ((s->type == PORT_UNKNOWN) || (s->type == PORT_SC26XX))
-		return 0;
+	if ((s->type != PORT_UNKNOWN) && (s->type != PORT_SC26XX))
+		return -EINVAL;

Why are you now returning a different value?

thanks,

greg k-h

#2 lore raw
Quoted 6 lines · Alexander Shiyan
Quoted 3 lines

The patch improves verify_port procedure by comparing the type of port and IRQ numbers simultaneously. This can be important in the case of multiple drivers SCCNXP in the system that are different IRQs.

So this fixes a bug? Really?

Only in theory.

Quoted 11 lines
Quoted 11 lines
---
 drivers/tty/serial/sccnxp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/sccnxp.c +0 -0
index c773041..92e6195 100644
@@ -713,8 +713,8 @@ static void sccnxp_config_port(struct uart_port *port, int flags)
 
Quoted 8 lines

drivers/tty/serial/sccnxp.c static void sccnxp_config_port(struct uart_port *port, int flags) · line 717

Quoted 6 lines
drivers/tty/serial/sccnxp.c +2 -2
 static int sccnxp_verify_port(struct uart_port *port, struct serial_struct *s)
 {
-	if ((s->type == PORT_UNKNOWN) || (s->type == PORT_SC26XX))
-		return 0;
+	if ((s->type != PORT_UNKNOWN) && (s->type != PORT_SC26XX))
+		return -EINVAL;

Why are you now returning a different value?

Value is not different. Patch just change logic a bit. Zero on success, same as before.

---

#3 lore raw
Quoted 8 lines · Alexander Shiyan
Quoted 6 lines · Alexander Shiyan
Quoted 3 lines

The patch improves verify_port procedure by comparing the type of port and IRQ numbers simultaneously. This can be important in the case of multiple drivers SCCNXP in the system that are different IRQs.

So this fixes a bug? Really?

Only in theory.

How? It really doesn't look like you are doing anything here, except rearranging the logic to look different, but yet do the same thing.

So again, why are you doing this?

greg k-h

#4 lore raw
Quoted 11 lines
Quoted 8 lines
Quoted 6 lines · Alexander Shiyan
Quoted 3 lines

The patch improves verify_port procedure by comparing the type of port and IRQ numbers simultaneously. This can be important in the case of multiple drivers SCCNXP in the system that are different IRQs.

So this fixes a bug? Really?

Only in theory.

How? It really doesn't look like you are doing anything here, except rearranging the logic to look different, but yet do the same thing.

Procedure do not compare IRQ before if port type is valid.

Quoted 1 line

So again, why are you doing this?

Well, just drop this patch. I cannot say more than now.

---