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

clocksource: arm_arch_timer: move arch_timer_needs_of_probing into DT init call

To cleanly split code paths specific to ACPI or DT at a higher level,
this patch removes arch_timer_init(), folding the relevant
parts of its logic into existing callers.

This pathes the way for further rework, and saves a few lines.

Signed-off-by: Fu Wei <fu.wei@linaro.org>
Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org>
[Mark: reword commit message]
Signed-off-by: Mark Rutland <mark.rutland@arm.com>

authored by

Fu Wei and committed by
Mark Rutland
ca0e1b52 13bf6992

+21 -25
+21 -25
drivers/clocksource/arm_arch_timer.c
··· 1105 1105 1106 1106 static int __init arch_timer_common_init(void) 1107 1107 { 1108 - if (acpi_disabled && arch_timer_needs_of_probing()) 1109 - return 0; 1110 - 1111 1108 arch_timer_banner(arch_timers_present); 1112 1109 arch_counter_register(arch_timers_present); 1113 1110 return arch_timer_arch_init(); ··· 1142 1145 return ARCH_TIMER_PHYS_SECURE_PPI; 1143 1146 } 1144 1147 1145 - static int __init arch_timer_init(void) 1146 - { 1147 - int ret; 1148 - 1149 - ret = arch_timer_register(); 1150 - if (ret) 1151 - return ret; 1152 - 1153 - ret = arch_timer_common_init(); 1154 - if (ret) 1155 - return ret; 1156 - 1157 - arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; 1158 - 1159 - return 0; 1160 - } 1161 - 1162 1148 static int __init arch_timer_of_init(struct device_node *np) 1163 1149 { 1164 - int i; 1150 + int i, ret; 1165 1151 u32 rate; 1166 1152 1167 1153 if (arch_timers_present & ARCH_TIMER_TYPE_CP15) { ··· 1155 1175 arch_timers_present |= ARCH_TIMER_TYPE_CP15; 1156 1176 for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) 1157 1177 arch_timer_ppi[i] = irq_of_parse_and_map(np, i); 1178 + 1179 + arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; 1158 1180 1159 1181 rate = arch_timer_get_cntfrq; 1160 1182 arch_timer_of_configure_rate(rate, np); ··· 1185 1203 arch_counter_suspend_stop = of_property_read_bool(np, 1186 1204 "arm,no-tick-in-suspend"); 1187 1205 1188 - return arch_timer_init(); 1206 + ret = arch_timer_register(); 1207 + if (ret) 1208 + return ret; 1209 + 1210 + if (arch_timer_needs_of_probing()) 1211 + return 0; 1212 + 1213 + return arch_timer_common_init(); 1189 1214 } 1190 1215 CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init); 1191 1216 CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init); ··· 1274 1285 if (ret) 1275 1286 goto out; 1276 1287 1277 - return arch_timer_common_init(); 1288 + if (!arch_timer_needs_of_probing()) 1289 + ret = arch_timer_common_init(); 1278 1290 out: 1279 1291 iounmap(cntctlbase); 1280 1292 of_node_put(best_frame); ··· 1304 1314 /* Initialize per-processor generic timer */ 1305 1315 static int __init arch_timer_acpi_init(struct acpi_table_header *table) 1306 1316 { 1317 + int ret; 1307 1318 struct acpi_table_gtdt *gtdt; 1308 1319 1309 1320 if (arch_timers_present & ARCH_TIMER_TYPE_CP15) { ··· 1332 1341 map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, 1333 1342 gtdt->non_secure_el2_flags); 1334 1343 1344 + arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; 1345 + 1335 1346 /* 1336 1347 * When probing via ACPI, we have no mechanism to override the sysreg 1337 1348 * CNTFRQ value. This *must* be correct. ··· 1356 1363 /* Check for globally applicable workarounds */ 1357 1364 arch_timer_check_ool_workaround(ate_match_acpi_oem_info, table); 1358 1365 1359 - arch_timer_init(); 1360 - return 0; 1366 + ret = arch_timer_register(); 1367 + if (ret) 1368 + return ret; 1369 + 1370 + return arch_timer_common_init(); 1361 1371 } 1362 1372 CLOCKSOURCE_ACPI_DECLARE(arch_timer, ACPI_SIG_GTDT, arch_timer_acpi_init); 1363 1373 #endif