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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202409101939448128973d@mail.local>
Date: Tue, 10 Sep 2024 21:39:44 +0200
From: Alexandre Belloni <alexandre.belloni@...tlin.com>
To: Esben Haabendal <esben@...nix.com>
Cc: Rasmus Villemoes <linux@...musvillemoes.dk>, linux-rtc@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] rtc: isl12022: Add alarm support

Hello Esben,

On 10/09/2024 12:27:11+0200, Esben Haabendal wrote:
> The ISL12022 RTC has a combined INT/fOUT pin, which can be used for alarm
> interrupt when frequency output is not enabled.
> 
> The device-tree bindings should ensure that interrupt and clock output is
> not enabled at the same time.

Ideally, we would get a pinmuxing part in the driver to ensure this ;)

> +static int isl12022_rtc_read_alarm(struct device *dev,
> +				   struct rtc_wkalrm *alarm)
> +{
> +	struct rtc_time *const tm = &alarm->time;
> +	struct isl12022 *isl12022 = dev_get_drvdata(dev);
> +	struct regmap *regmap = isl12022->regmap;
> +	uint8_t buf[ISL12022_ALARM_SECTION_LEN];
> +	int ret, yr, i;
> +
> +	ret = regmap_bulk_read(regmap, ISL12022_ALARM_SECTION,
> +			       buf, sizeof(buf));
> +	if (ret) {
> +		dev_err(dev, "%s: reading ALARM registers failed\n",
> +			__func__);

I don't really like those error messages because there is nothing the
user can actually do apart from trying again and this bloats the kernel.

> +	/* The alarm doesn't store the year so get it from the rtc section */
> +	ret = regmap_read(regmap, ISL12022_REG_YR, &yr);
> +	if (ret) {
> +		dev_err(dev, "%s: reading YR register failed\n", __func__);

Ditto

> +	isl12022->rtc = rtc;
>  
>  	rtc->ops = &isl12022_rtc_ops;
>  	rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
>  	rtc->range_max = RTC_TIMESTAMP_END_2099;
>  
> +	if (client->irq > 0) {
> +		ret = isl12022_setup_irq(isl12022, client->irq);

You can't do this in probe, the RTC lifecycle is longer than the linux
system. Or said differently: "oh no, my linux has rebooted and now I
lost my future alarm" ;)


> +		if (ret)
> +			return ret;
> +	} else {
> +		clear_bit(RTC_FEATURE_ALARM, rtc->features);
> +	}
> +
>  	return devm_rtc_register_device(rtc);
>  }
>  

-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ