mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
block: Change direct_access calling convention
In order to support accesses to larger chunks of memory, pass in a 'size' parameter (counted in bytes), and return the amount available at that address. Add a new helper function, bdev_direct_access(), to handle common functionality including partition handling, checking the length requested is positive, checking for the sector being page-aligned, and checking the length of the request does not pass the end of the partition. Signed-off-by: Matthew Wilcox <[email protected]> Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Boaz Harrosh <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
c761d96b07
commit
dd22f551ac
7 changed files with 86 additions and 58 deletions
|
|
@ -28,8 +28,8 @@
|
|||
static int dcssblk_open(struct block_device *bdev, fmode_t mode);
|
||||
static void dcssblk_release(struct gendisk *disk, fmode_t mode);
|
||||
static void dcssblk_make_request(struct request_queue *q, struct bio *bio);
|
||||
static int dcssblk_direct_access(struct block_device *bdev, sector_t secnum,
|
||||
void **kaddr, unsigned long *pfn);
|
||||
static long dcssblk_direct_access(struct block_device *bdev, sector_t secnum,
|
||||
void **kaddr, unsigned long *pfn, long size);
|
||||
|
||||
static char dcssblk_segments[DCSSBLK_PARM_LEN] = "\0";
|
||||
|
||||
|
|
@ -866,25 +866,22 @@ fail:
|
|||
bio_io_error(bio);
|
||||
}
|
||||
|
||||
static int
|
||||
static long
|
||||
dcssblk_direct_access (struct block_device *bdev, sector_t secnum,
|
||||
void **kaddr, unsigned long *pfn)
|
||||
void **kaddr, unsigned long *pfn, long size)
|
||||
{
|
||||
struct dcssblk_dev_info *dev_info;
|
||||
unsigned long pgoff;
|
||||
unsigned long offset, dev_sz;
|
||||
|
||||
dev_info = bdev->bd_disk->private_data;
|
||||
if (!dev_info)
|
||||
return -ENODEV;
|
||||
if (secnum % (PAGE_SIZE/512))
|
||||
return -EINVAL;
|
||||
pgoff = secnum / (PAGE_SIZE / 512);
|
||||
if ((pgoff+1)*PAGE_SIZE-1 > dev_info->end - dev_info->start)
|
||||
return -ERANGE;
|
||||
*kaddr = (void *) (dev_info->start+pgoff*PAGE_SIZE);
|
||||
dev_sz = dev_info->end - dev_info->start;
|
||||
offset = secnum * 512;
|
||||
*kaddr = (void *) (dev_info->start + offset);
|
||||
*pfn = virt_to_phys(*kaddr) >> PAGE_SHIFT;
|
||||
|
||||
return 0;
|
||||
return dev_sz - offset;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Reference in a new issue