Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752514AbdGDJgw (ORCPT ); Tue, 4 Jul 2017 05:36:52 -0400 Received: from smtp73.ord1c.emailsrvr.com ([108.166.43.73]:43918 "EHLO smtp73.ord1c.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752043AbdGDJgv (ORCPT ); Tue, 4 Jul 2017 05:36:51 -0400 X-Auth-ID: siepeng@mev.co.uk X-Sender-Id: siepeng@mev.co.uk Subject: Re: [PATCH] staging: comedi: Use offset_in_page macro To: Amitoj Kaur Chawla , hsweeten@visionengravers.com, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org References: <20170703231334.GA2576@amitoj-Inspiron-3542> From: Ian Abbott Message-ID: <2fd3d16e-d2ec-2fde-b4c1-fc32e659e048@mev.co.uk> Date: Tue, 4 Jul 2017 10:36:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170703231334.GA2576@amitoj-Inspiron-3542> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1530 Lines: 44 On 04/07/17 00:13, Amitoj Kaur Chawla wrote: > Use offset_in_page macro instead of (var & ~PAGE_MASK) > > The Coccinelle semantic patch used to make this change is as follows: > // > @@ > unsigned long p; > @@ > - p & ~PAGE_MASK > + offset_in_page(p) > // > > Signed-off-by: Amitoj Kaur Chawla > --- > drivers/staging/comedi/comedi_buf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c > index 8e9b30b..b455ff6 100644 > --- a/drivers/staging/comedi/comedi_buf.c > +++ b/drivers/staging/comedi/comedi_buf.c > @@ -165,7 +165,7 @@ int comedi_buf_map_put(struct comedi_buf_map *bm) > int comedi_buf_map_access(struct comedi_buf_map *bm, unsigned long offset, > void *buf, int len, int write) > { > - unsigned int pgoff = offset & ~PAGE_MASK; > + unsigned int pgoff = offset_in_page(offset); > unsigned long pg = offset >> PAGE_SHIFT; > int done = 0; > > Seems reasonable, thanks. Being picky, I'd prefer it if the line `#include ` was added, since that is where the `offset_in_page` macro is defined. But it doesn't matter that much as the "mm.h" header file gets included indirectly, and there are plenty of examples where `offset_in_page` is used without including directly. Signed-off-by: Ian Abbott -- -=( Ian Abbott @ MEV Ltd. E-mail: )=- -=( Web: http://www.mev.co.uk/ )=-