diff options
author | Axel Lin <axel.lin@gmail.com> | 2011-08-10 09:11:26 -0400 |
---|---|---|
committer | John Stultz <john.stultz@linaro.org> | 2011-08-10 18:54:24 -0400 |
commit | bf6ed027bcc93f8d54d321fe87f0434b25699eb1 (patch) | |
tree | d4a4a0d65edd98eb64d7b4cde72098fdbb21c295 /drivers/rtc/rtc-ep93xx.c | |
parent | 322a8b034003c0d46d39af85bf24fee27b902f48 (diff) |
rtc: ep93xx: Fix 'rtc' may be used uninitialized warning
commit 92d921c5d "rtc: ep93xx: Initialize drvdata before registering device"
ensures the drvdata is initialized prior to registering the rtc device.
But it set the drvdata to an uninitialized pointer.
Thus calling platform_get_drvdata in ep93xx_rtc_remove does not get correct address.
This patch fixes below warning by adding struct rtc_device *rtc to struct ep93xx_rtc.
Then set platform drvdata to ep93xx_rtc instead of rtc.
CC drivers/rtc/rtc-ep93xx.o
drivers/rtc/rtc-ep93xx.c: In function 'ep93xx_rtc_probe':
drivers/rtc/rtc-ep93xx.c:154: warning: 'rtc' may be used uninitialized in this function
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Diffstat (limited to 'drivers/rtc/rtc-ep93xx.c')
-rw-r--r-- | drivers/rtc/rtc-ep93xx.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-ep93xx.c b/drivers/rtc/rtc-ep93xx.c index 335551d333b2..14a42a1edc66 100644 --- a/drivers/rtc/rtc-ep93xx.c +++ b/drivers/rtc/rtc-ep93xx.c | |||
@@ -36,6 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | struct ep93xx_rtc { | 37 | struct ep93xx_rtc { |
38 | void __iomem *mmio_base; | 38 | void __iomem *mmio_base; |
39 | struct rtc_device *rtc; | ||
39 | }; | 40 | }; |
40 | 41 | ||
41 | static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, | 42 | static int ep93xx_rtc_get_swcomp(struct device *dev, unsigned short *preload, |
@@ -130,7 +131,6 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
130 | { | 131 | { |
131 | struct ep93xx_rtc *ep93xx_rtc; | 132 | struct ep93xx_rtc *ep93xx_rtc; |
132 | struct resource *res; | 133 | struct resource *res; |
133 | struct rtc_device *rtc; | ||
134 | int err; | 134 | int err; |
135 | 135 | ||
136 | ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL); | 136 | ep93xx_rtc = devm_kzalloc(&pdev->dev, sizeof(*ep93xx_rtc), GFP_KERNEL); |
@@ -151,12 +151,12 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
151 | return -ENXIO; | 151 | return -ENXIO; |
152 | 152 | ||
153 | pdev->dev.platform_data = ep93xx_rtc; | 153 | pdev->dev.platform_data = ep93xx_rtc; |
154 | platform_set_drvdata(pdev, rtc); | 154 | platform_set_drvdata(pdev, ep93xx_rtc); |
155 | 155 | ||
156 | rtc = rtc_device_register(pdev->name, | 156 | ep93xx_rtc->rtc = rtc_device_register(pdev->name, |
157 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); | 157 | &pdev->dev, &ep93xx_rtc_ops, THIS_MODULE); |
158 | if (IS_ERR(rtc)) { | 158 | if (IS_ERR(ep93xx_rtc->rtc)) { |
159 | err = PTR_ERR(rtc); | 159 | err = PTR_ERR(ep93xx_rtc->rtc); |
160 | goto exit; | 160 | goto exit; |
161 | } | 161 | } |
162 | 162 | ||
@@ -167,7 +167,7 @@ static int __init ep93xx_rtc_probe(struct platform_device *pdev) | |||
167 | return 0; | 167 | return 0; |
168 | 168 | ||
169 | fail: | 169 | fail: |
170 | rtc_device_unregister(rtc); | 170 | rtc_device_unregister(ep93xx_rtc->rtc); |
171 | exit: | 171 | exit: |
172 | platform_set_drvdata(pdev, NULL); | 172 | platform_set_drvdata(pdev, NULL); |
173 | pdev->dev.platform_data = NULL; | 173 | pdev->dev.platform_data = NULL; |
@@ -176,11 +176,11 @@ exit: | |||
176 | 176 | ||
177 | static int __exit ep93xx_rtc_remove(struct platform_device *pdev) | 177 | static int __exit ep93xx_rtc_remove(struct platform_device *pdev) |
178 | { | 178 | { |
179 | struct rtc_device *rtc = platform_get_drvdata(pdev); | 179 | struct ep93xx_rtc *ep93xx_rtc = platform_get_drvdata(pdev); |
180 | 180 | ||
181 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); | 181 | sysfs_remove_group(&pdev->dev.kobj, &ep93xx_rtc_sysfs_files); |
182 | platform_set_drvdata(pdev, NULL); | 182 | platform_set_drvdata(pdev, NULL); |
183 | rtc_device_unregister(rtc); | 183 | rtc_device_unregister(ep93xx_rtc->rtc); |
184 | pdev->dev.platform_data = NULL; | 184 | pdev->dev.platform_data = NULL; |
185 | 185 | ||
186 | return 0; | 186 | return 0; |