提交 c18b4c52 编写于 作者: M Mirza Krak 提交者: Alexandre Belloni

rtc: pcf85063: do not register a RTC device if chip is not present

Add a sanity check to see if chip is present. If we can not communicate
with the chip there is no point in registering a RTC device.
Signed-off-by: NMirza Krak <mirza.krak@hostmobility.com>
Signed-off-by: NAlexandre Belloni <alexandre.belloni@free-electrons.com>
上级 aaa6f6ac
...@@ -191,12 +191,19 @@ static int pcf85063_probe(struct i2c_client *client, ...@@ -191,12 +191,19 @@ static int pcf85063_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct rtc_device *rtc; struct rtc_device *rtc;
int err;
dev_dbg(&client->dev, "%s\n", __func__); dev_dbg(&client->dev, "%s\n", __func__);
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
return -ENODEV; return -ENODEV;
err = i2c_smbus_read_byte_data(client, PCF85063_REG_CTRL1);
if (err < 0) {
dev_err(&client->dev, "RTC chip is not present\n");
return err;
}
rtc = devm_rtc_device_register(&client->dev, rtc = devm_rtc_device_register(&client->dev,
pcf85063_driver.driver.name, pcf85063_driver.driver.name,
&pcf85063_rtc_ops, THIS_MODULE); &pcf85063_rtc_ops, THIS_MODULE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册