patch-2.1.118 linux/drivers/block/z2ram.c

Next file: linux/drivers/cdrom/Makefile
Previous file: linux/drivers/block/xd.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.117/linux/drivers/block/z2ram.c linux/drivers/block/z2ram.c
@@ -63,46 +63,46 @@
 
     while ( TRUE )
     {
-        INIT_REQUEST;
+	INIT_REQUEST;
 
-        start = CURRENT->sector << 9;
-        len  = CURRENT->current_nr_sectors << 9;
+	start = CURRENT->sector << 9;
+	len  = CURRENT->current_nr_sectors << 9;
 
-        if ( ( start + len ) > z2ram_size )
-        {
-            printk( KERN_ERR DEVICE_NAME ": bad access: block=%ld, count=%ld\n",
-                CURRENT->sector,
-                CURRENT->current_nr_sectors);
-            end_request( FALSE );
-            continue;
-        }
-
-        if ( ( CURRENT->cmd != READ ) && ( CURRENT->cmd != WRITE ) )
-        {
-            printk( KERN_ERR DEVICE_NAME ": bad command: %d\n", CURRENT->cmd );
-            end_request( FALSE );
-            continue;
-        }
-
-        while ( len ) 
-        {
-            addr = start & Z2RAM_CHUNKMASK;
-            size = Z2RAM_CHUNKSIZE - addr;
-            if ( len < size )
-                size = len;
-
-            addr += z2ram_map[ start >> Z2RAM_CHUNKSHIFT ];
-
-            if ( CURRENT->cmd == READ )
-                memcpy( CURRENT->buffer, (char *)addr, size );
-            else
-                memcpy( (char *)addr, CURRENT->buffer, size );
-
-            start += size;
-            len -= size;
-        }
+	if ( ( start + len ) > z2ram_size )
+	{
+	    printk( KERN_ERR DEVICE_NAME ": bad access: block=%ld, count=%ld\n",
+		CURRENT->sector,
+		CURRENT->current_nr_sectors);
+	    end_request( FALSE );
+	    continue;
+	}
+
+	if ( ( CURRENT->cmd != READ ) && ( CURRENT->cmd != WRITE ) )
+	{
+	    printk( KERN_ERR DEVICE_NAME ": bad command: %d\n", CURRENT->cmd );
+	    end_request( FALSE );
+	    continue;
+	}
+
+	while ( len ) 
+	{
+	    addr = start & Z2RAM_CHUNKMASK;
+	    size = Z2RAM_CHUNKSIZE - addr;
+	    if ( len < size )
+		size = len;
+
+	    addr += z2ram_map[ start >> Z2RAM_CHUNKSHIFT ];
+
+	    if ( CURRENT->cmd == READ )
+		memcpy( CURRENT->buffer, (char *)addr, size );
+	    else
+		memcpy( (char *)addr, CURRENT->buffer, size );
+
+	    start += size;
+	    len -= size;
+	}
 
-        end_request( TRUE );
+	end_request( TRUE );
     }
 }
 
@@ -113,13 +113,13 @@
 
     for ( i = 0; i < Z2RAM_SIZE / Z2RAM_CHUNKSIZE; i++ )
     {
-        if ( test_bit( i, zorro_unused_z2ram ) )
-        {
-            z2_count++;
-            z2ram_map[ z2ram_size++ ] = 
-                ZTWO_VADDR( Z2RAM_START ) + ( i << Z2RAM_CHUNKSHIFT );
-            clear_bit( i, zorro_unused_z2ram );
-        }
+	if ( test_bit( i, zorro_unused_z2ram ) )
+	{
+	    z2_count++;
+	    z2ram_map[ z2ram_size++ ] = 
+		ZTWO_VADDR( Z2RAM_START ) + ( i << Z2RAM_CHUNKSHIFT );
+	    clear_bit( i, zorro_unused_z2ram );
+	}
     }
 
     return;
@@ -131,18 +131,18 @@
 
     while ( amiga_chip_avail() > ( Z2RAM_CHUNKSIZE * 4 ) )
     {
-        chip_count++;
-        z2ram_map[ z2ram_size ] =
-            (u_long)amiga_chip_alloc( Z2RAM_CHUNKSIZE );
-
-        if ( z2ram_map[ z2ram_size ] == 0 )
-        {
-            break;
-        }
+	chip_count++;
+	z2ram_map[ z2ram_size ] =
+	    (u_long)amiga_chip_alloc( Z2RAM_CHUNKSIZE );
+
+	if ( z2ram_map[ z2ram_size ] == 0 )
+	{
+	    break;
+	}
 
-        z2ram_size++;
+	z2ram_size++;
     }
-        
+	
     return;
 }
 
@@ -151,99 +151,99 @@
 {
     int device;
     int max_z2_map = ( Z2RAM_SIZE / Z2RAM_CHUNKSIZE ) *
-        sizeof( z2ram_map[0] );
+	sizeof( z2ram_map[0] );
     int max_chip_map = ( amiga_chip_size / Z2RAM_CHUNKSIZE ) *
-        sizeof( z2ram_map[0] );
+	sizeof( z2ram_map[0] );
 
     device = DEVICE_NR( inode->i_rdev );
 
     if ( current_device != -1 && current_device != device )
     {
-        return -EBUSY;
+	return -EBUSY;
     }
 
     if ( current_device == -1 )
     {
-        z2_count   = 0;
-        chip_count = 0;
-        z2ram_size = 0;
-
-        switch ( device )
-        {
-            case Z2MINOR_COMBINED:
-
-                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" );
-                    return -ENOMEM;
-                }
-
-                get_z2ram();
-                get_chipram();
-
-                if ( z2ram_size != 0 )
-                    printk( KERN_INFO DEVICE_NAME 
-                        ": 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   = 0;
+	chip_count = 0;
+	z2ram_size = 0;
+
+	switch ( device )
+	{
+	    case Z2MINOR_COMBINED:
+
+		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" );
+		    return -ENOMEM;
+		}
+
+		get_z2ram();
+		get_chipram();
+
+		if ( z2ram_size != 0 )
+		    printk( KERN_INFO DEVICE_NAME 
+			": 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 );
 
-            break;
+	    break;
 
     	    case Z2MINOR_Z2ONLY:
-                z2ram_map = kmalloc( max_z2_map, GFP_KERNEL );
-                if ( z2ram_map == NULL )
-                {
-                    printk( KERN_ERR DEVICE_NAME
-                        ": cannot get mem for z2ram_map\n" );
-                    return -ENOMEM;
-                }
-
-                get_z2ram();
-
-                if ( z2ram_size != 0 )
-                    printk( KERN_INFO DEVICE_NAME 
-                        ": using %iK of Zorro II RAM\n",
-                        z2_count * Z2RAM_CHUNK1024 );
-
-            break;
-
-            case Z2MINOR_CHIPONLY:
-                z2ram_map = kmalloc( max_chip_map, GFP_KERNEL );
-                if ( z2ram_map == NULL )
-                {
-                    printk( KERN_ERR DEVICE_NAME
-                        ": cannot get mem for z2ram_map\n" );
-                    return -ENOMEM;
-                }
-
-                get_chipram();
-
-                if ( z2ram_size != 0 )
-                    printk( KERN_INFO DEVICE_NAME 
-                        ": using %iK Chip RAM\n",
-                        chip_count * Z2RAM_CHUNK1024 );
-                    
-            break;
-
-            default:
-                return -ENODEV;
-        }
-
-        if ( z2ram_size == 0 )
-        {
-            kfree( z2ram_map );
-            printk( KERN_NOTICE DEVICE_NAME
-                ": no unused ZII/Chip RAM found\n" );
-            return -ENOMEM;
-        }
-
-        current_device = device;
-        z2ram_size <<= Z2RAM_CHUNKSHIFT;
-        z2_sizes[ device ] = z2ram_size >> 10;
-        blk_size[ MAJOR_NR ] = z2_sizes;
+		z2ram_map = kmalloc( max_z2_map, GFP_KERNEL );
+		if ( z2ram_map == NULL )
+		{
+		    printk( KERN_ERR DEVICE_NAME
+			": cannot get mem for z2ram_map\n" );
+		    return -ENOMEM;
+		}
+
+		get_z2ram();
+
+		if ( z2ram_size != 0 )
+		    printk( KERN_INFO DEVICE_NAME 
+			": using %iK of Zorro II RAM\n",
+			z2_count * Z2RAM_CHUNK1024 );
+
+	    break;
+
+	    case Z2MINOR_CHIPONLY:
+		z2ram_map = kmalloc( max_chip_map, GFP_KERNEL );
+		if ( z2ram_map == NULL )
+		{
+		    printk( KERN_ERR DEVICE_NAME
+			": cannot get mem for z2ram_map\n" );
+		    return -ENOMEM;
+		}
+
+		get_chipram();
+
+		if ( z2ram_size != 0 )
+		    printk( KERN_INFO DEVICE_NAME 
+			": using %iK Chip RAM\n",
+			chip_count * Z2RAM_CHUNK1024 );
+		    
+	    break;
+
+	    default:
+		return -ENODEV;
+	}
+
+	if ( z2ram_size == 0 )
+	{
+	    kfree( z2ram_map );
+	    printk( KERN_NOTICE DEVICE_NAME
+		": no unused ZII/Chip RAM found\n" );
+	    return -ENOMEM;
+	}
+
+	current_device = device;
+	z2ram_size <<= Z2RAM_CHUNKSHIFT;
+	z2_sizes[ device ] = z2ram_size >> 10;
+	blk_size[ MAJOR_NR ] = z2_sizes;
     }
 
 #if defined(MODULE)
@@ -258,7 +258,7 @@
 {
 
     if ( current_device == -1 )
-        return;     
+	return;     
 
     sync_dev( inode->i_rdev );
 
@@ -271,16 +271,17 @@
 
 static struct file_operations z2_fops =
 {
-        NULL,                   /* lseek - default */
-        block_read,             /* read - general block-dev read */
-        block_write,            /* write - general block-dev write */
-        NULL,                   /* readdir - bad */
-        NULL,                   /* poll */
-        NULL,                   /* ioctl */
-        NULL,                   /* mmap */
-        z2_open,                /* open */
-        z2_release,             /* release */
-        block_fsync             /* fsync */
+	NULL,                   /* lseek - default */
+	block_read,             /* read - general block-dev read */
+	block_write,            /* write - general block-dev write */
+	NULL,                   /* readdir - bad */
+	NULL,                   /* poll */
+	NULL,                   /* ioctl */
+	NULL,                   /* mmap */
+	z2_open,                /* open */
+	NULL,			/* flush */
+	z2_release,             /* release */
+	block_fsync             /* fsync */
 };
 
 __initfunc(int
@@ -288,13 +289,13 @@
 {
 
     if ( !MACH_IS_AMIGA )
-        return -ENXIO;
+	return -ENXIO;
 
     if ( register_blkdev( MAJOR_NR, DEVICE_NAME, &z2_fops ) )
     {
-        printk( KERN_ERR DEVICE_NAME ": Unable to get major %d\n",
-            MAJOR_NR );
-        return -EBUSY;
+	printk( KERN_ERR DEVICE_NAME ": Unable to get major %d\n",
+	    MAJOR_NR );
+	return -EBUSY;
     }
    
     blk_dev[ MAJOR_NR ].request_fn = DEVICE_REQUEST;
@@ -313,7 +314,7 @@
     error = z2_init();
     if ( error == 0 )
     {
-        printk( KERN_INFO DEVICE_NAME ": loaded as module\n" );
+	printk( KERN_INFO DEVICE_NAME ": loaded as module\n" );
     }
     
     return error;
@@ -325,29 +326,29 @@
     int i, j;
 
     if ( unregister_blkdev( MAJOR_NR, DEVICE_NAME ) != 0 )
-        printk( KERN_ERR DEVICE_NAME ": unregister of device failed\n");
+	printk( KERN_ERR DEVICE_NAME ": unregister of device failed\n");
 
     if ( current_device != -1 )
     {
-        i = 0;
+	i = 0;
 
-        for ( j = 0 ; j < z2_count; j++ )
-        {
-            set_bit( i++, zorro_unused_z2ram ); 
-        }
-
-        for ( j = 0 ; j < chip_count; j++ )
-        {
-            if ( z2ram_map[ i ] )
-            {
-                amiga_chip_free( (void *) z2ram_map[ i++ ] );
-            }
-        }
-
-        if ( z2ram_map != NULL )
-        {
-            kfree( z2ram_map );
-        }
+	for ( j = 0 ; j < z2_count; j++ )
+	{
+	    set_bit( i++, zorro_unused_z2ram ); 
+	}
+
+	for ( j = 0 ; j < chip_count; j++ )
+	{
+	    if ( z2ram_map[ i ] )
+	    {
+		amiga_chip_free( (void *) z2ram_map[ i++ ] );
+	    }
+	}
+
+	if ( z2ram_map != NULL )
+	{
+	    kfree( z2ram_map );
+	}
     }
 
     return;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov