summary refs log tree commit diff
path: root/drivers/rtc/rtc-pcf85063.c
diff options
context:
space:
mode:
authorMirza Krak <mirza.krak@hostmobility.com>2016-10-17 15:53:31 +0200
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>2016-11-04 23:08:59 +0100
commitc18b4c52c755175dc62aed7b409dca24f028ce76 (patch)
tree95208b94213cc244f6d3a098f88bc0d73456c747 /drivers/rtc/rtc-pcf85063.c
parentaaa6f6acaa5f89994103384cf7a12d12bb8a1b46 (diff)
downloadlinux-c18b4c52c755175dc62aed7b409dca24f028ce76.tar.gz
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: Mirza Krak <mirza.krak@hostmobility.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Diffstat (limited to 'drivers/rtc/rtc-pcf85063.c')
-rw-r--r--drivers/rtc/rtc-pcf85063.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index efb0a08ac117..a06dff994c83 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -191,12 +191,19 @@ static int pcf85063_probe(struct i2c_client *client,
 				const struct i2c_device_id *id)
 {
 	struct rtc_device *rtc;
+	int err;
 
 	dev_dbg(&client->dev, "%s\n", __func__);
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		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,
 				       pcf85063_driver.driver.name,
 				       &pcf85063_rtc_ops, THIS_MODULE);