mtd: spi-nor: intel: use ERR_CAST in return statement

Submitted by Nicholas Mc Guire on Feb. 13, 2017, 8:14 a.m.

Details

Message ID 1486973661-1164-1-git-send-email-der.herr@hofr.at
State New
Delegated to: Cyrille Pitchen
Headers show

Commit Message

Nicholas Mc Guire Feb. 13, 2017, 8:14 a.m.
This fixes a sparse warning about incorrect type in retrun expression

Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---

V2: fixed prefix and the truncated commit message noted by Boris Brezillon
    <boris.brezillon@free-electrons.com> - thanks!

sparse complained about:
drivers/mtd/spi-nor/intel-spi.c:731:28: warning: incorrect type in return expression (different address spaces)
drivers/mtd/spi-nor/intel-spi.c:731:28:    expected struct intel_spi *
drivers/mtd/spi-nor/intel-spi.c:731:28:    got void [noderef] <asn:2>*base

Patch was compile tested with: multi_v7_defconfig (implies CONFIG_MTD_SPI_NOR=y)

Patch is against 4.10-rc7 (localversion-next is next-20170213)

 drivers/mtd/spi-nor/intel-spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marek Vasut Feb. 14, 2017, 4:49 a.m.
On 02/13/2017 09:14 AM, Nicholas Mc Guire wrote:
> This fixes a sparse warning about incorrect type in retrun expression
> 
> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> ---
> 
> V2: fixed prefix and the truncated commit message noted by Boris Brezillon
>     <boris.brezillon@free-electrons.com> - thanks!
> 
> sparse complained about:
> drivers/mtd/spi-nor/intel-spi.c:731:28: warning: incorrect type in return expression (different address spaces)
> drivers/mtd/spi-nor/intel-spi.c:731:28:    expected struct intel_spi *
> drivers/mtd/spi-nor/intel-spi.c:731:28:    got void [noderef] <asn:2>*base
> 
> Patch was compile tested with: multi_v7_defconfig (implies CONFIG_MTD_SPI_NOR=y)

Was this driver even enabled with multi_v7 and MTD_SPI_NOR=y ?
Nonetheless, the patch is correct:

Acked-by: Marek Vasut <marek.vasut@gmail.com>

> Patch is against 4.10-rc7 (localversion-next is next-20170213)
> 
>  drivers/mtd/spi-nor/intel-spi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c
> index 2956f2c..1a6de4b 100644
> --- a/drivers/mtd/spi-nor/intel-spi.c
> +++ b/drivers/mtd/spi-nor/intel-spi.c
> @@ -728,7 +728,7 @@ struct intel_spi *intel_spi_probe(struct device *dev,
>  
>  	ispi->base = devm_ioremap_resource(dev, mem);
>  	if (IS_ERR(ispi->base))
> -		return ispi->base;
> +		return ERR_CAST(ispi->base);
>  
>  	ispi->dev = dev;
>  	ispi->info = info;
>
Mika Westerberg Feb. 14, 2017, 10 a.m.
On Mon, Feb 13, 2017 at 09:14:21AM +0100, Nicholas Mc Guire wrote:
> This fixes a sparse warning about incorrect type in retrun expression
> 
> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Boris Brezillon Feb. 14, 2017, 10:09 a.m.
On Mon, 13 Feb 2017 09:14:21 +0100
Nicholas Mc Guire <der.herr@hofr.at> wrote:

> This fixes a sparse warning about incorrect type in retrun expression

						      ^return

and you miss a comma at the end of this sentence.

> 
> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>

You forgot to add my ack (same comment on your other patches).

> ---
> 
> V2: fixed prefix and the truncated commit message noted by Boris Brezillon
>     <boris.brezillon@free-electrons.com> - thanks!
> 
> sparse complained about:
> drivers/mtd/spi-nor/intel-spi.c:731:28: warning: incorrect type in return expression (different address spaces)
> drivers/mtd/spi-nor/intel-spi.c:731:28:    expected struct intel_spi *
> drivers/mtd/spi-nor/intel-spi.c:731:28:    got void [noderef] <asn:2>*base
> 
> Patch was compile tested with: multi_v7_defconfig (implies CONFIG_MTD_SPI_NOR=y)
> 
> Patch is against 4.10-rc7 (localversion-next is next-20170213)
> 
>  drivers/mtd/spi-nor/intel-spi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c
> index 2956f2c..1a6de4b 100644
> --- a/drivers/mtd/spi-nor/intel-spi.c
> +++ b/drivers/mtd/spi-nor/intel-spi.c
> @@ -728,7 +728,7 @@ struct intel_spi *intel_spi_probe(struct device *dev,
>  
>  	ispi->base = devm_ioremap_resource(dev, mem);
>  	if (IS_ERR(ispi->base))
> -		return ispi->base;
> +		return ERR_CAST(ispi->base);
>  
>  	ispi->dev = dev;
>  	ispi->info = info;

Patch hide | download patch | download mbox

diff --git a/drivers/mtd/spi-nor/intel-spi.c b/drivers/mtd/spi-nor/intel-spi.c
index 2956f2c..1a6de4b 100644
--- a/drivers/mtd/spi-nor/intel-spi.c
+++ b/drivers/mtd/spi-nor/intel-spi.c
@@ -728,7 +728,7 @@  struct intel_spi *intel_spi_probe(struct device *dev,
 
 	ispi->base = devm_ioremap_resource(dev, mem);
 	if (IS_ERR(ispi->base))
-		return ispi->base;
+		return ERR_CAST(ispi->base);
 
 	ispi->dev = dev;
 	ispi->info = info;