From patchwork Thu Apr 4 23:42:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Brand X-Patchwork-Id: 234006 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-ye0-f186.google.com (mail-ye0-f186.google.com [209.85.213.186]) (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 1B0762C0084 for ; Fri, 5 Apr 2013 10:41:08 +1100 (EST) Received: by mail-ye0-f186.google.com with SMTP id m9sf986530yen.13 for ; Thu, 04 Apr 2013 16:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=x-received:x-beenthere:x-received:received-spf:x-server-uuid :subject:to:x-mailer:message-id:date:from:mime-version:x-wss-id :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=o1rTAVBYmk5YxdAIAhg+8GuG52ysjigaiATwZ74Fc34=; b=HcJZVReH08paD0uKrJgWsWGAArRsSqcMsXLA8J6rdqN5iuoqNSuyjbFjjLUoB7lMDq iAbmjrprnV1h1O8NBFv8XK0cSKOuGZ5gbTYpe37ftK4upU/vvsZlg75aCrsEYOQWPlQT +LrvTbZjPiLG3Jd9mtuH7RArJWcG0g6dU3jgwsY64/aGPOgi0PiOc3KvRVu26UQrDns/ bWlH+Vn9xbvRJ/0eOqjvn3juGEY32Yqd0KhrRYifDsuqDgUtBwPWNMlpSF7l9jpUstYn oaQTRiwA/GevDhS/qVyVFHvgje8Esntu+oMiyxNrYnl1zxM9E7cmnHyFz7M1KdTYp3km /a4Q== X-Received: by 10.50.150.166 with SMTP id uj6mr55605igb.1.1365118865356; Thu, 04 Apr 2013 16:41:05 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.140.102 with SMTP id rf6ls140231igb.10.canary; Thu, 04 Apr 2013 16:41:04 -0700 (PDT) X-Received: by 10.66.241.69 with SMTP id wg5mr1511729pac.2.1365118864703; Thu, 04 Apr 2013 16:41:04 -0700 (PDT) Received: from mms2.broadcom.com (mms2.broadcom.com. [216.31.210.18]) by gmr-mx.google.com with ESMTP id rs16si2067287pac.1.2013.04.04.16.41.04; Thu, 04 Apr 2013 16:41:04 -0700 (PDT) Received-SPF: pass (google.com: domain of cbrand@lbrmn-lnxub61.ric.broadcom.com designates 216.31.210.18 as permitted sender) client-ip=216.31.210.18; Received: from [10.9.208.53] by mms2.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.5)); Thu, 04 Apr 2013 16:36:24 -0700 X-Server-Uuid: 4500596E-606A-40F9-852D-14843D8201B2 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS06.corp.ad.broadcom.com (10.9.208.53) with Microsoft SMTP Server (TLS) id 14.1.438.0; Thu, 4 Apr 2013 16:40:51 -0700 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.1.438.0; Thu, 4 Apr 2013 16:40:51 -0700 Received: from lbrmn-lnxub61.ric.broadcom.com ( lbrmn-lnxub61.ric.broadcom.com [10.136.4.113]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 4241139292; Thu, 4 Apr 2013 16:40:50 -0700 (PDT) Received: by lbrmn-lnxub61.ric.broadcom.com (Postfix, from userid 28037) id 6AC95C410D9; Thu, 4 Apr 2013 16:42:59 -0700 (PDT) Subject: [rtc-linux] ioctl(RTC_IRQP_SET) returns -EACCES, not -EBUSY To: rtc-linux@googlegroups.com, a.zummo@towertech.it X-Mailer: mail (GNU Mailutils 2.2) Message-ID: <20130404234259.6AC95C410D9@lbrmn-lnxub61.ric.broadcom.com> Date: Thu, 4 Apr 2013 16:42:59 -0700 From: "Chris Brand" MIME-Version: 1.0 X-WSS-ID: 7D40D1F23A08759934-01-01 X-Original-Sender: cbrand@lbrmn-lnxub61.ric.broadcom.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of cbrand@lbrmn-lnxub61.ric.broadcom.com designates 216.31.210.18 as permitted sender) smtp.mail=cbrand@lbrmn-lnxub61.ric.broadcom.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: , Hi, I'm new here, so please be gentle... Playing with ioctl(RTC_IRQP_SET), I found that I was getting "Permission denied" unexpectedly. It turned out that the RTC was actually busy, and I was hitting some strange behaviour in the driver. I'd suggest something like the following patch to fix it. Chris (Not subscribed to the list) From: Chris Brand Date: Thu, 4 Apr 2013 16:19:16 -0700 Subject: [PATCH] RTC: Return -EBUSY, not -EACCES when device is busy If rtc->irq_task is non-NULL and task is NULL, they always differ, which means that in rtc_irq_set_state() and rtc_irq_set_freq(), whenever err is set to -EBUSY it will then immediately be set to -EACCES, misleading the caller as to the underlying problem. Signed-off-by: Chris Brand --- drivers/rtc/interface.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 42bd57d..40d4032 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c @@ -698,9 +698,9 @@ retry: spin_lock_irqsave(&rtc->irq_task_lock, flags); if (rtc->irq_task != NULL && task == NULL) err = -EBUSY; - if (rtc->irq_task != task) + else if (rtc->irq_task != task) err = -EACCES; - if (!err) { + else { if (rtc_update_hrtimer(rtc, enabled) < 0) { spin_unlock_irqrestore(&rtc->irq_task_lock, flags); cpu_relax(); @@ -734,9 +734,9 @@ retry: spin_lock_irqsave(&rtc->irq_task_lock, flags); if (rtc->irq_task != NULL && task == NULL) err = -EBUSY; - if (rtc->irq_task != task) + else if (rtc->irq_task != task) err = -EACCES; - if (!err) { + else { rtc->irq_freq = freq; if (rtc->pie_enabled && rtc_update_hrtimer(rtc, 1) < 0) { spin_unlock_irqrestore(&rtc->irq_task_lock, flags);