[PATCH] rtc: max8925: Set dev_set_drvdata before rtc_device_register

From: John Stultz
Date: Wed Apr 27 2011 - 14:45:21 EST


From: Zhangfei Gao <zhangfei.gao@xxxxxxxxxxx>

We now call rtc_read_alarm from rtc_device_register, so it
is important that the rtc device is fully initialized prior to
reigstration.

Because of this, With rtc-max8925, we see NULL pointer errors,
so call dev_set_drvdata before rtc_device_register

Thomas: This should go in for 2.6.39.

CC: Alessandro Zummo <a.zummo@xxxxxxxxxxxx>
CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Zhangfei Gao <zhangfei.gao@xxxxxxxxxxx>
[Reworded commit message -jstultz]
Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx>
---
drivers/rtc/rtc-max8925.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c
index 174036d..20494b5 100644
--- a/drivers/rtc/rtc-max8925.c
+++ b/drivers/rtc/rtc-max8925.c
@@ -257,6 +257,8 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
goto out_irq;
}

+ dev_set_drvdata(&pdev->dev, info);
+
info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev,
&max8925_rtc_ops, THIS_MODULE);
ret = PTR_ERR(info->rtc_dev);
@@ -265,7 +267,6 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev)
goto out_rtc;
}

- dev_set_drvdata(&pdev->dev, info);
platform_set_drvdata(pdev, info);

return 0;
--
1.7.3.2.146.gca209

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/