On Mon, Nov 23, 2020 at 12:10:54AM +0100, Alexandre Belloni wrote: > Hi, > > On 22/11/2020 23:27:37+0100, Jonathan Neuschäfer wrote: > > With this driver, mainline Linux can keep its time and date in sync with > > the vendor kernel. > > > > Advanced functionality like alarm and automatic power-on is not yet > > supported. > > > > Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@xxxxxxx> > Acked-by: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx> > > However, two comments below: > > > +static int ntxec_set_time(struct device *dev, struct rtc_time *tm) > > +{ > > + struct ntxec_rtc *rtc = dev_get_drvdata(dev); > > + int res = 0; > > + > > + /* > > + * To avoid time overflows while we're writing the full date/time, > > + * set the seconds field to zero before doing anything else. For the > > + * next 59 seconds (plus however long it takes until the RTC's next > > + * update of the second field), the seconds field will not overflow > > + * into the other fields. > > + */ > > + res = regmap_write(rtc->ec->regmap, NTXEC_REG_WRITE_SECOND, ntxec_reg8(0)); > > + if (res) > > + return res; > > + > > + res = regmap_write(rtc->ec->regmap, NTXEC_REG_WRITE_YEAR, ntxec_reg8(tm->tm_year - 100)); > > + if (res) > > + return res; > > + > > + res = regmap_write(rtc->ec->regmap, NTXEC_REG_WRITE_MONTH, ntxec_reg8(tm->tm_mon + 1)); > > + if (res) > > + return res; > > + > > + res = regmap_write(rtc->ec->regmap, NTXEC_REG_WRITE_DAY, ntxec_reg8(tm->tm_mday)); > > + if (res) > > + return res; > > + > > + res = regmap_write(rtc->ec->regmap, NTXEC_REG_WRITE_HOUR, ntxec_reg8(tm->tm_hour)); > > + if (res) > > + return res; > > + > > + res = regmap_write(rtc->ec->regmap, NTXEC_REG_WRITE_MINUTE, ntxec_reg8(tm->tm_min)); > > + if (res) > > + return res; > > + > > + return regmap_write(rtc->ec->regmap, NTXEC_REG_WRITE_SECOND, ntxec_reg8(tm->tm_sec)); > > Couldn't you do a regmap_block_write or a regmap_multi_reg_write which > would be more efficient as they would be locking the regmap only once. I can't find regmap_block_write anywhere, but regmap_multi_reg_write looks like a good approach to simplify the code here. [...] > Note that this won't compile after > https://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git/commit/?id=fdcfd854333be5b30377dc5daa9cd0fa1643a979 > > We can solve that with immutable branches though. Thanks for the heads-up. Please let me know if/when there is any action that I need to take here. Jonathan
Attachment:
signature.asc
Description: PGP signature