aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew.r.wilcox@intel.com>2015-01-07 11:05:34 -0500
committerJens Axboe <axboe@fb.com>2015-01-13 23:58:11 -0500
commitdd22f551ac0ad366f92f601835f6623b83adc331 (patch)
tree47f6c4f274b3b6989869734b32afdc2e5d85769d /arch
parentc761d96b079e99d106fa4064e730ef7d0f312f9d (diff)
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 <matthew.r.wilcox@intel.com> Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Boaz Harrosh <boaz@plexistor.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/sysdev/axonram.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/arch/powerpc/sysdev/axonram.c b/arch/powerpc/sysdev/axonram.c
index f532c92bf99d..20f8afe855d1 100644
--- a/arch/powerpc/sysdev/axonram.c
+++ b/arch/powerpc/sysdev/axonram.c
@@ -139,26 +139,17 @@ axon_ram_make_request(struct request_queue *queue, struct bio *bio)
139 * axon_ram_direct_access - direct_access() method for block device 139 * axon_ram_direct_access - direct_access() method for block device
140 * @device, @sector, @data: see block_device_operations method 140 * @device, @sector, @data: see block_device_operations method
141 */ 141 */
142static int 142static long
143axon_ram_direct_access(struct block_device *device, sector_t sector, 143axon_ram_direct_access(struct block_device *device, sector_t sector,
144 void **kaddr, unsigned long *pfn) 144 void **kaddr, unsigned long *pfn, long size)
145{ 145{
146 struct axon_ram_bank *bank = device->bd_disk->private_data; 146 struct axon_ram_bank *bank = device->bd_disk->private_data;
147 loff_t offset; 147 loff_t offset = (loff_t)sector << AXON_RAM_SECTOR_SHIFT;
148
149 offset = sector;
150 if (device->bd_part != NULL)
151 offset += device->bd_part->start_sect;
152 offset <<= AXON_RAM_SECTOR_SHIFT;
153 if (offset >= bank->size) {
154 dev_err(&bank->device->dev, "Access outside of address space\n");
155 return -ERANGE;
156 }
157 148
158 *kaddr = (void *)(bank->ph_addr + offset); 149 *kaddr = (void *)(bank->ph_addr + offset);
159 *pfn = virt_to_phys(kaddr) >> PAGE_SHIFT; 150 *pfn = virt_to_phys(kaddr) >> PAGE_SHIFT;
160 151
161 return 0; 152 return bank->size - offset;
162} 153}
163 154
164static const struct block_device_operations axon_ram_devops = { 155static const struct block_device_operations axon_ram_devops = {