Loading drivers/block/z2ram.c +236 −257 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ #include <linux/zorro.h> #define Z2MINOR_COMBINED (0) #define Z2MINOR_Z2ONLY (1) #define Z2MINOR_CHIPONLY (2) Loading Loading @@ -106,17 +105,15 @@ static blk_status_t z2_queue_rq(struct blk_mq_hw_ctx *hctx, return BLK_STS_OK; } static void get_z2ram( void ) static void get_z2ram(void) { int i; for ( i = 0; i < Z2RAM_SIZE / Z2RAM_CHUNKSIZE; i++ ) { if ( test_bit( i, zorro_unused_z2ram ) ) { for (i = 0; i < Z2RAM_SIZE / Z2RAM_CHUNKSIZE; i++) { if (test_bit(i, zorro_unused_z2ram)) { z2_count++; z2ram_map[z2ram_size++] = (unsigned long)ZTWO_VADDR(Z2RAM_START) + z2ram_map[z2ram_size++] = (unsigned long)ZTWO_VADDR(Z2RAM_START) + (i << Z2RAM_CHUNKSHIFT); clear_bit(i, zorro_unused_z2ram); } Loading @@ -125,18 +122,15 @@ get_z2ram( void ) return; } static void get_chipram( void ) static void get_chipram(void) { while ( amiga_chip_avail() > ( Z2RAM_CHUNKSIZE * 4 ) ) { while (amiga_chip_avail() > (Z2RAM_CHUNKSIZE * 4)) { chip_count++; z2ram_map[z2ram_size] = (u_long) amiga_chip_alloc(Z2RAM_CHUNKSIZE, "z2ram"); if ( z2ram_map[ z2ram_size ] == 0 ) { if (z2ram_map[z2ram_size] == 0) { break; } Loading @@ -149,8 +143,7 @@ get_chipram( void ) static int z2_open(struct block_device *bdev, fmode_t mode) { int device; int max_z2_map = ( Z2RAM_SIZE / Z2RAM_CHUNKSIZE ) * sizeof( z2ram_map[0] ); int max_z2_map = (Z2RAM_SIZE / Z2RAM_CHUNKSIZE) * sizeof(z2ram_map[0]); int max_chip_map = (amiga_chip_size / Z2RAM_CHUNKSIZE) * sizeof(z2ram_map[0]); int rc = -ENOMEM; Loading @@ -158,14 +151,12 @@ static int z2_open(struct block_device *bdev, fmode_t mode) device = MINOR(bdev->bd_dev); mutex_lock(&z2ram_mutex); if ( current_device != -1 && current_device != device ) { if (current_device != -1 && current_device != device) { rc = -EBUSY; goto err_out; } if ( current_device == -1 ) { if (current_device == -1) { z2_count = 0; chip_count = 0; list_count = 0; Loading Loading @@ -194,14 +185,13 @@ static int z2_open(struct block_device *bdev, fmode_t mode) vaddr = (unsigned long)ioremap_wt(paddr, size); #else vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size); vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size); #endif z2ram_map = kmalloc_array(size / Z2RAM_CHUNKSIZE, sizeof(z2ram_map[0]), GFP_KERNEL); if ( z2ram_map == NULL ) { sizeof(z2ram_map[0]), GFP_KERNEL); if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); goto err_out; Loading @@ -219,14 +209,13 @@ static int z2_open(struct block_device *bdev, fmode_t mode) ": using %iK List Entry %d Memory\n", list_count * Z2RAM_CHUNK1024, index); } else switch ( device ) { switch (device) { case Z2MINOR_COMBINED: z2ram_map = kmalloc( max_z2_map + max_chip_map, GFP_KERNEL ); if ( z2ram_map == NULL ) { z2ram_map = kmalloc(max_z2_map + max_chip_map, GFP_KERNEL); if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); goto err_out; Loading @@ -240,14 +229,14 @@ static int z2_open(struct block_device *bdev, fmode_t mode) ": using %iK Zorro II RAM and %iK Chip RAM (Total %dK)\n", z2_count * Z2RAM_CHUNK1024, chip_count * Z2RAM_CHUNK1024, ( z2_count + chip_count ) * Z2RAM_CHUNK1024 ); (z2_count + chip_count) * Z2RAM_CHUNK1024); break; case Z2MINOR_Z2ONLY: z2ram_map = kmalloc(max_z2_map, GFP_KERNEL); if ( z2ram_map == NULL ) { if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); goto err_out; Loading @@ -264,8 +253,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode) case Z2MINOR_CHIPONLY: z2ram_map = kmalloc(max_chip_map, GFP_KERNEL); if ( z2ram_map == NULL ) { if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); goto err_out; Loading @@ -287,8 +275,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode) break; } if ( z2ram_size == 0 ) { if (z2ram_size == 0) { printk(KERN_NOTICE DEVICE_NAME ": no unused ZII/Chip RAM found\n"); goto err_out_kfree; Loading @@ -309,8 +296,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode) return rc; } static void z2_release(struct gendisk *disk, fmode_t mode) static void z2_release(struct gendisk *disk, fmode_t mode) { mutex_lock(&z2ram_mutex); if (current_device == -1) { Loading @@ -323,8 +309,7 @@ z2_release(struct gendisk *disk, fmode_t mode) */ } static const struct block_device_operations z2_fops = { static const struct block_device_operations z2_fops = { .owner = THIS_MODULE, .open = z2_open, .release = z2_release, Loading @@ -343,8 +328,7 @@ static const struct blk_mq_ops z2_mq_ops = { .queue_rq = z2_queue_rq, }; static int __init z2_init(void) static int __init z2_init(void) { int ret; Loading Loading @@ -398,25 +382,20 @@ static void __exit z2_exit(void) blk_cleanup_queue(z2_queue); blk_mq_free_tag_set(&tag_set); if ( current_device != -1 ) { if (current_device != -1) { i = 0; for ( j = 0 ; j < z2_count; j++ ) { for (j = 0; j < z2_count; j++) { set_bit(i++, zorro_unused_z2ram); } for ( j = 0 ; j < chip_count; j++ ) { if ( z2ram_map[ i ] ) { for (j = 0; j < chip_count; j++) { if (z2ram_map[i]) { amiga_chip_free((void *)z2ram_map[i++]); } } if ( z2ram_map != NULL ) { if (z2ram_map != NULL) { kfree(z2ram_map); } } Loading Loading
drivers/block/z2ram.c +236 −257 Original line number Diff line number Diff line Loading @@ -42,7 +42,6 @@ #include <linux/zorro.h> #define Z2MINOR_COMBINED (0) #define Z2MINOR_Z2ONLY (1) #define Z2MINOR_CHIPONLY (2) Loading Loading @@ -106,17 +105,15 @@ static blk_status_t z2_queue_rq(struct blk_mq_hw_ctx *hctx, return BLK_STS_OK; } static void get_z2ram( void ) static void get_z2ram(void) { int i; for ( i = 0; i < Z2RAM_SIZE / Z2RAM_CHUNKSIZE; i++ ) { if ( test_bit( i, zorro_unused_z2ram ) ) { for (i = 0; i < Z2RAM_SIZE / Z2RAM_CHUNKSIZE; i++) { if (test_bit(i, zorro_unused_z2ram)) { z2_count++; z2ram_map[z2ram_size++] = (unsigned long)ZTWO_VADDR(Z2RAM_START) + z2ram_map[z2ram_size++] = (unsigned long)ZTWO_VADDR(Z2RAM_START) + (i << Z2RAM_CHUNKSHIFT); clear_bit(i, zorro_unused_z2ram); } Loading @@ -125,18 +122,15 @@ get_z2ram( void ) return; } static void get_chipram( void ) static void get_chipram(void) { while ( amiga_chip_avail() > ( Z2RAM_CHUNKSIZE * 4 ) ) { while (amiga_chip_avail() > (Z2RAM_CHUNKSIZE * 4)) { chip_count++; z2ram_map[z2ram_size] = (u_long) amiga_chip_alloc(Z2RAM_CHUNKSIZE, "z2ram"); if ( z2ram_map[ z2ram_size ] == 0 ) { if (z2ram_map[z2ram_size] == 0) { break; } Loading @@ -149,8 +143,7 @@ get_chipram( void ) static int z2_open(struct block_device *bdev, fmode_t mode) { int device; int max_z2_map = ( Z2RAM_SIZE / Z2RAM_CHUNKSIZE ) * sizeof( z2ram_map[0] ); int max_z2_map = (Z2RAM_SIZE / Z2RAM_CHUNKSIZE) * sizeof(z2ram_map[0]); int max_chip_map = (amiga_chip_size / Z2RAM_CHUNKSIZE) * sizeof(z2ram_map[0]); int rc = -ENOMEM; Loading @@ -158,14 +151,12 @@ static int z2_open(struct block_device *bdev, fmode_t mode) device = MINOR(bdev->bd_dev); mutex_lock(&z2ram_mutex); if ( current_device != -1 && current_device != device ) { if (current_device != -1 && current_device != device) { rc = -EBUSY; goto err_out; } if ( current_device == -1 ) { if (current_device == -1) { z2_count = 0; chip_count = 0; list_count = 0; Loading Loading @@ -194,14 +185,13 @@ static int z2_open(struct block_device *bdev, fmode_t mode) vaddr = (unsigned long)ioremap_wt(paddr, size); #else vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size); vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size); #endif z2ram_map = kmalloc_array(size / Z2RAM_CHUNKSIZE, sizeof(z2ram_map[0]), GFP_KERNEL); if ( z2ram_map == NULL ) { sizeof(z2ram_map[0]), GFP_KERNEL); if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); goto err_out; Loading @@ -219,14 +209,13 @@ static int z2_open(struct block_device *bdev, fmode_t mode) ": using %iK List Entry %d Memory\n", list_count * Z2RAM_CHUNK1024, index); } else switch ( device ) { switch (device) { case Z2MINOR_COMBINED: z2ram_map = kmalloc( max_z2_map + max_chip_map, GFP_KERNEL ); if ( z2ram_map == NULL ) { z2ram_map = kmalloc(max_z2_map + max_chip_map, GFP_KERNEL); if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); goto err_out; Loading @@ -240,14 +229,14 @@ static int z2_open(struct block_device *bdev, fmode_t mode) ": using %iK Zorro II RAM and %iK Chip RAM (Total %dK)\n", z2_count * Z2RAM_CHUNK1024, chip_count * Z2RAM_CHUNK1024, ( z2_count + chip_count ) * Z2RAM_CHUNK1024 ); (z2_count + chip_count) * Z2RAM_CHUNK1024); break; case Z2MINOR_Z2ONLY: z2ram_map = kmalloc(max_z2_map, GFP_KERNEL); if ( z2ram_map == NULL ) { if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); goto err_out; Loading @@ -264,8 +253,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode) case Z2MINOR_CHIPONLY: z2ram_map = kmalloc(max_chip_map, GFP_KERNEL); if ( z2ram_map == NULL ) { if (z2ram_map == NULL) { printk(KERN_ERR DEVICE_NAME ": cannot get mem for z2ram_map\n"); goto err_out; Loading @@ -287,8 +275,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode) break; } if ( z2ram_size == 0 ) { if (z2ram_size == 0) { printk(KERN_NOTICE DEVICE_NAME ": no unused ZII/Chip RAM found\n"); goto err_out_kfree; Loading @@ -309,8 +296,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode) return rc; } static void z2_release(struct gendisk *disk, fmode_t mode) static void z2_release(struct gendisk *disk, fmode_t mode) { mutex_lock(&z2ram_mutex); if (current_device == -1) { Loading @@ -323,8 +309,7 @@ z2_release(struct gendisk *disk, fmode_t mode) */ } static const struct block_device_operations z2_fops = { static const struct block_device_operations z2_fops = { .owner = THIS_MODULE, .open = z2_open, .release = z2_release, Loading @@ -343,8 +328,7 @@ static const struct blk_mq_ops z2_mq_ops = { .queue_rq = z2_queue_rq, }; static int __init z2_init(void) static int __init z2_init(void) { int ret; Loading Loading @@ -398,25 +382,20 @@ static void __exit z2_exit(void) blk_cleanup_queue(z2_queue); blk_mq_free_tag_set(&tag_set); if ( current_device != -1 ) { if (current_device != -1) { i = 0; for ( j = 0 ; j < z2_count; j++ ) { for (j = 0; j < z2_count; j++) { set_bit(i++, zorro_unused_z2ram); } for ( j = 0 ; j < chip_count; j++ ) { if ( z2ram_map[ i ] ) { for (j = 0; j < chip_count; j++) { if (z2ram_map[i]) { amiga_chip_free((void *)z2ram_map[i++]); } } if ( z2ram_map != NULL ) { if (z2ram_map != NULL) { kfree(z2ram_map); } } Loading