From patchwork Fri Jun 29 20:00:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 10497451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D8F1A6022E for ; Fri, 29 Jun 2018 20:00:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA2722976F for ; Fri, 29 Jun 2018 20:00:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE0162977E; Fri, 29 Jun 2018 20:00:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 556D02976F for ; Fri, 29 Jun 2018 20:00:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753568AbeF2UAb (ORCPT ); Fri, 29 Jun 2018 16:00:31 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:39207 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753338AbeF2UA3 (ORCPT ); Fri, 29 Jun 2018 16:00:29 -0400 Received: by mail-oi0-f65.google.com with SMTP id d189-v6so782179oib.6; Fri, 29 Jun 2018 13:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=7cYQb8eAwyMw6qlt0sH5RKGd9N0sDSpkLU1Y3AdKV9A=; b=Tswr+RH+2bfEcmRoFqbriLYeasvB0g9bpysLECnFGYJxVR2ddYJmVQLUGZgSGTDim5 KViGApzC8vJCuliI4k/eVbZTvNt1S4ux7l/PZFeMaExBZbXBl7IMPQVR+gveF9Ib8ygT a2c7Kvu9j3jpEoTfsjrW0YazIxFFCz8S0LuisSDn8sBiTAWJ4eP+f0j4ixe1mo0321L9 mTXTHpc49Qr5+ui1qXpZnRtYhufOGI1xn+AeKeXD7rXN4TFWLp/Gn9o2TtpHMbY8qWxG ZVIQ+fJuIqmks1cdmwOanoGUoGimJpmerdk5fSwc6hrWuVX1fWhy16cj+wbg9icBnxn0 KirA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=7cYQb8eAwyMw6qlt0sH5RKGd9N0sDSpkLU1Y3AdKV9A=; b=DlL4EWLq4sdf0+X0uPjPGIVj/s1OzcMpNpVyVB5D2qU2dD0UfJmxzXJnb34NYjcj7J /DY08N1V2DEuwHZVTntsWQ4ObLmzVEPGhLDw7jfa90AZfzeY6SRtd3AfawE02Ks0X2Fj D1OKXRZgGg7AMIBOYiPnanJy0wGNLVuCAg06amA20t9lATQrdhvx1zdwdKWXdOeHAiFU W8IWOeR2gKNPcvrDPhq5chP7qxHHm4y1bs5jyGFsou03oyXKNhAz5clIxXUky7j5UjKb qjZLDyal048w/E/yByDaRa8N7zT9i4bu19cSGO1FUD/W3BnLmLpiFLvckkLe2vB7zQNg xcdA== X-Gm-Message-State: APt69E2PR2eEX4qFduK1CkDii5aVRenM7qMV7v/XbIRQaUu6uWZDp7Al gWMh6shcFtkdCvS8Als8gv3raXawvEUetn8tejI= X-Google-Smtp-Source: AAOMgpfEfmWo8NxaEwDV0aWLpNn0pLPbNO2x1E+w0p1/klBWp2PFW9cUbnqfHUD8hetjpAGXceOEH8vasDFxC7kBSTI= X-Received: by 2002:aca:b3c5:: with SMTP id c188-v6mr9563262oif.9.1530302428524; Fri, 29 Jun 2018 13:00:28 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1049:0:0:0:0:0 with HTTP; Fri, 29 Jun 2018 13:00:27 -0700 (PDT) In-Reply-To: <1530236132-7968-1-git-send-email-Anson.Huang@nxp.com> References: <1530236132-7968-1-git-send-email-Anson.Huang@nxp.com> From: Fabio Estevam Date: Fri, 29 Jun 2018 17:00:27 -0300 Message-ID: Subject: Re: [PATCH] mmc: core: cd_label must be last entry of mmc_gpio struct To: Anson Huang Cc: Ulf Hansson , Adrian Hunter , Masahiro Yamada , evgreen@chromium.org, Shawn Lin , linux-mmc@vger.kernel.org, linux-kernel , NXP Linux Team Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Anson, On Thu, Jun 28, 2018 at 10:35 PM, Anson Huang 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 > --- > 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: 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 --- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 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