2020-12-22 13:35:17

by Zheng Yongjun

[permalink] [raw]
Subject: [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation

Don't open-code DIV_ROUND_UP() kernel macro.

Signed-off-by: Zheng Yongjun <[email protected]>
---
drivers/misc/kgdbts.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 945701bce553..cd086921a792 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -139,9 +139,8 @@ static int restart_from_top_after_write;
static int sstep_state;

/* Storage for the registers, in GDB format. */
-static unsigned long kgdbts_gdb_regs[(NUMREGBYTES +
- sizeof(unsigned long) - 1) /
- sizeof(unsigned long)];
+static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
+ sizeof(unsigned long)i)];
static struct pt_regs kgdbts_regs;

/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
--
2.22.0


2020-12-22 17:14:14

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation

On Tue, Dec 22, 2020 at 09:33:44PM +0800, Zheng Yongjun wrote:
> Don't open-code DIV_ROUND_UP() kernel macro.
>
> Signed-off-by: Zheng Yongjun <[email protected]>
> ---
> drivers/misc/kgdbts.c | 5 ++---

Arguably this patch should have kgdbts in the Subject line.


> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
> index 945701bce553..cd086921a792 100644
> --- a/drivers/misc/kgdbts.c
> +++ b/drivers/misc/kgdbts.c
> @@ -139,9 +139,8 @@ static int restart_from_top_after_write;
> static int sstep_state;
>
> /* Storage for the registers, in GDB format. */
> -static unsigned long kgdbts_gdb_regs[(NUMREGBYTES +
> - sizeof(unsigned long) - 1) /
> - sizeof(unsigned long)];
> +static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
> + sizeof(unsigned long)i)];

How was this patch tested? This code does not look like it is
compilable.


Daniel.

2020-12-29 02:57:57

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH -next] misc: use DIV_ROUND_UP macro to do calculation

Hi Zheng,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20201222]

url: https://github.com/0day-ci/linux/commits/Zheng-Yongjun/misc-use-DIV_ROUND_UP-macro-to-do-calculation/20201222-220138
base: 6c3eb1b174c07bcaa927003e8bc91e81ab1d5a9e
config: microblaze-randconfig-r022-20201221 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5b74808b6866933e6adc4d6475429e77c3ccbb23
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Zheng-Yongjun/misc-use-DIV_ROUND_UP-macro-to-do-calculation/20201222-220138
git checkout 5b74808b6866933e6adc4d6475429e77c3ccbb23
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

In file included from include/vdso/const.h:5,
from include/linux/const.h:4,
from include/linux/bits.h:5,
from include/linux/bitops.h:6,
from include/linux/kernel.h:11,
from drivers/misc/kgdbts.c:85:
>> drivers/misc/kgdbts.c:143:31: error: expected ')' before 'i'
143 | sizeof(unsigned long)i)];
| ^
include/uapi/linux/const.h:34:46: note: in definition of macro '__KERNEL_DIV_ROUND_UP'
34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
| ^
drivers/misc/kgdbts.c:142:38: note: in expansion of macro 'DIV_ROUND_UP'
142 | static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
| ^~~~~~~~~~~~
include/uapi/linux/const.h:34:45: note: to match this '('
34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
| ^
include/linux/math.h:36:22: note: in expansion of macro '__KERNEL_DIV_ROUND_UP'
36 | #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
| ^~~~~~~~~~~~~~~~~~~~~
drivers/misc/kgdbts.c:142:38: note: in expansion of macro 'DIV_ROUND_UP'
142 | static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
| ^~~~~~~~~~~~
>> drivers/misc/kgdbts.c:143:31: error: expected ')' before 'i'
143 | sizeof(unsigned long)i)];
| ^
include/uapi/linux/const.h:34:57: note: in definition of macro '__KERNEL_DIV_ROUND_UP'
34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
| ^
drivers/misc/kgdbts.c:142:38: note: in expansion of macro 'DIV_ROUND_UP'
142 | static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
| ^~~~~~~~~~~~
include/uapi/linux/const.h:34:56: note: to match this '('
34 | #define __KERNEL_DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
| ^
include/linux/math.h:36:22: note: in expansion of macro '__KERNEL_DIV_ROUND_UP'
36 | #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
| ^~~~~~~~~~~~~~~~~~~~~
drivers/misc/kgdbts.c:142:38: note: in expansion of macro 'DIV_ROUND_UP'
142 | static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
| ^~~~~~~~~~~~


vim +143 drivers/misc/kgdbts.c

140
141 /* Storage for the registers, in GDB format. */
142 static unsigned long kgdbts_gdb_regs[DIV_ROUND_UP(NUMREGBYTES,
> 143 sizeof(unsigned long)i)];
144 static struct pt_regs kgdbts_regs;
145

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (4.22 kB)
.config.gz (35.14 kB)
Download all attachments