* [PATCH] mmc: core: cd_label must be last entry of mmc_gpio struct
@ 2018-06-29 1:35 Anson Huang
2018-06-29 20:00 ` Fabio Estevam
0 siblings, 1 reply; 2+ messages in thread
From: Anson Huang @ 2018-06-29 1:35 UTC (permalink / raw)
To: ulf.hansson, adrian.hunter, yamada.masahiro, evgreen, shawn.lin,
linux-mmc, linux-kernel
Cc: Linux-imx
commit bfd694d5e21c ("mmc: core: Add tunable delay
before detecting card after card is inserted") adds
"u32 cd_debounce_delay_ms" to the last of mmc_gpio
struct and cause "char cd_label[0]" NOT work as string
pointer of card detect label, when "cat /proc/interrupts",
the devname for card detect gpio is incorrect as below:
144: 0 gpio-mxc 22 Edge ▒
161: 0 gpio-mxc 7 Edge ▒
Making "char cd_label[0]" the last entry of mmc_gpio struct,
the result is correct as below:
144: 0 gpio-mxc 22 Edge 2198000.mmc cd
161: 0 gpio-mxc 7 Edge 2190000.mmc cd
Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
---
drivers/mmc/core/slot-gpio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
index ef05e00..1ccf9dc 100644
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -27,8 +27,8 @@ struct mmc_gpio {
bool override_cd_active_level;
irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id);
char *ro_label;
- char cd_label[0];
u32 cd_debounce_delay_ms;
+ char cd_label[0];
};
static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mmc: core: cd_label must be last entry of mmc_gpio struct
2018-06-29 1:35 [PATCH] mmc: core: cd_label must be last entry of mmc_gpio struct Anson Huang
@ 2018-06-29 20:00 ` Fabio Estevam
0 siblings, 0 replies; 2+ messages in thread
From: Fabio Estevam @ 2018-06-29 20:00 UTC (permalink / raw)
To: Anson Huang
Cc: Ulf Hansson, Adrian Hunter, Masahiro Yamada, evgreen, Shawn Lin,
linux-mmc, linux-kernel, NXP Linux Team
Hi Anson,
On Thu, Jun 28, 2018 at 10:35 PM, Anson Huang <Anson.Huang@nxp.com> wrote:
> commit bfd694d5e21c ("mmc: core: Add tunable delay
> before detecting card after card is inserted") adds
> "u32 cd_debounce_delay_ms" to the last of mmc_gpio
> struct and cause "char cd_label[0]" NOT work as string
> pointer of card detect label, when "cat /proc/interrupts",
> the devname for card detect gpio is incorrect as below:
>
> 144: 0 gpio-mxc 22 Edge ▒
> 161: 0 gpio-mxc 7 Edge ▒
>
> Making "char cd_label[0]" the last entry of mmc_gpio struct,
> the result is correct as below:
>
> 144: 0 gpio-mxc 22 Edge 2198000.mmc cd
> 161: 0 gpio-mxc 7 Edge 2190000.mmc cd
Please add a Fixes: tag.
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
> drivers/mmc/core/slot-gpio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/core/slot-gpio.c b/drivers/mmc/core/slot-gpio.c
> index ef05e00..1ccf9dc 100644
> --- a/drivers/mmc/core/slot-gpio.c
> +++ b/drivers/mmc/core/slot-gpio.c
> @@ -27,8 +27,8 @@ struct mmc_gpio {
> bool override_cd_active_level;
> irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id);
> char *ro_label;
> - char cd_label[0];
> u32 cd_debounce_delay_ms;
> + char cd_label[0];
Thanks for the fix.
A more robust solution would be:
--- a/drivers/mmc/core/slot-gpio.c
+++ b/drivers/mmc/core/slot-gpio.c
@@ -27,8 +27,8 @@ struct mmc_gpio {
bool override_cd_active_level;
irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id);
char *ro_label;
- char cd_label[0];
u32 cd_debounce_delay_ms;
+ char cd_label[];
};
This way if someone tries to rearrange the struct members in the
future, then GCC will complain with the following error:
error: flexible array member not at end of struct
Please see a158531f3c92 ("gpio: 74x164: Fix crash during .remove()")
which provides a nice explanation for this same kind of problem.
Then you can add:
Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-29 20:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 1:35 [PATCH] mmc: core: cd_label must be last entry of mmc_gpio struct Anson Huang
2018-06-29 20:00 ` Fabio Estevam
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).