Skip to contentSkip to conversation

serial: exar: fix kbuild warnings and code style

PATCH In review Parker Newman 3 participants 8 messages Apr 19, 2024 – May 4, 2024 TTY layer and serial drivers

lore
Share & tools
lore
#0 lore raw

v2 cover serial: exar: fix kbuild warnings and code style

From: Parker Newman <[email protected]>

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:

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: return bool from exar_ee_read_bit()
serial: exar: remove ternaries from

    cti_get_port_type_xr17c15x_xr17v25x()
 drivers/tty/serial/8250/8250_exar.c | 36 ++++++++++++++---------------
 1 file changed, 18 insertions(+), 18 deletions(-)

base-commit: c6795fbffc4547b40933ec368200bd4926a41b44 --
2.43.2

#1 lore raw

PATCH v2 1/4 serial: exar: add missing kernel doc function parameters

From: Parker Newman <[email protected]>

Adds missing kernel doc function parameters to 3 functions.

Closes:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

---
 drivers/tty/serial/8250/8250_exar.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/tty/serial/8250/8250_exar.c +3 -0
index 5e42558cbb01..a180741da634 100644
@@ -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

#2 lore raw

PATCH v2 2/4 serial: exar: use return dev_err_probe instead of returning error code

In reply to Parker Newman

From: Parker Newman <[email protected]>

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

---
 drivers/tty/serial/8250/8250_exar.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_exar.c +2 -4
index a180741da634..01748ddbf729 100644
@@ -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

#3 lore raw

PATCH v2 3/4 serial: exar: return bool from exar_ee_read_bit()

In reply to Parker Newman

From: Parker Newman <[email protected]>

Change exar_ee_read_bit() to return a bool instead of u8. Removed need for ternary or if/else for return value.

---
Changes in v2:
- Change exar_ee_read_bit() to return a bool

 drivers/tty/serial/8250/8250_exar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/8250/8250_exar.c +2 -2
index 01748ddbf729..8665d3b7b673 100644
@@ -300,7 +300,7 @@ static inline void exar_ee_write_bit(struct exar8250 *priv, int bit)
 	udelay(2);
 }
 
-static inline u8 exar_ee_read_bit(struct exar8250 *priv)
+static inline bool exar_ee_read_bit(struct exar8250 *priv)
 {
 	u8 regb;
 	u8 value = UART_EXAR_REGB_EECS;
@@ -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;
 }
 
 /**

--
2.43.2

#4 lore raw

PATCH v2 4/4 serial: exar: remove ternaries from cti_get_port_type_xr17c15x_xr17v25x()

In reply to Parker Newman

From: Parker Newman <[email protected]>

Remove ternary operators from cti_get_port_type_xr17c15x_xr17v25x() for better readability.

---
Changes in v2:
- Removed ternary operators completely

 drivers/tty/serial/8250/8250_exar.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
drivers/tty/serial/8250/8250_exar.c +11 -12
index 8665d3b7b673..521d2acf4004 100644
@@ -726,7 +726,7 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
 							struct pci_dev *pcidev,
 							unsigned int port_num)
 {
-	enum cti_port_type port_type;
+	enum cti_port_type port_type = CTI_PORT_TYPE_RS232;
 
 	switch (pcidev->subsystem_device) {
 	// RS232 only cards
@@ -737,23 +737,22 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_SP_232_NS:
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_XPRS_LP_232:
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_8_XPRS_LP_232_NS:
-		port_type = CTI_PORT_TYPE_RS232;
 		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;
+		if (port_num)
+			port_type = 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;
+		if (port_num > 1)
+			port_type = 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;
+		if (port_num > 3)
+			port_type = CTI_PORT_TYPE_RS422_485;
 		break;
 	// RS232/RS422/RS485 HW (jumper) selectable
 	case PCI_SUBDEVICE_ID_CONNECT_TECH_PCI_UART_2:
@@ -789,13 +788,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;
+		if (port_num > 5)
+			port_type = 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;
+		if (port_num > 1)
+			port_type = CTI_PORT_TYPE_RS422_485;
 		break;
 	default:
 		dev_err(&pcidev->dev, "unknown/unsupported device\n");

--
2.43.2

maintainer Reviewed-by on v2 4/4
#5 lore raw

Re: [PATCH v2 4/4] serial: exar: remove ternaries from cti_get_port_type_xr17c15x_xr17v25x()

Quoted 6 lines · Parker Newman

From: Parker Newman <[email protected]>

Remove ternary operators from cti_get_port_type_xr17c15x_xr17v25x() for better readability.

Much better.

drivers/tty/serial/8250/8250_exar.c static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p · line 732

Quoted 11 lines
drivers/tty/serial/8250/8250_exar.c +1 -1
@@ -726,7 +726,7 @@ static enum cti_port_type cti_get_port_type_xr17c15x_xr17v25x(struct exar8250 *p
  							struct pci_dev *pcidev,
  							unsigned int port_num)
  {
-	enum cti_port_type port_type;
+	enum cti_port_type port_type = CTI_PORT_TYPE_RS232;
 
  	switch (pcidev->subsystem_device) {
  	// RS232 only cards

Unrelated to this one, but // comments are discouraged in the kernel, IMO?

thanks,

Signature · 2 lines
js
suse labs
#6 lore raw
In reply to Parker Newman
Quoted 8 lines · On Fri, 19 Apr 2024 10:17:00 -0400 Parker Newman <[email protected]> wrote:

From: Parker Newman <[email protected]>

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:

These patches should not be required anymore. Andy Shevchenko has submitted a more comprehensive clean up patch set that makes this set unneeded.

Thanks,
Parker

Quoted 15 lines

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: return bool from exar_ee_read_bit()
serial: exar: remove ternaries from

    cti_get_port_type_xr17c15x_xr17v25x()
 drivers/tty/serial/8250/8250_exar.c | 36 ++++++++++++++---------------
 1 file changed, 18 insertions(+), 18 deletions(-)

base-commit: c6795fbffc4547b40933ec368200bd4926a41b44 --
2.43.2

#7 lore raw
Quoted 12 lines · Parker Newman
Quoted 8 lines · On Fri, 19 Apr 2024 10:17:00 -0400 Parker Newman <[email protected]> wrote:

From: Parker Newman <[email protected]>

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:

Quoted 5 lines

These patches should not be required anymore. Andy Shevchenko has submitted a more comprehensive clean up patch set that makes this set unneeded.

Thanks for letting me know, now dropped.

greg k-h