From patchwork Mon Jun 3 19:20:22 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikolay Balandin X-Patchwork-Id: 248392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-fa0-x23d.google.com (mail-fa0-x23d.google.com [IPv6:2a00:1450:4001:c02::23d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 3B5B62C00A4 for ; Tue, 4 Jun 2013 05:21:24 +1000 (EST) Received: by mail-fa0-f61.google.com with SMTP id u1sf7298fae.16 for ; Mon, 03 Jun 2013 12:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=mime-version:x-beenthere:from:to:cc:subject:date:message-id :x-mailer:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-google-group-id :list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=t1A4SVFqkykhiDfAeqLawyBAH0sME6cIwrl6lH13umU=; b=pgpsxeS4PtdjkiY9BxElzffdkAeqNw8bX84uTCJEWJThjGj+5+unebZQvfqjzHLulo hij1RD1R1hPIsJnZj8xHwNfjO6+utuYOnrAnDtypBW45mG/YmIhrlMXjY5JTzC+n81dV T9I7JQ5pnfWYBOqI7kd/fV/VJ2CJziunAE60xvH3AESgE6CAKjC7GgoyesckR19ZaQwO JYwqYywDkFATzkJJMgjF46rUKKBoVxGBL4o9QMtk2mM6urHJUD5achWgH59Rst/Y4HNr YcqBsHvwE3Fi4enKq29JFlGBy2oDDJfci9XP2M1OTFNpy+5drj++qRpf3Y/xM/wAo0ff iz6A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-beenthere:from:to:cc:subject:date:message-id :x-mailer:x-original-sender:x-original-authentication-results :reply-to:precedence:mailing-list:list-id:x-google-group-id :list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=t1A4SVFqkykhiDfAeqLawyBAH0sME6cIwrl6lH13umU=; b=K4snmXMGPMt2gdiyrD9yHcy2K3GToCMfxnjsD6R2Ob8X0urZLiadkVhW4T8MAOZkgN pI7pmHshTnxDJ/m6red9Mr2Ar2VkH6+237QAbzjWddC3y9dzijBoUugcgClBz02K8TGd JlzHUoNC7FiPUtmolgFDYjsVbgD6LCOYLn7OCXfcBasAZr8EZR1OmXrjBfnnWYVdEk0S RewyQkSRvbIDeT315i0mS+QD2ukGPYqsiCCxEK0mNTh8HR4c9VSrSCnbCUETXHDkDZJH H4gcNhy/PzYo9y/bOLg9555Ltu8A0CiQFjFhFx5D/EQHmrdf81v1sY66dOykVv/x4JjF X4Vg== X-Received: by 10.180.208.114 with SMTP id md18mr1271190wic.9.1370287279102; Mon, 03 Jun 2013 12:21:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: rtc-linux@googlegroups.com Received: by 10.180.8.37 with SMTP id o5ls955483wia.50.gmail; Mon, 03 Jun 2013 12:21:18 -0700 (PDT) X-Received: by 10.204.183.197 with SMTP id ch5mr1980778bkb.3.1370287278240; Mon, 03 Jun 2013 12:21:18 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by gmr-mx.google.com with ESMTPS id ev8si3000483bkc.1.2013.06.03.12.21.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Jun 2013 12:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of n.a.balandin@gmail.com designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by mail-lb0-f171.google.com with SMTP id v5so1424436lbc.16 for ; Mon, 03 Jun 2013 12:21:17 -0700 (PDT) X-Received: by 10.152.170.194 with SMTP id ao2mr11412749lac.48.1370287277872; Mon, 03 Jun 2013 12:21:17 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-154-241.pppoe.mtu-net.ru. [91.76.154.241]) by mx.google.com with ESMTPSA id c7sm13000278lag.3.2013.06.03.12.21.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Jun 2013 12:21:17 -0700 (PDT) From: Nikolay Balandin To: Alessandro Zummo , Rob Landley , rtc-linux@googlegroups.com, linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dmitry Krivoschekov , Alexander Stauffenberg , Nikolay Balandin Subject: [rtc-linux] [PATCH v1 1/1] Documentation/rtc: update ioctl return values checkings in example code Date: Mon, 3 Jun 2013 23:20:22 +0400 Message-Id: <1370287222-24417-1-git-send-email-n.a.balandin@gmail.com> X-Mailer: git-send-email 1.7.9.5 X-Original-Sender: n.a.balandin@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of n.a.balandin@gmail.com designates 209.85.217.171 as permitted sender) smtp.mail=n.a.balandin@gmail.com; dkim=pass header.i=@gmail.com Reply-To: rtc-linux@googlegroups.com Precedence: list Mailing-list: list rtc-linux@googlegroups.com; contact rtc-linux+owners@googlegroups.com List-ID: X-Google-Group-Id: 712029733259 List-Post: , List-Help: , List-Archive: Sender: rtc-linux@googlegroups.com List-Subscribe: , List-Unsubscribe: , From: Nikolay Balandin 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 --- 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);