summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2021-02-22 10:39:38 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-02-22 10:39:38 +0100
commit71f28d7e89bdd96f671959180ab78f9cce287927 (patch)
tree61379d90c1b89cdf60def60951289f2724494259 /drivers
parent34d4be79d78569e6800c6fc59bfeb8b7c0ea2f5b (diff)
parent129e3317a6b283cb7bb10eb8cb0f531b603893c0 (diff)
downloadbarebox-71f28d7e89bdd96f671959180ab78f9cce287927.tar.gz
barebox-71f28d7e89bdd96f671959180ab78f9cce287927.tar.xz
Merge branch 'for-next/ext4'
Diffstat (limited to 'drivers')
-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
-rw-r--r--drivers/block/efi-block-io.c8
-rw-r--r--drivers/mci/mci-core.c36
-rw-r--r--drivers/nvme/host/core.c12
-rw-r--r--drivers/usb/storage/usb.c25
8 files changed, 66 insertions, 65 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) {
diff --git a/drivers/block/efi-block-io.c b/drivers/block/efi-block-io.c
index 30db486876..4768c219ed 100644
--- a/drivers/block/efi-block-io.c
+++ b/drivers/block/efi-block-io.c
@@ -28,7 +28,7 @@ struct efi_block_io_media{
bool write_caching;
u32 block_size;
u32 io_align;
- u64 last_block;
+ sector_t last_block;
u64 lowest_aligned_lba; /* added in Revision 2 */
u32 logical_blocks_per_physical_block; /* added in Revision 2 */
u32 optimal_transfer_length_granularity; /* added in Revision 3 */
@@ -53,8 +53,8 @@ struct efi_bio_priv {
u32 media_id;
};
-static int efi_bio_read(struct block_device *blk, void *buffer, int block,
- int num_blocks)
+static int efi_bio_read(struct block_device *blk, void *buffer, sector_t block,
+ blkcnt_t num_blocks)
{
struct efi_bio_priv *priv = container_of(blk, struct efi_bio_priv, blk);
efi_status_t efiret;
@@ -69,7 +69,7 @@ static int efi_bio_read(struct block_device *blk, void *buffer, int block,
}
static int efi_bio_write(struct block_device *blk,
- const void *buffer, int block, int num_blocks)
+ const void *buffer, sector_t block, blkcnt_t num_blocks)
{
struct efi_bio_priv *priv = container_of(blk, struct efi_bio_priv, blk);
efi_status_t efiret;
diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index 002bfeb1cf..017f25d35f 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -398,16 +398,16 @@ int mci_switch(struct mci *mci, unsigned index, unsigned value)
return mci_send_cmd(mci, &cmd, NULL);
}
-static int mci_calc_blk_cnt(uint64_t cap, unsigned shift)
+static blkcnt_t mci_calc_blk_cnt(blkcnt_t cap, unsigned shift)
{
- unsigned ret = cap >> shift;
+ blkcnt_t ret = cap >> shift;
if (ret > 0x7fffffff) {
pr_warn("Limiting card size due to 31 bit contraints\n");
return 0x7fffffff;
}
- return (int)ret;
+ return ret;
}
static void mci_part_add(struct mci *mci, uint64_t size,
@@ -1342,14 +1342,14 @@ static int mci_blk_part_switch(struct mci_part *part)
* This routine expects the buffer has the correct size to read all data!
*/
static int __maybe_unused mci_sd_write(struct block_device *blk,
- const void *buffer, int block, int num_blocks)
+ const void *buffer, sector_t block, blkcnt_t num_blocks)
{
struct mci_part *part = container_of(blk, struct mci_part, blk);
struct mci *mci = part->mci;
struct mci_host *host = mci->host;
int rc;
- unsigned max_req_block = num_blocks;
- int write_block;
+ blkcnt_t max_req_block = num_blocks;
+ blkcnt_t write_block;
if (mci->host->max_req_size)
max_req_block = mci->host->max_req_size / mci->write_bl_len;
@@ -1361,7 +1361,7 @@ static int __maybe_unused mci_sd_write(struct block_device *blk,
return -EPERM;
}
- dev_dbg(&mci->dev, "%s: Write %d block(s), starting at %d\n",
+ dev_dbg(&mci->dev, "%s: Write %llu block(s), starting at %llu\n",
__func__, num_blocks, block);
if (mci->write_bl_len != SECTOR_SIZE) {
@@ -1372,15 +1372,15 @@ static int __maybe_unused mci_sd_write(struct block_device *blk,
/* size of the block number field in the MMC/SD command is 32 bit only */
if (block > MAX_BUFFER_NUMBER) {
- dev_dbg(&mci->dev, "Cannot handle block number %d. Too large!\n", block);
+ dev_dbg(&mci->dev, "Cannot handle block number %llu. Too large!\n", block);
return -EINVAL;
}
while (num_blocks) {
- write_block = min_t(int, num_blocks, max_req_block);
+ write_block = min(num_blocks, max_req_block);
rc = mci_block_write(mci, buffer, block, write_block);
if (rc != 0) {
- dev_dbg(&mci->dev, "Writing block %d failed with %d\n", block, rc);
+ dev_dbg(&mci->dev, "Writing block %llu failed with %d\n", block, rc);
return rc;
}
num_blocks -= write_block;
@@ -1401,13 +1401,13 @@ static int __maybe_unused mci_sd_write(struct block_device *blk,
*
* This routine expects the buffer has the correct size to store all data!
*/
-static int mci_sd_read(struct block_device *blk, void *buffer, int block,
- int num_blocks)
+static int mci_sd_read(struct block_device *blk, void *buffer, sector_t block,
+ blkcnt_t num_blocks)
{
struct mci_part *part = container_of(blk, struct mci_part, blk);
struct mci *mci = part->mci;
- unsigned max_req_block = num_blocks;
- int read_block;
+ blkcnt_t max_req_block = num_blocks;
+ blkcnt_t read_block;
int rc;
if (mci->host->max_req_size)
@@ -1415,7 +1415,7 @@ static int mci_sd_read(struct block_device *blk, void *buffer, int block,
mci_blk_part_switch(part);
- dev_dbg(&mci->dev, "%s: Read %d block(s), starting at %d\n",
+ dev_dbg(&mci->dev, "%s: Read %llu block(s), starting at %llu\n",
__func__, num_blocks, block);
if (mci->read_bl_len != SECTOR_SIZE) {
@@ -1425,15 +1425,15 @@ static int mci_sd_read(struct block_device *blk, void *buffer, int block,
}
if (block > MAX_BUFFER_NUMBER) {
- dev_err(&mci->dev, "Cannot handle block number %d. Too large!\n", block);
+ dev_err(&mci->dev, "Cannot handle block number %llu. Too large!\n", block);
return -EINVAL;
}
while (num_blocks) {
- read_block = min_t(int, num_blocks, max_req_block);
+ read_block = min(num_blocks, max_req_block);
rc = mci_read_block(mci, buffer, block, read_block);
if (rc != 0) {
- dev_dbg(&mci->dev, "Reading block %d failed with %d\n", block, rc);
+ dev_dbg(&mci->dev, "Reading block %llu failed with %d\n", block, rc);
return rc;
}
num_blocks -= read_block;
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 257679fae8..a27a409cf5 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -222,7 +222,7 @@ static void __nvme_revalidate_disk(struct block_device *blk,
}
static void nvme_setup_rw(struct nvme_ns *ns, struct nvme_command *cmnd,
- int block, int num_block)
+ sector_t block, blkcnt_t num_block)
{
cmnd->rw.nsid = cpu_to_le32(ns->head->ns_id);
cmnd->rw.slba = cpu_to_le64(nvme_block_nr(ns, block));
@@ -239,7 +239,7 @@ static void nvme_setup_flush(struct nvme_ns *ns, struct nvme_command *cmnd)
}
static int nvme_submit_sync_rw(struct nvme_ns *ns, struct nvme_command *cmnd,
- void *buffer, int block, int num_blocks)
+ void *buffer, sector_t block, blkcnt_t num_blocks)
{
/*
* ns->ctrl->max_hw_sectors is in units of 512 bytes, so we
@@ -251,7 +251,7 @@ static int nvme_submit_sync_rw(struct nvme_ns *ns, struct nvme_command *cmnd,
if (num_blocks > max_hw_sectors) {
while (num_blocks) {
- const int chunk = min_t(int, num_blocks,
+ const u32 chunk = min_t(blkcnt_t, num_blocks,
max_hw_sectors);
ret = nvme_submit_sync_rw(ns, cmnd, buffer, block,
@@ -275,7 +275,7 @@ static int nvme_submit_sync_rw(struct nvme_ns *ns, struct nvme_command *cmnd,
if (ret) {
dev_err(ns->ctrl->dev,
- "I/O failed: block: %d, num blocks: %d, status code type: %xh, status code %02xh\n",
+ "I/O failed: block: %llu, num blocks: %llu, status code type: %xh, status code %02xh\n",
block, num_blocks, (ret >> 8) & 0xf,
ret & 0xff);
return -EIO;
@@ -286,7 +286,7 @@ static int nvme_submit_sync_rw(struct nvme_ns *ns, struct nvme_command *cmnd,
static int nvme_block_device_read(struct block_device *blk, void *buffer,
- int block, int num_blocks)
+ sector_t block, blkcnt_t num_blocks)
{
struct nvme_ns *ns = to_nvme_ns(blk);
struct nvme_command cmnd = { };
@@ -298,7 +298,7 @@ static int nvme_block_device_read(struct block_device *blk, void *buffer,
static int __maybe_unused
nvme_block_device_write(struct block_device *blk, const void *buffer,
- int block, int num_blocks)
+ sector_t block, blkcnt_t num_blocks)
{
struct nvme_ns *ns = to_nvme_ns(blk);
struct nvme_command cmnd = { };
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index e0ef4f5ef3..c264dd4b71 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -185,7 +185,7 @@ exit:
}
static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
- u32 start, u8 *data, u16 blocks)
+ sector_t start, u8 *data, u16 blocks)
{
u8 cmd[10];
@@ -206,7 +206,7 @@ static int usb_stor_io_10(struct us_blk_dev *usb_blkdev, u8 opcode,
/* Read / write a chunk of sectors on media */
static int usb_stor_blk_io(struct block_device *disk_dev,
- int sector_start, int sector_count, void *buffer,
+ sector_t sector_start, blkcnt_t sector_count, void *buffer,
bool read)
{
struct us_blk_dev *pblk_dev = container_of(disk_dev,
@@ -223,18 +223,18 @@ static int usb_stor_blk_io(struct block_device *disk_dev,
}
/* read / write the requested data */
- dev_dbg(dev, "%s %u block(s), starting from %d\n",
+ dev_dbg(dev, "%s %llu block(s), starting from %llu\n",
read ? "Read" : "Write",
sector_count, sector_start);
while (sector_count > 0) {
- unsigned n = min(sector_count, US_MAX_IO_BLK);
+ u16 n = min_t(blkcnt_t, sector_count, US_MAX_IO_BLK);
if (usb_stor_io_10(pblk_dev,
read ? SCSI_READ10 : SCSI_WRITE10,
sector_start,
buffer, n)) {
- dev_dbg(dev, "I/O error at sector %d\n", sector_start);
+ dev_dbg(dev, "I/O error at sector %llu\n", sector_start);
break;
}
sector_start += n;
@@ -247,14 +247,14 @@ static int usb_stor_blk_io(struct block_device *disk_dev,
/* Write a chunk of sectors to media */
static int __maybe_unused usb_stor_blk_write(struct block_device *blk,
- const void *buffer, int block, int num_blocks)
+ const void *buffer, sector_t block, blkcnt_t num_blocks)
{
return usb_stor_blk_io(blk, block, num_blocks, (void *)buffer, false);
}
/* Read a chunk of sectors from media */
-static int usb_stor_blk_read(struct block_device *blk, void *buffer, int block,
- int num_blocks)
+static int usb_stor_blk_read(struct block_device *blk, void *buffer, sector_t block,
+ blkcnt_t num_blocks)
{
return usb_stor_blk_io(blk, block, num_blocks, buffer, true);
}
@@ -305,17 +305,18 @@ static int usb_stor_init_blkdev(struct us_blk_dev *pblk_dev)
return result;
}
- if (last_lba > INT_MAX - 1) {
- last_lba = INT_MAX - 1;
+ if (last_lba == U32_MAX) {
+ last_lba = U32_MAX - 1;
dev_warn(dev,
- "Limiting device size due to 31 bit contraints\n");
+ "Limiting device size due to 32 bit constraints\n");
+ /* To support LBA >= U32_MAX, a READ CAPACITY (16) should be issued here */
}
pblk_dev->blk.num_blocks = last_lba + 1;
if (block_length != SECTOR_SIZE)
pr_warn("Support only %d bytes sectors\n", SECTOR_SIZE);
pblk_dev->blk.blockbits = SECTOR_SHIFT;
- dev_dbg(dev, "Capacity = 0x%x, blockshift = 0x%x\n",
+ dev_dbg(dev, "Capacity = 0x%llx, blockshift = 0x%x\n",
pblk_dev->blk.num_blocks, pblk_dev->blk.blockbits);
return 0;