From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Sender: rtc-linux@googlegroups.com Received: from mail.free-electrons.com (down.free-electrons.com. [37.187.137.238]) by gmr-mx.google.com with ESMTP id e78si115160wmc.3.2016.04.19.15.44.44 for ; Tue, 19 Apr 2016 15:44:44 -0700 (PDT) Date: Wed, 20 Apr 2016 00:44:43 +0200 From: Alexandre Belloni To: Martin Kepplinger Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: [rtc-linux] Re: [PATCH] rtc-pcf2123: use sign_extend32() for sign extension Message-ID: <20160419224443.GI29844@piout.net> References: <1460974664-7525-1-git-send-email-martink@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 In-Reply-To: <1460974664-7525-1-git-send-email-martink@posteo.de> Reply-To: rtc-linux@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Please always include a commit message else, I'm fine with the patch. On 18/04/2016 at 12:17:44 +0200, Martin Kepplinger wrote : > Signed-off-by: Martin Kepplinger > --- > drivers/rtc/rtc-pcf2123.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c > index f22e060..b4478cc 100644 > --- a/drivers/rtc/rtc-pcf2123.c > +++ b/drivers/rtc/rtc-pcf2123.c > @@ -96,7 +96,7 @@ > #define CD_TMR_TE BIT(3) /* Countdown timer enable */ > > /* PCF2123_REG_OFFSET BITS */ > -#define OFFSET_SIGN_BIT BIT(6) /* 2's complement sign bit */ > +#define OFFSET_SIGN_BIT 6 /* 2's complement sign bit */ > #define OFFSET_COARSE BIT(7) /* Coarse mode offset */ > #define OFFSET_STEP (2170) /* Offset step in parts per billion */ > > @@ -217,7 +217,7 @@ static int pcf2123_read_offset(struct device *dev, long *offset) > if (reg & OFFSET_COARSE) > reg <<= 1; /* multiply by 2 and sign extend */ > else > - reg |= (reg & OFFSET_SIGN_BIT) << 1; /* sign extend only */ > + reg = sign_extend32(reg, OFFSET_SIGN_BIT); > > *offset = ((long)reg) * OFFSET_STEP; > > -- > 2.1.4 > -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- -- You received this message because you are subscribed to "rtc-linux". Membership options at http://groups.google.com/group/rtc-linux . Please read http://groups.google.com/group/rtc-linux/web/checklist before submitting a driver. --- You received this message because you are subscribed to the Google Groups "rtc-linux" group. To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/d/optout. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752091AbcDSWor (ORCPT ); Tue, 19 Apr 2016 18:44:47 -0400 Received: from down.free-electrons.com ([37.187.137.238]:38630 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750903AbcDSWoq (ORCPT ); Tue, 19 Apr 2016 18:44:46 -0400 Date: Wed, 20 Apr 2016 00:44:43 +0200 From: Alexandre Belloni To: Martin Kepplinger Cc: a.zummo@towertech.it, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] rtc-pcf2123: use sign_extend32() for sign extension Message-ID: <20160419224443.GI29844@piout.net> References: <1460974664-7525-1-git-send-email-martink@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460974664-7525-1-git-send-email-martink@posteo.de> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Please always include a commit message else, I'm fine with the patch. On 18/04/2016 at 12:17:44 +0200, Martin Kepplinger wrote : > Signed-off-by: Martin Kepplinger > --- > drivers/rtc/rtc-pcf2123.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/rtc/rtc-pcf2123.c b/drivers/rtc/rtc-pcf2123.c > index f22e060..b4478cc 100644 > --- a/drivers/rtc/rtc-pcf2123.c > +++ b/drivers/rtc/rtc-pcf2123.c > @@ -96,7 +96,7 @@ > #define CD_TMR_TE BIT(3) /* Countdown timer enable */ > > /* PCF2123_REG_OFFSET BITS */ > -#define OFFSET_SIGN_BIT BIT(6) /* 2's complement sign bit */ > +#define OFFSET_SIGN_BIT 6 /* 2's complement sign bit */ > #define OFFSET_COARSE BIT(7) /* Coarse mode offset */ > #define OFFSET_STEP (2170) /* Offset step in parts per billion */ > > @@ -217,7 +217,7 @@ static int pcf2123_read_offset(struct device *dev, long *offset) > if (reg & OFFSET_COARSE) > reg <<= 1; /* multiply by 2 and sign extend */ > else > - reg |= (reg & OFFSET_SIGN_BIT) << 1; /* sign extend only */ > + reg = sign_extend32(reg, OFFSET_SIGN_BIT); > > *offset = ((long)reg) * OFFSET_STEP; > > -- > 2.1.4 > -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com