* [PATCH] mtd: nand: Fix build issues due to an anonymous union
@ 2018-01-19 18:11 Miquel Raynal
2018-01-19 18:13 ` Boris Brezillon
2018-01-20 13:52 ` Boris Brezillon
0 siblings, 2 replies; 4+ messages in thread
From: Miquel Raynal @ 2018-01-19 18:11 UTC (permalink / raw)
To: Boris Brezillon, Richard Weinberger, David Woodhouse,
Brian Norris, Marek Vasut, Cyrille Pitchen
Cc: linux-mtd, Andrew Morton, Miquel Raynal
GCC-4.4.4 raises errors when assigning a parameter in an anonymous
union, leading to this kind of failure:
drivers/mtd/nand/marvell_nand.c:1936:
warning: missing braces around initializer
warning: (near initialization for '(anonymous)[1].<anonymous>')
error: unknown field 'data' specified in initializer
error: unknown field 'addr' specified in initializer
Work around the situation by naming these unions.
Reported-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
---
drivers/mtd/nand/nand_base.c | 13 +++++++------
include/linux/mtd/rawnand.h | 14 ++++++++++----
2 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index e4e39890a975..a3260e6207b8 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2332,23 +2332,24 @@ nand_op_parser_must_split_instr(const struct nand_op_parser_pattern_elem *pat,
{
switch (pat->type) {
case NAND_OP_ADDR_INSTR:
- if (!pat->addr.maxcycles)
+ if (!pat->ctx.addr.maxcycles)
break;
if (instr->ctx.addr.naddrs - *start_offset >
- pat->addr.maxcycles) {
- *start_offset += pat->addr.maxcycles;
+ pat->ctx.addr.maxcycles) {
+ *start_offset += pat->ctx.addr.maxcycles;
return true;
}
break;
case NAND_OP_DATA_IN_INSTR:
case NAND_OP_DATA_OUT_INSTR:
- if (!pat->data.maxlen)
+ if (!pat->ctx.data.maxlen)
break;
- if (instr->ctx.data.len - *start_offset > pat->data.maxlen) {
- *start_offset += pat->data.maxlen;
+ if (instr->ctx.data.len - *start_offset >
+ pat->ctx.data.maxlen) {
+ *start_offset += pat->ctx.data.maxlen;
return true;
}
break;
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index 469dc724f5df..f89fd2331f4a 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -962,7 +962,7 @@ struct nand_op_parser_pattern_elem {
union {
struct nand_op_parser_addr_constraints addr;
struct nand_op_parser_data_constraints data;
- };
+ } ctx;
};
#define NAND_OP_PARSER_PAT_CMD_ELEM(_opt) \
@@ -975,21 +975,27 @@ struct nand_op_parser_pattern_elem {
{ \
.type = NAND_OP_ADDR_INSTR, \
.optional = _opt, \
- .addr.maxcycles = _maxcycles, \
+ .ctx.addr = { \
+ .maxcycles = _maxcycles, \
+ }, \
}
#define NAND_OP_PARSER_PAT_DATA_IN_ELEM(_opt, _maxlen) \
{ \
.type = NAND_OP_DATA_IN_INSTR, \
.optional = _opt, \
- .data.maxlen = _maxlen, \
+ .ctx.data = { \
+ .maxlen = _maxlen, \
+ }, \
}
#define NAND_OP_PARSER_PAT_DATA_OUT_ELEM(_opt, _maxlen) \
{ \
.type = NAND_OP_DATA_OUT_INSTR, \
.optional = _opt, \
- .data.maxlen = _maxlen, \
+ .ctx.data = { \
+ .maxlen = _maxlen, \
+ }, \
}
#define NAND_OP_PARSER_PAT_WAITRDY_ELEM(_opt) \
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: nand: Fix build issues due to an anonymous union
2018-01-19 18:11 [PATCH] mtd: nand: Fix build issues due to an anonymous union Miquel Raynal
@ 2018-01-19 18:13 ` Boris Brezillon
2018-01-19 19:33 ` Andrew Morton
2018-01-20 13:52 ` Boris Brezillon
1 sibling, 1 reply; 4+ messages in thread
From: Boris Brezillon @ 2018-01-19 18:13 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
Cyrille Pitchen, linux-mtd, Andrew Morton
On Fri, 19 Jan 2018 19:11:27 +0100
Miquel Raynal <miquel.raynal@free-electrons.com> wrote:
> GCC-4.4.4 raises errors when assigning a parameter in an anonymous
> union, leading to this kind of failure:
>
> drivers/mtd/nand/marvell_nand.c:1936:
> warning: missing braces around initializer
> warning: (near initialization for '(anonymous)[1].<anonymous>')
> error: unknown field 'data' specified in initializer
> error: unknown field 'addr' specified in initializer
>
> Work around the situation by naming these unions.
>
> Reported-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
> ---
> drivers/mtd/nand/nand_base.c | 13 +++++++------
> include/linux/mtd/rawnand.h | 14 ++++++++++----
> 2 files changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index e4e39890a975..a3260e6207b8 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2332,23 +2332,24 @@ nand_op_parser_must_split_instr(const struct nand_op_parser_pattern_elem *pat,
> {
> switch (pat->type) {
> case NAND_OP_ADDR_INSTR:
> - if (!pat->addr.maxcycles)
> + if (!pat->ctx.addr.maxcycles)
> break;
>
> if (instr->ctx.addr.naddrs - *start_offset >
> - pat->addr.maxcycles) {
> - *start_offset += pat->addr.maxcycles;
> + pat->ctx.addr.maxcycles) {
> + *start_offset += pat->ctx.addr.maxcycles;
> return true;
> }
> break;
>
> case NAND_OP_DATA_IN_INSTR:
> case NAND_OP_DATA_OUT_INSTR:
> - if (!pat->data.maxlen)
> + if (!pat->ctx.data.maxlen)
> break;
>
> - if (instr->ctx.data.len - *start_offset > pat->data.maxlen) {
> - *start_offset += pat->data.maxlen;
> + if (instr->ctx.data.len - *start_offset >
> + pat->ctx.data.maxlen) {
> + *start_offset += pat->ctx.data.maxlen;
> return true;
> }
> break;
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index 469dc724f5df..f89fd2331f4a 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -962,7 +962,7 @@ struct nand_op_parser_pattern_elem {
> union {
> struct nand_op_parser_addr_constraints addr;
> struct nand_op_parser_data_constraints data;
> - };
> + } ctx;
> };
>
> #define NAND_OP_PARSER_PAT_CMD_ELEM(_opt) \
> @@ -975,21 +975,27 @@ struct nand_op_parser_pattern_elem {
> { \
> .type = NAND_OP_ADDR_INSTR, \
> .optional = _opt, \
> - .addr.maxcycles = _maxcycles, \
> + .ctx.addr = { \
> + .maxcycles = _maxcycles, \
> + }, \
Or just
.ctx.addr.maxcycles = _maxcycles,
No need to send a new version, I'll fix it when applying.
> }
>
> #define NAND_OP_PARSER_PAT_DATA_IN_ELEM(_opt, _maxlen) \
> { \
> .type = NAND_OP_DATA_IN_INSTR, \
> .optional = _opt, \
> - .data.maxlen = _maxlen, \
> + .ctx.data = { \
> + .maxlen = _maxlen, \
> + }, \
> }
>
> #define NAND_OP_PARSER_PAT_DATA_OUT_ELEM(_opt, _maxlen) \
> { \
> .type = NAND_OP_DATA_OUT_INSTR, \
> .optional = _opt, \
> - .data.maxlen = _maxlen, \
> + .ctx.data = { \
> + .maxlen = _maxlen, \
> + }, \
> }
>
> #define NAND_OP_PARSER_PAT_WAITRDY_ELEM(_opt) \
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: nand: Fix build issues due to an anonymous union
2018-01-19 18:13 ` Boris Brezillon
@ 2018-01-19 19:33 ` Andrew Morton
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2018-01-19 19:33 UTC (permalink / raw)
To: Boris Brezillon
Cc: Miquel Raynal, Richard Weinberger, David Woodhouse, Brian Norris,
Marek Vasut, Cyrille Pitchen, linux-mtd
On Fri, 19 Jan 2018 19:13:39 +0100 Boris Brezillon <boris.brezillon@free-electrons.com> wrote:
> On Fri, 19 Jan 2018 19:11:27 +0100
> Miquel Raynal <miquel.raynal@free-electrons.com> wrote:
>
> > GCC-4.4.4 raises errors when assigning a parameter in an anonymous
> > union, leading to this kind of failure:
> >
> > drivers/mtd/nand/marvell_nand.c:1936:
> > warning: missing braces around initializer
> > warning: (near initialization for '(anonymous)[1].<anonymous>')
> > error: unknown field 'data' specified in initializer
> > error: unknown field 'addr' specified in initializer
> >
> > Work around the situation by naming these unions.
> >
> > Reported-by: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Tested-by: Andrew Morton <akpm@linux-foundation.org>
> > @@ -975,21 +975,27 @@ struct nand_op_parser_pattern_elem {
> > { \
> > .type = NAND_OP_ADDR_INSTR, \
> > .optional = _opt, \
> > - .addr.maxcycles = _maxcycles, \
> > + .ctx.addr = { \
> > + .maxcycles = _maxcycles, \
> > + }, \
>
> Or just
> .ctx.addr.maxcycles = _maxcycles,
>
> No need to send a new version, I'll fix it when applying.
Yes, this also works with gcc-4.4.4:
--- a/include/linux/mtd/rawnand.h~mtd-nand-fix-build-issues-due-to-an-anonymous-union-fix
+++ a/include/linux/mtd/rawnand.h
@@ -975,27 +975,21 @@ struct nand_op_parser_pattern_elem {
{ \
.type = NAND_OP_ADDR_INSTR, \
.optional = _opt, \
- .ctx.addr = { \
- .maxcycles = _maxcycles, \
- }, \
+ .ctx.addr.maxcycles = _maxcycles, \
}
#define NAND_OP_PARSER_PAT_DATA_IN_ELEM(_opt, _maxlen) \
{ \
.type = NAND_OP_DATA_IN_INSTR, \
.optional = _opt, \
- .ctx.data = { \
- .maxlen = _maxlen, \
- }, \
+ .ctx.data.maxlen = _maxlen, \
}
#define NAND_OP_PARSER_PAT_DATA_OUT_ELEM(_opt, _maxlen) \
{ \
.type = NAND_OP_DATA_OUT_INSTR, \
.optional = _opt, \
- .ctx.data = { \
- .maxlen = _maxlen, \
- }, \
+ .ctx.data.maxlen = _maxlen, \
}
#define NAND_OP_PARSER_PAT_WAITRDY_ELEM(_opt) \
_
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: nand: Fix build issues due to an anonymous union
2018-01-19 18:11 [PATCH] mtd: nand: Fix build issues due to an anonymous union Miquel Raynal
2018-01-19 18:13 ` Boris Brezillon
@ 2018-01-20 13:52 ` Boris Brezillon
1 sibling, 0 replies; 4+ messages in thread
From: Boris Brezillon @ 2018-01-20 13:52 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, David Woodhouse, Brian Norris, Marek Vasut,
Cyrille Pitchen, linux-mtd, Andrew Morton
On Fri, 19 Jan 2018 19:11:27 +0100
Miquel Raynal <miquel.raynal@free-electrons.com> wrote:
> GCC-4.4.4 raises errors when assigning a parameter in an anonymous
> union, leading to this kind of failure:
>
> drivers/mtd/nand/marvell_nand.c:1936:
> warning: missing braces around initializer
> warning: (near initialization for '(anonymous)[1].<anonymous>')
> error: unknown field 'data' specified in initializer
> error: unknown field 'addr' specified in initializer
>
> Work around the situation by naming these unions.
>
> Reported-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
Applied.
Thanks,
Boris
> ---
> drivers/mtd/nand/nand_base.c | 13 +++++++------
> include/linux/mtd/rawnand.h | 14 ++++++++++----
> 2 files changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index e4e39890a975..a3260e6207b8 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -2332,23 +2332,24 @@ nand_op_parser_must_split_instr(const struct nand_op_parser_pattern_elem *pat,
> {
> switch (pat->type) {
> case NAND_OP_ADDR_INSTR:
> - if (!pat->addr.maxcycles)
> + if (!pat->ctx.addr.maxcycles)
> break;
>
> if (instr->ctx.addr.naddrs - *start_offset >
> - pat->addr.maxcycles) {
> - *start_offset += pat->addr.maxcycles;
> + pat->ctx.addr.maxcycles) {
> + *start_offset += pat->ctx.addr.maxcycles;
> return true;
> }
> break;
>
> case NAND_OP_DATA_IN_INSTR:
> case NAND_OP_DATA_OUT_INSTR:
> - if (!pat->data.maxlen)
> + if (!pat->ctx.data.maxlen)
> break;
>
> - if (instr->ctx.data.len - *start_offset > pat->data.maxlen) {
> - *start_offset += pat->data.maxlen;
> + if (instr->ctx.data.len - *start_offset >
> + pat->ctx.data.maxlen) {
> + *start_offset += pat->ctx.data.maxlen;
> return true;
> }
> break;
> diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
> index 469dc724f5df..f89fd2331f4a 100644
> --- a/include/linux/mtd/rawnand.h
> +++ b/include/linux/mtd/rawnand.h
> @@ -962,7 +962,7 @@ struct nand_op_parser_pattern_elem {
> union {
> struct nand_op_parser_addr_constraints addr;
> struct nand_op_parser_data_constraints data;
> - };
> + } ctx;
> };
>
> #define NAND_OP_PARSER_PAT_CMD_ELEM(_opt) \
> @@ -975,21 +975,27 @@ struct nand_op_parser_pattern_elem {
> { \
> .type = NAND_OP_ADDR_INSTR, \
> .optional = _opt, \
> - .addr.maxcycles = _maxcycles, \
> + .ctx.addr = { \
> + .maxcycles = _maxcycles, \
> + }, \
> }
>
> #define NAND_OP_PARSER_PAT_DATA_IN_ELEM(_opt, _maxlen) \
> { \
> .type = NAND_OP_DATA_IN_INSTR, \
> .optional = _opt, \
> - .data.maxlen = _maxlen, \
> + .ctx.data = { \
> + .maxlen = _maxlen, \
> + }, \
> }
>
> #define NAND_OP_PARSER_PAT_DATA_OUT_ELEM(_opt, _maxlen) \
> { \
> .type = NAND_OP_DATA_OUT_INSTR, \
> .optional = _opt, \
> - .data.maxlen = _maxlen, \
> + .ctx.data = { \
> + .maxlen = _maxlen, \
> + }, \
> }
>
> #define NAND_OP_PARSER_PAT_WAITRDY_ELEM(_opt) \
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-20 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 18:11 [PATCH] mtd: nand: Fix build issues due to an anonymous union Miquel Raynal
2018-01-19 18:13 ` Boris Brezillon
2018-01-19 19:33 ` Andrew Morton
2018-01-20 13:52 ` Boris Brezillon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.