On Thursday, July 05, 2012, Daniel Lezcano wrote:
We have the state index passed as parameter to the 'enter' function. Most of the drivers assign their 'enter' functions several times in the cpuidle_state structure, as we have the index, we can delegate to the driver to handle their own callback array.
That will have the benefit of removing multiple lines of code in the different drivers.
Hmm. I suppose the cpuidle subsystem was designed the way it was for a reason. Among other things, this was to avoid recurrence in callbacks - please see acpi_idle_enter_bm() for example.
Now, if .enter() is moved to the driver structure, it will have to be an all-purpose complicated routine calling itself recursively at least in some cases. I'm not quite convinced that would be an improvement.
On the other hand, I don't see anything wrong with setting several callback pointers to the same routine.
Thanks, Rafael