summaryrefslogtreecommitdiffstats
path: root/drivers/ata
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-02-16 21:02:03 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-02-18 09:23:42 +0100
commit130fbc7f6c67357a58823c8f17ecef7d276386a9 (patch)
treecbf03d20fa48605aac314b871ffa925c76a2013f /drivers/ata
parent47fe8d54c41a8076bb936f4b45304117af3a493d (diff)
downloadbarebox-130fbc7f6c67357a58823c8f17ecef7d276386a9.tar.gz
barebox-130fbc7f6c67357a58823c8f17ecef7d276386a9.tar.xz
block: use 64-bit types for sector offset and count on all platforms
barebox' use of int for the sector offset puts an upper bound of 1TB on the size of supported block devices, which is already exceeded by common place USB mass storage. Increasing the sizes involved to 64 bit like Linux does won't magically add missing driver support, but it gives us at least a fighting chance. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/ata')
-rw-r--r--drivers/ata/ahci.c12
-rw-r--r--drivers/ata/disk_ata_drive.c10
-rw-r--r--drivers/ata/disk_bios_drive.c16
-rw-r--r--drivers/ata/ide-sff.c12
4 files changed, 25 insertions, 25 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 049a36bb44..6d251f248a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -215,7 +215,7 @@ static int ahci_read_id(struct ata_port *ata, void *buf)
}
static int ahci_rw(struct ata_port *ata, void *rbuf, const void *wbuf,
- unsigned int block, int num_blocks)
+ sector_t block, blkcnt_t num_blocks)
{
struct ahci_port *ahci = container_of(ata, struct ahci_port, ata);
u8 fis[20];
@@ -237,7 +237,7 @@ static int ahci_rw(struct ata_port *ata, void *rbuf, const void *wbuf,
while (num_blocks) {
int now;
- now = min(MAX_SATA_BLOCKS_READ_WRITE, num_blocks);
+ now = min_t(blkcnt_t, MAX_SATA_BLOCKS_READ_WRITE, num_blocks);
fis[4] = (block >> 0) & 0xff;
fis[5] = (block >> 8) & 0xff;
@@ -270,14 +270,14 @@ static int ahci_rw(struct ata_port *ata, void *rbuf, const void *wbuf,
return 0;
}
-static int ahci_read(struct ata_port *ata, void *buf, unsigned int block,
- int num_blocks)
+static int ahci_read(struct ata_port *ata, void *buf, sector_t block,
+ blkcnt_t num_blocks)
{
return ahci_rw(ata, buf, NULL, block, num_blocks);
}
-static int ahci_write(struct ata_port *ata, const void *buf, unsigned int block,
- int num_blocks)
+static int ahci_write(struct ata_port *ata, const void *buf, sector_t block,
+ blkcnt_t num_blocks)
{
return ahci_rw(ata, NULL, buf, block, num_blocks);
}
diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
index 11f7151e51..3d9503fe7e 100644
--- a/drivers/ata/disk_ata_drive.c
+++ b/drivers/ata/disk_ata_drive.c
@@ -26,7 +26,7 @@
#include <disks.h>
#include <dma.h>
-static uint64_t ata_id_n_sectors(uint16_t *id)
+static blkcnt_t ata_id_n_sectors(uint16_t *id)
{
if (ata_id_has_lba(id)) {
if (ata_id_has_lba48(id))
@@ -75,7 +75,7 @@ static void __maybe_unused ata_dump_id(uint16_t *id)
unsigned char serial[ATA_ID_SERNO_LEN + 1];
unsigned char firmware[ATA_ID_FW_REV_LEN + 1];
unsigned char product[ATA_ID_PROD_LEN + 1];
- uint64_t n_sectors;
+ sector_t n_sectors;
/* Serial number */
ata_id_c_string(id, serial, ATA_ID_SERNO, sizeof(serial));
@@ -165,8 +165,8 @@ static void ata_fix_endianess(uint16_t *buf, unsigned wds)
* @note Due to 'block' is of type 'int' only small disks can be handled!
* @todo Optimize the read loop
*/
-static int ata_read(struct block_device *blk, void *buffer, int block,
- int num_blocks)
+static int ata_read(struct block_device *blk, void *buffer, sector_t block,
+ blkcnt_t num_blocks)
{
struct ata_port *port = container_of(blk, struct ata_port, blk);
@@ -187,7 +187,7 @@ static int ata_read(struct block_device *blk, void *buffer, int block,
* @todo Optimize the write loop
*/
static int __maybe_unused ata_write(struct block_device *blk,
- const void *buffer, int block, int num_blocks)
+ const void *buffer, sector_t block, blkcnt_t num_blocks)
{
struct ata_port *port = container_of(blk, struct ata_port, blk);
diff --git a/drivers/ata/disk_bios_drive.c b/drivers/ata/disk_bios_drive.c
index 363af3c6dd..8f522eeba6 100644
--- a/drivers/ata/disk_bios_drive.c
+++ b/drivers/ata/disk_bios_drive.c
@@ -115,7 +115,7 @@ static struct DAPS bios_daps __attribute__((aligned(16)));
* @param buffer Buffer to read from or write to (in the low memory area)
* @return 0 on success, anything else on failure
*/
-static int biosdisk_bios_call(struct media_access *media, int cmd, uint64_t sector_start, unsigned sector_count, void *buffer)
+static int biosdisk_bios_call(struct media_access *media, int cmd, sector_t sector_start, blkcnt_t sector_count, void *buffer)
{
int rc;
@@ -150,12 +150,12 @@ static int biosdisk_bios_call(struct media_access *media, int cmd, uint64_t sect
*
* @note Due to 'block' is of type 'int' only small disks can be handled!
*/
-static int biosdisk_read(struct block_device *blk, void *buffer, int block,
- int num_blocks)
+static int biosdisk_read(struct block_device *blk, void *buffer, sector_t block,
+ blkcnt_t num_blocks)
{
int rc;
- uint64_t sector_start = block;
- unsigned sector_count = num_blocks;
+ sector_t sector_start = block;
+ blkcnt_t sector_count = num_blocks;
struct media_access *media = to_media_access(blk);
while (sector_count >= SECTORS_AT_ONCE) {
@@ -191,11 +191,11 @@ static int biosdisk_read(struct block_device *blk, void *buffer, int block,
* @note Due to 'block' is of type 'int' only small disks can be handled!
*/
static int __maybe_unused biosdisk_write(struct block_device *blk,
- const void *buffer, int block, int num_blocks)
+ const void *buffer, sector_t block, blkcnt_t num_blocks)
{
int rc;
- uint64_t sector_start = block;
- unsigned sector_count = num_blocks;
+ sector_t sector_start = block;
+ blkcnt_t sector_count = num_blocks;
struct media_access *media = to_media_access(blk);
while (sector_count >= SECTORS_AT_ONCE) {
diff --git a/drivers/ata/ide-sff.c b/drivers/ata/ide-sff.c
index b7c8847266..a735c8c32c 100644
--- a/drivers/ata/ide-sff.c
+++ b/drivers/ata/ide-sff.c
@@ -138,7 +138,7 @@ static int ata_wait_ready(struct ide_port *ide, unsigned timeout)
* @param num Sector number
*/
static int ata_set_lba_sector(struct ata_port *port, unsigned drive,
- uint64_t num)
+ sector_t num)
{
struct ide_port *ide = to_ata_drive_access(port);
@@ -324,11 +324,11 @@ static int ide_reset(struct ata_port *port)
* @note Due to 'block' is of type 'int' only small disks can be handled!
* @todo Optimize the read loop
*/
-static int ide_read(struct ata_port *port, void *buffer, unsigned int block,
- int num_blocks)
+static int ide_read(struct ata_port *port, void *buffer, sector_t block,
+ blkcnt_t num_blocks)
{
int rc;
- uint64_t sector = block;
+ sector_t sector = block;
struct ide_port *ide = to_ata_drive_access(port);
while (num_blocks) {
@@ -372,10 +372,10 @@ static int ide_read(struct ata_port *port, void *buffer, unsigned int block,
* @todo Optimize the write loop
*/
static int __maybe_unused ide_write(struct ata_port *port,
- const void *buffer, unsigned int block, int num_blocks)
+ const void *buffer, sector_t block, blkcnt_t num_blocks)
{
int rc;
- uint64_t sector = block;
+ sector_t sector = block;
struct ide_port *ide = to_ata_drive_access(port);
while (num_blocks) {