From patchwork Tue Sep 5 11:55:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9938515 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 593D4600CB for ; Tue, 5 Sep 2017 11:57:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BCC9287F9 for ; Tue, 5 Sep 2017 11:57:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40B5928956; Tue, 5 Sep 2017 11:57:27 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham 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 F41A2287F9 for ; Tue, 5 Sep 2017 11:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750932AbdIEL5X (ORCPT ); Tue, 5 Sep 2017 07:57:23 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:63329 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750922AbdIEL5U (ORCPT ); Tue, 5 Sep 2017 07:57:20 -0400 X-IronPort-AV: E=Sophos;i="5.41,480,1498492800"; d="scan'208";a="48874036" Received: from sjappemgw12.hgst.com (HELO sjappemgw11.hgst.com) ([199.255.44.66]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2017 19:55:50 +0800 Received: from grmp3g2.hitachigst.global (HELO mwashi.localdomain.com) ([10.86.59.51]) by sjappemgw11.hgst.com with ESMTP; 05 Sep 2017 04:55:46 -0700 From: Damien Le Moal To: linux-scsi@vger.kernel.org, "Martin K . Petersen" Cc: Jens Axboe , Christoph Hellwig , Bart Van Assche Subject: [PATCH V3 2/2] scsi: sd: Use sectors_to_logical() Date: Tue, 5 Sep 2017 20:55:36 +0900 Message-Id: <20170905115536.2896-3-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170905115536.2896-1-damien.lemoal@wdc.com> References: <20170905115536.2896-1-damien.lemoal@wdc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Replace open coded conversions. Signed-off-by: Damien Le Moal Reviewed-by: Bart Van Assche --- drivers/scsi/sd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 0a824e9f4d63..c5d05b1c58a5 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -738,8 +738,8 @@ static int sd_setup_unmap_cmnd(struct scsi_cmnd *cmd) { struct scsi_device *sdp = cmd->device; struct request *rq = cmd->request; - u64 sector = blk_rq_pos(rq) >> (ilog2(sdp->sector_size) - 9); - u32 nr_sectors = blk_rq_sectors(rq) >> (ilog2(sdp->sector_size) - 9); + u64 sector = sectors_to_logical(sdp, blk_rq_pos(rq)); + u32 nr_sectors = sectors_to_logical(sdp, blk_rq_sectors(rq)); unsigned int data_len = 24; char *buf; @@ -772,8 +772,8 @@ static int sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, bool unmap) { struct scsi_device *sdp = cmd->device; struct request *rq = cmd->request; - u64 sector = blk_rq_pos(rq) >> (ilog2(sdp->sector_size) - 9); - u32 nr_sectors = blk_rq_sectors(rq) >> (ilog2(sdp->sector_size) - 9); + u64 sector = sectors_to_logical(sdp, blk_rq_pos(rq)); + u32 nr_sectors = sectors_to_logical(sdp, blk_rq_sectors(rq)); u32 data_len = sdp->sector_size; rq->special_vec.bv_page = alloc_page(GFP_ATOMIC | __GFP_ZERO); @@ -802,8 +802,8 @@ static int sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, bool unmap) { struct scsi_device *sdp = cmd->device; struct request *rq = cmd->request; - u64 sector = blk_rq_pos(rq) >> (ilog2(sdp->sector_size) - 9); - u32 nr_sectors = blk_rq_sectors(rq) >> (ilog2(sdp->sector_size) - 9); + u64 sector = sectors_to_logical(sdp, blk_rq_pos(rq)); + u32 nr_sectors = sectors_to_logical(sdp, blk_rq_sectors(rq)); u32 data_len = sdp->sector_size; rq->special_vec.bv_page = alloc_page(GFP_ATOMIC | __GFP_ZERO); @@ -833,8 +833,8 @@ static int sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd) struct request *rq = cmd->request; struct scsi_device *sdp = cmd->device; struct scsi_disk *sdkp = scsi_disk(rq->rq_disk); - u64 sector = blk_rq_pos(rq) >> (ilog2(sdp->sector_size) - 9); - u32 nr_sectors = blk_rq_sectors(rq) >> (ilog2(sdp->sector_size) - 9); + u64 sector = sectors_to_logical(sdp, blk_rq_pos(rq)); + u32 nr_sectors = sectors_to_logical(sdp, blk_rq_sectors(rq)); int ret; if (!(rq->cmd_flags & REQ_NOUNMAP)) {