From patchwork Sat Apr 13 16:00:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Lin X-Patchwork-Id: 236363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail-pb0-f63.google.com (mail-pb0-f63.google.com [209.85.160.63]) (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 7DA812C009F for ; Sun, 14 Apr 2013 02:00:50 +1000 (EST) Received: by mail-pb0-f63.google.com with SMTP id rr4sf1064812pbb.28 for ; Sat, 13 Apr 2013 09:00:49 -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-received :message-id:subject:from:to:cc:date:x-mailer:mime-version :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=TUws/s33nhtehKg4FgMs7aEGVGzUFKg8uv2opBnfEZA=; b=JbLszJI1z2GYeOysdlom2MBvPJYDW9iKvgZKEzE+gNS+CGB8IgSxV4TX6hhgA+d3og vOoePFEcKqwlHGeidzb14CSq9BiKfouV7i0R1lXKkQqdBJD5JoI5VOzxHtl1M/8pP9Ux 4zLdBWGXUTEgjBwQ7IYxNLNYvhNLYjZTVmo58hBPfvjhvW/5HRDA3AXWNLKtFyUwOT2r 12vQkOhszjls4TKk4GV7uSwKhRbfE/TremwTTnBSf2ZGGwnGPdMGUjd0GeUg0dPwFXt/ HjX3IIfoabLz3NsX68TmDiurVzikd6BLjsFhZQWspsyMMviZn3tut16HCXd0BD5KujzZ MZhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :message-id:subject:from:to:cc:date:x-mailer:mime-version :x-gm-message-state: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=TUws/s33nhtehKg4FgMs7aEGVGzUFKg8uv2opBnfEZA=; b=l7604AxNfFggfqUfMZH4MxEkR9GTLGb6K0hliM5+s4gooVQbTtCcJFDWus76ZCsLpJ FWJOqAjLT8YyVRoX1YcBShYAz3vyKzSR6WiRvmri5T6ym837XmSnD4ZWSQjg9hnCzckG +aArS/bwdSUVLjeIC41/hmm+ynfcVgBoN3aAudjRK2h7jeotT6Snhe4bzTd6vYiSlIHt vUGXX/hMpP0/+Oq3SfoxhJQDsM7sr1RPMn26f9AoqFe7GXNOUsckWs0FB/OEnG+lySsr kz8cTi8v7N26pyDsRNcsGj3fGhZ5Ws5UCWTffWh6+sXebqJgww4Rh7uISWyjsepCkuKY yP0Q== X-Received: by 10.50.47.105 with SMTP id c9mr280211ign.2.1365868848463; Sat, 13 Apr 2013 09:00:48 -0700 (PDT) X-BeenThere: rtc-linux@googlegroups.com Received: by 10.50.156.198 with SMTP id wg6ls410112igb.31.canary; Sat, 13 Apr 2013 09:00:47 -0700 (PDT) X-Received: by 10.66.251.6 with SMTP id zg6mr1951320pac.28.1365868847623; Sat, 13 Apr 2013 09:00:47 -0700 (PDT) Received: from mail-da0-x22a.google.com (mail-da0-x22a.google.com [2607:f8b0:400e:c00::22a]) by gmr-mx.google.com with ESMTPS id fn10si2473221pab.1.2013.04.13.09.00.47 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Apr 2013 09:00:47 -0700 (PDT) Received-SPF: pass (google.com: domain of axel.lin@ingics.com designates 2607:f8b0:400e:c00::22a as permitted sender) client-ip=2607:f8b0:400e:c00::22a; Received: by mail-da0-f42.google.com with SMTP id n15so1516775dad.29 for ; Sat, 13 Apr 2013 09:00:47 -0700 (PDT) X-Received: by 10.68.64.161 with SMTP id p1mr20816892pbs.119.1365868847373; Sat, 13 Apr 2013 09:00:47 -0700 (PDT) Received: from [192.168.0.102] (114-40-9-162.dynamic.hinet.net. [114.40.9.162]) by mx.google.com with ESMTPS id qh4sm14320179pac.8.2013.04.13.09.00.43 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Apr 2013 09:00:45 -0700 (PDT) Message-ID: <1365868840.7445.5.camel@phoenix> Subject: [rtc-linux] [PATCH RFT] rtc: max8997: Fix bit settings for enable smpl From: Axel Lin To: Andrew Morton Cc: Jonghwa Lee , Jingoo Han , Devendra Naga , Alessandro Zummo , rtc-linux@googlegroups.com Date: Sun, 14 Apr 2013 00:00:40 +0800 X-Mailer: Evolution 3.6.2-0ubuntu0.1 Mime-Version: 1.0 X-Gm-Message-State: ALoCoQn9w6MebFiY8LgUK00PDLci4PWpXwAbvlEuTpEqiLEtPD4EV3QjoE6N3UAhTOwBLEOgyRoX X-Original-Sender: axel.lin@ingics.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of axel.lin@ingics.com designates 2607:f8b0:400e:c00::22a as permitted sender) smtp.mail=axel.lin@ingics.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: , Current code looks wrong to me because it writes 0 to SMPLT_MASK bits for both 'enable' and 'disable' cases. It looks to me that it should write (3 << SMPLT_SHIFT) to SMPLT_MASK bits when enable smpl. I think it is less error prone by setting val with: val = enable ? mask : 0; Signed-off-by: Axel Lin --- Hi, I don't have the datasheet, so I'm not really sure this patch is correct or not. I'd appreciate if someone can review and test this patch. Regards, Axel. drivers/rtc/rtc-max8997.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/rtc/rtc-max8997.c b/drivers/rtc/rtc-max8997.c index 5693619..46eeee0 100644 --- a/drivers/rtc/rtc-max8997.c +++ b/drivers/rtc/rtc-max8997.c @@ -375,12 +375,8 @@ static void max8997_rtc_enable_wtsr(struct max8997_rtc_info *info, bool enable) if (!wtsr_en) return; - if (enable) - val = (1 << WTSR_EN_SHIFT) | (3 << WTSRT_SHIFT); - else - val = 0; - mask = WTSR_EN_MASK | WTSRT_MASK; + val = enable ? mask : 0; dev_info(info->dev, "%s: %s WTSR\n", __func__, enable ? "enable" : "disable"); @@ -403,12 +399,8 @@ static void max8997_rtc_enable_smpl(struct max8997_rtc_info *info, bool enable) if (!smpl_en) return; - if (enable) - val = (1 << SMPL_EN_SHIFT) | (0 << SMPLT_SHIFT); - else - val = 0; - mask = SMPL_EN_MASK | SMPLT_MASK; + val = enable ? mask : 0; dev_info(info->dev, "%s: %s SMPL\n", __func__, enable ? "enable" : "disable");