src: Factorize the code by adding get_counter_value()