From patchwork Tue Mar 31 13:27:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 6129941 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 16089BF4A6 for ; Tue, 31 Mar 2015 13:27:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3ECDA201ED for ; Tue, 31 Mar 2015 13:27:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58BC8201E4 for ; Tue, 31 Mar 2015 13:27:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754508AbbCaN1N (ORCPT ); Tue, 31 Mar 2015 09:27:13 -0400 Received: from mail-wi0-f171.google.com ([209.85.212.171]:32769 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754219AbbCaN1M (ORCPT ); Tue, 31 Mar 2015 09:27:12 -0400 Received: by wixm2 with SMTP id m2so14306393wix.0 for ; Tue, 31 Mar 2015 06:27:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=Ut8aiWu7NqaLIgkEXWFDlhHlVHFL2WA4unT9vzQ5IN0=; b=U+uS3hkzIiFlML7ptiHawx+6SIeulUB8b2Aq6yVxHO5w2ini/Bh5FyKTOuM1+lC9JZ fUgDsLnLF0fzosa8Z/Bj6MO/q46EGkHvCmK1S+ytvbmYzWU+eGk/jdkCzxEfm+V2Setb 75WPtCUpz7sQ9hbfWdgPlTZ5njnLm2LtBo6kn5jqvD1gun/+yuCMGhzmIu2+B/QscBpS 33nMIk7t+hWva8217+eNv+KRMS6z3K2ykFr+yOSNR3DYPhrWNpxi0QB8Eq4NAqZyOX/Z r2cSVMgvDdAOD/TNrdkifMjOpAOLn8Xl0p6I0QidJmk8//MbS9Xwq2USLflAzMwuW2o4 FVTA== X-Gm-Message-State: ALoCoQlC9AOu3snWhrNOr++MRcnTsUT0sw9+ag0u/vAEfZjfEp1v8kZtUSKwZR5y3nw3wUqoSJZ2 X-Received: by 10.180.206.13 with SMTP id lk13mr5301442wic.95.1427808430976; Tue, 31 Mar 2015 06:27:10 -0700 (PDT) Received: from [10.0.0.5] ([207.232.55.62]) by mx.google.com with ESMTPSA id k6sm20966785wia.6.2015.03.31.06.27.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 31 Mar 2015 06:27:10 -0700 (PDT) Message-ID: <551AA0AD.4000604@plexistor.com> Date: Tue, 31 Mar 2015 16:27:09 +0300 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Christoph Hellwig CC: linux-nvdimm@ml01.01.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, ross.zwisler@linux.intel.com, axboe@kernel.dk Subject: [PATCH 4/6] SQUSHME: pmem: Micro cleaning References: <1427358764-6126-1-git-send-email-hch@lst.de> <55143A8B.2060304@plexistor.com> <20150331092526.GA25958@lst.de> <551A9EB3.8000605@plexistor.com> In-Reply-To: <551A9EB3.8000605@plexistor.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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; }