From: rmallon@gmail.com (Ryan Mallon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/6] rtc: rtc-m48t86: add hooks to support driver side memory mapping
Date: Tue, 02 Apr 2013 16:37:36 +1100 [thread overview]
Message-ID: <515A6EA0.1010700@gmail.com> (raw)
In-Reply-To: <20130401234207.GL1953@edkhil>
On 02/04/13 10:42, Alexander Clouter wrote:
> On Tue, Apr 02, 2013 at 10:36:43AM +1100, Ryan Mallon wrote:
>> On 02/04/13 10:22, Alexander Clouter wrote:
>>> If platform_data is not defined (as before), then named memory io
>>> ranges need to be defined ("rtc_index" and "rtc_data"). The driver
>>> then maps those regions and uses them as the RTC index and data
>>> addresses.
>>>
>>> Does compile with the following warnings, I cannot see the codepath
>>> affected myself:
>>> ----
>>> drivers/rtc/rtc-m48t86.c: In function ?m48t86_rtc_probe?:
>>> drivers/rtc/rtc-m48t86.c:180: warning: ?res_index? may be used
>>> uninitialized in this function
>>> drivers/rtc/rtc-m48t86.c:180: warning: ?res_data? may be used
>>> uninitialized in this function
>>
>> It is caused by the exit paths. If pdev->dev.platform_data is set, the
>> res_index and res_data are never initialised, but in the error case you
>> still for rtc_device_register you jump to out_io_data, which will then
>> dereference res_index/res_data. You need to make the exit paths
>> conditional on pdev->dev.platform_data (or init res_index/data to NULL
>> and make the release_mem_regions conditional on that).
>
> However, the 'goto out_io_data' in the 'IS_ERR(priv->rtc)' is wrapped in
> a 'if (!pdev->dev.platform_data)', else we jump to out_free.
Ah right, I missed that. In that case, I can't see the problem either :-/.
>
> I suspect I am probably missing something *too* obvious here for it to
> click?
It could be gcc being dumb, though this does seem a straight-forward
enough case for gcc to get it correct. It would be nice to get rid of
the warning though. Doing:
struct resource *res_index = NULL; /* Avoid GCC warning */
Isn't too costly.
~Ryan
WARNING: multiple messages have this Message-ID (diff)
From: Ryan Mallon <rmallon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Alexander Clouter <alex-L4GPcECwBoDe9xe1eoZjHA@public.gmane.org>
Cc: Alessandro Zummo
<a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org>,
Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org,
Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>,
Hartley Sweeten
<hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [PATCH 2/6] rtc: rtc-m48t86: add hooks to support driver side memory mapping
Date: Tue, 02 Apr 2013 16:37:36 +1100 [thread overview]
Message-ID: <515A6EA0.1010700@gmail.com> (raw)
In-Reply-To: <20130401234207.GL1953@edkhil>
On 02/04/13 10:42, Alexander Clouter wrote:
> On Tue, Apr 02, 2013 at 10:36:43AM +1100, Ryan Mallon wrote:
>> On 02/04/13 10:22, Alexander Clouter wrote:
>>> If platform_data is not defined (as before), then named memory io
>>> ranges need to be defined ("rtc_index" and "rtc_data"). The driver
>>> then maps those regions and uses them as the RTC index and data
>>> addresses.
>>>
>>> Does compile with the following warnings, I cannot see the codepath
>>> affected myself:
>>> ----
>>> drivers/rtc/rtc-m48t86.c: In function ‘m48t86_rtc_probe’:
>>> drivers/rtc/rtc-m48t86.c:180: warning: ‘res_index’ may be used
>>> uninitialized in this function
>>> drivers/rtc/rtc-m48t86.c:180: warning: ‘res_data’ may be used
>>> uninitialized in this function
>>
>> It is caused by the exit paths. If pdev->dev.platform_data is set, the
>> res_index and res_data are never initialised, but in the error case you
>> still for rtc_device_register you jump to out_io_data, which will then
>> dereference res_index/res_data. You need to make the exit paths
>> conditional on pdev->dev.platform_data (or init res_index/data to NULL
>> and make the release_mem_regions conditional on that).
>
> However, the 'goto out_io_data' in the 'IS_ERR(priv->rtc)' is wrapped in
> a 'if (!pdev->dev.platform_data)', else we jump to out_free.
Ah right, I missed that. In that case, I can't see the problem either :-/.
>
> I suspect I am probably missing something *too* obvious here for it to
> click?
It could be gcc being dumb, though this does seem a straight-forward
enough case for gcc to get it correct. It would be nice to get rid of
the warning though. Doing:
struct resource *res_index = NULL; /* Avoid GCC warning */
Isn't too costly.
~Ryan
next prev parent reply other threads:[~2013-04-02 5:37 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-01 23:22 [PATCHv2 0/6] add devicetree bindings for rtc-m48t86 Alexander Clouter
2013-04-01 23:22 ` Alexander Clouter
2013-04-01 23:22 ` [PATCH 1/6] rtc: rtc-m48t86: move m48t86.h to platform_data Alexander Clouter
2013-04-01 23:22 ` Alexander Clouter
2013-04-01 23:22 ` [PATCH 2/6] rtc: rtc-m48t86: add hooks to support driver side memory mapping Alexander Clouter
2013-04-01 23:22 ` Alexander Clouter
2013-04-01 23:36 ` Ryan Mallon
2013-04-01 23:36 ` Ryan Mallon
2013-04-01 23:42 ` Alexander Clouter
2013-04-01 23:42 ` Alexander Clouter
2013-04-02 5:37 ` Ryan Mallon [this message]
2013-04-02 5:37 ` Ryan Mallon
2013-04-02 5:34 ` Ryan Mallon
2013-04-02 5:34 ` Ryan Mallon
2013-04-02 11:04 ` [PATCHv2 " Alexander Clouter
2013-04-02 11:04 ` Alexander Clouter
2013-04-04 7:25 ` [PATCH " Andrew Lunn
2013-04-04 7:25 ` Andrew Lunn
2013-04-01 23:22 ` [PATCH 3/6] rtc: rtc-m48t86: add detect method for RTC Alexander Clouter
2013-04-01 23:22 ` Alexander Clouter
2013-04-01 23:22 ` [PATCH 4/6] arm: orion5x: move ts78xx to use rtc-m48t86 driver side memory interface Alexander Clouter
2013-04-01 23:22 ` Alexander Clouter
2013-04-02 11:50 ` Jason Cooper
2013-04-02 11:50 ` Jason Cooper
2013-04-01 23:22 ` [PATCH 5/6] arm: ep93xx: move ts72xx " Alexander Clouter
2013-04-01 23:22 ` Alexander Clouter
2013-04-01 23:22 ` [PATCH 6/6] rtc: rtc-m48t86: add devicetree bindings Alexander Clouter
2013-04-01 23:22 ` Alexander Clouter
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=515A6EA0.1010700@gmail.com \
--to=rmallon@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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.