From patchwork Tue Nov 3 22:01:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 37533 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-px0-f138.google.com (mail-px0-f138.google.com [209.85.216.138]) by ozlabs.org (Postfix) with ESMTP id 230A1B7BD1 for ; Wed, 4 Nov 2009 09:02:25 +1100 (EST) Received: by pxi2 with SMTP id 2so2854640pxi.11 for ; Tue, 03 Nov 2009 14:02:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received:received-spf:received:received:date:from :to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:x-spam-status:x-spam-checker-version :x-mimedefang-filter:x-scanned-by:reply-to:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; bh=/XztIv5oT9qnieaob+VfrEIf14G+mzj2H/9ru1eEPRs=; b=pflrKjlvpRyoUTT9FkSn2K5QjzMKLiR7+zFoj4yJMI7c2i4WSwZfayDOjx8gppw25q MxUmiBKSM4eG2jGJkydTnlCBq6qNrqFFfxtrpMeYcZ+CYrZKiM3tC419C6hDONXme1IQ RJQTe14LD66F5mGojaMbG/A7PhfwtIgyWQHV8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results:date :from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:x-spam-status:x-spam-checker-version :x-mimedefang-filter:x-scanned-by:reply-to:sender:precedence :x-google-loop:mailing-list:list-id:list-post:list-help :list-unsubscribe:x-beenthere-env:x-beenthere; b=dT5prJPcddSNbDzHLkAJVk0dFwOvYfF7+C5420z1YXR6XCjzVNKtIl+qJrKcCszOOb ZTfCqAlT2gdzhEXjHwrep6ha56lzDHZawHFuj3s+9amXtdQRBflQKvARxTy05A252MSd ajeTcwz46Mb+T+BjYPY/tuWk/OZWCf9q2t10w= Received: by 10.140.126.14 with SMTP id y14mr14878rvc.1.1257285743315; Tue, 03 Nov 2009 14:02:23 -0800 (PST) Received: by 10.106.156.19 with SMTP id d19gr3011pre.0; Tue, 03 Nov 2009 14:02:23 -0800 (PST) X-Sender: akpm@linux-foundation.org X-Apparently-To: rtc-linux@googlegroups.com Received: by 10.114.105.11 with SMTP id d11mr97518wac.21.1257285741765; Tue, 03 Nov 2009 14:02:21 -0800 (PST) Received: by 10.114.105.11 with SMTP id d11mr97517wac.21.1257285741745; Tue, 03 Nov 2009 14:02:21 -0800 (PST) Received: from smtp1.linux-foundation.org (smtp1.linux-foundation.org [140.211.169.13]) by gmr-mx.google.com with ESMTP id 19si52696pzk.12.2009.11.03.14.02.21; Tue, 03 Nov 2009 14:02:21 -0800 (PST) Received-SPF: pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.13 as permitted sender) client-ip=140.211.169.13; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of akpm@linux-foundation.org designates 140.211.169.13 as permitted sender) smtp.mail=akpm@linux-foundation.org Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id nA3M1HdD009402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Nov 2009 14:01:19 -0800 Received: from akpm.mtv.corp.google.com (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with SMTP id nA3M1Hqk025386; Tue, 3 Nov 2009 14:01:17 -0800 Date: Tue, 3 Nov 2009 14:01:16 -0800 From: Andrew Morton To: svalentine@concentris-systems.com Cc: rtc-linux@googlegroups.com, a.zummo@towertech.it, raph@8d.com, linux-kernel@vger.kernel.org Subject: [rtc-linux] Re: [PATCH] RTC: v3020 driver bugfix Message-Id: <20091103140116.5e03df08.akpm@linux-foundation.org> In-Reply-To: <36176.167.216.14.194.1256001083.squirrel@www.concentris-systems.com> References: <36176.167.216.14.194.1256001083.squirrel@www.concentris-systems.com> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.9; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Spam-Status: No, hits=-5.017 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED, PATCH_SUBJECT_OSDL X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Reply-To: rtc-linux@googlegroups.com Sender: rtc-linux@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rtc-linux@googlegroups.com; contact rtc-linux+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rtc-linux@googlegroups.com X-BeenThere: rtc-linux@googlegroups.com On Mon, 19 Oct 2009 15:11:23 -1000 (HST) "Scott Valentine" wrote: > v3020 read_bit always returns 0 when left_shift > 7 > > The v3020 read_bit function's return type is (unsigned char). The code > returns a value masked by (1 << left_shift) that is casted to the return > type. If left_shift is larger than 7, the cast will always result in a 0 > return value. The problem was discovered with left_shift = 16, and the > included patch corrects the problem. > > The bug was introduced in the last (Apr 3 2009) commit of the file, kernel > versions 2.6.30 and later. > > diff -uNr a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c > --- a/drivers/rtc/rtc-v3020.c 2009-10-15 14:41:50.000000000 -1000 > +++ b/drivers/rtc/rtc-v3020.c 2009-10-19 14:06:27.000000000 -1000 > @@ -96,7 +96,7 @@ > > static unsigned char v3020_mmio_read_bit(struct v3020 *chip) > { > - return readl(chip->ioaddress) & (1 << chip->leftshift); > + return ((readl(chip->ioaddress) & (1 << chip->leftshift)) != 0); > } > > static struct v3020_chip_ops v3020_mmio_ops = { OK. It's strange that the function returns `unsigned char' instead of say int or bool. We may as well do this in the same way as v3020_gpio_read_bit(): --- a/drivers/rtc/rtc-v3020.c~rtc-v3020-fix-v3020_mmio_read_bit +++ a/drivers/rtc/rtc-v3020.c @@ -96,7 +96,7 @@ static void v3020_mmio_write_bit(struct static unsigned char v3020_mmio_read_bit(struct v3020 *chip) { - return readl(chip->ioaddress) & (1 << chip->leftshift); + return !!(readl(chip->ioaddress) & (1 << chip->leftshift)); } static struct v3020_chip_ops v3020_mmio_ops = {