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>] [day] [month] [year] [list]
Message-Id: <1370287222-24417-1-git-send-email-n.a.balandin@gmail.com>
Date:	Mon,  3 Jun 2013 23:20:22 +0400
From:	Nikolay Balandin <n.a.balandin@...il.com>
To:	Alessandro Zummo <a.zummo@...ertech.it>,
	Rob Landley <rob@...dley.net>, rtc-linux@...glegroups.com,
	linux-doc@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org,
	Dmitry Krivoschekov <dkrivoschokov@....rtsoft.ru>,
	Alexander Stauffenberg <Alexander.Stauffenberg@...tron.com>,
	Nikolay Balandin <nbalandin@....rtsoft.ru>
Subject: [PATCH v1 1/1] Documentation/rtc: update ioctl return values checkings in example code

From: Nikolay Balandin <nbalandin@....rtsoft.ru>

Update ioctl return values for rtc example code to correctly determine
does the rtc driver support corresponding IRQ type or not.

According to the rtc subsystem interface return values:
 For the update and alarm interrupts rtc subsystem interface will
return -EINVAL error code if a device driver does not implement
corresponding handler (RTC_UIE_ON or RTC_ALM_SET).
 For the periodic IRQs (RTC_IRQP_READ) rtc-dev will return 0 as a period
if rtc->irq_freq property is not initialized.

Signed-off-by: Nikolay Balandin <nbalandin@....rtsoft.ru>
---
 Documentation/rtc.txt |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/Documentation/rtc.txt b/Documentation/rtc.txt
index 32aa400..f911e4a 100644
--- a/Documentation/rtc.txt
+++ b/Documentation/rtc.txt
@@ -270,7 +270,7 @@ int main(int argc, char **argv)
 	/* Turn on update interrupts (one per second) */
 	retval = ioctl(fd, RTC_UIE_ON, 0);
 	if (retval == -1) {
-		if (errno == ENOTTY) {
+		if (errno == EINVAL) {
 			fprintf(stderr,
 				"\n...Update IRQs not supported.\n");
 			goto test_READ;
@@ -353,7 +353,7 @@ test_READ:
 
 	retval = ioctl(fd, RTC_ALM_SET, &rtc_tm);
 	if (retval == -1) {
-		if (errno == ENOTTY) {
+		if (errno == EINVAL) {
 			fprintf(stderr,
 				"\n...Alarm IRQs not supported.\n");
 			goto test_PIE;
@@ -401,13 +401,12 @@ test_PIE:
 	/* Read periodic IRQ rate */
 	retval = ioctl(fd, RTC_IRQP_READ, &tmp);
 	if (retval == -1) {
-		/* not all RTCs support periodic IRQs */
-		if (errno == ENOTTY) {
-			fprintf(stderr, "\nNo periodic IRQ support\n");
-			goto done;
-		}
 		perror("RTC_IRQP_READ ioctl");
 		exit(errno);
+	} else if (tmp == 0) {
+		/* not all RTCs support periodic IRQs */
+		fprintf(stderr, "\nNo periodic IRQ support\n");
+		goto done;
 	}
 	fprintf(stderr, "\nPeriodic IRQ rate is %ldHz.\n", tmp);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ