mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 04:42:12 +00:00
uio_mf624: Align memory regions to page size and set correct offsets
mf624 card has its registers not aligned to pages. Since commit
b655028795
("uio: we cannot mmap unaligned page contents") mmap()ing
mf624 registers fails, because now the uio drivers must set
uio_mem->addr to be page-aligned.
We align the address here and set the newly introduced offs field to
the offset of the mf264 registers within the page so that userspace
can find the address of the mmap()ed register by reading
/sys/class/uio/uio?/maps/map?/offset.
Tested with real mf624 card.
Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a15d2ddba9
commit
270579d95f
@ -129,11 +129,15 @@ static int mf624_irqcontrol(struct uio_info *info, s32 irq_on)
|
||||
|
||||
static int mf624_setup_mem(struct pci_dev *dev, int bar, struct uio_mem *mem, const char *name)
|
||||
{
|
||||
resource_size_t start = pci_resource_start(dev, bar);
|
||||
resource_size_t len = pci_resource_len(dev, bar);
|
||||
|
||||
mem->name = name;
|
||||
mem->addr = pci_resource_start(dev, bar);
|
||||
mem->addr = start & PAGE_MASK;
|
||||
mem->offs = start & ~PAGE_MASK;
|
||||
if (!mem->addr)
|
||||
return -ENODEV;
|
||||
mem->size = pci_resource_len(dev, bar);
|
||||
mem->size = ((start & ~PAGE_MASK) + len + PAGE_SIZE - 1) & PAGE_MASK;
|
||||
mem->memtype = UIO_MEM_PHYS;
|
||||
mem->internal_addr = pci_ioremap_bar(dev, bar);
|
||||
if (!mem->internal_addr)
|
||||
|
Loading…
Reference in New Issue
Block a user