The role of energy conditions in f(R) cosmology