Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

serial: 8250_exar: Extract cti_board_init_osc_freq() helper

Extract cti_board_init_osc_freq() helper to avoid code duplication.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Parker Newman <pnewman@connecttech.com>
Link: https://lore.kernel.org/r/20240503171917.2921250-7-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Andy Shevchenko and committed by
Greg Kroah-Hartman
c5f59747 1cf8520a

+19 -29
+19 -29
drivers/tty/serial/8250/8250_exar.c
··· 695 695 { 696 696 u16 lower_word; 697 697 u16 upper_word; 698 - int osc_freq; 699 698 700 699 lower_word = exar_ee_read(priv, eeprom_offset); 701 700 // Check if EEPROM word was blank ··· 705 706 if (upper_word == 0xFFFF) 706 707 return -EIO; 707 708 708 - osc_freq = FIELD_PREP(CTI_EE_MASK_OSC_FREQ_LOWER, lower_word) | 709 - FIELD_PREP(CTI_EE_MASK_OSC_FREQ_UPPER, upper_word); 710 - 711 - return osc_freq; 709 + return FIELD_PREP(CTI_EE_MASK_OSC_FREQ_LOWER, lower_word) | 710 + FIELD_PREP(CTI_EE_MASK_OSC_FREQ_UPPER, upper_word); 712 711 } 713 712 714 713 /** ··· 885 888 886 889 // Disable power-on RS485 tri-state via MPIO 887 890 return cti_tristate_disable(priv, port->port_id); 891 + } 892 + 893 + static void cti_board_init_osc_freq(struct exar8250 *priv, struct pci_dev *pcidev, u8 eeprom_offset) 894 + { 895 + int osc_freq; 896 + 897 + osc_freq = cti_read_osc_freq(priv, eeprom_offset); 898 + if (osc_freq <= 0) { 899 + dev_warn(&pcidev->dev, "failed to read OSC freq from EEPROM, using default\n"); 900 + osc_freq = CTI_DEFAULT_PCI_OSC_FREQ; 901 + } 902 + 903 + priv->osc_freq = osc_freq; 888 904 } 889 905 890 906 static int cti_port_setup_common(struct exar8250 *priv, ··· 1105 1095 return 0; 1106 1096 } 1107 1097 1108 - static int cti_board_init_xr17v25x(struct exar8250 *priv, 1109 - struct pci_dev *pcidev) 1098 + static int cti_board_init_xr17v25x(struct exar8250 *priv, struct pci_dev *pcidev) 1110 1099 { 1111 - int osc_freq; 1112 - 1113 - osc_freq = cti_read_osc_freq(priv, CTI_EE_OFF_XR17V25X_OSC_FREQ); 1114 - if (osc_freq < 0) { 1115 - dev_warn(&pcidev->dev, 1116 - "failed to read osc freq from EEPROM, using default\n"); 1117 - osc_freq = CTI_DEFAULT_PCI_OSC_FREQ; 1118 - } 1119 - 1120 - priv->osc_freq = osc_freq; 1100 + cti_board_init_osc_freq(priv, pcidev, CTI_EE_OFF_XR17V25X_OSC_FREQ); 1121 1101 1122 1102 /* enable interrupts on cards that need the "PLX fix" */ 1123 1103 switch (pcidev->subsystem_device) { ··· 1123 1123 return 0; 1124 1124 } 1125 1125 1126 - static int cti_board_init_xr17c15x(struct exar8250 *priv, 1127 - struct pci_dev *pcidev) 1126 + static int cti_board_init_xr17c15x(struct exar8250 *priv, struct pci_dev *pcidev) 1128 1127 { 1129 - int osc_freq; 1130 - 1131 - osc_freq = cti_read_osc_freq(priv, CTI_EE_OFF_XR17C15X_OSC_FREQ); 1132 - if (osc_freq <= 0) { 1133 - dev_warn(&pcidev->dev, 1134 - "failed to read osc freq from EEPROM, using default\n"); 1135 - osc_freq = CTI_DEFAULT_PCI_OSC_FREQ; 1136 - } 1137 - 1138 - priv->osc_freq = osc_freq; 1128 + cti_board_init_osc_freq(priv, pcidev, CTI_EE_OFF_XR17C15X_OSC_FREQ); 1139 1129 1140 1130 /* enable interrupts on cards that need the "PLX fix" */ 1141 1131 switch (pcidev->subsystem_device) {