Hi,

On 17/10/2016 at 15:53:31 +0200, Mirza Krak wrote :
> From: Mirza Krak <mirza.k...@hostmobility.com>
> 
> 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.
> 

Does it makes sense? If the device is not present, why has it been
registered in the first place?

> Signed-off-by: Mirza Krak <mirza.k...@hostmobility.com>
> ---
>  drivers/rtc/rtc-pcf85063.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
> index efb0a08..a06dff9 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);
> -- 
> 2.1.4
> 

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups 
"rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rtc-linux+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to