From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755730AbbI3N3i (ORCPT ); Wed, 30 Sep 2015 09:29:38 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33643 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755402AbbI3N3g (ORCPT ); Wed, 30 Sep 2015 09:29:36 -0400 From: Sudip Mukherjee To: David Woodhouse , Brian Norris , Dongsheng Yang Cc: linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, lkp@intel.com, Sudip Mukherjee Subject: [PATCH v2] mtd: mtdram: fix build error Date: Wed, 30 Sep 2015 18:59:26 +0530 Message-Id: <1443619766-8134-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org i386 allmodconfig fails with: ERROR: "__umoddi3" [drivers/mtd/devices/mtdram.ko] undefined! ERROR: "__moddi3" [drivers/mtd/devices/mtdram.ko] undefined! arm allmodconfig fails with: ERROR: "__aeabi_uldivmod" [drivers/mtd/devices/mtdram.ko] undefined! ERROR: "__aeabi_ldivmod" [drivers/mtd/devices/mtdram.ko] undefined! mips allmodconfig fails with: ERROR: "__umoddi3" [drivers/mtd/devices/mtdram.ko] undefined! ERROR: "__moddi3" [drivers/mtd/devices/mtdram.ko] undefined! The modulus operation is not being supported by these compilers. Use do_div() instead which returns the remainder. Fixes: 7827e3acad2d ("mtd: mtdram: check offs and len in mtdram->erase") Signed-off-by: Sudip Mukherjee --- v1 showed build warning with cris and xtensa. I have checked v2 with arm, cris and xtensa. drivers/mtd/devices/mtdram.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/devices/mtdram.c b/drivers/mtd/devices/mtdram.c index 73fa297..21b6a05 100644 --- a/drivers/mtd/devices/mtdram.c +++ b/drivers/mtd/devices/mtdram.c @@ -35,15 +35,21 @@ static struct mtd_info *mtd_info; static int check_offs_len(struct mtd_info *mtd, loff_t ofs, uint64_t len) { int ret = 0; + uint64_t temp_len, rem; /* Start address must align on block boundary */ - if (ofs % mtd->erasesize) { + temp_len = ofs; + rem = do_div(temp_len, mtd->erasesize); + if (rem) { pr_debug("%s: unaligned address\n", __func__); ret = -EINVAL; } /* Length must align on block boundary */ - if (len % mtd->erasesize) { + temp_len = len; + rem = do_div(temp_len, mtd->erasesize); + + if (rem) { pr_debug("%s: length not block aligned\n", __func__); ret = -EINVAL; } -- 1.9.1