fix error return get/set_native_max functions
PATCH 1/1 fix error return get/set_native_max functions
In ide-disk.c we have functions
idedisk_read_native_max_address
idedisk_read_native_max_address_ext
idedisk_set_max_address
idedisk_set_max_address_ext
that are documented as
/*
* Sets maximum virtual LBA address of the drive.
* Returns new maximum virtual LBA address (> 0) or 0 on failure. */
The IDE command they execute returns the largest address, and 1 is added to get the capacity. Unfortunately, the code does
addr = 0;
if (ide_command_succeeds) {
addr = ...
}
addr++;so that the return value on error is 1 instead of 0. The patch below moves the addr++.
Andries
drivers/ide/ide-disk.c +10 -6
@@ -964,12 +964,13 @@ | ((args.tfRegister[ IDE_HCYL_OFFSET] ) << 16) | ((args.tfRegister[IDE_LCYL_OFFSET ] ) <<8 ) | ((args.tfRegister[IDE_SECTOR_OFFSET ] )); + addr++;/* since the return value is (maxlba - 1), we add 1 */ } - addr++;/* since the return value is (maxlba - 1), we add 1 */ return addr; } -static unsigned long long idedisk_read_native_max_address_ext (ide_drive_t *drive) +static unsigned long long +idedisk_read_native_max_address_ext (ide_drive_t *drive) {ide_task_t args;unsigned long long addr =0 ;
@@ -992,8 +993,8 @@ ((args.tfRegister[IDE_LCYL_OFFSET ])<<8 ) | (args.tfRegister[IDE_SECTOR_OFFSET ]); addr = ((__u64 )high <<24 ) | low; + addr++;/* since the return value is (maxlba - 1), we add 1 */ } - addr++;/* since the return value is (maxlba - 1), we add 1 */ return addr; }
@@ -1002,7 +1003,8 @@* Sets maximum virtual LBA address of the drive. * Returns new maximum virtual LBA address (> 0) or 0 on failure. */ -static unsigned long idedisk_set_max_address (ide_drive_t *drive,unsigned long addr_req) +static unsigned long +idedisk_set_max_address (ide_drive_t *drive,unsigned long addr_req) {ide_task_t args;unsigned long addr_set =0 ;
@@ -1024,12 +1026,13 @@ | ((args.tfRegister[ IDE_HCYL_OFFSET] ) << 16) | ((args.tfRegister[IDE_LCYL_OFFSET ] ) <<8 ) | ((args.tfRegister[IDE_SECTOR_OFFSET ] )); + addr_set++; } - addr_set++;return addr_set; } -static unsigned long long idedisk_set_max_address_ext (ide_drive_t *drive,unsigned long long addr_req) +static unsigned long long +idedisk_set_max_address_ext (ide_drive_t *drive,unsigned long long addr_req) {ide_task_t args;unsigned long long addr_set =0 ;
@@ -1059,6 +1062,7 @@ ((args.tfRegister[IDE_LCYL_OFFSET ])<<8 ) | (args.tfRegister[IDE_SECTOR_OFFSET ]); addr_set = ((__u64 )high <<24 ) | low; + addr_set++; }return addr_set; }
Quoted 22 lines · On Tue, 5 Aug 2003 [email protected] wrote:
In
ide-disk.cwe have functions
idedisk_read_native_max_address
idedisk_read_native_max_address_ext
idedisk_set_max_address
idedisk_set_max_address_ext
that are documented as/*
* Sets maximum virtual LBA address of the drive.
* Returns new maximum virtual LBA address (> 0) or 0 on failure. */The IDE command they execute returns the largest address, and 1 is added to get the capacity. Unfortunately, the code does
addr = 0; if (ide_command_succeeds) { addr = ... } addr++;
Quoted 4 lines
so that the return value on error is 1 instead of 0. The patch below moves the addr++.
Andries
This change is okay, thanks.
However changing coding style is not...
drivers/ide/ide-disk.c line 1010
Quoted 10 lines
drivers/ide/ide-disk.c +2
-1@@ -1002,7 +1003,8 @@* Sets maximum virtual LBA address of the drive. * Returns new maximum virtual LBA address (> 0) or 0 on failure. */ -static unsigned long idedisk_set_max_address (ide_drive_t *drive,unsigned long addr_req) +static unsigned long +idedisk_set_max_address (ide_drive_t *drive,unsigned long addr_req) {ide_task_t args;unsigned long addr_set =0 ;
--
Bartlomiej