From patchwork Mon Jan 23 11:59:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9532369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D620A60434 for ; Mon, 23 Jan 2017 12:02:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B71412833C for ; Mon, 23 Jan 2017 12:02:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAF3128342; Mon, 23 Jan 2017 12:02:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DE0A2833C for ; Mon, 23 Jan 2017 12:02:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751052AbdAWMAV (ORCPT ); Mon, 23 Jan 2017 07:00:21 -0500 Received: from mail-wj0-f194.google.com ([209.85.210.194]:36051 "EHLO mail-wj0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751013AbdAWMAU (ORCPT ); Mon, 23 Jan 2017 07:00:20 -0500 Received: by mail-wj0-f194.google.com with SMTP id kq3so1730728wjc.3 for ; Mon, 23 Jan 2017 03:59:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=voj2J8C+Ul+xyoGF3jY8O/gAjtoJ3/Emv4klB0rX3OY=; b=A+heqvY62L1xCqCEQyeGZ9quWBYgbNjnvaaVfi8Bq1A2xsVNMwFiJy328Gt7ftxkqb ezAUvv+/d/P26t4P2PLV1jUSYR2zF5CKisFRqqv0HVDK/xO3I06i2ZZIJiz0hHzLZ4TA xttu6zbx1L+USP1TtLKlR9JS2W24cF52IMFOk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=voj2J8C+Ul+xyoGF3jY8O/gAjtoJ3/Emv4klB0rX3OY=; b=kcwoqZkR+2uzV+pIXrdveHEXwZdZMrOykDSnHbdV1Vu/aYO0nNjN1Z43E3OvqgRDus cjDxZLaSTi6zhh2qkLrEPVZC6JyRvjwl+//kWAxTrwkA2okQZ6TQ6OGuBOwV965Ueu7w btlxpKkoLcWnay/de652SRtNpayRV+0Y+EwPPOcNI6zvvXi+fBu8wUMvfC2hV44/BMWJ BDDNXyeBBpDFsqUElktpUFVrJu1ZfEKoH7+hQ4k5CmSIq4pYWwxb7y74E+DAzXIs1sH3 3qOnOVjJsQY5tm0lDJkIsSHfgSg6AfSJJ2RFspPSK2yx7sJ7xq3Tov5H8Pcctwyzr+y2 Ku2Q== X-Gm-Message-State: AIkVDXLadiZZz+7x2ImmDWX57jf/HnLGQJ28RuZUi0azR/XclVSnOXHrI/fT7oDU1IyEkg== X-Received: by 10.223.176.93 with SMTP id g29mr23700091wra.7.1485172786663; Mon, 23 Jan 2017 03:59:46 -0800 (PST) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id x135sm20715381wme.23.2017.01.23.03.59.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jan 2017 03:59:46 -0800 (PST) From: "=?UTF-8?q?Matias=20Bj=C3=B8rling?=" X-Google-Original-From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 5/8] lightnvm: make nvm_map_* return void Date: Mon, 23 Jan 2017 12:59:16 +0100 Message-Id: <20170123115919.14339-6-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170123115919.14339-1-matias@cnexlabs.com> References: <20170123115919.14339-1-matias@cnexlabs.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The only check there was done was a debugging check. Remove it and replace the return value with void to reduce error checking. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 18d4873..a1a7a5a 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -407,31 +407,17 @@ static int nvm_register_map(struct nvm_dev *dev) return -ENOMEM; } -static int nvm_map_to_dev(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p) +static void nvm_map_to_dev(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p) { struct nvm_dev_map *dev_map = tgt_dev->map; struct nvm_ch_map *ch_map = &dev_map->chnls[p->g.ch]; int lun_off = ch_map->lun_offs[p->g.lun]; - struct nvm_dev *dev = tgt_dev->parent; - struct nvm_dev_map *dev_rmap = dev->rmap; - struct nvm_ch_map *ch_rmap; - int lun_roff; p->g.ch += ch_map->ch_off; p->g.lun += lun_off; - - ch_rmap = &dev_rmap->chnls[p->g.ch]; - lun_roff = ch_rmap->lun_offs[p->g.lun]; - - if (unlikely(ch_rmap->ch_off < 0 || lun_roff < 0)) { - pr_err("nvm: corrupted device partition table\n"); - return -EINVAL; - } - - return 0; } -static int nvm_map_to_tgt(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p) +static void nvm_map_to_tgt(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p) { struct nvm_dev *dev = tgt_dev->parent; struct nvm_dev_map *dev_rmap = dev->rmap; @@ -440,34 +426,27 @@ static int nvm_map_to_tgt(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *p) p->g.ch -= ch_rmap->ch_off; p->g.lun -= lun_roff; - - return 0; } -static int nvm_trans_rq(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd, +static void nvm_trans_rq(struct nvm_tgt_dev *tgt_dev, struct nvm_rq *rqd, int flag) { int i; - int ret; if (rqd->nr_ppas == 1) { if (flag == TRANS_TGT_TO_DEV) - return nvm_map_to_dev(tgt_dev, &rqd->ppa_addr); + nvm_map_to_dev(tgt_dev, &rqd->ppa_addr); else - return nvm_map_to_tgt(tgt_dev, &rqd->ppa_addr); + nvm_map_to_tgt(tgt_dev, &rqd->ppa_addr); + return; } for (i = 0; i < rqd->nr_ppas; i++) { if (flag == TRANS_TGT_TO_DEV) - ret = nvm_map_to_dev(tgt_dev, &rqd->ppa_list[i]); + nvm_map_to_dev(tgt_dev, &rqd->ppa_list[i]); else - ret = nvm_map_to_tgt(tgt_dev, &rqd->ppa_list[i]); - - if (ret) - break; + nvm_map_to_tgt(tgt_dev, &rqd->ppa_list[i]); } - - return ret; } static struct ppa_addr nvm_trans_ppa(struct nvm_tgt_dev *tgt_dev, @@ -665,9 +644,7 @@ int nvm_erase_blk(struct nvm_tgt_dev *tgt_dev, struct ppa_addr *ppas, int flags) if (!dev->ops->erase_block) return 0; - ret = nvm_map_to_dev(tgt_dev, ppas); - if (ret) - return ret; + nvm_map_to_dev(tgt_dev, ppas); memset(&rqd, 0, sizeof(struct nvm_rq));