forked from luck/tmp_suning_uos_patched
rtc: rtc-rs5c313: Fix late hardware init
rs5c313_rtc_init() calls platform_driver_register(), and initializes the hardware. This is wrong because of two reasons: 1. As soon as the driver has been registered, the device may be probed. If devm_rtc_device_register() is called before hardware initialization, reading the current time will fail: rs5c313 rs5c313: rs5c313_rtc_read_time: timeout error rs5c313 rs5c313: registered as rtc0 rs5c313 rs5c313: rs5c313_rtc_read_time: timeout error rs5c313 rs5c313: hctosys: unable to read the hardware clock 2. If the platform device does not exist, the driver will still write to a hardware device that may not be present. Fix this by moving the hardware initialization sequence to the driver's .probe() method. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20200814110731.29029-3-geert+renesas@glider.be
This commit is contained in:
parent
fc9656a370
commit
f65e727464
|
@ -366,8 +366,13 @@ static const struct rtc_class_ops rs5c313_rtc_ops = {
|
|||
|
||||
static int rs5c313_rtc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct rtc_device *rtc = devm_rtc_device_register(&pdev->dev, "rs5c313",
|
||||
&rs5c313_rtc_ops, THIS_MODULE);
|
||||
struct rtc_device *rtc;
|
||||
|
||||
rs5c313_init_port();
|
||||
rs5c313_check_xstp_bit();
|
||||
|
||||
rtc = devm_rtc_device_register(&pdev->dev, "rs5c313", &rs5c313_rtc_ops,
|
||||
THIS_MODULE);
|
||||
|
||||
return PTR_ERR_OR_ZERO(rtc);
|
||||
}
|
||||
|
@ -381,16 +386,7 @@ static struct platform_driver rs5c313_rtc_platform_driver = {
|
|||
|
||||
static int __init rs5c313_rtc_init(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = platform_driver_register(&rs5c313_rtc_platform_driver);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
rs5c313_init_port();
|
||||
rs5c313_check_xstp_bit();
|
||||
|
||||
return 0;
|
||||
return platform_driver_register(&rs5c313_rtc_platform_driver);
|
||||
}
|
||||
|
||||
static void __exit rs5c313_rtc_exit(void)
|
||||
|
|
Loading…
Reference in New Issue
Block a user