Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mirza Krak and committed by
Alexandre Belloni
c18b4c52 aaa6f6ac

+7
+7
drivers/rtc/rtc-pcf85063.c
··· 191 191 const struct i2c_device_id *id) 192 192 { 193 193 struct rtc_device *rtc; 194 + int err; 194 195 195 196 dev_dbg(&client->dev, "%s\n", __func__); 196 197 197 198 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 198 199 return -ENODEV; 200 + 201 + err = i2c_smbus_read_byte_data(client, PCF85063_REG_CTRL1); 202 + if (err < 0) { 203 + dev_err(&client->dev, "RTC chip is not present\n"); 204 + return err; 205 + } 199 206 200 207 rtc = devm_rtc_device_register(&client->dev, 201 208 pcf85063_driver.driver.name,