rtc: max8907c: fix startup crash
Prashant Gaikwad [Fri, 26 Aug 2011 13:25:07 +0000 (18:25 +0530)]
The rtc_device_register() call has changed semantics so that it will
immediately call out to rtc_read_alarm() and since the callbacks require
the drvdata to be set, we need to set it before the registration call to
valid NULL dereference.

Based on 21b398e9670f0bb8f05b7b4cd03e018e8a0b7522

Change-Id: I4960a180ffb63415310bf9fce05de155d0633337
Reviewed-on: http://git-master/r/49460
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>

Rebase-Id: Rb5896ff9928b249d97c263e1647ca451e0380b74

drivers/rtc/rtc-max8907c.c

index 6ea2816..d4cd11a 100644 (file)
@@ -229,6 +229,7 @@ static int max8907c_rtc_probe(struct platform_device *pdev)
                goto out_irq;
        }
 
+       dev_set_drvdata(&pdev->dev, info);
        info->rtc_dev = rtc_device_register("max8907c-rtc", &pdev->dev,
                                        &max8907c_rtc_ops, THIS_MODULE);
        ret = PTR_ERR(info->rtc_dev);
@@ -239,8 +240,6 @@ static int max8907c_rtc_probe(struct platform_device *pdev)
 
        max8907c_set_bits(chip->i2c_power, MAX8907C_REG_SYSENSEL, 0x2, 0x2);
 
-       dev_set_drvdata(&pdev->dev, info);
-
        platform_set_drvdata(pdev, info);
 
        device_init_wakeup(&pdev->dev, 1);