Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 126631
b: refs/heads/master
c: ea0a337
h: refs/heads/master
i:
  126629: 6192545
  126627: ca01c89
  126623: 6040c77
v: v3
  • Loading branch information
Vijay Kumar authored and Greg Kroah-Hartman committed Jan 6, 2009
1 parent 89644dd commit 2fac7db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ee49abcf167856fb2020525b332a6adbb55d1957
refs/heads/master: ea0a337f34ddd95ca833a7b152ad55a1360b3101
22 changes: 14 additions & 8 deletions trunk/drivers/staging/poch/poch.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ static ssize_t show_direction(struct device *dev,
}
static DEVICE_ATTR(dir, S_IRUSR|S_IRGRP, show_direction, NULL);

static unsigned long npages(unsigned long bytes)
{
if (bytes % PAGE_SIZE == 0)
return bytes / PAGE_SIZE;
else
return (bytes / PAGE_SIZE) + 1;
}

static ssize_t show_mmap_size(struct device *dev,
struct device_attribute *attr, char *buf)
{
Expand All @@ -309,10 +317,8 @@ static ssize_t show_mmap_size(struct device *dev,
unsigned long header_pages;
unsigned long total_group_pages;

/* FIXME: We do not have to add 1, if group_size a multiple of
PAGE_SIZE. */
group_pages = (channel->group_size / PAGE_SIZE) + 1;
header_pages = (channel->header_size / PAGE_SIZE) + 1;
group_pages = npages(channel->group_size);
header_pages = npages(channel->header_size);
total_group_pages = group_pages * channel->group_count;

mmap_size = (header_pages + total_group_pages) * PAGE_SIZE;
Expand Down Expand Up @@ -350,8 +356,8 @@ static int poch_channel_alloc_groups(struct channel_info *channel)
unsigned long group_pages;
unsigned long header_pages;

group_pages = (channel->group_size / PAGE_SIZE) + 1;
header_pages = (channel->header_size / PAGE_SIZE) + 1;
group_pages = npages(channel->group_size);
header_pages = npages(channel->header_size);

for (i = 0; i < channel->group_count; i++) {
struct poch_group_info *group;
Expand Down Expand Up @@ -850,8 +856,8 @@ static int poch_mmap(struct file *filp, struct vm_area_struct *vma)
return -EINVAL;
}

group_pages = (channel->group_size / PAGE_SIZE) + 1;
header_pages = (channel->header_size / PAGE_SIZE) + 1;
group_pages = npages(channel->group_size);
header_pages = npages(channel->header_size);
total_group_pages = group_pages * channel->group_count;

size = vma->vm_end - vma->vm_start;
Expand Down

0 comments on commit 2fac7db

Please sign in to comment.