patch-2.2.0-pre6 linux/drivers/cdrom/sonycd535.c

Next file: linux/drivers/char/README.epca
Previous file: linux/drivers/cdrom/cdrom.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.0-pre5/linux/drivers/cdrom/sonycd535.c linux/drivers/cdrom/sonycd535.c
@@ -151,6 +151,8 @@
 # define CDU535_MESSAGE_NAME	"Sony CDU-535"
 #endif
 
+#define CDU535_BLOCK_SIZE	2048 
+ 
 #ifndef MAX_SPINUP_RETRY
 # define MAX_SPINUP_RETRY		3	/* 1 is sufficient for most drives... */
 #endif
@@ -591,7 +593,6 @@
 seek_and_read_N_blocks(Byte params[], int n_blocks, Byte status[2],
 					   Byte **buff, int buf_size)
 {
-	const int block_size = 2048;
 	Byte cmd_buff[7];
 	int  i;
 	int  read_status;
@@ -599,7 +600,7 @@
 	Byte *data_buff;
 	int  sector_count = 0;
 
-	if (buf_size < ((long)block_size) * n_blocks)
+	if (buf_size < CDU535_BLOCK_SIZE * n_blocks)
 		return NO_ROOM;
 
 	set_drive_mode(SONY535_CDROM_DRIVE_MODE, status);
@@ -625,7 +626,7 @@
 			if ((read_status & SONY535_DATA_NOT_READY_BIT) == 0) {
 				/* data is ready, read it */
 				data_buff = buff[sector_count++];
-				for (i = 0; i < block_size; i++)
+				for (i = 0; i < CDU535_BLOCK_SIZE; i++)
 					*data_buff++ = inb(data_reg);	/* unrolling this loop does not seem to help */
 				data_valid = 1;
 				break;			/* exit the timeout loop */
@@ -639,7 +640,7 @@
 	/* read all the data, now read the status */
 	if ((i = read_exec_status(status)) != 0)
 		return i;
-	return block_size * sector_count;
+	return CDU535_BLOCK_SIZE * sector_count;
 }	/* seek_and_read_N_blocks() */
 
 /****************************************************************************
@@ -776,7 +777,7 @@
  * The OS calls this to perform a read or write operation to the drive.
  * Write obviously fail.  Reads to a read ahead of sony_buffer_size
  * bytes to help speed operations.  This especially helps since the OS
- * uses 1024 byte blocks and the drive uses 2048 byte blocks.  Since most
+ * may use 1024 byte blocks and the drive uses 2048 byte blocks.  Since most
  * data access on a CD is done sequentially, this saves a lot of operations.
  */
 static void
@@ -873,7 +874,7 @@
 						 * seek_and_read_N_blocks for the various cases.
 						 */
 						int readStatus = seek_and_read_N_blocks(params, read_size,
-									status, sony_buffer, (read_size * 2048));
+									status, sony_buffer, (read_size * CDU535_BLOCK_SIZE));
 						if (0 <= readStatus)	/* Good data; common case, placed first */
 							break;
 						if (readStatus == NO_ROOM || spin_up_retry == MAX_SPINUP_RETRY) {
@@ -1480,6 +1481,8 @@
 	NULL						/* revalidate */
 };
 
+static int sonycd535_block_size = CDU535_BLOCK_SIZE;
+
 /*
  * Initialize the driver.
  */
@@ -1580,7 +1583,7 @@
 			if (do_sony_cmd(cmd_buff, 2, status, ret_buff, 1, 1) == 0) {
 				/* set the drive mode successful, we are set! */
 				sony_buffer_size = SONY535_BUFFER_SIZE;
-				sony_buffer_sectors = sony_buffer_size / 2048;
+				sony_buffer_sectors = sony_buffer_size / CDU535_BLOCK_SIZE;
 
 				printk(KERN_INFO CDU535_MESSAGE_NAME " I/F CDROM : %8.8s %16.16s %4.4s",
 					   drive_config.vendor_id,
@@ -1597,6 +1600,7 @@
 					return -EIO;
 				}
 				blk_dev[MAJOR_NR].request_fn = DEVICE_REQUEST;
+				blksize_size[MAJOR_NR] = &sonycd535_block_size;
 				read_ahead[MAJOR_NR] = 8;	/* 8 sector (4kB) read-ahead */
 
 				sony_toc = (struct s535_sony_toc *)
@@ -1617,7 +1621,8 @@
 					return -ENOMEM;
 				}
 				for (i = 0; i < sony_buffer_sectors; i++) {
-					sony_buffer[i] = (Byte *)kmalloc(2048, GFP_KERNEL);
+					sony_buffer[i] =
+								(Byte *)kmalloc(CDU535_BLOCK_SIZE, GFP_KERNEL);
 					if (sony_buffer[i] == NULL) {
 						while (--i>=0)
 							kfree(sony_buffer[i]);
@@ -1680,7 +1685,7 @@
 
 	release_region(sony535_cd_base_io, 4);
 	for (i = 0; i < sony_buffer_sectors; i++)
-		kfree_s(sony_buffer[i], 2048);
+		kfree_s(sony_buffer[i], CDU535_BLOCK_SIZE);
 	kfree_s(sony_buffer, 4 * sony_buffer_sectors);
 	kfree_s(last_sony_subcode, sizeof *last_sony_subcode);
 	kfree_s(sony_toc, sizeof *sony_toc);

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