Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3120071pxb; Tue, 12 Oct 2021 22:20:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjLrBh9tZOYKhAxFTlxJ8zpktV61KfZkAc9zaiikSmGMoxC6TjWc/7M640AKSP5/UhKJvE X-Received: by 2002:aa7:8882:0:b0:44c:9270:1cba with SMTP id z2-20020aa78882000000b0044c92701cbamr35986085pfe.26.1634102447307; Tue, 12 Oct 2021 22:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634102447; cv=none; d=google.com; s=arc-20160816; b=qhHQNc9arwFvq0A1Jg/VSbeE0Tgzj8SlDol0rzaxg9HrENFLyAVtqqmzOsDjkAngTL IkrjOAPpQaBjUoFR1cEYiU5KBCwBrtMZkJffSitN0Mk6NzkLZypDbeMPTW2ZW97bgFE0 /K2uBz+THB8bPasG/iupuRJxFcXHXRaqi3JpEiSaG02c9sZmrTQQ2ZCP/ROLBmaFMTHD ZFP0pivR4mrGwzlwn1kUiYNTTHLr0oza9Ix/Ub79r4aXj7HFTURG01WkAaNHJ3dgU9ZM 8Jo58USTwy43difkc7KMicg/hM+4MmgWg0WnhvfQq53dBUv+Eq1GQUd6mXEo0nfWBrrd J/1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1lNPQaRpzOMqDjq+W29E2FqgHNPMuQktxUoVAMHRW6k=; b=WcYpHbIAO3XknltpWWS9sGrJsR93YPqHbGqchIZblx6ZASU5y40N0Cf0sss9N/Q6DA 4mB4QwqUfde0c8ASMuc993QJUGXooBewZwIJltX95wQAHr5KUiMYqWLFkhweEsy6EYeM HBtW/hczgkPlA7FkpWWvlH+Rk2noe5aBHqH8CNIO4FMeR9bVqFGfTa1+GunCkvCVe9pK QE80hSxoOvy5lAe1pKlh7MgZFye+hRHE8ko2CPmd5SZhcDd2MM1BnOdS0QO6D1ChiPqc 8DQgKI3/i3D4/xjJNPXrB2YedSC+/PM513CC7F0n4SWF4Pyo9kF7FcwbKXGpI7dYKH/x /SEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cnK0OQUU; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g14si17399140pfm.203.2021.10.12.22.20.33; Tue, 12 Oct 2021 22:20:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=cnK0OQUU; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237736AbhJMFV2 (ORCPT + 99 others); Wed, 13 Oct 2021 01:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237684AbhJMFV0 (ORCPT ); Wed, 13 Oct 2021 01:21:26 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187B6C061771; Tue, 12 Oct 2021 22:19:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1lNPQaRpzOMqDjq+W29E2FqgHNPMuQktxUoVAMHRW6k=; b=cnK0OQUUmD59S3qMMwOCg07Xqu b65fChUuNH8gIZ5zFG9s3tfFOujmJzNsoPNw+AtwAIJihhYtlDNSVOaE+DwYG22fD1LKIZIbInufc eNd34k3OVE+Lum+V/zvu5MLgGPuSFoOmWiskijST8R7hqMvv3SDiYktZig3jFh6JUoPhLEwfhwT+k x9PKo3es8B+G2Da5u0W+Q7B+eCdefXDpPbh0sY2v/xBkSyOSzbeqgexvCy7C33wfvif2QBNOl3y3o vA4dIt9Z0P07uV5pAtDEmGZtoHfDPZgy274e7M/cwRBuSBQTcZE+E03XmUbQc1a8P7wgtB/z8sC0X NVUEnkIQ==; Received: from 089144212063.atnat0021.highway.a1.net ([89.144.212.63] helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1maWbc-00768E-Im; Wed, 13 Oct 2021 05:15:40 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Coly Li , Mike Snitzer , Song Liu , David Sterba , Josef Bacik , "Theodore Ts'o" , OGAWA Hirofumi , Dave Kleikamp , Ryusuke Konishi , Anton Altaparmakov , Konstantin Komarov , Kees Cook , Phillip Lougher , Jan Kara , linux-block@vger.kernel.org, dm-devel@redhat.com, drbd-dev@lists.linbit.com, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, jfs-discussion@lists.sourceforge.net, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, ntfs3@lists.linux.dev, reiserfs-devel@vger.kernel.org Subject: [PATCH 05/29] mtd/block2mtd: use bdev_nr_sectors instead of open coding it Date: Wed, 13 Oct 2021 07:10:18 +0200 Message-Id: <20211013051042.1065752-6-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211013051042.1065752-1-hch@lst.de> References: <20211013051042.1065752-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Use the proper helper to read the block device size. Signed-off-by: Christoph Hellwig --- drivers/mtd/devices/block2mtd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index c08721b11642b..d2d1a712188ce 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -269,7 +269,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, goto err_free_block2mtd; } - if ((long)dev->blkdev->bd_inode->i_size % erase_size) { + if ((long)(bdev_nr_sectors(dev->blkdev) << SECTOR_SHIFT) % erase_size) { pr_err("erasesize must be a divisor of device size\n"); goto err_free_block2mtd; } @@ -284,7 +284,8 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, dev->mtd.name = name; - dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK; + dev->mtd.size = + (bdev_nr_sectors(dev->blkdev) << SECTOR_SHIFT) & PAGE_MASK; dev->mtd.erasesize = erase_size; dev->mtd.writesize = 1; dev->mtd.writebufsize = PAGE_SIZE; -- 2.30.2