1159
1159
struct mtd_file_info *mfi = file->private_data;
1160
1160
struct mtd_info *mtd = mfi->mtd;
1161
1161
struct map_info *map = mtd->priv;
1162
resource_size_t start, off;
1163
unsigned long len, vma_len;
1165
1163
/* This is broken because it assumes the MTD device is map-based
1166
1164
and that mtd->priv is a valid struct map_info. It should be
1167
1165
replaced with something that uses the mtd_get_unmapped_area()
1168
1166
operation properly. */
1169
1167
if (0 /*mtd->type == MTD_RAM || mtd->type == MTD_ROM*/) {
1170
off = get_vm_offset(vma);
1172
len = PAGE_ALIGN((start & ~PAGE_MASK) + map->size);
1174
vma_len = get_vm_size(vma);
1176
/* Overflow in off+len? */
1177
if (vma_len + off < off)
1179
/* Does it fit in the mapping? */
1180
if (vma_len + off > len)
1184
/* Did that overflow? */
1187
if (set_vm_offset(vma, off) < 0)
1189
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
1191
1168
#ifdef pgprot_noncached
1192
if (file->f_flags & O_DSYNC || off >= __pa(high_memory))
1169
if (file->f_flags & O_DSYNC || map->phys >= __pa(high_memory))
1193
1170
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
1195
if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
1196
vma->vm_end - vma->vm_start,
1172
return vm_iomap_memory(vma, map->phys, map->size);
1202
1174
return -ENOSYS;