-27
drivers/mtd/mtdchar.c
-27
drivers/mtd/mtdchar.c
···
1123
1123
}
1124
1124
#endif
1125
1125
1126
-
static inline unsigned long get_vm_size(struct vm_area_struct *vma)
1127
-
{
1128
-
return vma->vm_end - vma->vm_start;
1129
-
}
1130
-
1131
-
static inline resource_size_t get_vm_offset(struct vm_area_struct *vma)
1132
-
{
1133
-
return (resource_size_t) vma->vm_pgoff << PAGE_SHIFT;
1134
-
}
1135
-
1136
-
/*
1137
-
* Set a new vm offset.
1138
-
*
1139
-
* Verify that the incoming offset really works as a page offset,
1140
-
* and that the offset and size fit in a resource_size_t.
1141
-
*/
1142
-
static inline int set_vm_offset(struct vm_area_struct *vma, resource_size_t off)
1143
-
{
1144
-
pgoff_t pgoff = off >> PAGE_SHIFT;
1145
-
if (off != (resource_size_t) pgoff << PAGE_SHIFT)
1146
-
return -EINVAL;
1147
-
if (off + get_vm_size(vma) - 1 < off)
1148
-
return -EINVAL;
1149
-
vma->vm_pgoff = pgoff;
1150
-
return 0;
1151
-
}
1152
-
1153
1126
/*
1154
1127
* set up a mapping for shared memory segments
1155
1128
*/