Skip to content

Commit 81e6617

Browse files
Christoph Hellwigaxboe
authored andcommitted
mtip32xx: return a blk_status_t from mtip_send_trim
This allows for better error propagation and simpler code. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 10966fa commit 81e6617

File tree

1 file changed

+11
-19
lines changed

1 file changed

+11
-19
lines changed

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,23 +1423,19 @@ static int mtip_get_smart_attr(struct mtip_port *port, unsigned int id,
14231423
* @dd pointer to driver_data structure
14241424
* @lba starting lba
14251425
* @len # of 512b sectors to trim
1426-
*
1427-
* return value
1428-
* -ENOMEM Out of dma memory
1429-
* -EINVAL Invalid parameters passed in, trim not supported
1430-
* -EIO Error submitting trim request to hw
14311426
*/
1432-
static int mtip_send_trim(struct driver_data *dd, unsigned int lba,
1433-
unsigned int len)
1427+
static blk_status_t mtip_send_trim(struct driver_data *dd, unsigned int lba,
1428+
unsigned int len)
14341429
{
1435-
int i, rv = 0;
14361430
u64 tlba, tlen, sect_left;
14371431
struct mtip_trim_entry *buf;
14381432
dma_addr_t dma_addr;
14391433
struct host_to_dev_fis fis;
1434+
blk_status_t ret = BLK_STS_OK;
1435+
int i;
14401436

14411437
if (!len || dd->trim_supp == false)
1442-
return -EINVAL;
1438+
return BLK_STS_IOERR;
14431439

14441440
/* Trim request too big */
14451441
WARN_ON(len > (MTIP_MAX_TRIM_ENTRY_LEN * MTIP_MAX_TRIM_ENTRIES));
@@ -1454,7 +1450,7 @@ static int mtip_send_trim(struct driver_data *dd, unsigned int lba,
14541450
buf = dmam_alloc_coherent(&dd->pdev->dev, ATA_SECT_SIZE, &dma_addr,
14551451
GFP_KERNEL);
14561452
if (!buf)
1457-
return -ENOMEM;
1453+
return BLK_STS_RESOURCE;
14581454
memset(buf, 0, ATA_SECT_SIZE);
14591455

14601456
for (i = 0, sect_left = len, tlba = lba;
@@ -1486,10 +1482,10 @@ static int mtip_send_trim(struct driver_data *dd, unsigned int lba,
14861482
ATA_SECT_SIZE,
14871483
0,
14881484
MTIP_TRIM_TIMEOUT_MS) < 0)
1489-
rv = -EIO;
1485+
ret = BLK_STS_IOERR;
14901486

14911487
dmam_free_coherent(&dd->pdev->dev, ATA_SECT_SIZE, buf, dma_addr);
1492-
return rv;
1488+
return ret;
14931489
}
14941490

14951491
/*
@@ -3634,13 +3630,9 @@ static blk_status_t mtip_queue_rq(struct blk_mq_hw_ctx *hctx,
36343630

36353631
blk_mq_start_request(rq);
36363632

3637-
if (req_op(rq) == REQ_OP_DISCARD) {
3638-
if (mtip_send_trim(dd, blk_rq_pos(rq), blk_rq_sectors(rq)) < 0)
3639-
return BLK_STS_IOERR;
3640-
} else {
3641-
mtip_hw_submit_io(dd, rq, cmd, hctx);
3642-
}
3643-
3633+
if (req_op(rq) == REQ_OP_DISCARD)
3634+
return mtip_send_trim(dd, blk_rq_pos(rq), blk_rq_sectors(rq));
3635+
mtip_hw_submit_io(dd, rq, cmd, hctx);
36443636
return BLK_STS_OK;
36453637
}
36463638

0 commit comments

Comments
 (0)