rtc: rv8803: switch to rtc_register_device

This removes a possible race condition and allows for further improvement
of the driver.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
This commit is contained in:
Alexandre Belloni 2017-07-06 11:42:03 +02:00
parent 697e5a47aa
commit 7133eca195
1 changed files with 9 additions and 6 deletions

View File

@ -577,6 +577,11 @@ static int rv8803_probe(struct i2c_client *client,
if (flags & RV8803_FLAG_AF) if (flags & RV8803_FLAG_AF)
dev_warn(&client->dev, "An alarm maybe have been missed.\n"); dev_warn(&client->dev, "An alarm maybe have been missed.\n");
rv8803->rtc = devm_rtc_allocate_device(&client->dev);
if (IS_ERR(rv8803->rtc)) {
return PTR_ERR(rv8803->rtc);
}
if (client->irq > 0) { if (client->irq > 0) {
err = devm_request_threaded_irq(&client->dev, client->irq, err = devm_request_threaded_irq(&client->dev, client->irq,
NULL, rv8803_handle_irq, NULL, rv8803_handle_irq,
@ -592,12 +597,10 @@ static int rv8803_probe(struct i2c_client *client,
} }
} }
rv8803->rtc = devm_rtc_device_register(&client->dev, client->name, rv8803->rtc->ops = &rv8803_rtc_ops;
&rv8803_rtc_ops, THIS_MODULE); err = rtc_register_device(rv8803->rtc);
if (IS_ERR(rv8803->rtc)) { if (err)
dev_err(&client->dev, "unable to register the class device\n"); return err;
return PTR_ERR(rv8803->rtc);
}
err = rv8803_write_reg(rv8803->client, RV8803_EXT, RV8803_EXT_WADA); err = rv8803_write_reg(rv8803->client, RV8803_EXT, RV8803_EXT_WADA);
if (err) if (err)