devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Clouter <alex-L4GPcECwBoDe9xe1eoZjHA@public.gmane.org>
To: Ryan Mallon <rmallon-Re5JQEeQqe8AvxtiuMwx3w@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, 2 Apr 2013 00:42:07 +0100	[thread overview]
Message-ID: <20130401234207.GL1953@edkhil> (raw)
In-Reply-To: <515A1A0B.8040803-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

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.

I suspect I am probably missing something *too* obvious here for it to click?

Cheers

>> +	priv->rtc = rtc_device_register("m48t86",
>> +				&pdev->dev, &m48t86_rtc_ops, THIS_MODULE);
>> +	if (IS_ERR(priv->rtc)) {                <--------------
>> +		err = PTR_ERR(priv->rtc);
>> +		if (!pdev->dev.platform_data)   <--------------
>> +			goto out_io_data;
>> +		else
>> +			goto out_free;
>> +	}
>>
>>  	/* read battery status */
>> -	reg = ops->readbyte(M48T86_REG_D);
>> -	dev_info(&dev->dev, "battery %s\n",
>> +	reg = m48t86_rtc_readbyte(&pdev->dev, M48T86_REG_D);
>> +	dev_info(&pdev->dev, "battery %s\n",
>>  		(reg & M48T86_REG_D_VRT) ? "ok" : "exhausted");
>>
>>  	return 0;
>> +
>> +out_io_data:
>> +	iounmap(priv->io_data);
>> +out_io_index:
>> +	iounmap(priv->io_index);
>> +out_release_data:
>> +	release_mem_region(res_data->start, resource_size(res_data));
>> +out_release_index:
>> +	release_mem_region(res_index->start, resource_size(res_index));
>> +out_free:
>> +	platform_set_drvdata(pdev, NULL);
>> +	kfree(priv);
>> +	return err;
>>  }

-- 
Alexander Clouter
.sigmonster says: Zeus gave Leda the bird.
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

  parent reply	other threads:[~2013-04-01 23:42 UTC|newest]

Thread overview: 14+ 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
     [not found] ` <1364858565-17192-1-git-send-email-alex-L4GPcECwBoDe9xe1eoZjHA@public.gmane.org>
2013-04-01 23:22   ` [PATCH 1/6] rtc: rtc-m48t86: move m48t86.h to platform_data Alexander Clouter
2013-04-01 23:22   ` [PATCH 2/6] rtc: rtc-m48t86: add hooks to support driver side memory mapping Alexander Clouter
     [not found]     ` <1364858565-17192-3-git-send-email-alex-L4GPcECwBoDe9xe1eoZjHA@public.gmane.org>
2013-04-01 23:36       ` Ryan Mallon
     [not found]         ` <515A1A0B.8040803-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-04-01 23:42           ` Alexander Clouter [this message]
2013-04-02  5:37             ` Ryan Mallon
2013-04-02  5:34       ` Ryan Mallon
2013-04-02 11:04       ` [PATCHv2 " Alexander Clouter
2013-04-04  7:25       ` [PATCH " Andrew Lunn
2013-04-01 23:22   ` [PATCH 4/6] arm: orion5x: move ts78xx to use rtc-m48t86 driver side memory interface Alexander Clouter
     [not found]     ` <1364858565-17192-5-git-send-email-alex-L4GPcECwBoDe9xe1eoZjHA@public.gmane.org>
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   ` [PATCH 6/6] rtc: rtc-m48t86: add devicetree bindings Alexander Clouter
2013-04-01 23:22 ` [PATCH 3/6] rtc: rtc-m48t86: add detect method for RTC 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=20130401234207.GL1953@edkhil \
    --to=alex-l4gpcecwbode9xe1eozjha@public.gmane.org \
    --cc=a.zummo-BfzFCNDTiLLj+vYz1yj4TQ@public.gmane.org \
    --cc=andrew-g2DYL2Zd6BY@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=hsweeten-3FF4nKcrg1dE2c76skzGb0EOCMrvLtNR@public.gmane.org \
    --cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=rmallon-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
    --cc=rtc-linux-/JYPxA39Uh5TLH3MbocFFw@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).