Some error checks had unlikely some did not. Put unlikely on all error handling paths. (I like unlikely for error paths specially for readability) Also use bio_data_dir() to extract away the READA flag Signed-off-by: Boaz Harrosh <boaz@xxxxxxxxxxxxx> --- drivers/block/pmem.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/block/pmem.c b/drivers/block/pmem.c index 6a45fd5..209a410 100644 --- a/drivers/block/pmem.c +++ b/drivers/block/pmem.c @@ -76,7 +76,7 @@ static void pmem_make_request(struct request_queue *q, struct bio *bio) struct bvec_iter iter; int err = 0; - if (bio_end_sector(bio) > get_capacity(bdev->bd_disk)) { + if (unlikely(bio_end_sector(bio) > get_capacity(bdev->bd_disk))) { err = -EIO; goto out; } @@ -86,9 +86,7 @@ static void pmem_make_request(struct request_queue *q, struct bio *bio) goto out; } - rw = bio_rw(bio); - if (rw == READA) - rw = READ; + rw = bio_data_dir(bio); sector = bio->bi_iter.bi_sector; bio_for_each_segment(bvec, bio, iter) { @@ -124,7 +122,7 @@ static long pmem_direct_access(struct block_device *bdev, sector_t sector, struct pmem_device *pmem = bdev->bd_disk->private_data; size_t offset = sector << 9; - if (!pmem) + if (unlikely(!pmem)) return -ENODEV; *kaddr = pmem->virt_addr + offset; @@ -149,7 +147,7 @@ static int pmem_mapmem(struct pmem_device *pmem) res_mem = request_mem_region_exclusive(pmem->phys_addr, pmem->size, "pmem"); - if (!res_mem) { + if (unlikely(!res_mem)) { pr_warn("pmem: request_mem_region_exclusive phys=0x%llx size=0x%zx failed\n", pmem->phys_addr, pmem->size); return -EINVAL; @@ -192,7 +190,7 @@ static int pmem_probe(struct platform_device *pdev) return -ENXIO; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) + if (unlikely(!res)) return -ENXIO; pmem = kzalloc(sizeof(*pmem), GFP_KERNEL); @@ -273,11 +271,11 @@ static int __init pmem_init(void) int error; pmem_major = register_blkdev(0, "pmem"); - if (pmem_major < 0) + if (unlikely(pmem_major < 0)) return pmem_major; error = platform_driver_register(&pmem_driver); - if (error) + if (unlikely(error)) unregister_blkdev(pmem_major, "pmem"); return error; } -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html