diff mbox series

[v2,09/11] rtc: rx8010: switch to using the preferred RTC API

Message ID 20200910130446.5689-10-brgl@bgdev.pl
State Superseded
Headers show
Series rtc: rx8010: use regmap instead of i2c smbus API | expand

Commit Message

Bartosz Golaszewski Sept. 10, 2020, 1:04 p.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Use devm_rtc_allocate_device() + rtc_register_device() instead of the
deprecated devm_rtc_device_register().

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/rtc/rtc-rx8010.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Comments

Alexandre Belloni Sept. 11, 2020, 12:33 p.m. UTC | #1
On 10/09/2020 15:04:44+0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> 
> Use devm_rtc_allocate_device() + rtc_register_device() instead of the
> deprecated devm_rtc_device_register().
> 
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> ---
>  drivers/rtc/rtc-rx8010.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c
> index 0665878e8843..bb6578aad972 100644
> --- a/drivers/rtc/rtc-rx8010.c
> +++ b/drivers/rtc/rtc-rx8010.c
> @@ -447,16 +447,21 @@ static int rx8010_probe(struct i2c_client *client,
>  		}
>  	}
>  
> -	rx8010->rtc = devm_rtc_device_register(dev, client->name,
> -		&rx8010_rtc_ops, THIS_MODULE);
> -
> +	rx8010->rtc = devm_rtc_allocate_device(dev);
>  	if (IS_ERR(rx8010->rtc)) {
> -		dev_err(dev, "unable to register the class device\n");
> +		dev_err(dev, "unable to allocate rtc device\n");
>  		return PTR_ERR(rx8010->rtc);
>  	}
>  
> +	rx8010->rtc->ops = &rx8010_rtc_ops;
>  	rx8010->rtc->max_user_freq = 1;
>  
> +	err = rtc_register_device(rx8010->rtc);
> +	if (err) {
> +		dev_err(dev, "unable to register the class device\n");

There is no path were this would fail silently so I prefer cutting down
on the number of strings in the drivers. So you can just:

	return rtc_register_device(rx8010->rtc);

> +		return err;
> +	}
> +
>  	return 0;
>  }
>  
> -- 
> 2.26.1
>
diff mbox series

Patch

diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c
index 0665878e8843..bb6578aad972 100644
--- a/drivers/rtc/rtc-rx8010.c
+++ b/drivers/rtc/rtc-rx8010.c
@@ -447,16 +447,21 @@  static int rx8010_probe(struct i2c_client *client,
 		}
 	}
 
-	rx8010->rtc = devm_rtc_device_register(dev, client->name,
-		&rx8010_rtc_ops, THIS_MODULE);
-
+	rx8010->rtc = devm_rtc_allocate_device(dev);
 	if (IS_ERR(rx8010->rtc)) {
-		dev_err(dev, "unable to register the class device\n");
+		dev_err(dev, "unable to allocate rtc device\n");
 		return PTR_ERR(rx8010->rtc);
 	}
 
+	rx8010->rtc->ops = &rx8010_rtc_ops;
 	rx8010->rtc->max_user_freq = 1;
 
+	err = rtc_register_device(rx8010->rtc);
+	if (err) {
+		dev_err(dev, "unable to register the class device\n");
+		return err;
+	}
+
 	return 0;
 }