Final goal of the refactoring is to abstract everything that the chips have in common and handle it in generic code. Then we can get rid of all the "switch (chip)" and "if (chip == xxx)" code. To give one example: A lot of chips have a bit for setting 12hr / 24hr mode. However some chips have this config bit in the timekeeping registers, others in a config register, and on some chips it's inverted. But the functionality of the bit is always the same. Ultimately adding support for a chip just requires to add one config structure member. The way to reach this goal is a long one and to faciliate reviewing the patches I'll split them into series of 5 to 10 patches. Heiner Kallweit (5): rtc: ds1307: factor out determining the chip type rtc: ds1307: factor out trickle charger initialization rtc: ds1307: factor out fixing the weekday rtc: ds1307: introduce constants for the timekeeping register masks rtc: ds1307: improve ds1307_set_time to respect config flag bits drivers/rtc/rtc-ds1307.c | 256 ++++++++++++++++++++++++++--------------------- 1 file changed, 140 insertions(+), 116 deletions(-) -- 2.14.1