cleanup
PATCH 1/1 cleanup
Recently I saw someone who estimated the value of all Linux source code by counting source code lines. This patch lowers that estimate. No behaviour is changed (intentionally).
Andries
linux/drivers/scsi/tmscsim.c renamed from linux-2.4.6-pre9/linux/drivers/scsi/tmscsim.c +25 -110
@@ -1350,84 +1350,7 @@return (0 ); } -/* We ignore mapping problems, as we expect everybody to respect -* valid partition tables. Waiting for complaints ;-) */ -#ifdef CONFIG_SCSI_DC390T_TRADMAP -/* -* The next function, partsize(), is copied from scsicam.c. -* -* This is ugly code duplication, but I didn't find another way to solve it: -* We want to respect the partition table and if it fails, we apply the -* DC390 BIOS heuristic. Too bad, just calling scsicam_bios_param() doesn't do -* the job, because we don't know, whether the values returned are from -* the part. table or determined by setsize(). Unfortunately the setsize() -* values differ from the ones chosen by the DC390 BIOS. -* -* Looking forward to seeing suggestions for a better solution! KG, 98/10/14 -*/ -#include <asm/unaligned.h> - -/* -* Function : static int partsize(struct buffer_head *bh, unsigned long -* capacity,unsigned int *cyls, unsigned int *hds, unsigned int *secs); -* -* Purpose : to determine the BIOS mapping used to create the partition -* table, storing the results in *cyls, *hds, and *secs -* -* Returns : -1 on failure, 0 on success. -* -*/ - -static int partsize (struct buffer_head *bh,unsigned long capacity, -unsigned int *cyls,unsigned int *hds,unsigned int *secs) { -struct partition *p, *largest =NULL ; -int i, largest_cyl; -int cyl, ext_cyl, end_head, end_cyl, end_sector; -unsigned int logical_end, physical_end, ext_physical_end; - - -if (*(unsigned short *) (bh->b_data+510 ) ==0xAA55 ) { -for (largest_cyl =-1 , p = (struct partition *) - (0x1BE + bh->b_data), i =0 ; i <4 ; ++i, ++p) { -if (!p->sys_ind) -continue ; - cyl = p->cyl + ((p->sector &0xc0 ) <<2 ); -if (cyl > largest_cyl) { - largest_cyl = cyl; - largest = p; - } - } - } - -if (largest) { - end_cyl = largest->end_cyl + ((largest->end_sector &0xc0 ) <<2 ); - end_head = largest->end_head; - end_sector = largest->end_sector &0x3f ; - - physical_end = end_cyl * (end_head +1 ) * end_sector + - end_head * end_sector + end_sector; - -/* This is the actual _sector_ number at the end */ - logical_end =get_unaligned (&largest->start_sect) - +get_unaligned (&largest->nr_sects); - -/* This is for >1023 cylinders */ - ext_cyl= (logical_end-(end_head * end_sector + end_sector)) - /(end_head +1 ) / end_sector; - ext_physical_end = ext_cyl * (end_head +1 ) * end_sector + - end_head * end_sector + end_sector; - -if ((logical_end == physical_end) || - (end_cyl==1023 && ext_physical_end==logical_end)) { - *secs = end_sector; - *hds = end_head +1 ; - *cyls = capacity / ((end_head +1 ) * end_sector); -return 0 ; - } - } -return -1 ; -}/*********************************************************************** * Function:
@@ -1440,46 +1363,38 @@* Note: * In contrary to other externally callable funcs (DC390_), we don't lock ***********************************************************************/ -int DC390_bios_param (Disk *disk,kdev_t devno,int geom[]) +int DC390_bios_param (Disk *disk,kdev_t dev,int *geom) {int heads, sectors, cylinders; -PACB pACB = (PACB ) disk->device->host->hostdata; -struct buffer_head *bh; -int ret_code =-1 ; -int size = disk->capacity; - -if ((bh =bread (MKDEV (MAJOR (devno),MINOR (devno)&~0xf ),0 ,1024 ))) - { -/* try to infer mapping from partition table */ - ret_code =partsize (bh, (unsigned long ) size, (unsigned int *) geom +2 , - (unsigned int *) geom +0 , (unsigned int *) geom +1 ); -brelse (bh); - } -if (ret_code ==-1 ) - { - heads =64 ; - sectors =32 ; - cylinders = size / (heads * sectors); - -if ( (pACB->Gmode2 &GREATER_1G ) && (cylinders >1024 ) ) - { - heads =255 ; - sectors =63 ; - cylinders = size / (heads * sectors); - } - - geom[0 ] = heads; - geom[1 ] = sectors; - geom[2 ] = cylinders; +PACB pACB; +unsigned long size = disk->capacity; + +if (scsi_bios_param_from_MBR (dev, size, geom) ==0 ) +return 0 ; + + heads =64 ; + sectors =32 ; + cylinders = size / (heads * sectors); + + pACB = (PACB ) disk->device->host->hostdata; + +if ( (pACB->Gmode2 &GREATER_1G ) && (cylinders >1024 ) ) { + heads =255 ; + sectors =63 ; + cylinders = size / (heads * sectors); } -return (0 ); + geom[0 ] = heads; + geom[1 ] = sectors; + geom[2 ] = cylinders; + +return 0 ; }#else -int DC390_bios_param (Disk *disk,kdev_t devno,int geom[]) +int DC390_bios_param (Disk *disk,kdev_t dev,int *geom) { -return scsicam_bios_param (disk, devno, geom); -}; +return scsicam_bios_param (disk, dev, geom); +}#endif
linux/drivers/scsi/BusLogic.c renamed from linux-2.4.6-pre9/linux/drivers/scsi/BusLogic.c +1 -1
@@ -4127,7 +4127,7 @@/* Attempt to read the first 1024 bytes from the disk device. */ - BufferHead =bread (MKDEV (MAJOR (Device),MINOR (Device) & ~0x0F ),0 ,1024 ); + BufferHead =scsi_get_block_zero (Device);if (BufferHead ==NULL )return 0 ;/* If the boot sector partition table flag is valid, search for a partition
linux/drivers/scsi/aic7xxx/aic7xxx_linux.c renamed from linux-2.4.6-pre9/linux/drivers/scsi/aic7xxx/aic7xxx_linux.c +8 -13
@@ -2669,34 +2669,29 @@* Return the disk geometry for the given SCSI device. */ int -ahc_linux_biosparam (Disk *disk,kdev_t dev,int geom[]) +ahc_linux_biosparam (Disk *disk,kdev_t dev,int *geom) {int heads;int sectors;int cylinders; -int ret;int extended;struct ahc_softc *ahc; -struct buffer_head *bh; +unsigned long size = disk->capacity; - ahc = *((struct ahc_softc **)disk->device->host->hostdata); - bh =bread (MKDEV (MAJOR (dev),MINOR (dev) & ~0xf ),0 ,1024 ); +if (scsi_bios_param_from_MBR (dev, size, geom) ==0 ) +return 0 ; -if (bh) { - ret =scsi_partsize (bh, disk->capacity, - &geom[2 ], &geom[0 ], &geom[1 ]); -brelse (bh); -if (ret !=-1 ) -return (ret); - } heads =64 ; sectors =32 ; cylinders = disk->capacity / (heads * sectors); + ahc = *((struct ahc_softc **)disk->device->host->hostdata); +if (disk->device->channel ==0 ) extended = (ahc->flags &AHC_EXTENDED_TRANS_A ) !=0 ;else extended = (ahc->flags &AHC_EXTENDED_TRANS_B ) !=0 ; +if (extended && cylinders >=1024 ) { heads =255 ; sectors =63 ;
@@ -2705,7 +2700,7 @@ geom[0 ] = heads; geom[1 ] = sectors; geom[2 ] = cylinders; -return (0 ); +return 0 ; }/*
linux/drivers/scsi/aic7xxx_old.c renamed from linux-2.4.6-pre9/linux/drivers/scsi/aic7xxx_old.c +8 -16
@@ -11994,29 +11994,21 @@* Return the disk geometry for the given SCSI device. *-F*************************************************************************/ int -aic7xxx_biosparam (Disk *disk,kdev_t dev,int geom[]) +aic7xxx_biosparam (Disk *disk,kdev_t dev,int *geom) { -int heads, sectors, cylinders, ret; +int heads, sectors, cylinders;struct aic7xxx_host *p; -struct buffer_head *bh; - p = (struct aic7xxx_host *) disk->device->host->hostdata; - bh =bread (MKDEV (MAJOR (dev),MINOR (dev)&~0xf ),0 ,1024 ); - -if ( bh ) - { - ret =scsi_partsize (bh, disk->capacity, &geom[2 ], &geom[0 ], &geom[1 ]); -brelse (bh); -if ( ret !=-1 ) -return (ret); - } +if (scsi_bios_param_from_MBR (dev, disk->capacity, geom) ==0 ) +return 0 ; heads =64 ; sectors =32 ; cylinders = disk->capacity / (heads * sectors); -if ((p->flags &AHC_EXTEND_TRANS_A ) && (cylinders >1024 )) - { + p = (struct aic7xxx_host *) disk->device->host->hostdata; + +if ((p->flags &AHC_EXTEND_TRANS_A ) && (cylinders >1024 )) { heads =255 ; sectors =63 ; cylinders = disk->capacity / (heads * sectors);
@@ -12026,7 +12018,7 @@ geom[1 ] = sectors; geom[2 ] = cylinders; -return (0 ); +return 0 ; }/*+F*************************************************************************
linux/drivers/scsi/scsi.h renamed from linux-2.4.6-pre9/linux/drivers/scsi/scsi.h +5 -3
@@ -443,9 +443,11 @@/* * Prototypes for functions in scsicam.c */ -extern int scsi_partsize (struct buffer_head *bh,unsigned long capacity, -unsigned int *cyls,unsigned int *hds, -unsigned int *secs); +extern struct buffer_head *scsi_get_block_zero (kdev_t dev); +extern int scsi_bios_param_from_MBR (kdev_t dev,unsigned long size,int *ip); +extern int scsi_partsize (struct buffer_head *bh,unsigned long capacity, +unsigned int *cyls,unsigned int *hds, +unsigned int *secs);/* * Prototypes for functions in scsi_dma.c
linux/drivers/scsi/scsicam.c renamed from linux-2.4.6-pre9/linux/drivers/scsi/scsicam.c +49 -45
130 lines not on this page · raw message