@@ -1026,12 +1026,14 @@ int ata_device_sector_io64(int device, void *buf, u64 lba, u32 nsectors, int dir
10261026 USE_SPD_REGS ;
10271027 int res = 0 , retries ;
10281028 u16 sector , lcyl , hcyl , select , command , len ;
1029+ u32 chunk ;
10291030
10301031 while (res == 0 && nsectors > 0 ) {
10311032
10321033 if (atad_devinfo [device ].lba48 && (ata_dvrp_workaround ? (lba >= atad_devinfo [device ].total_sectors ) : 1 )) {
10331034 /* Setup for 48-bit LBA. */
1034- len = (u16 )((nsectors > 65536 ) ? 65536 : nsectors ); /* 0 means 65536 in LBA48 */
1035+ chunk = (nsectors > 65536 ) ? 65536 : nsectors ;
1036+ len = (u16 )chunk ; /* 0 means 65536 in the LBA48 sector count register. */
10351037
10361038 /* Combine bits 24-31 and bits 0-7 of lba into sector. */
10371039 sector = ((lba >> 16 ) & 0xff00 ) | (lba & 0xff );
@@ -1043,7 +1045,8 @@ int ata_device_sector_io64(int device, void *buf, u64 lba, u32 nsectors, int dir
10431045 command = (dir == 1 ) ? ATA_C_WRITE_DMA_EXT : ATA_C_READ_DMA_EXT ;
10441046 } else {
10451047 /* Setup for 28-bit LBA. */
1046- len = (nsectors > 256 ) ? 256 : nsectors ;
1048+ chunk = (nsectors > 256 ) ? 256 : nsectors ;
1049+ len = (u16 )chunk ;
10471050 sector = lba & 0xff ;
10481051 lcyl = (lba >> 8 ) & 0xff ;
10491052 hcyl = (lba >> 16 ) & 0xff ;
@@ -1062,7 +1065,7 @@ int ata_device_sector_io64(int device, void *buf, u64 lba, u32 nsectors, int dir
10621065#endif
10631066#endif
10641067
1065- if ((res = sceAtaExecCmd (buf , len , 0 , len , sector , lcyl , hcyl , select , command )) != 0 )
1068+ if ((res = sceAtaExecCmd (buf , chunk , 0 , len , sector , lcyl , hcyl , select , command )) != 0 )
10661069 break ;
10671070
10681071#ifdef ATA_USE_DEV9
@@ -1084,9 +1087,9 @@ int ata_device_sector_io64(int device, void *buf, u64 lba, u32 nsectors, int dir
10841087 break ;
10851088 }
10861089
1087- buf = (void * )((u8 * )buf + len * 512 );
1088- lba += len ;
1089- nsectors -= len ;
1090+ buf = (void * )((u8 * )buf + chunk * 512 );
1091+ lba += chunk ;
1092+ nsectors -= chunk ;
10901093 }
10911094
10921095 return res ;
0 commit comments