aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2014-02-12 08:41:21 -0500
committerWim Van Sebroeck <wim@iguana.be>2014-03-31 07:29:18 -0400
commit2e79a368473d55db3237120dea0f561660dac5bd (patch)
treeacf73a7c2bee7723d3019c8ae2ff2ff35d143534
parent4c7fbbc4a57a35ed109f58f52eff1a04660789e9 (diff)
watchdog: xilinx: Use of_property_read_u32
Use of_property_read_u32 functions to clean probe function. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r--drivers/watchdog/of_xilinx_wdt.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/drivers/watchdog/of_xilinx_wdt.c b/drivers/watchdog/of_xilinx_wdt.c
index 3b2469e42138..8c1a3f9fcefe 100644
--- a/drivers/watchdog/of_xilinx_wdt.c
+++ b/drivers/watchdog/of_xilinx_wdt.c
@@ -146,8 +146,7 @@ static u32 xwdt_selftest(struct xwdt_device *xdev)
146static int xwdt_probe(struct platform_device *pdev) 146static int xwdt_probe(struct platform_device *pdev)
147{ 147{
148 int rc; 148 int rc;
149 u32 *tmptr; 149 u32 pfreq, enable_once = 0;
150 u32 *pfreq;
151 struct resource *res; 150 struct resource *res;
152 struct xwdt_device *xdev; 151 struct xwdt_device *xdev;
153 bool no_timeout = false; 152 bool no_timeout = false;
@@ -167,32 +166,28 @@ static int xwdt_probe(struct platform_device *pdev)
167 if (IS_ERR(xdev->base)) 166 if (IS_ERR(xdev->base))
168 return PTR_ERR(xdev->base); 167 return PTR_ERR(xdev->base);
169 168
170 pfreq = (u32 *)of_get_property(pdev->dev.of_node, 169 rc = of_property_read_u32(pdev->dev.of_node, "clock-frequency", &pfreq);
171 "clock-frequency", NULL); 170 if (rc) {
172
173 if (pfreq == NULL) {
174 dev_warn(&pdev->dev, 171 dev_warn(&pdev->dev,
175 "The watchdog clock frequency cannot be obtained\n"); 172 "The watchdog clock frequency cannot be obtained\n");
176 no_timeout = true; 173 no_timeout = true;
177 } 174 }
178 175
179 tmptr = (u32 *)of_get_property(pdev->dev.of_node, 176 rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-interval",
180 "xlnx,wdt-interval", NULL); 177 &xdev->wdt_interval);
181 if (tmptr == NULL) { 178 if (rc) {
182 dev_warn(&pdev->dev, 179 dev_warn(&pdev->dev,
183 "Parameter \"xlnx,wdt-interval\" not found\n"); 180 "Parameter \"xlnx,wdt-interval\" not found\n");
184 no_timeout = true; 181 no_timeout = true;
185 } else {
186 xdev->wdt_interval = *tmptr;
187 } 182 }
188 183
189 tmptr = (u32 *)of_get_property(pdev->dev.of_node, 184 rc = of_property_read_u32(pdev->dev.of_node, "xlnx,wdt-enable-once",
190 "xlnx,wdt-enable-once", NULL); 185 &enable_once);
191 if (tmptr == NULL) { 186 if (rc)
192 dev_warn(&pdev->dev, 187 dev_warn(&pdev->dev,
193 "Parameter \"xlnx,wdt-enable-once\" not found\n"); 188 "Parameter \"xlnx,wdt-enable-once\" not found\n");
194 watchdog_set_nowayout(xilinx_wdt_wdd, true); 189
195 } 190 watchdog_set_nowayout(xilinx_wdt_wdd, enable_once);
196 191
197/* 192/*
198 * Twice of the 2^wdt_interval / freq because the first wdt overflow is 193 * Twice of the 2^wdt_interval / freq because the first wdt overflow is
@@ -200,7 +195,7 @@ static int xwdt_probe(struct platform_device *pdev)
200 */ 195 */
201 if (!no_timeout) 196 if (!no_timeout)
202 xilinx_wdt_wdd->timeout = 2 * ((1 << xdev->wdt_interval) / 197 xilinx_wdt_wdd->timeout = 2 * ((1 << xdev->wdt_interval) /
203 *pfreq); 198 pfreq);
204 199
205 spin_lock_init(&xdev->spinlock); 200 spin_lock_init(&xdev->spinlock);
206 watchdog_set_drvdata(xilinx_wdt_wdd, xdev); 201 watchdog_set_drvdata(xilinx_wdt_wdd, xdev);