From patchwork Wed Jan 13 22:04:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101172 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp3631016lbb; Wed, 13 Jan 2016 14:04:40 -0800 (PST) X-Received: by 10.66.252.6 with SMTP id zo6mr771360pac.154.1452722680691; Wed, 13 Jan 2016 14:04:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cz10si4599001pad.0.2016.01.13.14.04.40; Wed, 13 Jan 2016 14:04:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754916AbcAMWEi (ORCPT + 29 others); Wed, 13 Jan 2016 17:04:38 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:51210 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750761AbcAMWEh (ORCPT ); Wed, 13 Jan 2016 17:04:37 -0500 Received: from wuerfel.localnet ([134.3.118.24]) by mrelayeu.kundenserver.de (mreue003) with ESMTPSA (Nemesis) id 0M9tPw-1aUV5H0SRk-00B7Fq; Wed, 13 Jan 2016 23:04:11 +0100 From: Arnd Bergmann To: axboe@kernel.dk Cc: Matias Bjorling , Linux Kernel Mailing List , linux-arm-kernel@lists.infradead.org, torvalds@linux-foundation.org Subject: [PATCH v2] null_blk: use sector_div instead of do_div Date: Wed, 13 Jan 2016 23:04:08 +0100 Message-ID: <11387794.RmibjdD6Rx@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.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mK85X7lWg Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dividing a sector_t number should be done using sector_div rather than do_div to optimize the 32-bit sector_t case, and with the latest do_div optimizations, we now get a compile-time warning for this: arch/arm/include/asm/div64.h:32:95: note: expected 'uint64_t * {aka long long unsigned int *}' but argument is of type 'sector_t * {aka long unsigned int *}' drivers/block/null_blk.c:521:81: warning: comparison of distinct pointer types lacks a cast This changes the newly added code to use sector_div. It is a simplified version of the original patch, as Linus Torvalds pointed out that we should not be using an expensive division function in the first place. This version was suggested by Matias Bjorling. Signed-off-by: Arnd Bergmann Cc: Matias Bjorling Fixes: b2b7e00148a2 ("null_blk: register as a LightNVM device") --- [resent to Jens' correct address, sorry about the duplicates] diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 95dff91135ad..6f9587156569 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -495,17 +495,17 @@ static int null_lnvm_id(struct nvm_dev *dev, struct nvm_id *id) id->ppaf.ch_offset = 56; id->ppaf.ch_len = 8; - do_div(size, bs); /* convert size to pages */ - do_div(size, 256); /* concert size to pgs pr blk */ + sector_div(size, bs); /* convert size to pages */ + size >>= 8; /* concert size to pgs pr blk */ grp = &id->groups[0]; grp->mtype = 0; grp->fmtype = 0; grp->num_ch = 1; grp->num_pg = 256; blksize = size; - do_div(size, (1 << 16)); + size >>= 16; grp->num_lun = size + 1; - do_div(blksize, grp->num_lun); + sector_div(blksize, grp->num_lun); grp->num_blk = blksize; grp->num_pln = 1;