stm: Use common flash wait loop instead of inlining