Skip to content

Commit a66bd75

Browse files
tititiou36torvalds
authored andcommitted
watch_queue: Use the bitmap API when applicable
Use bitmap_alloc() to simplify code, improve the semantic and reduce some open-coded arithmetic in allocator arguments. Also change a memset(0xff) into an equivalent bitmap_fill() to keep consistency. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 96a4d89 commit a66bd75

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

kernel/watch_queue.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
220220
struct page **pages;
221221
unsigned long *bitmap;
222222
unsigned long user_bufs;
223-
unsigned int bmsize;
224223
int ret, i, nr_pages;
225224

226225
if (!wqueue)
@@ -259,13 +258,11 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
259258
pages[i]->index = i * WATCH_QUEUE_NOTES_PER_PAGE;
260259
}
261260

262-
bmsize = (nr_notes + BITS_PER_LONG - 1) / BITS_PER_LONG;
263-
bmsize *= sizeof(unsigned long);
264-
bitmap = kmalloc(bmsize, GFP_KERNEL);
261+
bitmap = bitmap_alloc(nr_notes, GFP_KERNEL);
265262
if (!bitmap)
266263
goto error_p;
267264

268-
memset(bitmap, 0xff, bmsize);
265+
bitmap_fill(bitmap, nr_notes);
269266
wqueue->notes = pages;
270267
wqueue->notes_bitmap = bitmap;
271268
wqueue->nr_pages = nr_pages;

0 commit comments

Comments
 (0)