From: Chanwoo Choi <cw00.choi@samsung.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: a.zummo@towertech.it, kgene.kim@samsung.com,
kyungmin.park@samsung.com, rtc-linux@googlegroups.com,
linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCHv2 1/5] rtc: s3c: Define s3c_rtc structure to remove global variables.
Date: Mon, 25 Aug 2014 09:57:33 +0900 [thread overview]
Message-ID: <53FA89FD.1030004@samsung.com> (raw)
In-Reply-To: <20140822134204.1fa5be7aeb76a50b45ccc5f5@linux-foundation.org>
Dear Andrew,
On 08/23/2014 05:42 AM, Andrew Morton wrote:
> On Tue, 12 Aug 2014 11:01:07 +0900 y@samsung.com wrote:
>
>> This patch define s3c_rtc structure including necessary variables for S3C RTC
>> device instead of global variables. This patch improves the readability by
>> removing global variables.
>
> Below is the v1->v2 delta.
>
> Why were all those tests of info->base added? Can it really be zero?
> I don't see how.
If some functions (e.g., s3c_rtc_settime) accesses the rtc register
by using info->base before the initialization of info->base in s3c_rtc_probe,
I thought that null pointer error would happen.
But, I missed one point which info->base might have the garbate data instead of NULL.
I'll add the initialization code for info->base.
info->base = NULL;
If you don't agree it, I'll drop this code checking the state of info->base on next patchset(v3).
Best Regads,
Chanwoo Choi
>
> --- a/drivers/rtc/rtc-s3c.c~rtc-s3c-define-s3c_rtc-structure-to-remove-global-variables-v2
> +++ a/drivers/rtc/rtc-s3c.c
> @@ -121,6 +121,9 @@ static int s3c_rtc_setaie(struct device
> struct s3c_rtc *info = dev_get_drvdata(dev);
> unsigned int tmp;
>
> + if (!info->base)
> + return -EINVAL;
> +
> dev_dbg(info->dev, "%s: aie=%d\n", __func__, enabled);
>
> clk_enable(info->rtc_clk);
> @@ -180,6 +183,9 @@ static int s3c_rtc_gettime(struct device
> struct s3c_rtc *info = dev_get_drvdata(dev);
> unsigned int have_retried = 0;
>
> + if (!info->base)
> + return -EINVAL;
> +
> clk_enable(info->rtc_clk);
> retry_get_time:
> rtc_tm->tm_min = readb(info->base + S3C2410_RTCMIN);
> @@ -224,6 +230,9 @@ static int s3c_rtc_settime(struct device
> struct s3c_rtc *info = dev_get_drvdata(dev);
> int year = tm->tm_year - 100;
>
> + if (!info->base)
> + return -EINVAL;
> +
> dev_dbg(dev, "set time %04d.%02d.%02d %02d:%02d:%02d\n",
> 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday,
> tm->tm_hour, tm->tm_min, tm->tm_sec);
> @@ -255,6 +264,9 @@ static int s3c_rtc_getalarm(struct devic
> struct rtc_time *alm_tm = &alrm->time;
> unsigned int alm_en;
>
> + if (!info->base)
> + return -EINVAL;
> +
> clk_enable(info->rtc_clk);
> alm_tm->tm_sec = readb(info->base + S3C2410_ALMSEC);
> alm_tm->tm_min = readb(info->base + S3C2410_ALMMIN);
> @@ -317,6 +329,9 @@ static int s3c_rtc_setalarm(struct devic
> struct rtc_time *tm = &alrm->time;
> unsigned int alrm_en;
>
> + if (!info->base)
> + return -EINVAL;
> +
> clk_enable(info->rtc_clk);
> dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n",
> alrm->enabled,
> @@ -357,6 +372,9 @@ static int s3c_rtc_proc(struct device *d
> struct s3c_rtc *info = dev_get_drvdata(dev);
> unsigned int ticnt;
>
> + if (!info->base)
> + return -EINVAL;
> +
> clk_enable(info->rtc_clk);
> if (info->cpu_type == TYPE_S3C64XX) {
> ticnt = readw(info->base + S3C2410_RTCCON);
> @@ -548,7 +566,7 @@ static int s3c_rtc_probe(struct platform
> rtc_tm.tm_min = 0;
> rtc_tm.tm_sec = 0;
>
> - s3c_rtc_settime(NULL, &rtc_tm);
> + s3c_rtc_settime(&pdev->dev, &rtc_tm);
>
> dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n");
> }
> _
>
>
next prev parent reply other threads:[~2014-08-25 0:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <y@samsung.com>
2012-05-22 5:57 ` [PATCH v3 2/2] regulator: Add support for MAX77686 yadi.brar01
2012-05-23 1:40 ` jonghwa3.lee
2012-05-23 4:16 ` Yadwinder Singh Brar
2012-05-23 4:40 ` jonghwa3.lee
2012-05-23 5:23 ` Yadwinder Singh Brar
2012-05-23 5:33 ` jonghwa3.lee
2012-05-23 10:18 ` Mark Brown
2012-05-23 13:02 ` Yadwinder Singh Brar
2012-05-23 6:08 ` Yadwinder Singh Brar
2012-05-23 1:50 ` jonghwa3.lee
2012-05-23 4:17 ` Yadwinder Singh Brar
2014-08-12 2:01 ` [PATCHv2 0/5] rtc: s3c: Refactoring s3c-rtc driver and support Exynos3250 RTC y
2014-08-12 2:01 ` [PATCHv2 1/5] rtc: s3c: Define s3c_rtc structure to remove global variables y
2014-08-22 20:42 ` Andrew Morton
2014-08-25 0:57 ` Chanwoo Choi [this message]
2014-08-26 21:31 ` Andrew Morton
2014-08-28 4:49 ` Chanwoo Choi
2014-08-12 2:01 ` [PATCHv2 2/5] rtc: s3c: Remove warning message when checking coding style with checkpatch script y
2014-08-12 2:01 ` [PATCHv2 3/5] rtc: s3c: Add s3c_rtc_data structure to use variant data instead of s3c_cpu_type y
2014-08-12 2:01 ` [PATCHv2 4/5] rtc: s3c: Add support for RTC of Exynos3250 SoC y
2014-08-12 2:01 ` [PATCHv2 5/5] ARM: dts: Fix wrong compatible string of Exynos3250 RTC dt node y
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=53FA89FD.1030004@samsung.com \
--to=cw00.choi@samsung.com \
--cc=a.zummo@towertech.it \
--cc=akpm@linux-foundation.org \
--cc=kgene.kim@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
/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