2019-04-09 04:59:14

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH] mtd: rawnand: constify elements of NAND_OP_PARSER(_PATTERN)

Currently, drivers are able to constify a nand_op_parser array,
but not nand_op_parser_pattern and nand_op_parser_pattern_elem
since they are instantiated by using the NAND_OP_PARSER(_PATTERN).

Add 'const' to them in order to move more driver data from .data to
.rodata section.

Signed-off-by: Masahiro Yamada <[email protected]>
---

include/linux/mtd/rawnand.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index b7445a44a814..ebde52088e4d 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -805,7 +805,7 @@ struct nand_op_parser_pattern {
#define NAND_OP_PARSER_PATTERN(_exec, ...) \
{ \
.exec = _exec, \
- .elems = (struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }, \
+ .elems = (const struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }, \
.nelems = sizeof((struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }) / \
sizeof(struct nand_op_parser_pattern_elem), \
}
@@ -831,7 +831,7 @@ struct nand_op_parser {

#define NAND_OP_PARSER(...) \
{ \
- .patterns = (struct nand_op_parser_pattern[]) { __VA_ARGS__ }, \
+ .patterns = (const struct nand_op_parser_pattern[]) { __VA_ARGS__ }, \
.npatterns = sizeof((struct nand_op_parser_pattern[]) { __VA_ARGS__ }) / \
sizeof(struct nand_op_parser_pattern), \
}
--
2.17.1


2019-04-09 09:55:18

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH] mtd: rawnand: constify elements of NAND_OP_PARSER(_PATTERN)

On Tue, 9 Apr 2019 13:53:32 +0900
Masahiro Yamada <[email protected]> wrote:

> Currently, drivers are able to constify a nand_op_parser array,
> but not nand_op_parser_pattern and nand_op_parser_pattern_elem
> since they are instantiated by using the NAND_OP_PARSER(_PATTERN).
>
> Add 'const' to them in order to move more driver data from .data to
> .rodata section.
>
> Signed-off-by: Masahiro Yamada <[email protected]>

Reviewed-by: Boris Brezillon <[email protected]>

> ---
>
> include/linux/mtd/rawnand.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index b7445a44a814..ebde52088e4d 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -805,7 +805,7 @@ struct nand_op_parser_pattern {
> #define NAND_OP_PARSER_PATTERN(_exec, ...) \
> { \
> .exec = _exec, \
> - .elems = (struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }, \
> + .elems = (const struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }, \
> .nelems = sizeof((struct nand_op_parser_pattern_elem[]) { __VA_ARGS__ }) / \
> sizeof(struct nand_op_parser_pattern_elem), \
> }
> @@ -831,7 +831,7 @@ struct nand_op_parser {
>
> #define NAND_OP_PARSER(...) \
> { \
> - .patterns = (struct nand_op_parser_pattern[]) { __VA_ARGS__ }, \
> + .patterns = (const struct nand_op_parser_pattern[]) { __VA_ARGS__ }, \
> .npatterns = sizeof((struct nand_op_parser_pattern[]) { __VA_ARGS__ }) / \
> sizeof(struct nand_op_parser_pattern), \
> }

2019-04-18 16:23:13

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH] mtd: rawnand: constify elements of NAND_OP_PARSER(_PATTERN)

Hi Masahiro,

Masahiro Yamada <[email protected]> wrote on Tue, 9 Apr
2019 13:53:32 +0900:

> Currently, drivers are able to constify a nand_op_parser array,
> but not nand_op_parser_pattern and nand_op_parser_pattern_elem
> since they are instantiated by using the NAND_OP_PARSER(_PATTERN).
>
> Add 'const' to them in order to move more driver data from .data to
> .rodata section.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>

Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git
branch nand/next.

Thanks,
Miquèl