All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: spi/tegra114: add spi driver
Date: Mon, 4 Apr 2016 11:33:29 +0530	[thread overview]
Message-ID: <570203B1.3040304@nvidia.com> (raw)
In-Reply-To: <20160401135227.GA24190@mwanda>


On Friday 01 April 2016 07:22 PM, Dan Carpenter wrote:
> Hello Laxman Dewangan,
>
> The patch f333a331adfa: "spi/tegra114: add spi driver" from Feb 22,
> 2013, leads to the following static checker warning:
>
> 	drivers/spi/spi-tegra114.c:621 tegra_spi_init_dma_param()
> 	error: uninitialized variable 'dma_phys'.
>
> drivers/spi/spi-tegra114.c
>     583          dma_addr_t dma_phys;
>                  ^^^^^^^^^^^^^^^^^^^
>     584          int ret;
>     585          struct dma_slave_config dma_sconfig;
>     586
>     587          dma_chan = dma_request_slave_channel_reason(tspi->dev,
>     588                                          dma_to_memory ? "rx" : "tx");
>     589          if (IS_ERR(dma_chan)) {
>     590                  ret = PTR_ERR(dma_chan);
>     591                  if (ret != -EPROBE_DEFER)
>     592                          dev_err(tspi->dev,
>     593                                  "Dma channel is not available: %d\n", ret);
>     594                  return ret;
>     595          }
>     596
>     597          dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size,
>     598                                  &dma_phys, GFP_KERNEL);
>
> The issue is that in dma_alloc_attrs() if we can dma_alloc_from_coherent()
> then dma_phys is not set.  I'm getting a couple similar errors and I'm
> not certian what to do about it.
>


The issue is with compiler actually.
we have code as
         dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size,
                                 &dma_phys, GFP_KERNEL);
         if (!dma_buf) {
                 dev_err(tspi->dev, " Not able to allocate the dma 
buffer\n");
                 dma_release_channel(dma_chan);
                 return -ENOMEM;
         }

So if returned value "dma_buf" is not NULL then we can assume that 
dma_phy is initialized other wise it should return NULL.

The static check is not able to find out that calling function has 
initialized it or not.

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
Cc: <linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	<linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: spi/tegra114: add spi driver
Date: Mon, 4 Apr 2016 11:33:29 +0530	[thread overview]
Message-ID: <570203B1.3040304@nvidia.com> (raw)
In-Reply-To: <20160401135227.GA24190@mwanda>


On Friday 01 April 2016 07:22 PM, Dan Carpenter wrote:
> Hello Laxman Dewangan,
>
> The patch f333a331adfa: "spi/tegra114: add spi driver" from Feb 22,
> 2013, leads to the following static checker warning:
>
> 	drivers/spi/spi-tegra114.c:621 tegra_spi_init_dma_param()
> 	error: uninitialized variable 'dma_phys'.
>
> drivers/spi/spi-tegra114.c
>     583          dma_addr_t dma_phys;
>                  ^^^^^^^^^^^^^^^^^^^
>     584          int ret;
>     585          struct dma_slave_config dma_sconfig;
>     586
>     587          dma_chan = dma_request_slave_channel_reason(tspi->dev,
>     588                                          dma_to_memory ? "rx" : "tx");
>     589          if (IS_ERR(dma_chan)) {
>     590                  ret = PTR_ERR(dma_chan);
>     591                  if (ret != -EPROBE_DEFER)
>     592                          dev_err(tspi->dev,
>     593                                  "Dma channel is not available: %d\n", ret);
>     594                  return ret;
>     595          }
>     596
>     597          dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size,
>     598                                  &dma_phys, GFP_KERNEL);
>
> The issue is that in dma_alloc_attrs() if we can dma_alloc_from_coherent()
> then dma_phys is not set.  I'm getting a couple similar errors and I'm
> not certian what to do about it.
>


The issue is with compiler actually.
we have code as
         dma_buf = dma_alloc_coherent(tspi->dev, tspi->dma_buf_size,
                                 &dma_phys, GFP_KERNEL);
         if (!dma_buf) {
                 dev_err(tspi->dev, " Not able to allocate the dma 
buffer\n");
                 dma_release_channel(dma_chan);
                 return -ENOMEM;
         }

So if returned value "dma_buf" is not NULL then we can assume that 
dma_phy is initialized other wise it should return NULL.

The static check is not able to find out that calling function has 
initialized it or not.

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-04-04  6:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-01 13:52 spi/tegra114: add spi driver Dan Carpenter
2016-04-04  6:03 ` Laxman Dewangan [this message]
2016-04-04  6:03   ` Laxman Dewangan
     [not found]   ` <570203B1.3040304-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-04-04  8:56     ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=570203B1.3040304@nvidia.com \
    --to=ldewangan-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
    --cc=dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.