linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: mtdram: fix build error
@ 2015-09-30  8:35 Sudip Mukherjee
  2015-09-30  8:50 ` kbuild test robot
  2015-09-30  9:28 ` kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Sudip Mukherjee @ 2015-09-30  8:35 UTC (permalink / raw)
  To: David Woodhouse, Brian Norris, Dongsheng Yang
  Cc: linux-kernel, linux-mtd, Stephen Rothwell, Sudip Mukherjee

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!

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 <sudip@vectorindia.org>
---
 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..d085167 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;
+	unsigned long 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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: mtdram: fix build error
  2015-09-30  8:35 [PATCH] mtd: mtdram: fix build error Sudip Mukherjee
@ 2015-09-30  8:50 ` kbuild test robot
  2015-09-30  9:28 ` kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2015-09-30  8:50 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: kbuild-all, David Woodhouse, Brian Norris, Dongsheng Yang,
	linux-kernel, linux-mtd, Stephen Rothwell, Sudip Mukherjee

[-- Attachment #1: Type: text/plain, Size: 2581 bytes --]

Hi Sudip,

[auto build test results on next-20150930 -- if it's inappropriate base, please ignore]

config: cris-etrax-100lx_v2_defconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout f2fe6774b45537be1dca5fee8e89943524bc777b
  # save the attached .config to linux build tree
  make.cross ARCH=cris 

All warnings (new ones prefixed by >>):

   drivers/mtd/devices/mtdram.c: In function 'check_offs_len':
>> drivers/mtd/devices/mtdram.c:42:8: warning: comparison of distinct pointer types lacks a cast [enabled by default]
>> drivers/mtd/devices/mtdram.c:42:2: warning: right shift count >= width of type [enabled by default]
>> drivers/mtd/devices/mtdram.c:42:2: warning: passing argument 1 of '__div64_32' from incompatible pointer type [enabled by default]
   include/asm-generic/div64.h:35:17: note: expected 'uint64_t *' but argument is of type 'long unsigned int *'
   drivers/mtd/devices/mtdram.c:50:8: warning: comparison of distinct pointer types lacks a cast [enabled by default]
   drivers/mtd/devices/mtdram.c:50:2: warning: right shift count >= width of type [enabled by default]
   drivers/mtd/devices/mtdram.c:50:2: warning: passing argument 1 of '__div64_32' from incompatible pointer type [enabled by default]
   include/asm-generic/div64.h:35:17: note: expected 'uint64_t *' but argument is of type 'long unsigned int *'

vim +42 drivers/mtd/devices/mtdram.c

    26	module_param(total_size, ulong, 0);
    27	MODULE_PARM_DESC(total_size, "Total device size in KiB");
    28	module_param(erase_size, ulong, 0);
    29	MODULE_PARM_DESC(erase_size, "Device erase block size in KiB");
    30	#endif
    31	
    32	// We could store these in the mtd structure, but we only support 1 device..
    33	static struct mtd_info *mtd_info;
    34	
    35	static int check_offs_len(struct mtd_info *mtd, loff_t ofs, uint64_t len)
    36	{
    37		int ret = 0;
    38		unsigned long temp_len, rem;
    39	
    40		/* Start address must align on block boundary */
    41		temp_len = ofs;
  > 42		rem = do_div(temp_len, mtd->erasesize);
    43		if (rem) {
    44			pr_debug("%s: unaligned address\n", __func__);
    45			ret = -EINVAL;
    46		}
    47	
    48		/* Length must align on block boundary */
    49		temp_len = len;
    50		rem = do_div(temp_len, mtd->erasesize);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 7946 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: mtdram: fix build error
  2015-09-30  8:35 [PATCH] mtd: mtdram: fix build error Sudip Mukherjee
  2015-09-30  8:50 ` kbuild test robot
@ 2015-09-30  9:28 ` kbuild test robot
  2015-09-30  9:46   ` Sudip Mukherjee
  1 sibling, 1 reply; 4+ messages in thread
From: kbuild test robot @ 2015-09-30  9:28 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: kbuild-all, David Woodhouse, Brian Norris, Dongsheng Yang,
	linux-kernel, linux-mtd, Stephen Rothwell, Sudip Mukherjee

[-- Attachment #1: Type: text/plain, Size: 4915 bytes --]

Hi Sudip,

[auto build test results on next-20150930 -- if it's inappropriate base, please ignore]

config: xtensa-allyesconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout f2fe6774b45537be1dca5fee8e89943524bc777b
  # save the attached .config to linux build tree
  make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   In file included from arch/xtensa/include/generated/asm/div64.h:1:0,
                    from include/linux/kernel.h:136,
                    from include/linux/list.h:8,
                    from include/linux/module.h:9,
                    from drivers/mtd/devices/mtdram.c:12:
   drivers/mtd/devices/mtdram.c: In function 'check_offs_len':
   include/asm-generic/div64.h:43:28: warning: comparison of distinct pointer types lacks a cast
     (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
                               ^
>> drivers/mtd/devices/mtdram.c:42:8: note: in expansion of macro 'do_div'
     rem = do_div(temp_len, mtd->erasesize);
           ^
   drivers/mtd/devices/mtdram.c:42:2: warning: right shift count >= width of type
     rem = do_div(temp_len, mtd->erasesize);
     ^
   In file included from arch/xtensa/include/generated/asm/div64.h:1:0,
                    from include/linux/kernel.h:136,
                    from include/linux/list.h:8,
                    from include/linux/module.h:9,
                    from drivers/mtd/devices/mtdram.c:12:
   include/asm-generic/div64.h:48:11: warning: passing argument 1 of '__div64_32' from incompatible pointer type
      __rem = __div64_32(&(n), __base); \
              ^
>> drivers/mtd/devices/mtdram.c:42:8: note: in expansion of macro 'do_div'
     rem = do_div(temp_len, mtd->erasesize);
           ^
   include/asm-generic/div64.h:35:17: note: expected 'uint64_t *' but argument is of type 'long unsigned int *'
    extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
                    ^
   include/asm-generic/div64.h:43:28: warning: comparison of distinct pointer types lacks a cast
     (void)(((typeof((n)) *)0) == ((uint64_t *)0)); \
                               ^
   drivers/mtd/devices/mtdram.c:50:8: note: in expansion of macro 'do_div'
     rem = do_div(temp_len, mtd->erasesize);
           ^
   drivers/mtd/devices/mtdram.c:50:2: warning: right shift count >= width of type
     rem = do_div(temp_len, mtd->erasesize);
     ^
   In file included from arch/xtensa/include/generated/asm/div64.h:1:0,
                    from include/linux/kernel.h:136,
                    from include/linux/list.h:8,
                    from include/linux/module.h:9,
                    from drivers/mtd/devices/mtdram.c:12:
   include/asm-generic/div64.h:48:11: warning: passing argument 1 of '__div64_32' from incompatible pointer type
      __rem = __div64_32(&(n), __base); \
              ^
   drivers/mtd/devices/mtdram.c:50:8: note: in expansion of macro 'do_div'
     rem = do_div(temp_len, mtd->erasesize);
           ^
   include/asm-generic/div64.h:35:17: note: expected 'uint64_t *' but argument is of type 'long unsigned int *'
    extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
                    ^

vim +/do_div +42 drivers/mtd/devices/mtdram.c

     6	 * Copyright (c) 2005 Joern Engel <joern@wh.fh-wedel.de>
     7	 *
     8	 * This code is GPL
     9	 *
    10	 */
    11	
  > 12	#include <linux/module.h>
    13	#include <linux/slab.h>
    14	#include <linux/ioport.h>
    15	#include <linux/vmalloc.h>
    16	#include <linux/init.h>
    17	#include <linux/mtd/mtd.h>
    18	#include <linux/mtd/mtdram.h>
    19	
    20	static unsigned long total_size = CONFIG_MTDRAM_TOTAL_SIZE;
    21	static unsigned long erase_size = CONFIG_MTDRAM_ERASE_SIZE;
    22	#define MTDRAM_TOTAL_SIZE (total_size * 1024)
    23	#define MTDRAM_ERASE_SIZE (erase_size * 1024)
    24	
    25	#ifdef MODULE
    26	module_param(total_size, ulong, 0);
    27	MODULE_PARM_DESC(total_size, "Total device size in KiB");
    28	module_param(erase_size, ulong, 0);
    29	MODULE_PARM_DESC(erase_size, "Device erase block size in KiB");
    30	#endif
    31	
    32	// We could store these in the mtd structure, but we only support 1 device..
    33	static struct mtd_info *mtd_info;
    34	
    35	static int check_offs_len(struct mtd_info *mtd, loff_t ofs, uint64_t len)
    36	{
    37		int ret = 0;
    38		unsigned long temp_len, rem;
    39	
    40		/* Start address must align on block boundary */
    41		temp_len = ofs;
  > 42		rem = do_div(temp_len, mtd->erasesize);
    43		if (rem) {
    44			pr_debug("%s: unaligned address\n", __func__);
    45			ret = -EINVAL;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 42541 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] mtd: mtdram: fix build error
  2015-09-30  9:28 ` kbuild test robot
@ 2015-09-30  9:46   ` Sudip Mukherjee
  0 siblings, 0 replies; 4+ messages in thread
From: Sudip Mukherjee @ 2015-09-30  9:46 UTC (permalink / raw)
  To: kbuild test robot
  Cc: kbuild-all, David Woodhouse, Brian Norris, Dongsheng Yang,
	linux-kernel, linux-mtd, Stephen Rothwell

On Wed, Sep 30, 2015 at 05:28:10PM +0800, kbuild test robot wrote:
> Hi Sudip,
Thanks for the warning info. v2 is getting tested on arm, cris and
xtensa. Will post after checking them.

regards
sudip

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-30  9:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-30  8:35 [PATCH] mtd: mtdram: fix build error Sudip Mukherjee
2015-09-30  8:50 ` kbuild test robot
2015-09-30  9:28 ` kbuild test robot
2015-09-30  9:46   ` Sudip Mukherjee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).