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

ARM: cpuidle: Don't register the driver when back-end init returns -ENXIO

There's no point to register the cpuidle driver for the current CPU, when
the initialization of the arch specific back-end data fails by returning
-ENXIO.

Instead, let's re-order the sequence to its original flow, by first trying
to initialize the back-end part and then act accordingly on the returned
error code. Additionally, let's print the error message, no matter of what
error code that was returned.

Fixes: a0d46a3dfdc3 (ARM: cpuidle: Register per cpuidle device)
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: 4.19+ <stable@vger.kernel.org> # v4.19+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Ulf Hansson and committed by
Rafael J. Wysocki
763f191a 65102238

+10 -12
+10 -12
drivers/cpuidle/cpuidle-arm.c
··· 103 103 goto out_kfree_drv; 104 104 } 105 105 106 - ret = cpuidle_register_driver(drv); 107 - if (ret) { 108 - if (ret != -EBUSY) 109 - pr_err("Failed to register cpuidle driver\n"); 110 - goto out_kfree_drv; 111 - } 112 - 113 106 /* 114 107 * Call arch CPU operations in order to initialize 115 108 * idle states suspend back-end specific data ··· 110 117 ret = arm_cpuidle_init(cpu); 111 118 112 119 /* 113 - * Skip the cpuidle device initialization if the reported 120 + * Allow the initialization to continue for other CPUs, if the reported 114 121 * failure is a HW misconfiguration/breakage (-ENXIO). 115 122 */ 116 - if (ret == -ENXIO) 117 - return 0; 118 - 119 123 if (ret) { 120 124 pr_err("CPU %d failed to init idle CPU ops\n", cpu); 121 - goto out_unregister_drv; 125 + ret = ret == -ENXIO ? 0 : ret; 126 + goto out_kfree_drv; 127 + } 128 + 129 + ret = cpuidle_register_driver(drv); 130 + if (ret) { 131 + if (ret != -EBUSY) 132 + pr_err("Failed to register cpuidle driver\n"); 133 + goto out_kfree_drv; 122 134 } 123 135 124 136 dev = kzalloc(sizeof(*dev), GFP_KERNEL);