From patchwork Wed Mar 22 20:59:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9640079 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 5C6C4601E9 for ; Wed, 22 Mar 2017 20:59:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A0D128420 for ; Wed, 22 Mar 2017 20:59:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E81228485; Wed, 22 Mar 2017 20:59:45 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 984A228420 for ; Wed, 22 Mar 2017 20:59:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932573AbdCVU7o (ORCPT ); Wed, 22 Mar 2017 16:59:44 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34420 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932208AbdCVU7n (ORCPT ); Wed, 22 Mar 2017 16:59:43 -0400 Received: by mail-wm0-f66.google.com with SMTP id u132so12908940wmg.1 for ; Wed, 22 Mar 2017 13:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=+Hdfg4/JlFnozAmg5aR787nxZjx8/PAYJnccmfreodU=; b=Hpb3qDnx1UIpo1cCa7GuFWNcopojCppO3HhSyJV8p1mweRczuN8rKB89iajtfgRXl4 +inaExLRe/lK9eRQM26gi6E+YVRM7BBAutQ7JBNoMjU2irKqB2y4TDy9rHhzed4DYelU 9IE+MnsMf+swEY5HKudLj8jdllSkdgrLGELl3KHGYluv6NXEHohD+BQUxDo/zYJm5OEV 9hE+EZYuXja5blpqEYCDJNqLgguKegLJJA/bWdIsSjv64FRfROWMTJHjUpTqST5BJkqr UnVDvPQlYekeHkNV3Pk+5kEk66rQXkTGYnyGXr43w7G5qCzdlkMo8UScgMpw9cqv3hmZ qKIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=+Hdfg4/JlFnozAmg5aR787nxZjx8/PAYJnccmfreodU=; b=i7rafn7cdQ/md85R5UX8zG53J+O6gBSzS7RGg6Y9vJwmPYGN3B89FWzpH6zCCD8pSl NXViCPlPS+RvSqd64HyDng0EQHwF9fb0EQ1+jkwz/ISIk1/NUcDr2tWHnAOKc9aVa6I8 j/wHRImOHbIZRuzIppf09QhAdeOSFCALmXritYkmCk5vID+jzCYKT9jCPlj6VEw0N8pu 6alySUsM/2SVPTUbfkVF5OTic5MY/rFMVROTzRmqtjNWrJSQqooXeAWXaOEJCbUo7ttz /hVFOllRpzbNp1SmEzIPSev14skXulS+2vNGTeahv6WiwNG+XHpP1aNkSx2z9RQvmGYQ +IvQ== X-Gm-Message-State: AFeK/H0Vb98cZzgow9/BiKVOgpfvpiVGYZg9zwTh87sDeFJZBZdjAvQ+LJ8Nm5lEDWhaLg== X-Received: by 10.28.207.14 with SMTP id f14mr9597266wmg.72.1490216380968; Wed, 22 Mar 2017 13:59:40 -0700 (PDT) Received: from ?IPv6:2003:c6:ebdc:4000:94d5:56f1:aebf:596a? (p200300C6EBDC400094D556F1AEBF596A.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:94d5:56f1:aebf:596a]) by smtp.googlemail.com with ESMTPSA id 190sm1719423wmk.17.2017.03.22.13.59.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Mar 2017 13:59:40 -0700 (PDT) To: Ulf Hansson Cc: "linux-mmc@vger.kernel.org" From: Heiner Kallweit Subject: [PATCH] mmc: sdio: improve mmc_io_rw_extended Message-ID: <76e7bc2c-0cb0-4fca-7e2f-00770cd72a1b@gmail.com> Date: Wed, 22 Mar 2017 21:59:29 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Improve mmc_io_rw_extended a little: - using DIV_ROUND_UP achieves the same but is better readable - simplify code by using sg_set_buf - simplify one statement by using -= operator Signed-off-by: Heiner Kallweit --- drivers/mmc/core/sdio_ops.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c index 3c0d3ab4..abaaba38 100644 --- a/drivers/mmc/core/sdio_ops.c +++ b/drivers/mmc/core/sdio_ops.c @@ -152,7 +152,7 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; left_size = data.blksz * data.blocks; - nents = (left_size - 1) / seg_size + 1; + nents = DIV_ROUND_UP(left_size, seg_size); if (nents > 1) { if (sg_alloc_table(&sgtable, nents, GFP_KERNEL)) return -ENOMEM; @@ -161,10 +161,9 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, data.sg_len = nents; for_each_sg(data.sg, sg_ptr, data.sg_len, i) { - sg_set_page(sg_ptr, virt_to_page(buf + (i * seg_size)), - min(seg_size, left_size), - offset_in_page(buf + (i * seg_size))); - left_size = left_size - seg_size; + sg_set_buf(sg_ptr, buf + i * seg_size, + min(seg_size, left_size)); + left_size -= seg_size; } } else { data.sg = &sg;