diff mbox series

[V1] mmc: sdhci-uhs2: correction of incorrect type in argument

Message ID 20241030112216.4057-1-victorshihgli@gmail.com
State New
Headers show
Series [V1] mmc: sdhci-uhs2: correction of incorrect type in argument | expand

Commit Message

Victor Shih Oct. 30, 2024, 11:22 a.m. UTC
From: Victor Shih <victor.shih@genesyslogic.com.tw>

There is a type issue in the argument in the __sdhci_uhs2_send_command()
that will generate a warning when building the kernel.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202410260525.ZUuPhMJz-lkp@intel.com/
Signed-off-by: Ben Chuang <ben.chuang@genesyslogic.com.tw>
Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw>
---
 drivers/mmc/host/sdhci-uhs2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Adrian Hunter Oct. 30, 2024, 12:45 p.m. UTC | #1
On 30/10/24 13:22, Victor Shih wrote:
> From: Victor Shih <victor.shih@genesyslogic.com.tw>
> 
> There are unnecessary variables in the sdhci_uhs2_send_command()
> that will generate a warning when building the kernel.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202410252107.y9EgrTbA-lkp@intel.com/
> Signed-off-by: Ben Chuang <ben.chuang@genesyslogic.com.tw>
> Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-uhs2.c | 25 -------------------------
>  1 file changed, 25 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
> index c488c6d56015..43820eb5a7ea 100644
> --- a/drivers/mmc/host/sdhci-uhs2.c
> +++ b/drivers/mmc/host/sdhci-uhs2.c
> @@ -684,7 +684,6 @@ static void __sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_comman
>  
>  static bool sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_command *cmd)
>  {
> -	int flags;
>  	u32 mask;
>  	unsigned long timeout;
>  
> @@ -714,30 +713,6 @@ static bool sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_command
>  
>  	sdhci_uhs2_set_transfer_mode(host, cmd);
>  
> -	if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
> -		WARN_ONCE(1, "Unsupported response type!\n");
> -		/*
> -		 * This does not happen in practice because 136-bit response
> -		 * commands never have busy waiting, so rather than complicate
> -		 * the error path, just remove busy waiting and continue.
> -		 */
> -		cmd->flags &= ~MMC_RSP_BUSY;
> -	}
> -
> -	if (!(cmd->flags & MMC_RSP_PRESENT))
> -		flags = SDHCI_CMD_RESP_NONE;
> -	else if (cmd->flags & MMC_RSP_136)
> -		flags = SDHCI_CMD_RESP_LONG;
> -	else if (cmd->flags & MMC_RSP_BUSY)
> -		flags = SDHCI_CMD_RESP_SHORT_BUSY;
> -	else
> -		flags = SDHCI_CMD_RESP_SHORT;
> -
> -	if (cmd->flags & MMC_RSP_CRC)
> -		flags |= SDHCI_CMD_CRC;
> -	if (cmd->flags & MMC_RSP_OPCODE)
> -		flags |= SDHCI_CMD_INDEX;
> -
>  	timeout = jiffies;
>  	if (host->data_timeout)
>  		timeout += nsecs_to_jiffies(host->data_timeout);
Ulf Hansson Oct. 31, 2024, 4:39 p.m. UTC | #2
On Wed, 30 Oct 2024 at 12:22, Victor Shih <victorshihgli@gmail.com> wrote:
>
> From: Victor Shih <victor.shih@genesyslogic.com.tw>
>
> There are unnecessary variables in the sdhci_uhs2_send_command()
> that will generate a warning when building the kernel.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202410252107.y9EgrTbA-lkp@intel.com/
> Signed-off-by: Ben Chuang <ben.chuang@genesyslogic.com.tw>
> Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw>

Applied for next, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-uhs2.c | 25 -------------------------
>  1 file changed, 25 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
> index c488c6d56015..43820eb5a7ea 100644
> --- a/drivers/mmc/host/sdhci-uhs2.c
> +++ b/drivers/mmc/host/sdhci-uhs2.c
> @@ -684,7 +684,6 @@ static void __sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_comman
>
>  static bool sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_command *cmd)
>  {
> -       int flags;
>         u32 mask;
>         unsigned long timeout;
>
> @@ -714,30 +713,6 @@ static bool sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_command
>
>         sdhci_uhs2_set_transfer_mode(host, cmd);
>
> -       if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
> -               WARN_ONCE(1, "Unsupported response type!\n");
> -               /*
> -                * This does not happen in practice because 136-bit response
> -                * commands never have busy waiting, so rather than complicate
> -                * the error path, just remove busy waiting and continue.
> -                */
> -               cmd->flags &= ~MMC_RSP_BUSY;
> -       }
> -
> -       if (!(cmd->flags & MMC_RSP_PRESENT))
> -               flags = SDHCI_CMD_RESP_NONE;
> -       else if (cmd->flags & MMC_RSP_136)
> -               flags = SDHCI_CMD_RESP_LONG;
> -       else if (cmd->flags & MMC_RSP_BUSY)
> -               flags = SDHCI_CMD_RESP_SHORT_BUSY;
> -       else
> -               flags = SDHCI_CMD_RESP_SHORT;
> -
> -       if (cmd->flags & MMC_RSP_CRC)
> -               flags |= SDHCI_CMD_CRC;
> -       if (cmd->flags & MMC_RSP_OPCODE)
> -               flags |= SDHCI_CMD_INDEX;
> -
>         timeout = jiffies;
>         if (host->data_timeout)
>                 timeout += nsecs_to_jiffies(host->data_timeout);
> --
> 2.25.1
>
Ulf Hansson Oct. 31, 2024, 4:39 p.m. UTC | #3
On Wed, 30 Oct 2024 at 14:08, Adrian Hunter <adrian.hunter@intel.com> wrote:
>
> On 30/10/24 13:22, Victor Shih wrote:
> > From: Victor Shih <victor.shih@genesyslogic.com.tw>
> >
> > There is a type issue in the argument in the __sdhci_uhs2_send_command()
> > that will generate a warning when building the kernel.
> >
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202410260525.ZUuPhMJz-lkp@intel.com/
> > Signed-off-by: Ben Chuang <ben.chuang@genesyslogic.com.tw>
> > Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw>

Applied for next and by adding a suggested-by tag from Adrian, thanks!

> > ---
> >  drivers/mmc/host/sdhci-uhs2.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
> > index 43820eb5a7ea..7f41ca67b069 100644
> > --- a/drivers/mmc/host/sdhci-uhs2.c
> > +++ b/drivers/mmc/host/sdhci-uhs2.c
> > @@ -649,7 +649,8 @@ static void __sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_comman
> >        * MSB when preparing config read/write commands.
> >        */
> >       for (j = 0; j < cmd->uhs2_cmd->payload_len / sizeof(u32); j++) {
> > -             sdhci_writel(host, *(cmd->uhs2_cmd->payload + j), SDHCI_UHS2_CMD_PACKET + i);
> > +             sdhci_writel(host, *(__force u32 *)(cmd->uhs2_cmd->payload + j),
> > +                          SDHCI_UHS2_CMD_PACKET + i);
> >               i += 4;
> >       }
> >
>
> Thanks for doing this.
>
> I just noticed there is another issue that was reported but
> did not get highlighted:
>
> >> drivers/mmc/host/sdhci-uhs2.c:73:16: sparse: sparse: cast to restricted __be16
>
> So the following is needed also:
>
> diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
> index 0a597240d299..c53b64d50c0d 100644
> --- a/drivers/mmc/host/sdhci-uhs2.c
> +++ b/drivers/mmc/host/sdhci-uhs2.c
> @@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(sdhci_uhs2_dump_regs);
>
>  static inline u16 uhs2_dev_cmd(struct mmc_command *cmd)
>  {
> -       return be16_to_cpu((__be16)cmd->uhs2_cmd->arg) & UHS2_ARG_IOADR_MASK;
> +       return be16_to_cpu((__force __be16)cmd->uhs2_cmd->arg) & UHS2_ARG_IOADR_MASK;
>  }
>
>  static inline int mmc_opt_regulator_set_ocr(struct mmc_host *mmc,
>

Let's deal with the issue above as another separate patch on top.
Victor, can you please submit a patch according to the above and add
Adrian's suggested-by tag.

Kind regards
Uffe
Victor Shih Nov. 1, 2024, 10:40 a.m. UTC | #4
On Fri, Nov 1, 2024 at 12:39 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>
> On Wed, 30 Oct 2024 at 14:08, Adrian Hunter <adrian.hunter@intel.com> wrote:
> >
> > On 30/10/24 13:22, Victor Shih wrote:
> > > From: Victor Shih <victor.shih@genesyslogic.com.tw>
> > >
> > > There is a type issue in the argument in the __sdhci_uhs2_send_command()
> > > that will generate a warning when building the kernel.
> > >
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Closes: https://lore.kernel.org/oe-kbuild-all/202410260525.ZUuPhMJz-lkp@intel.com/
> > > Signed-off-by: Ben Chuang <ben.chuang@genesyslogic.com.tw>
> > > Signed-off-by: Victor Shih <victor.shih@genesyslogic.com.tw>
>
> Applied for next and by adding a suggested-by tag from Adrian, thanks!
>
> > > ---
> > >  drivers/mmc/host/sdhci-uhs2.c | 3 ++-
> > >  1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
> > > index 43820eb5a7ea..7f41ca67b069 100644
> > > --- a/drivers/mmc/host/sdhci-uhs2.c
> > > +++ b/drivers/mmc/host/sdhci-uhs2.c
> > > @@ -649,7 +649,8 @@ static void __sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_comman
> > >        * MSB when preparing config read/write commands.
> > >        */
> > >       for (j = 0; j < cmd->uhs2_cmd->payload_len / sizeof(u32); j++) {
> > > -             sdhci_writel(host, *(cmd->uhs2_cmd->payload + j), SDHCI_UHS2_CMD_PACKET + i);
> > > +             sdhci_writel(host, *(__force u32 *)(cmd->uhs2_cmd->payload + j),
> > > +                          SDHCI_UHS2_CMD_PACKET + i);
> > >               i += 4;
> > >       }
> > >
> >
> > Thanks for doing this.
> >
> > I just noticed there is another issue that was reported but
> > did not get highlighted:
> >
> > >> drivers/mmc/host/sdhci-uhs2.c:73:16: sparse: sparse: cast to restricted __be16
> >
> > So the following is needed also:
> >
> > diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
> > index 0a597240d299..c53b64d50c0d 100644
> > --- a/drivers/mmc/host/sdhci-uhs2.c
> > +++ b/drivers/mmc/host/sdhci-uhs2.c
> > @@ -70,7 +70,7 @@ EXPORT_SYMBOL_GPL(sdhci_uhs2_dump_regs);
> >
> >  static inline u16 uhs2_dev_cmd(struct mmc_command *cmd)
> >  {
> > -       return be16_to_cpu((__be16)cmd->uhs2_cmd->arg) & UHS2_ARG_IOADR_MASK;
> > +       return be16_to_cpu((__force __be16)cmd->uhs2_cmd->arg) & UHS2_ARG_IOADR_MASK;
> >  }
> >
> >  static inline int mmc_opt_regulator_set_ocr(struct mmc_host *mmc,
> >
>
> Let's deal with the issue above as another separate patch on top.
> Victor, can you please submit a patch according to the above and add
> Adrian's suggested-by tag.
>
> Kind regards
> Uffe

Hi, Ulf and Adrian

I got it. I will be submitting a separate patch based on the above comments
and adding Adrian's suggested-by tag.
Thank you very much for your help and advice

Thanks, Victor Shih
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci-uhs2.c b/drivers/mmc/host/sdhci-uhs2.c
index 43820eb5a7ea..7f41ca67b069 100644
--- a/drivers/mmc/host/sdhci-uhs2.c
+++ b/drivers/mmc/host/sdhci-uhs2.c
@@ -649,7 +649,8 @@  static void __sdhci_uhs2_send_command(struct sdhci_host *host, struct mmc_comman
 	 * MSB when preparing config read/write commands.
 	 */
 	for (j = 0; j < cmd->uhs2_cmd->payload_len / sizeof(u32); j++) {
-		sdhci_writel(host, *(cmd->uhs2_cmd->payload + j), SDHCI_UHS2_CMD_PACKET + i);
+		sdhci_writel(host, *(__force u32 *)(cmd->uhs2_cmd->payload + j),
+			     SDHCI_UHS2_CMD_PACKET + i);
 		i += 4;
 	}