Class of viable modified f(R) gravities describing inflation and the onset of accelerated expansion