lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 23 Nov 2020 00:10:54 +0100 From: Alexandre Belloni <alexandre.belloni@...tlin.com> To: Jonathan Neuschäfer <j.neuschaefer@....net> Cc: linux-kernel@...r.kernel.org, Lee Jones <lee.jones@...aro.org>, Rob Herring <robh+dt@...nel.org>, Thierry Reding <thierry.reding@...il.com>, Uwe Kleine-König <u.kleine-koenig@...gutronix.de>, Alessandro Zummo <a.zummo@...ertech.it>, Shawn Guo <shawnguo@...nel.org>, Sascha Hauer <s.hauer@...gutronix.de>, Pengutronix Kernel Team <kernel@...gutronix.de>, Fabio Estevam <festevam@...il.com>, NXP Linux Team <linux-imx@....com>, Sam Ravnborg <sam@...nborg.org>, Linus Walleij <linus.walleij@...aro.org>, Heiko Stuebner <heiko.stuebner@...obroma-systems.com>, Stephan Gerhold <stephan@...hold.net>, Lubomir Rintel <lkundrak@...sk>, Mark Brown <broonie@...nel.org>, allen <allen.chen@....com.tw>, Mauro Carvalho Chehab <mchehab+huawei@...nel.org>, "David S. Miller" <davem@...emloft.net>, devicetree@...r.kernel.org, linux-pwm@...r.kernel.org, linux-rtc@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, Heiko Stuebner <heiko@...ech.de>, Josua Mayer <josua.mayer@....eu>, Andreas Kemnade <andreas@...nade.info>, Arnd Bergmann <arnd@...db.de>, Daniel Palmer <daniel@...f.com>, Andy Shevchenko <andy.shevchenko@...il.com> Subject: Re: [PATCH v4 5/7] rtc: New driver for RTC in Netronix embedded controller 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@....net> Acked-by: Alexandre Belloni <alexandre.belloni@...tlin.com> 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. > +} > + > +static const struct rtc_class_ops ntxec_rtc_ops = { > + .read_time = ntxec_read_time, > + .set_time = ntxec_set_time, > +}; > + > +static int ntxec_rtc_probe(struct platform_device *pdev) > +{ > + struct rtc_device *dev; > + struct ntxec_rtc *rtc; > + > + rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); > + if (!rtc) > + return -ENOMEM; > + > + rtc->dev = &pdev->dev; > + rtc->ec = dev_get_drvdata(pdev->dev.parent); > + platform_set_drvdata(pdev, rtc); > + > + dev = devm_rtc_allocate_device(&pdev->dev); > + if (IS_ERR(dev)) > + return PTR_ERR(dev); > + > + dev->ops = &ntxec_rtc_ops; > + dev->range_min = RTC_TIMESTAMP_BEGIN_2000; > + dev->range_max = 9025257599LL; /* 2255-12-31 23:59:59 */ > + > + return rtc_register_device(dev); 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. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Powered by blists - more mailing lists