Message ID | 20240927132944.19285-2-hardevsinh.palaniya@siliconsignals.io (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [1/4] spi: spi-fsl-dspi: Fix casting warnings | expand |
On Fri, Sep 27, 2024 at 06:58:33PM +0530, Hardevsinh Palaniya wrote: > Sparse warnings: > > drivers/spi/spi-fsl-qspi.c:635:25: warning: cast from restricted __be32 > > Signed-off-by: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io> > --- > drivers/spi/spi-fsl-qspi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c > index 79bac30e79af..e4a2a6049e33 100644 > --- a/drivers/spi/spi-fsl-qspi.c > +++ b/drivers/spi/spi-fsl-qspi.c > @@ -632,7 +632,7 @@ static int fsl_qspi_readl_poll_tout(struct fsl_qspi *q, void __iomem *base, > u32 reg; > > if (!q->devtype_data->little_endian) > - mask = (u32)cpu_to_be32(mask); > + mask =(__force u32)cpu_to_be32(mask); Most this kind warning report the real problem. I don't suggest fix as it the 'if branch' should be removed. and simple return read_poll_timeout(qspi_readl, reg, !(reg & mask), delay_us, timeout_us, q, base); qspi_readl() already handle endian problem. Frank > > return readl_poll_timeout(base, reg, !(reg & mask), delay_us, > timeout_us); > -- > 2.43.0 >
Hi Frank, Thanks for the suggestions >> if (!q->devtype_data->little_endian) >> - mask = (u32)cpu_to_be32(mask); >> + mask =(__force u32)cpu_to_be32(mask); > >Most this kind warning report the real problem. I don't suggest fix as it I’m curious about the types of real problems that might arise >the 'if branch' should be removed. > >and simple > >return read_poll_timeout(qspi_readl, reg, !(reg & mask), delay_us, timeout_us, > q, base); > >qspi_readl() already handle endian problem. I agree , it is a good approach since qspi_readl() already handles the endian issue I will change it to your approach. > >Frank Best Regards, Hardev
Hi Frank, >> if (!q->devtype_data->little_endian) >> - mask = (u32)cpu_to_be32(mask); >> + mask =(__force u32)cpu_to_be32(mask); > >Most this kind warning report the real problem. I don't suggest fix as it Should I drop patches 2 and 4 as per your suggestion. >the 'if branch' should be removed. > >and simple > >return read_poll_timeout(qspi_readl, reg, !(reg & mask), delay_us, timeout_us, q, base); > >qspi_readl() already handle endian problem. would you prefer I resend them with the changes you've recommended? Best Regards, Hardev
diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c index 79bac30e79af..e4a2a6049e33 100644 --- a/drivers/spi/spi-fsl-qspi.c +++ b/drivers/spi/spi-fsl-qspi.c @@ -632,7 +632,7 @@ static int fsl_qspi_readl_poll_tout(struct fsl_qspi *q, void __iomem *base, u32 reg; if (!q->devtype_data->little_endian) - mask = (u32)cpu_to_be32(mask); + mask =(__force u32)cpu_to_be32(mask); return readl_poll_timeout(base, reg, !(reg & mask), delay_us, timeout_us);
Sparse warnings: drivers/spi/spi-fsl-qspi.c:635:25: warning: cast from restricted __be32 Signed-off-by: Hardevsinh Palaniya <hardevsinh.palaniya@siliconsignals.io> --- drivers/spi/spi-fsl-qspi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)