All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/4] serial: exar: fix kbuild warnings and code style
@ 2024-04-18 15:36 Parker Newman
  2024-04-18 15:36 ` [PATCH v1 1/4] serial: exar: add missing kernel doc function parameters Parker Newman
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Parker Newman @ 2024-04-18 15:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial; +Cc: Parker Newman

From: Parker Newman <pnewman@connecttech.com>

This is a series of small patches fixing kbuilds error and code style
issues based on feedback during review of main patches.

Original patches thread:
Link: https://lore.kernel.org/linux-serial/cover.1713382717.git.pnewman@connecttech.com/

Thank you,
Parker Newman (4):
  serial: exar: add missing kernel doc function parameters
  serial: exar: use return dev_err_probe instead of returning error code
  serial: exar: remove unneeded parenthesis
  serial: exar: change port_type ternary line wrapping

 drivers/tty/serial/8250/8250_exar.c | 47 +++++++++++++++--------------
 1 file changed, 24 insertions(+), 23 deletions(-)


base-commit: c6795fbffc4547b40933ec368200bd4926a41b44
--
2.43.2


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v1 1/4] serial: exar: add missing kernel doc function parameters
  2024-04-18 15:36 [PATCH v1 0/4] serial: exar: fix kbuild warnings and code style Parker Newman
@ 2024-04-18 15:36 ` Parker Newman
  2024-04-18 15:36 ` [PATCH v1 2/4] serial: exar: use return dev_err_probe instead of returning error code Parker Newman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Parker Newman @ 2024-04-18 15:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial
  Cc: Parker Newman, kernel test robot

From: Parker Newman <pnewman@connecttech.com>

Adds missing kernel doc function parameters to 3 functions.

Reported-by: kernel test robot <lkp@intel.com>
Closes:
https://lore.kernel.org/oe-kbuild-all/202404181353.1VIC4cz9-lkp@intel.com/

Signed-off-by: Parker Newman <pnewman@connecttech.com>
---
 drivers/tty/serial/8250/8250_exar.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 5e42558cbb01..a180741da634 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -715,6 +715,7 @@ static int cti_read_osc_freq(struct exar8250 *priv, u8 eeprom_offset)
 /**
  * cti_get_port_type_xr17c15x_xr17v25x() - Get port type of xr17c15x/xr17v25x
  * @priv: Device's private structure
+ * @pcidev: PCI device pointer
  * @port_num: Port to get type of
  *
  * CTI xr17c15x and xr17v25x based cards port types are based on PCI IDs.
@@ -807,6 +808,7 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
 /**
  * cti_get_port_type_fpga() - Get the port type of a CTI FPGA card
  * @priv: Device's private structure
+ * @pcidev: PCI device pointer
  * @port_num: Port to get type of
  *
  * FPGA based cards port types are based on PCI IDs.
@@ -836,6 +838,7 @@ static enum cti_port_type cti_get_port_type_fpga(struct exar8250 *priv,
 /**
  * cti_get_port_type_xr17v35x() - Read port type from the EEPROM
  * @priv: Device's private structure
+ * @pcidev: PCI device pointer
  * @port_num: port offset
  *
  * CTI XR17V35X based cards have the port types stored in the EEPROM.
--
2.43.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 2/4] serial: exar: use return dev_err_probe instead of returning error code
  2024-04-18 15:36 [PATCH v1 0/4] serial: exar: fix kbuild warnings and code style Parker Newman
  2024-04-18 15:36 ` [PATCH v1 1/4] serial: exar: add missing kernel doc function parameters Parker Newman
@ 2024-04-18 15:36 ` Parker Newman
  2024-04-18 15:36 ` [PATCH v1 3/4] serial: exar: remove unneeded parenthesis Parker Newman
  2024-04-18 15:36 ` [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping Parker Newman
  3 siblings, 0 replies; 11+ messages in thread
From: Parker Newman @ 2024-04-18 15:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial; +Cc: Parker Newman

From: Parker Newman <pnewman@connecttech.com>

Change to returning dev_err_probe() instead of returning the error code
after calling dev_err_probe().

Signed-off-by: Parker Newman <pnewman@connecttech.com>
---
 drivers/tty/serial/8250/8250_exar.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index a180741da634..01748ddbf729 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -1551,9 +1551,8 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)

 	nr_ports = exar_get_nr_ports(board, pcidev);
 	if (nr_ports == 0) {
-		dev_err_probe(&pcidev->dev, -ENODEV,
+		return dev_err_probe(&pcidev->dev, -ENODEV,
 				"failed to get number of ports\n");
-		return -ENODEV;
 	}

 	priv = devm_kzalloc(&pcidev->dev, struct_size(priv, line, nr_ports), GFP_KERNEL);
@@ -1587,9 +1586,8 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 	if (board->board_init) {
 		rc = board->board_init(priv, pcidev);
 		if (rc) {
-			dev_err_probe(&pcidev->dev, rc,
+			return dev_err_probe(&pcidev->dev, rc,
 					"failed to init serial board\n");
-			return rc;
 		}
 	}

--
2.43.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 3/4] serial: exar: remove unneeded parenthesis
  2024-04-18 15:36 [PATCH v1 0/4] serial: exar: fix kbuild warnings and code style Parker Newman
  2024-04-18 15:36 ` [PATCH v1 1/4] serial: exar: add missing kernel doc function parameters Parker Newman
  2024-04-18 15:36 ` [PATCH v1 2/4] serial: exar: use return dev_err_probe instead of returning error code Parker Newman
@ 2024-04-18 15:36 ` Parker Newman
  2024-04-19  6:58   ` Greg Kroah-Hartman
  2024-04-18 15:36 ` [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping Parker Newman
  3 siblings, 1 reply; 11+ messages in thread
From: Parker Newman @ 2024-04-18 15:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial; +Cc: Parker Newman

From: Parker Newman <pnewman@connecttech.com>

Remove unneeded parenthesis from several locations.

Based on feedback from:
Link: https://lore.kernel.org/linux-serial/f2353b8c-2079-b895-2707-f6be83161288@linux.intel.com

Signed-off-by: Parker Newman <pnewman@connecttech.com>
---
 drivers/tty/serial/8250/8250_exar.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 01748ddbf729..10725ad0f3ef 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -317,7 +317,7 @@ static inline u8 exar_ee_read_bit(struct exar8250 *priv)

 	regb = exar_read_reg(priv, UART_EXAR_REGB);

-	return (regb & UART_EXAR_REGB_EEDO ? 1 : 0);
+	return regb & UART_EXAR_REGB_EEDO ? 1 : 0;
 }

 /**
@@ -741,18 +741,18 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
 		break;
 	// 1x RS232, 1x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1:
-		port_type = (port_num == 0) ?
+		port_type = port_num == 0 ?
 			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
 		break;
 	// 2x RS232, 2x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2:
-		port_type = (port_num < 2) ?
+		port_type = port_num < 2 ?
 			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
 		break;
 	// 4x RS232, 4x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4:
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4_SP:
-		port_type = (port_num < 4) ?
+		port_type = port_num < 4 ?
 			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
 		break;
 	// RS232/RS422/RS485 HW (jumper) selectable
@@ -789,12 +789,12 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
 		break;
 	// 6x RS232, 2x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_6_2_SP:
-		port_type = (port_num < 6) ?
+		port_type = port_num < 6 ?
 			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
 		break;
 	// 2x RS232, 6x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_6_SP:
-		port_type = (port_num < 2) ?
+		port_type = port_num < 2 ?
 			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
 		break;
 	default:
@@ -981,10 +981,10 @@ static int cti_port_setup_xr17v35x(struct exar8250 *priv,
 	if (ret)
 		return ret;

-	exar_write_reg(priv, (offset + UART_EXAR_8XMODE), 0x00);
-	exar_write_reg(priv, (offset + UART_EXAR_FCTR), UART_FCTR_EXAR_TRGD);
-	exar_write_reg(priv, (offset + UART_EXAR_TXTRG), 128);
-	exar_write_reg(priv, (offset + UART_EXAR_RXTRG), 128);
+	exar_write_reg(priv, offset + UART_EXAR_8XMODE, 0x00);
+	exar_write_reg(priv, offset + UART_EXAR_FCTR, UART_FCTR_EXAR_TRGD);
+	exar_write_reg(priv, offset + UART_EXAR_TXTRG, 128);
+	exar_write_reg(priv, offset + UART_EXAR_RXTRG, 128);

 	return 0;
 }
@@ -1037,10 +1037,10 @@ static int cti_port_setup_xr17v25x(struct exar8250 *priv,
 	if (ret)
 		return ret;

-	exar_write_reg(priv, (offset + UART_EXAR_8XMODE), 0x00);
-	exar_write_reg(priv, (offset + UART_EXAR_FCTR), UART_FCTR_EXAR_TRGD);
-	exar_write_reg(priv, (offset + UART_EXAR_TXTRG), 32);
-	exar_write_reg(priv, (offset + UART_EXAR_RXTRG), 32);
+	exar_write_reg(priv, offset + UART_EXAR_8XMODE, 0x00);
+	exar_write_reg(priv, offset + UART_EXAR_FCTR, UART_FCTR_EXAR_TRGD);
+	exar_write_reg(priv, offset + UART_EXAR_TXTRG, 32);
+	exar_write_reg(priv, offset + UART_EXAR_RXTRG, 32);

 	return 0;
 }
--
2.43.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping
  2024-04-18 15:36 [PATCH v1 0/4] serial: exar: fix kbuild warnings and code style Parker Newman
                   ` (2 preceding siblings ...)
  2024-04-18 15:36 ` [PATCH v1 3/4] serial: exar: remove unneeded parenthesis Parker Newman
@ 2024-04-18 15:36 ` Parker Newman
  2024-04-19  6:07   ` Jiri Slaby
  2024-04-19  6:57   ` Greg Kroah-Hartman
  3 siblings, 2 replies; 11+ messages in thread
From: Parker Newman @ 2024-04-18 15:36 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial; +Cc: Parker Newman

From: Parker Newman <pnewman@connecttech.com>

Change line wrapping of ternary operators in
cti_get_port_type_xr17c15x_xr17v25x() for better readability.

Old example:

	port_type = port_num == 0 ?
			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;

New:
	port_type = port_num == 0 ? CTI_PORT_TYPE_RS232 :
				CTI_PORT_TYPE_RS422_485;

Based on feedback from:
Link: https://lore.kernel.org/linux-serial/f2353b8c-2079-b895-2707-f6be83161288@linux.intel.com

Signed-off-by: Parker Newman <pnewman@connecttech.com>
---
 drivers/tty/serial/8250/8250_exar.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
index 10725ad0f3ef..a76b4e5bab4e 100644
--- a/drivers/tty/serial/8250/8250_exar.c
+++ b/drivers/tty/serial/8250/8250_exar.c
@@ -741,19 +741,19 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
 		break;
 	// 1x RS232, 1x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1:
-		port_type = port_num == 0 ?
-			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
+		port_type = port_num == 0 ? CTI_PORT_TYPE_RS232 :
+					CTI_PORT_TYPE_RS422_485;
 		break;
 	// 2x RS232, 2x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2:
-		port_type = port_num < 2 ?
-			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
+		port_type = port_num < 2 ? CTI_PORT_TYPE_RS232 :
+					CTI_PORT_TYPE_RS422_485;
 		break;
 	// 4x RS232, 4x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4:
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4_SP:
-		port_type = port_num < 4 ?
-			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
+		port_type = port_num < 4 ? CTI_PORT_TYPE_RS232 :
+					CTI_PORT_TYPE_RS422_485;
 		break;
 	// RS232/RS422/RS485 HW (jumper) selectable
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2:
@@ -789,13 +789,13 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
 		break;
 	// 6x RS232, 2x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_6_2_SP:
-		port_type = port_num < 6 ?
-			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
+		port_type = port_num < 6 ? CTI_PORT_TYPE_RS232 :
+					CTI_PORT_TYPE_RS422_485;
 		break;
 	// 2x RS232, 6x RS422/RS485
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_6_SP:
-		port_type = port_num < 2 ?
-			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
+		port_type = port_num < 2 ? CTI_PORT_TYPE_RS232 :
+					CTI_PORT_TYPE_RS422_485;
 		break;
 	default:
 		dev_err(&pcidev->dev, "unknown/unsupported device\n");
--
2.43.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping
  2024-04-18 15:36 ` [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping Parker Newman
@ 2024-04-19  6:07   ` Jiri Slaby
  2024-04-19 12:17     ` Parker Newman
  2024-04-19  6:57   ` Greg Kroah-Hartman
  1 sibling, 1 reply; 11+ messages in thread
From: Jiri Slaby @ 2024-04-19  6:07 UTC (permalink / raw)
  To: Parker Newman, Greg Kroah-Hartman, linux-kernel, linux-serial
  Cc: Parker Newman, Ilpo Järvinen

On 18. 04. 24, 17:36, Parker Newman wrote:
> From: Parker Newman <pnewman@connecttech.com>
> 
> Change line wrapping of ternary operators in
> cti_get_port_type_xr17c15x_xr17v25x() for better readability.
> 
> Old example:
> 
> 	port_type = port_num == 0 ?
> 			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> 
> New:
> 	port_type = port_num == 0 ? CTI_PORT_TYPE_RS232 :
> 				CTI_PORT_TYPE_RS422_485;

This is worse IMO. Ilpo suggested a bit different alignment. But still...

> Based on feedback from:
> Link: https://lore.kernel.org/linux-serial/f2353b8c-2079-b895-2707-f6be83161288@linux.intel.com

You should have CCed the author.

> Signed-off-by: Parker Newman <pnewman@connecttech.com>
> ---
>   drivers/tty/serial/8250/8250_exar.c | 20 ++++++++++----------
>   1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 10725ad0f3ef..a76b4e5bab4e 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -741,19 +741,19 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
>   		break;
>   	// 1x RS232, 1x RS422/RS485
>   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1:
> -		port_type = port_num == 0 ?
> -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> +		port_type = port_num == 0 ? CTI_PORT_TYPE_RS232 :
> +					CTI_PORT_TYPE_RS422_485;


Well, could you initialize port_type = CTI_PORT_TYPE_RS232? And here do 
only:
if (port_num > 0)
     return CTI_PORT_TYPE_RS422_485;
?


>   		break;
>   	// 2x RS232, 2x RS422/RS485
>   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2:
> -		port_type = port_num < 2 ?
> -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> +		port_type = port_num < 2 ? CTI_PORT_TYPE_RS232 :
> +					CTI_PORT_TYPE_RS422_485;

And so on.

>   		break;
>   	// 4x RS232, 4x RS422/RS485
>   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4:
>   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4_SP:
> -		port_type = port_num < 4 ?
> -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> +		port_type = port_num < 4 ? CTI_PORT_TYPE_RS232 :
> +					CTI_PORT_TYPE_RS422_485;
>   		break;
>   	// RS232/RS422/RS485 HW (jumper) selectable
>   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2:
> @@ -789,13 +789,13 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
>   		break;
>   	// 6x RS232, 2x RS422/RS485
>   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_6_2_SP:
> -		port_type = port_num < 6 ?
> -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> +		port_type = port_num < 6 ? CTI_PORT_TYPE_RS232 :
> +					CTI_PORT_TYPE_RS422_485;
>   		break;
>   	// 2x RS232, 6x RS422/RS485
>   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_6_SP:
> -		port_type = port_num < 2 ?
> -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> +		port_type = port_num < 2 ? CTI_PORT_TYPE_RS232 :
> +					CTI_PORT_TYPE_RS422_485;
>   		break;
>   	default:
>   		dev_err(&pcidev->dev, "unknown/unsupported device\n");
> --
> 2.43.2
> 

-- 
js
suse labs


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping
  2024-04-18 15:36 ` [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping Parker Newman
  2024-04-19  6:07   ` Jiri Slaby
@ 2024-04-19  6:57   ` Greg Kroah-Hartman
  1 sibling, 0 replies; 11+ messages in thread
From: Greg Kroah-Hartman @ 2024-04-19  6:57 UTC (permalink / raw)
  To: Parker Newman; +Cc: Jiri Slaby, linux-kernel, linux-serial, Parker Newman

On Thu, Apr 18, 2024 at 11:36:31AM -0400, Parker Newman wrote:
> From: Parker Newman <pnewman@connecttech.com>
> 
> Change line wrapping of ternary operators in
> cti_get_port_type_xr17c15x_xr17v25x() for better readability.
> 
> Old example:
> 
> 	port_type = port_num == 0 ?
> 			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> 
> New:
> 	port_type = port_num == 0 ? CTI_PORT_TYPE_RS232 :
> 				CTI_PORT_TYPE_RS422_485;
> 
> Based on feedback from:
> Link: https://lore.kernel.org/linux-serial/f2353b8c-2079-b895-2707-f6be83161288@linux.intel.com
> 
> Signed-off-by: Parker Newman <pnewman@connecttech.com>
> ---
>  drivers/tty/serial/8250/8250_exar.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 10725ad0f3ef..a76b4e5bab4e 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -741,19 +741,19 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
>  		break;
>  	// 1x RS232, 1x RS422/RS485
>  	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1:
> -		port_type = port_num == 0 ?
> -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> +		port_type = port_num == 0 ? CTI_PORT_TYPE_RS232 :
> +					CTI_PORT_TYPE_RS422_485;

I missed this the first time, PLEASE never use ? : unless you have to.
Spell it out and use an if statement, the compiler doesn't care, and you
write code for people to read it first, cpus second.  So this should
look like:
		if (port_num)
			port_type = CTI_PORT_TYPE_RS422_485;
		else
			port_type = CTI_PORT_TYPE_RS232;

Much simpler and easier to understand when you look at this in 10 years
and try to scan to figure out what went wrong with the logic here...

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 3/4] serial: exar: remove unneeded parenthesis
  2024-04-18 15:36 ` [PATCH v1 3/4] serial: exar: remove unneeded parenthesis Parker Newman
@ 2024-04-19  6:58   ` Greg Kroah-Hartman
  2024-04-19  7:01     ` Jiri Slaby
  0 siblings, 1 reply; 11+ messages in thread
From: Greg Kroah-Hartman @ 2024-04-19  6:58 UTC (permalink / raw)
  To: Parker Newman; +Cc: Jiri Slaby, linux-kernel, linux-serial, Parker Newman

On Thu, Apr 18, 2024 at 11:36:30AM -0400, Parker Newman wrote:
> From: Parker Newman <pnewman@connecttech.com>
> 
> Remove unneeded parenthesis from several locations.
> 
> Based on feedback from:
> Link: https://lore.kernel.org/linux-serial/f2353b8c-2079-b895-2707-f6be83161288@linux.intel.com
> 
> Signed-off-by: Parker Newman <pnewman@connecttech.com>
> ---
>  drivers/tty/serial/8250/8250_exar.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> index 01748ddbf729..10725ad0f3ef 100644
> --- a/drivers/tty/serial/8250/8250_exar.c
> +++ b/drivers/tty/serial/8250/8250_exar.c
> @@ -317,7 +317,7 @@ static inline u8 exar_ee_read_bit(struct exar8250 *priv)
> 
>  	regb = exar_read_reg(priv, UART_EXAR_REGB);
> 
> -	return (regb & UART_EXAR_REGB_EEDO ? 1 : 0);
> +	return regb & UART_EXAR_REGB_EEDO ? 1 : 0;

Again, spell out the ? : stuff here please.  Using () isn't the problem :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 3/4] serial: exar: remove unneeded parenthesis
  2024-04-19  6:58   ` Greg Kroah-Hartman
@ 2024-04-19  7:01     ` Jiri Slaby
  2024-04-19 12:50       ` Parker Newman
  0 siblings, 1 reply; 11+ messages in thread
From: Jiri Slaby @ 2024-04-19  7:01 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Parker Newman
  Cc: linux-kernel, linux-serial, Parker Newman

On 19. 04. 24, 8:58, Greg Kroah-Hartman wrote:
> On Thu, Apr 18, 2024 at 11:36:30AM -0400, Parker Newman wrote:
>> From: Parker Newman <pnewman@connecttech.com>
>>
>> Remove unneeded parenthesis from several locations.
>>
>> Based on feedback from:
>> Link: https://lore.kernel.org/linux-serial/f2353b8c-2079-b895-2707-f6be83161288@linux.intel.com
>>
>> Signed-off-by: Parker Newman <pnewman@connecttech.com>
>> ---
>>   drivers/tty/serial/8250/8250_exar.c | 28 ++++++++++++++--------------
>>   1 file changed, 14 insertions(+), 14 deletions(-)
>>
>> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
>> index 01748ddbf729..10725ad0f3ef 100644
>> --- a/drivers/tty/serial/8250/8250_exar.c
>> +++ b/drivers/tty/serial/8250/8250_exar.c
>> @@ -317,7 +317,7 @@ static inline u8 exar_ee_read_bit(struct exar8250 *priv)
>>
>>   	regb = exar_read_reg(priv, UART_EXAR_REGB);
>>
>> -	return (regb & UART_EXAR_REGB_EEDO ? 1 : 0);
>> +	return regb & UART_EXAR_REGB_EEDO ? 1 : 0;
> 
> Again, spell out the ? : stuff here please.  Using () isn't the problem :)

Could this in fact be inline bool exar_is_ee_set() (or alike) and return 
that regb & UART_EXAR_REGB_EEDO directly (w/o using ternary at all)?

thanks,
-- 
js
suse labs


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping
  2024-04-19  6:07   ` Jiri Slaby
@ 2024-04-19 12:17     ` Parker Newman
  0 siblings, 0 replies; 11+ messages in thread
From: Parker Newman @ 2024-04-19 12:17 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: Greg Kroah-Hartman, linux-kernel, linux-serial, Parker Newman,
	Ilpo Järvinen

On Fri, 19 Apr 2024 08:07:50 +0200
Jiri Slaby <jirislaby@kernel.org> wrote:

> On 18. 04. 24, 17:36, Parker Newman wrote:
> > From: Parker Newman <pnewman@connecttech.com>
> >
> > Change line wrapping of ternary operators in
> > cti_get_port_type_xr17c15x_xr17v25x() for better readability.
> >
> > Old example:
> >
> > 	port_type = port_num == 0 ?
> > 			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> >
> > New:
> > 	port_type = port_num == 0 ? CTI_PORT_TYPE_RS232 :
> > 				CTI_PORT_TYPE_RS422_485;
>
> This is worse IMO. Ilpo suggested a bit different alignment. But still...
>
> > Based on feedback from:
> > Link: https://lore.kernel.org/linux-serial/f2353b8c-2079-b895-2707-f6be83161288@linux.intel.com
>
> You should have CCed the author.
>
> > Signed-off-by: Parker Newman <pnewman@connecttech.com>
> > ---
> >   drivers/tty/serial/8250/8250_exar.c | 20 ++++++++++----------
> >   1 file changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> > index 10725ad0f3ef..a76b4e5bab4e 100644
> > --- a/drivers/tty/serial/8250/8250_exar.c
> > +++ b/drivers/tty/serial/8250/8250_exar.c
> > @@ -741,19 +741,19 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
> >   		break;
> >   	// 1x RS232, 1x RS422/RS485
> >   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_1_1:
> > -		port_type = port_num == 0 ?
> > -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> > +		port_type = port_num == 0 ? CTI_PORT_TYPE_RS232 :
> > +					CTI_PORT_TYPE_RS422_485;
>
>
> Well, could you initialize port_type = CTI_PORT_TYPE_RS232? And here do
> only:
> if (port_num > 0)
>      return CTI_PORT_TYPE_RS422_485;
> ?
>

I like this idea I will move to that. Thanks.

>
> >   		break;
> >   	// 2x RS232, 2x RS422/RS485
> >   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_2:
> > -		port_type = port_num < 2 ?
> > -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> > +		port_type = port_num < 2 ? CTI_PORT_TYPE_RS232 :
> > +					CTI_PORT_TYPE_RS422_485;
>
> And so on.
>
> >   		break;
> >   	// 4x RS232, 4x RS422/RS485
> >   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4:
> >   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_4_4_SP:
> > -		port_type = port_num < 4 ?
> > -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> > +		port_type = port_num < 4 ? CTI_PORT_TYPE_RS232 :
> > +					CTI_PORT_TYPE_RS422_485;
> >   		break;
> >   	// RS232/RS422/RS485 HW (jumper) selectable
> >   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2:
> > @@ -789,13 +789,13 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
> >   		break;
> >   	// 6x RS232, 2x RS422/RS485
> >   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_6_2_SP:
> > -		port_type = port_num < 6 ?
> > -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> > +		port_type = port_num < 6 ? CTI_PORT_TYPE_RS232 :
> > +					CTI_PORT_TYPE_RS422_485;
> >   		break;
> >   	// 2x RS232, 6x RS422/RS485
> >   	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2_6_SP:
> > -		port_type = port_num < 2 ?
> > -			CTI_PORT_TYPE_RS232 : CTI_PORT_TYPE_RS422_485;
> > +		port_type = port_num < 2 ? CTI_PORT_TYPE_RS232 :
> > +					CTI_PORT_TYPE_RS422_485;
> >   		break;
> >   	default:
> >   		dev_err(&pcidev->dev, "unknown/unsupported device\n");
> > --
> > 2.43.2
> >
>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v1 3/4] serial: exar: remove unneeded parenthesis
  2024-04-19  7:01     ` Jiri Slaby
@ 2024-04-19 12:50       ` Parker Newman
  0 siblings, 0 replies; 11+ messages in thread
From: Parker Newman @ 2024-04-19 12:50 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: Greg Kroah-Hartman, linux-kernel, linux-serial, Parker Newman

On Fri, 19 Apr 2024 09:01:22 +0200
Jiri Slaby <jirislaby@kernel.org> wrote:

> On 19. 04. 24, 8:58, Greg Kroah-Hartman wrote:
> > On Thu, Apr 18, 2024 at 11:36:30AM -0400, Parker Newman wrote:
> >> From: Parker Newman <pnewman@connecttech.com>
> >>
> >> Remove unneeded parenthesis from several locations.
> >>
> >> Based on feedback from:
> >> Link: https://lore.kernel.org/linux-serial/f2353b8c-2079-b895-2707-f6be83161288@linux.intel.com
> >>
> >> Signed-off-by: Parker Newman <pnewman@connecttech.com>
> >> ---
> >>   drivers/tty/serial/8250/8250_exar.c | 28 ++++++++++++++--------------
> >>   1 file changed, 14 insertions(+), 14 deletions(-)
> >>
> >> diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c
> >> index 01748ddbf729..10725ad0f3ef 100644
> >> --- a/drivers/tty/serial/8250/8250_exar.c
> >> +++ b/drivers/tty/serial/8250/8250_exar.c
> >> @@ -317,7 +317,7 @@ static inline u8 exar_ee_read_bit(struct exar8250 *priv)
> >>
> >>   	regb = exar_read_reg(priv, UART_EXAR_REGB);
> >>
> >> -	return (regb & UART_EXAR_REGB_EEDO ? 1 : 0);
> >> +	return regb & UART_EXAR_REGB_EEDO ? 1 : 0;
> >
> > Again, spell out the ? : stuff here please.  Using () isn't the problem :)
>
> Could this in fact be inline bool exar_is_ee_set() (or alike) and return
> that regb & UART_EXAR_REGB_EEDO directly (w/o using ternary at all)?
>
> thanks,

That would work. I will update.
Thanks,
Parker

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-04-19 12:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-18 15:36 [PATCH v1 0/4] serial: exar: fix kbuild warnings and code style Parker Newman
2024-04-18 15:36 ` [PATCH v1 1/4] serial: exar: add missing kernel doc function parameters Parker Newman
2024-04-18 15:36 ` [PATCH v1 2/4] serial: exar: use return dev_err_probe instead of returning error code Parker Newman
2024-04-18 15:36 ` [PATCH v1 3/4] serial: exar: remove unneeded parenthesis Parker Newman
2024-04-19  6:58   ` Greg Kroah-Hartman
2024-04-19  7:01     ` Jiri Slaby
2024-04-19 12:50       ` Parker Newman
2024-04-18 15:36 ` [PATCH v1 4/4] serial: exar: change port_type ternary line wrapping Parker Newman
2024-04-19  6:07   ` Jiri Slaby
2024-04-19 12:17     ` Parker Newman
2024-04-19  6:57   ` Greg Kroah-Hartman

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.