314static ssize_t
315__xip_file_write(struct file *filp, const char __user *buf,
316 size_t count, loff_t pos, loff_t *ppos)
317{
318 struct address_space * mapping = filp->f_mapping;
319 const struct address_space_operations *a_ops = mapping->a_ops;
320 struct inode *inode = mapping->host;
321 long status = 0;
322 size_t bytes;
323 ssize_t written = 0;
324
325 BUG_ON(!mapping->a_ops->get_xip_mem);
326
327 do {
328 unsigned long index;
329 unsigned long offset;
330 size_t copied;
331 void *xip_mem;
332 unsigned long xip_pfn;
333
334 offset = (pos & (PAGE_CACHE_SIZE -1));
335 index = pos >> PAGE_CACHE_SHIFT;
336 bytes = PAGE_CACHE_SIZE - offset;
337 if (bytes > count)
338 bytes = count;
339
340 status = a_ops->get_xip_mem(mapping, index, 0,
341 &xip_mem, &xip_pfn);
342 if (status == -ENODATA) {
343
344 mutex_lock(&xip_sparse_mutex);
345 status = a_ops->get_xip_mem(mapping, index, 1,
346 &xip_mem, &xip_pfn);
347 mutex_unlock(&xip_sparse_mutex);
348 if (!status)
349
350 __xip_unmap(mapping, index);
351 }
352
353 if (status)
354 break;