Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1680614 > unrolled thread
| Started by | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| First post | 2017-07-04 01:20 +0200 |
| Last post | 2017-07-04 11:40 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] staging: comedi: Use offset_in_page macro Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2017-07-04 01:20 +0200
Re: [PATCH] staging: comedi: Use offset_in_page macro Ian Abbott <abbotti@mev.co.uk> - 2017-07-04 11:40 +0200
| From | Amitoj Kaur Chawla <amitoj1606@gmail.com> |
|---|---|
| Date | 2017-07-04 01:20 +0200 |
| Subject | [PATCH] staging: comedi: Use offset_in_page macro |
| Message-ID | <tZiNk-8jY-5@gated-at.bofh.it> |
Use offset_in_page macro instead of (var & ~PAGE_MASK)
The Coccinelle semantic patch used to make this change is as follows:
// <smpl>
@@
unsigned long p;
@@
- p & ~PAGE_MASK
+ offset_in_page(p)
// </smpl>
Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
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;
--
2.7.4
[toc] | [next] | [standalone]
| From | Ian Abbott <abbotti@mev.co.uk> |
|---|---|
| Date | 2017-07-04 11:40 +0200 |
| Message-ID | <tZstk-6qV-31@gated-at.bofh.it> |
| In reply to | #1680614 |
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:
> // <smpl>
> @@
> unsigned long p;
> @@
> - p & ~PAGE_MASK
> + offset_in_page(p)
> // </smpl>
>
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
> 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 <linux/mm.h>` 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 <linux/mm.h>
directly.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web