Skip to contentSkip to conversation

rtc: remove all uses of devm_rtc_device_register()

PATCH In review Bartosz Golaszewski 3 participants 62 messages Nov 19, 2020

Subsystems (13)
lore
Share & tools
lore
#0 lore raw

cover rtc: remove all uses of devm_rtc_device_register()

From: Bartosz Golaszewski <[email protected]>

So we now have two functions whose names are easy to confuse. I spent some time and simply converted all RTC drivers to using the preferred interface.

Obviously these have only been compile-tested. I hope I didn't broke too many drivers in the process. Most of the conversions was easy, sometime it required removing unnecessary goto labels. There's also one patch using a different devres helpers in here.

Bartosz Golaszewski (59):
rtc: da9055: stop using deprecated RTC API
rtc: m41t94: stop using deprecated RTC API
rtc: ds1390: stop using deprecated RTC API
rtc: ds3232: stop using deprecated RTC API
rtc: rx6110: stop using deprecated RTC API
rtc: palmas: stop using deprecated RTC API
rtc: bq32k: stop using deprecated RTC API
rtc: m48t35: stop using deprecated RTC API
rtc: pcf50633: stop using deprecated RTC API
rtc: pcf8583: stop using deprecated RTC API
rtc: efi: stop using deprecated RTC API
rtc: pcf8523: stop using deprecated RTC API
rtc: stm32: stop using deprecated RTC API
rtc: max8925: stop using deprecated RTC API
rtc: max8907: stop using deprecated RTC API
rtc: pxa: stop using deprecated RTC API
rtc: hym8563: stop using deprecated RTC API
rtc: max6916: stop using deprecated RTC API
rtc: max8998: stop using deprecated RTC API
rtc: s5m: use devm_i2c_new_dummy_device()
rtc: s5m: stop using deprecated RTC API
rtc: moxart: stop using deprecated RTC API
rtc: hid: stop using deprecated RTC API
rtc: generic: stop using deprecated RTC API
rtc: lpc24xx: stop using deprecated RTC API
rtc: spear: stop using deprecated RTC API
rtc: max77686: stop using deprecated RTC API
rtc: ds1286: stop using deprecated RTC API
rtc: twl: stop using deprecated RTC API
rtc: s3c: stop using deprecated RTC API
rtc: mcp795: stop using deprecated RTC API
rtc: x1205: stop using deprecated RTC API
rtc: max6902: stop using deprecated RTC API
rtc: max6900: stop using deprecated RTC API
rtc: rx8025: stop using deprecated RTC API
rtc: asm9260: stop using deprecated RTC API
rtc: opal: stop using deprecated RTC API
rtc: rc5t583: stop using deprecated RTC API
rtc: wm8350: stop using deprecated RTC API
rtc: r7301: stop using deprecated RTC API
rtc: max8997: stop using deprecated RTC API
rtc: isl12022: stop using deprecated RTC API
rtc: tps80031: stop using deprecated RTC API
rtc: rs5c372: stop using deprecated RTC API
rtc: mt7622: stop using deprecated RTC API
rtc: ds1302: stop using deprecated RTC API
rtc: bq4802: stop using deprecated RTC API
rtc: rs5c313: stop using deprecated RTC API
rtc: em3027: stop using deprecated RTC API
rtc: v3020: stop using deprecated RTC API
rtc: ds1216: stop using deprecated RTC API
rtc: rx4581: stop using deprecated RTC API
rtc: m41t93: stop using deprecated RTC API
rtc: fm3130: stop using deprecated RTC API
rtc: rtd119x: stop using deprecated RTC API
rtc: msm6242: stop using deprecated RTC API
rtc: as3722: stop using deprecated RTC API
rtc: lp8788: stop using deprecated RTC API
rtc: remove devm_rtc_device_register()

 .../driver-api/driver-model/devres.rst        |  1 -
 drivers/rtc/class.c                           | 36 -------------
 drivers/rtc/rtc-as3722.c                      | 14 +++---
 drivers/rtc/rtc-asm9260.c                     | 10 ++--
 drivers/rtc/rtc-bq32k.c                       |  8 +--
 drivers/rtc/rtc-bq4802.c                      | 30 +++++------
 drivers/rtc/rtc-da9055.c                      | 19 +++----
 drivers/rtc/rtc-ds1216.c                      |  8 +--
 drivers/rtc/rtc-ds1286.c                      | 15 +++---
 drivers/rtc/rtc-ds1302.c                      | 14 +++---
 drivers/rtc/rtc-ds1390.c                      | 13 +++--
 drivers/rtc/rtc-ds3232.c                      |  7 +--
 drivers/rtc/rtc-efi.c                         |  6 +--
 drivers/rtc/rtc-em3027.c                      |  6 +--
 drivers/rtc/rtc-fm3130.c                      | 22 +++-----
 drivers/rtc/rtc-generic.c                     |  6 +--
 drivers/rtc/rtc-hid-sensor-time.c             | 21 ++++----
 drivers/rtc/rtc-hym8563.c                     |  6 +--
 drivers/rtc/rtc-isl12022.c                    | 11 ++--
 drivers/rtc/rtc-lp8788.c                      | 11 ++--
 drivers/rtc/rtc-lpc24xx.c                     | 10 ++--
 drivers/rtc/rtc-m41t93.c                      |  6 +--
 drivers/rtc/rtc-m41t94.c                      |  8 +--
 drivers/rtc/rtc-m48t35.c                      | 10 ++--
 drivers/rtc/rtc-max6900.c                     |  6 +--
 drivers/rtc/rtc-max6902.c                     |  7 +--
 drivers/rtc/rtc-max6916.c                     |  6 +--
 drivers/rtc/rtc-max77686.c                    | 13 ++---
 drivers/rtc/rtc-max8907.c                     | 14 +++---
 drivers/rtc/rtc-max8925.c                     | 14 +++---
 drivers/rtc/rtc-max8997.c                     | 21 ++++----
 drivers/rtc/rtc-max8998.c                     | 13 ++---
 drivers/rtc/rtc-mcp795.c                      |  7 +--
 drivers/rtc/rtc-moxart.c                      | 12 ++---
 drivers/rtc/rtc-msm6242.c                     |  7 +--
 drivers/rtc/rtc-mt7622.c                      | 10 ++--
 drivers/rtc/rtc-opal.c                        |  6 +--
 drivers/rtc/rtc-palmas.c                      | 15 +++---
 drivers/rtc/rtc-pcf50633.c                    |  8 +--
 drivers/rtc/rtc-pcf8523.c                     |  7 +--
 drivers/rtc/rtc-pcf8583.c                     | 10 ++--
 drivers/rtc/rtc-pxa.c                         | 13 ++---
 drivers/rtc/rtc-r7301.c                       |  7 +--
 drivers/rtc/rtc-rc5t583.c                     | 14 +++---
 drivers/rtc/rtc-rs5c313.c                     |  9 ++--
 drivers/rtc/rtc-rs5c372.c                     | 36 +++++--------
 drivers/rtc/rtc-rtd119x.c                     | 13 +++--
 drivers/rtc/rtc-rx4581.c                      |  7 +--
 drivers/rtc/rtc-rx6110.c                      | 12 ++---
 drivers/rtc/rtc-rx8025.c                      | 11 ++--
 drivers/rtc/rtc-s3c.c                         | 10 ++--
 drivers/rtc/rtc-s5m.c                         | 50 ++++++++-----------
 drivers/rtc/rtc-spear.c                       | 10 ++--
 drivers/rtc/rtc-stm32.c                       | 18 ++++---
 drivers/rtc/rtc-tps80031.c                    | 15 +++---
 drivers/rtc/rtc-twl.c                         | 12 ++---
 drivers/rtc/rtc-v3020.c                       |  9 +++-
 drivers/rtc/rtc-wm8350.c                      | 14 +++---
 drivers/rtc/rtc-x1205.c                       |  7 ++-
 include/linux/rtc.h                           |  4 --
 60 files changed, 346 insertions(+), 399 deletions(-)
Signature · 1 line
2.29.1
#1 lore raw

PATCH 1/59 rtc: da9055: stop using deprecated RTC API

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-da9055.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
drivers/rtc/rtc-da9055.c +8 -11
index 844168fcae1e..1e76042c2ed7 100644
@@ -279,23 +279,22 @@ static int da9055_rtc_probe(struct platform_device *pdev)
 
 	ret = da9055_rtc_device_init(rtc->da9055, pdata);
 	if (ret < 0)
-		goto err_rtc;
+		return ret;
 
 	ret = da9055_reg_read(rtc->da9055, DA9055_REG_ALARM_Y);
 	if (ret < 0)
-		goto err_rtc;
+		return ret;
 
 	if (ret & DA9055_RTC_ALM_EN)
 		rtc->alarm_enable = 1;
 
 	device_init_wakeup(&pdev->dev, 1);
 
-	rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-					&da9055_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rtc->rtc)) {
-		ret = PTR_ERR(rtc->rtc);
-		goto err_rtc;
-	}
+	rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(rtc->rtc))
+		return PTR_ERR(rtc->rtc);
+
+	rtc->rtc->ops = &da9055_rtc_ops;
 
 	alm_irq = platform_get_irq_byname(pdev, "ALM");
 	if (alm_irq < 0)
@@ -308,9 +307,7 @@ static int da9055_rtc_probe(struct platform_device *pdev)
 	if (ret != 0)
 		dev_err(rtc->da9055->dev, "irq registration failed: %d\n", ret);
 
-err_rtc:
-	return ret;
-
+	return devm_rtc_register_device(rtc->rtc);
 }
 
 #ifdef CONFIG_PM
Signature · 1 line
2.29.1
#2 lore raw

PATCH 2/59 rtc: m41t94: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-m41t94.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rtc/rtc-m41t94.c +4 -4
index 6803b0273302..6e970ad350d8 100644
@@ -120,14 +120,14 @@ static int m41t94_probe(struct spi_device *spi)
 		return res;
 	}
 
-	rtc = devm_rtc_device_register(&spi->dev, m41t94_driver.driver.name,
-					&m41t94_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&spi->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
-	spi_set_drvdata(spi, rtc);
+	rtc->ops = &m41t94_rtc_ops;
 
-	return 0;
+	spi_set_drvdata(spi, rtc);
+	return devm_rtc_register_device(rtc);
 }
 
 static struct spi_driver m41t94_driver = {
Signature · 1 line
2.29.1
#3 lore raw

PATCH 3/59 rtc: ds1390: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-ds1390.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/rtc/rtc-ds1390.c +6 -7
index 66fc8617d07e..9e4d09eac323 100644
@@ -203,14 +203,13 @@ static int ds1390_probe(struct spi_device *spi)
 	if (spi->dev.of_node)
 		ds1390_trickle_of_init(spi);
 
-	chip->rtc = devm_rtc_device_register(&spi->dev, "ds1390",
-					&ds1390_rtc_ops, THIS_MODULE);
-	if (IS_ERR(chip->rtc)) {
-		dev_err(&spi->dev, "unable to register device\n");
-		res = PTR_ERR(chip->rtc);
-	}
+	chip->rtc = devm_rtc_allocate_device(&spi->dev);
+	if (IS_ERR(chip->rtc))
+		return PTR_ERR(chip->rtc);
+
+	chip->rtc->ops = &ds1390_rtc_ops;
 
-	return res;
+	return devm_rtc_register_device(chip->rtc);
 }
 
 static const struct of_device_id ds1390_of_match[] = {
Signature · 1 line
2.29.1
#4 lore raw

PATCH 4/59 rtc: ds3232: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-ds3232.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-ds3232.c +4 -3
index 16b89035d135..962f84b1ba66 100644
@@ -513,11 +513,12 @@ static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq,
 
 	ds3232_hwmon_register(dev, name);
 
-	ds3232->rtc = devm_rtc_device_register(dev, name, &ds3232_rtc_ops,
-						THIS_MODULE);
+	ds3232->rtc = devm_rtc_allocate_device(dev);
 	if (IS_ERR(ds3232->rtc))
 		return PTR_ERR(ds3232->rtc);
 
+	ds3232->rtc->ops = &ds3232_rtc_ops;
+
 	ret = devm_rtc_nvmem_register(ds3232->rtc, &nvmem_cfg);
 	if(ret)
 		return ret;
@@ -534,7 +535,7 @@ static int ds3232_probe(struct device *dev, struct regmap *regmap, int irq,
 		}
 	}
 
-	return 0;
+	return devm_rtc_register_device(ds3232->rtc);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.29.1
#5 lore raw

PATCH 5/59 rtc: rx6110: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-rx6110.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/rtc/rtc-rx6110.c +5 -7
index a7b671a21022..cdb05b67912e 100644
@@ -315,20 +315,18 @@ static int rx6110_probe(struct rx6110_data *rx6110, struct device *dev)
 {
 	int err;
 
-	rx6110->rtc = devm_rtc_device_register(dev,
-					       RX6110_DRIVER_NAME,
-					       &rx6110_rtc_ops, THIS_MODULE);
-
+	rx6110->rtc = devm_rtc_allocate_device(dev);
 	if (IS_ERR(rx6110->rtc))
 		return PTR_ERR(rx6110->rtc);
 
+	rx6110->rtc->ops = &rx6110_rtc_ops;
+	rx6110->rtc->max_user_freq = 1;
+
 	err = rx6110_init(rx6110);
 	if (err)
 		return err;
 
-	rx6110->rtc->max_user_freq = 1;
-
-	return 0;
+	return devm_rtc_register_device(rx6110->rtc);
 }
 
 #ifdef CONFIG_SPI_MASTER
Signature · 1 line
2.29.1
#6 lore raw

PATCH 6/59 rtc: palmas: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-palmas.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/rtc/rtc-palmas.c +7 -8
index 4bcfb88674d3..d97a751b4a9a 100644
@@ -301,13 +301,12 @@ static int palmas_rtc_probe(struct platform_device *pdev)
 	palmas_rtc->irq = platform_get_irq(pdev, 0);
 
 	device_init_wakeup(&pdev->dev, 1);
-	palmas_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-				&palmas_rtc_ops, THIS_MODULE);
-	if (IS_ERR(palmas_rtc->rtc)) {
-		ret = PTR_ERR(palmas_rtc->rtc);
-		dev_err(&pdev->dev, "RTC register failed, err = %d\n", ret);
-		return ret;
-	}
+
+	palmas_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(palmas_rtc->rtc))
+		return PTR_ERR(palmas_rtc->rtc);
+
+	palmas_rtc->rtc->ops = &palmas_rtc_ops;
 
 	ret = devm_request_threaded_irq(&pdev->dev, palmas_rtc->irq, NULL,
 			palmas_rtc_interrupt,
@@ -318,7 +317,7 @@ static int palmas_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	return 0;
+	return devm_rtc_register_device(palmas_rtc->rtc);
 }
 
 static int palmas_rtc_remove(struct platform_device *pdev)
Signature · 1 line
2.29.1
#7 lore raw

PATCH 7/59 rtc: bq32k: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-bq32k.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rtc/rtc-bq32k.c +4 -4
index 933e4237237d..75ac0697160e 100644
@@ -280,11 +280,12 @@ static int bq32k_probe(struct i2c_client *client,
 	if (client->dev.of_node)
 		trickle_charger_of_init(dev, client->dev.of_node);
 
-	rtc = devm_rtc_device_register(&client->dev, bq32k_driver.driver.name,
-						&bq32k_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&client->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &bq32k_rtc_ops;
+
 	error = bq32k_sysfs_register(&client->dev);
 	if (error) {
 		dev_err(&client->dev,
@@ -292,10 +293,9 @@ static int bq32k_probe(struct i2c_client *client,
 		return error;
 	}
 
-
 	i2c_set_clientdata(client, rtc);
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static int bq32k_remove(struct i2c_client *client)
Signature · 1 line
2.29.1
#8 lore raw

PATCH 8/59 rtc: m48t35: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-m48t35.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-m48t35.c +7 -3
index 92f19bf997b2..0f4a3cb1e1f0 100644
@@ -173,9 +173,13 @@ static int m48t35_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 
-	priv->rtc = devm_rtc_device_register(&pdev->dev, "m48t35",
-				  &m48t35_ops, THIS_MODULE);
-	return PTR_ERR_OR_ZERO(priv->rtc);
+	priv->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(priv->rtc))
+		return PTR_ERR(priv->rtc);
+
+	priv->rtc->ops = &m48t35_ops;
+
+	return devm_rtc_register_device(priv->rtc);
 }
 
 static struct platform_driver m48t35_platform_driver = {
Signature · 1 line
2.29.1
#9 lore raw

PATCH 9/59 rtc: pcf50633: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-pcf50633.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/rtc/rtc-pcf50633.c +5 -3
index 48951a16d65d..d1ee023ce505 100644
@@ -249,15 +249,17 @@ static int pcf50633_rtc_probe(struct platform_device *pdev)
 
 	rtc->pcf = dev_to_pcf50633(pdev->dev.parent);
 	platform_set_drvdata(pdev, rtc);
-	rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "pcf50633-rtc",
-				&pcf50633_rtc_ops, THIS_MODULE);
 
+	rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(rtc->rtc_dev))
 		return PTR_ERR(rtc->rtc_dev);
 
+	rtc->rtc_dev->ops = &pcf50633_rtc_ops;
+
 	pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_ALARM,
 					pcf50633_rtc_irq, rtc);
-	return 0;
+
+	return devm_rtc_register_device(rtc->rtc_dev);
 }
 
 static int pcf50633_rtc_remove(struct platform_device *pdev)
Signature · 1 line
2.29.1
#10 lore raw

PATCH 10/59 rtc: pcf8583: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-pcf8583.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/rtc/rtc-pcf8583.c +6 -4
index c80ca20e5d8d..93c7bb52bb78 100644
@@ -290,11 +290,13 @@ static int pcf8583_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, pcf8583);
 
-	pcf8583->rtc = devm_rtc_device_register(&client->dev,
-				pcf8583_driver.driver.name,
-				&pcf8583_rtc_ops, THIS_MODULE);
+	pcf8583->rtc = devm_rtc_allocate_device(&client->dev);
+	if (IS_ERR(pcf8583->rtc))
+		return PTR_ERR(pcf8583->rtc);
 
-	return PTR_ERR_OR_ZERO(pcf8583->rtc);
+	pcf8583->rtc->ops = &pcf8583_rtc_ops;
+
+	return devm_rtc_register_device(pcf8583->rtc);
 }
 
 static const struct i2c_device_id pcf8583_id[] = {
Signature · 1 line
2.29.1
#11 lore raw

PATCH 11/59 rtc: efi: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-efi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-efi.c +3 -3
index edb64debd173..47e79a54ecae 100644
@@ -261,15 +261,15 @@ static int __init efi_rtc_probe(struct platform_device *dev)
 	if (efi.get_time(&eft, &cap) != EFI_SUCCESS)
 		return -ENODEV;
 
-	rtc = devm_rtc_device_register(&dev->dev, "rtc-efi", &efi_rtc_ops,
-					THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&dev->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &efi_rtc_ops;
 	rtc->uie_unsupported = 1;
 	platform_set_drvdata(dev, rtc);
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static struct platform_driver efi_rtc_driver = {
Signature · 1 line
2.29.1
#12 lore raw

PATCH 12/59 rtc: pcf8523: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-pcf8523.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-pcf8523.c +4 -3
index 57d351dfe272..b525998cd70e 100644
@@ -356,12 +356,13 @@ static int pcf8523_probe(struct i2c_client *client,
 	if (err < 0)
 		return err;
 
-	rtc = devm_rtc_device_register(&client->dev, DRIVER_NAME,
-				       &pcf8523_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&client->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
-	return 0;
+	rtc->ops = &pcf8523_rtc_ops;
+
+	return devm_rtc_register_device(rtc);
 }
 
 static const struct i2c_device_id pcf8523_id[] = {
Signature · 1 line
2.29.1
#13 lore raw

PATCH 13/59 rtc: stm32: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-stm32.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/rtc/rtc-stm32.c +10 -8
index d774aa18f57a..9d6be4fa885d 100644
@@ -795,14 +795,11 @@ static int stm32_rtc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, rtc);
 
-	rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, pdev->name,
-						&stm32_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rtc->rtc_dev)) {
-		ret = PTR_ERR(rtc->rtc_dev);
-		dev_err(&pdev->dev, "rtc device registration failed, err=%d\n",
-			ret);
-		goto err;
-	}
+	rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(rtc->rtc_dev))
+		return PTR_ERR(rtc->rtc_dev);
+
+	rtc->rtc_dev->ops = &stm32_rtc_ops;
 
 	/* Handle RTC alarm interrupts */
 	ret = devm_request_threaded_irq(&pdev->dev, rtc->irq_alarm, NULL,
@@ -829,7 +826,12 @@ static int stm32_rtc_probe(struct platform_device *pdev)
 			 (ver >> STM32_RTC_VERR_MINREV_SHIFT) & 0xF);
 	}
 
+	ret = devm_rtc_register_device(rtc->rtc_dev);
+	if (ret)
+		goto err;
+
 	return 0;
+
 err:
 	if (rtc->data->has_pclk)
 		clk_disable_unprepare(rtc->pclk);
Signature · 1 line
2.29.1
#14 lore raw

PATCH 14/59 rtc: max8925: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-max8925.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/rtc/rtc-max8925.c +6 -8
index 64bb8ac6ef62..902403d2fb59 100644
@@ -272,15 +272,13 @@ static int max8925_rtc_probe(struct platform_device *pdev)
 
 	device_init_wakeup(&pdev->dev, 1);
 
-	info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8925-rtc",
-					&max8925_rtc_ops, THIS_MODULE);
-	ret = PTR_ERR(info->rtc_dev);
-	if (IS_ERR(info->rtc_dev)) {
-		dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
-		return ret;
-	}
+	info->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(info->rtc_dev))
+		return PTR_ERR(info->rtc_dev);
 
-	return 0;
+	info->rtc_dev->ops = &max8925_rtc_ops;
+
+	return devm_rtc_register_device(info->rtc_dev);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.29.1
#15 lore raw

PATCH 15/59 rtc: max8907: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-max8907.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/rtc/rtc-max8907.c +6 -8
index db3495d10274..7987f7f99bcc 100644
@@ -186,13 +186,11 @@ static int max8907_rtc_probe(struct platform_device *pdev)
 	rtc->max8907 = max8907;
 	rtc->regmap = max8907->regmap_rtc;
 
-	rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8907-rtc",
-					&max8907_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rtc->rtc_dev)) {
-		ret = PTR_ERR(rtc->rtc_dev);
-		dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
-		return ret;
-	}
+	rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(rtc->rtc_dev))
+		return PTR_ERR(rtc->rtc_dev);
+
+	rtc->rtc_dev->ops = &max8907_rtc_ops;
 
 	rtc->irq = regmap_irq_get_virq(max8907->irqc_rtc,
 				       MAX8907_IRQ_RTC_ALARM0);
@@ -206,7 +204,7 @@ static int max8907_rtc_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Failed to request IRQ%d: %d\n",
 			rtc->irq, ret);
 
-	return ret;
+	return devm_rtc_register_device(rtc->rtc_dev);
 }
 
 static struct platform_driver max8907_rtc_driver = {
Signature · 1 line
2.29.1
#16 lore raw

PATCH 16/59 rtc: pxa: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-pxa.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/rtc/rtc-pxa.c +5 -8
index d2f1d8f754bf..56d22576ae0e 100644
@@ -351,17 +351,14 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)
 
 	rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
 
-	pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc",
-						&pxa_rtc_ops, THIS_MODULE);
-	if (IS_ERR(pxa_rtc->rtc)) {
-		ret = PTR_ERR(pxa_rtc->rtc);
-		dev_err(dev, "Failed to register RTC device -> %d\n", ret);
-		return ret;
-	}
+	pxa_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(pxa_rtc->rtc))
+		return PTR_ERR(pxa_rtc->rtc);
 
+	pxa_rtc->rtc->ops = &pxa_rtc_ops;
 	device_init_wakeup(dev, 1);
 
-	return 0;
+	return devm_rtc_register_device(pxa_rtc->rtc);
 }
 
 static int __exit pxa_rtc_remove(struct platform_device *pdev)
Signature · 1 line
2.29.1
#17 lore raw

PATCH 17/59 rtc: hym8563: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-hym8563.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-hym8563.c +3 -3
index 24e0095be058..f39568c6d390 100644
@@ -558,11 +558,11 @@ static int hym8563_probe(struct i2c_client *client,
 	dev_dbg(&client->dev, "rtc information is %s\n",
 		(ret & HYM8563_SEC_VL) ? "invalid" : "valid");
 
-	hym8563->rtc = devm_rtc_device_register(&client->dev, client->name,
-						&hym8563_rtc_ops, THIS_MODULE);
+	hym8563->rtc = devm_rtc_allocate_device(&client->dev);
 	if (IS_ERR(hym8563->rtc))
 		return PTR_ERR(hym8563->rtc);
 
+	hym8563->rtc->ops = &hym8563_rtc_ops;
 	/* the hym8563 alarm only supports a minute accuracy */
 	hym8563->rtc->uie_unsupported = 1;
 
@@ -570,7 +570,7 @@ static int hym8563_probe(struct i2c_client *client,
 	hym8563_clkout_register_clk(hym8563);
 #endif
 
-	return 0;
+	return devm_rtc_register_device(hym8563->rtc);
 }
 
 static const struct i2c_device_id hym8563_id[] = {
Signature · 1 line
2.29.1
#18 lore raw

PATCH 18/59 rtc: max6916: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-max6916.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-max6916.c +3 -3
index e72e768ab8ff..06e98d6351ee 100644
@@ -137,14 +137,14 @@ static int max6916_probe(struct spi_device *spi)
 	max6916_read_reg(&spi->dev, MAX6916_STATUS_REG, &data);
 	dev_info(&spi->dev, "MAX6916 RTC Status Reg = 0x%02x\n", data);
 
-	rtc = devm_rtc_device_register(&spi->dev, "max6916",
-				       &max6916_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&spi->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &max6916_rtc_ops;
 	spi_set_drvdata(spi, rtc);
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static struct spi_driver max6916_driver = {
Signature · 1 line
2.29.1
#19 lore raw

PATCH 19/59 rtc: max8998: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-max8998.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/rtc/rtc-max8998.c +5 -8
index c873b4509b3c..25b4f24d93b4 100644
@@ -262,14 +262,11 @@ static int max8998_rtc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, info);
 
-	info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8998-rtc",
-			&max8998_rtc_ops, THIS_MODULE);
+	info->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(info->rtc_dev))
+		return PTR_ERR(info->rtc_dev);
 
-	if (IS_ERR(info->rtc_dev)) {
-		ret = PTR_ERR(info->rtc_dev);
-		dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
-		return ret;
-	}
+	info->rtc_dev->ops = &max8998_rtc_ops;
 
 	if (!max8998->irq_domain)
 		goto no_irq;
@@ -295,7 +292,7 @@ static int max8998_rtc_probe(struct platform_device *pdev)
 				" RTC updates will be extremely slow.\n");
 	}
 
-	return 0;
+	return devm_rtc_register_device(info->rtc_dev);
 }
 
 static const struct platform_device_id max8998_rtc_id[] = {
Signature · 1 line
2.29.1
#20 lore raw

PATCH 20/59 rtc: s5m: use devm_i2c_new_dummy_device()

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Use the managed variant of i2c_new_dummy_device() to shrink code and remove the goto label.

---
 drivers/rtc/rtc-s5m.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
drivers/rtc/rtc-s5m.c +8 -16
index eb9dde4095a9..3432c6213b4c 100644
@@ -760,7 +760,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	info->i2c = i2c_new_dummy_device(s5m87xx->i2c->adapter, RTC_I2C_ADDR);
+	info->i2c = devm_i2c_new_dummy_device(&pdev->dev, s5m87xx->i2c->adapter,
+					      RTC_I2C_ADDR);
 	if (IS_ERR(info->i2c)) {
 		dev_err(&pdev->dev, "Failed to allocate I2C for RTC\n");
 		return PTR_ERR(info->i2c);
@@ -768,10 +769,9 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 
 	info->regmap = devm_regmap_init_i2c(info->i2c, regmap_cfg);
 	if (IS_ERR(info->regmap)) {
-		ret = PTR_ERR(info->regmap);
 		dev_err(&pdev->dev, "Failed to allocate RTC register map: %d\n",
-				ret);
-		goto err;
+			ret);
+		return PTR_ERR(info->regmap);
 	}
 
 	info->dev = &pdev->dev;
@@ -781,10 +781,9 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 	if (s5m87xx->irq_data) {
 		info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
 		if (info->irq <= 0) {
-			ret = -EINVAL;
 			dev_err(&pdev->dev, "Failed to get virtual IRQ %d\n",
 				alarm_irq);
-			goto err;
+			return -EINVAL;
 		}
 	}
 
@@ -797,10 +796,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 	info->rtc_dev = devm_rtc_device_register(&pdev->dev, "s5m-rtc",
 						 &s5m_rtc_ops, THIS_MODULE);
 
-	if (IS_ERR(info->rtc_dev)) {
-		ret = PTR_ERR(info->rtc_dev);
-		goto err;
-	}
+	if (IS_ERR(info->rtc_dev))
+		return PTR_ERR(info->rtc_dev);
 
 	if (!info->irq) {
 		dev_info(&pdev->dev, "Alarm IRQ not available\n");
@@ -813,15 +810,10 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->irq, ret);
-		goto err;
+		return ret;
 	}
 
 	return 0;
-
-err:
-	i2c_unregister_device(info->i2c);
-
-	return ret;
 }
 
 static int s5m_rtc_remove(struct platform_device *pdev)
Signature · 1 line
2.29.1
#21 lore raw

PATCH 21/59 rtc: s5m: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-s5m.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/rtc/rtc-s5m.c +15 -15
index 3432c6213b4c..0ddd3f445943 100644
@@ -793,27 +793,27 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 
 	device_init_wakeup(&pdev->dev, 1);
 
-	info->rtc_dev = devm_rtc_device_register(&pdev->dev, "s5m-rtc",
-						 &s5m_rtc_ops, THIS_MODULE);
-
+	info->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(info->rtc_dev))
 		return PTR_ERR(info->rtc_dev);
 
-	if (!info->irq) {
-		dev_info(&pdev->dev, "Alarm IRQ not available\n");
-		return 0;
-	}
+	info->rtc_dev->ops = &s5m_rtc_ops;
 
-	ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
-					s5m_rtc_alarm_irq, 0, "rtc-alarm0",
-					info);
-	if (ret < 0) {
-		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
-			info->irq, ret);
-		return ret;
+	if (info->irq) {
+		ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
+						s5m_rtc_alarm_irq, 0,
+						"rtc-alarm0", info);
+		if (ret < 0) {
+			dev_err(&pdev->dev,
+				"Failed to request alarm IRQ: %d: %d\n",
+				info->irq, ret);
+			return ret;
+		}
+	} else {
+		dev_info(&pdev->dev, "Alarm IRQ not available\n");
 	}
 
-	return 0;
+	return devm_rtc_register_device(info->rtc_dev);
 }
 
 static int s5m_rtc_remove(struct platform_device *pdev)
Signature · 1 line
2.29.1
#22 lore raw

PATCH 22/59 rtc: moxart: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-moxart.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/rtc/rtc-moxart.c +5 -7
index 6b24ac9e1cfa..f354bc8abecf 100644
@@ -294,15 +294,13 @@ static int moxart_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	moxart_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-						   &moxart_rtc_ops,
-						   THIS_MODULE);
-	if (IS_ERR(moxart_rtc->rtc)) {
-		dev_err(&pdev->dev, "devm_rtc_device_register failed\n");
+	moxart_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(moxart_rtc->rtc))
 		return PTR_ERR(moxart_rtc->rtc);
-	}
 
-	return 0;
+	moxart_rtc->rtc->ops = &moxart_rtc_ops;
+
+	return devm_rtc_register_device(moxart_rtc->rtc);
 }
 
 static const struct of_device_id moxart_rtc_match[] = {
Signature · 1 line
2.29.1
#23 lore raw

PATCH 23/59 rtc: hid: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-hid-sensor-time.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/rtc/rtc-hid-sensor-time.c +9 -12
index 1b42ee0758d2..06cd21d6d2d1 100644
@@ -267,21 +267,18 @@ static int hid_time_probe(struct platform_device *pdev)
 		goto err_open;
 	}
 
-	/*
-	 * Enable HID input processing early in order to be able to read the
-	 * clock already in devm_rtc_device_register().
-	 */
-	hid_device_io_start(hsdev->hdev);
+	time_state->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(time_state->rtc)) {
+		ret = PTR_ERR(time_state->rtc);
+		goto err_rtc;
+	}
 
-	time_state->rtc = devm_rtc_device_register(&pdev->dev,
-					"hid-sensor-time", &hid_time_rtc_ops,
-					THIS_MODULE);
+	time_state->rtc->ops = &hid_time_rtc_ops;
+	hid_device_io_start(hsdev->hdev);
 
-	if (IS_ERR(time_state->rtc)) {
+	ret = devm_rtc_register_device(time_state->rtc);
+	if (ret) {
 		hid_device_io_stop(hsdev->hdev);
-		ret = PTR_ERR(time_state->rtc);
-		time_state->rtc = NULL;
-		dev_err(&pdev->dev, "rtc device register failed!\n");
 		goto err_rtc;
 	}
 
Signature · 1 line
2.29.1
#24 lore raw

PATCH 24/59 rtc: generic: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-generic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-generic.c +3 -3
index 89ae78e93b83..6254f65bee7d 100644
@@ -15,14 +15,14 @@ static int __init generic_rtc_probe(struct platform_device *dev)
 	struct rtc_device *rtc;
 	const struct rtc_class_ops *ops = dev_get_platdata(&dev->dev);
 
-	rtc = devm_rtc_device_register(&dev->dev, "rtc-generic",
-					ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&dev->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = ops;
 	platform_set_drvdata(dev, rtc);
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static struct platform_driver generic_rtc_driver = {
Signature · 1 line
2.29.1
#25 lore raw

PATCH 25/59 rtc: lpc24xx: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-lpc24xx.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-lpc24xx.c +7 -3
index eec881a81067..e28a00be2c0d 100644
@@ -247,14 +247,18 @@ static int lpc24xx_rtc_probe(struct platform_device *pdev)
 		goto disable_clks;
 	}
 
-	rtc->rtc = devm_rtc_device_register(&pdev->dev, "lpc24xx-rtc",
-					    &lpc24xx_rtc_ops, THIS_MODULE);
+	rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(rtc->rtc)) {
-		dev_err(&pdev->dev, "can't register rtc device\n");
 		ret = PTR_ERR(rtc->rtc);
 		goto disable_clks;
 	}
 
+	rtc->rtc->ops = &lpc24xx_rtc_ops;
+
+	ret = devm_rtc_register_device(rtc->rtc);
+	if (ret)
+		goto disable_clks;
+
 	return 0;
 
 disable_clks:
Signature · 1 line
2.29.1
#26 lore raw

PATCH 26/59 rtc: spear: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-spear.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/rtc/rtc-spear.c +6 -4
index 833daeb7b60e..acdb37b98cc5 100644
@@ -383,17 +383,19 @@ static int spear_rtc_probe(struct platform_device *pdev)
 	spin_lock_init(&config->lock);
 	platform_set_drvdata(pdev, config);
 
-	config->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-					&spear_rtc_ops, THIS_MODULE);
+	config->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(config->rtc)) {
-		dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
-				PTR_ERR(config->rtc));
 		status = PTR_ERR(config->rtc);
 		goto err_disable_clock;
 	}
 
+	config->rtc->ops = &spear_rtc_ops;
 	config->rtc->uie_unsupported = 1;
 
+	status = devm_rtc_register_device(config->rtc);
+	if (status)
+		goto err_disable_clock;
+
 	if (!device_can_wakeup(&pdev->dev))
 		device_init_wakeup(&pdev->dev, 1);
 
Signature · 1 line
2.29.1
#27 lore raw

PATCH 27/59 rtc: max77686: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-max77686.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/rtc/rtc-max77686.c +7 -6
index d51cc12114cb..e2edae346f1c 100644
@@ -758,17 +758,14 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 
 	device_init_wakeup(&pdev->dev, 1);
 
-	info->rtc_dev = devm_rtc_device_register(&pdev->dev, id->name,
-					&max77686_rtc_ops, THIS_MODULE);
-
+	info->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(info->rtc_dev)) {
 		ret = PTR_ERR(info->rtc_dev);
-		dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
-		if (ret == 0)
-			ret = -EINVAL;
 		goto err_rtc;
 	}
 
+	info->rtc_dev->ops = &max77686_rtc_ops;
+
 	info->virq = regmap_irq_get_virq(info->rtc_irq_data,
 					 MAX77686_RTCIRQ_RTCA1);
 	if (info->virq <= 0) {
@@ -784,6 +781,10 @@ static int max77686_rtc_probe(struct platform_device *pdev)
 		goto err_rtc;
 	}
 
+	ret = devm_rtc_register_device(info->rtc_dev);
+	if (ret)
+		goto err_rtc;
+
 	return 0;
 
 err_rtc:
Signature · 1 line
2.29.1
#28 lore raw

PATCH 28/59 rtc: ds1286: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-ds1286.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/rtc/rtc-ds1286.c +8 -7
index 7acf849d4902..0886ac9890c3 100644
@@ -322,7 +322,6 @@ static const struct rtc_class_ops ds1286_ops = {
 
 static int ds1286_probe(struct platform_device *pdev)
 {
-	struct rtc_device *rtc;
 	struct ds1286_priv *priv;
 
 	priv = devm_kzalloc(&pdev->dev, sizeof(struct ds1286_priv), GFP_KERNEL);
@@ -335,12 +334,14 @@ static int ds1286_probe(struct platform_device *pdev)
 
 	spin_lock_init(&priv->lock);
 	platform_set_drvdata(pdev, priv);
-	rtc = devm_rtc_device_register(&pdev->dev, "ds1286", &ds1286_ops,
-					THIS_MODULE);
-	if (IS_ERR(rtc))
-		return PTR_ERR(rtc);
-	priv->rtc = rtc;
-	return 0;
+
+	priv->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(priv->rtc))
+		return PTR_ERR(priv->rtc);
+
+	priv->rtc->ops = &ds1286_ops;
+
+	return devm_rtc_register_device(priv->rtc);
 }
 
 static struct platform_driver ds1286_platform_driver = {
Signature · 1 line
2.29.1
#29 lore raw

PATCH 29/59 rtc: twl: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-twl.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/rtc/rtc-twl.c +5 -7
index c24d1e18f56c..5caf8900b6cd 100644
@@ -562,13 +562,11 @@ static int twl_rtc_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, twl_rtc);
 	device_init_wakeup(&pdev->dev, 1);
 
-	twl_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-					&twl_rtc_ops, THIS_MODULE);
-	if (IS_ERR(twl_rtc->rtc)) {
-		dev_err(&pdev->dev, "can't register RTC device, err %ld\n",
-			PTR_ERR(twl_rtc->rtc));
+	twl_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(twl_rtc->rtc))
 		return PTR_ERR(twl_rtc->rtc);
-	}
+
+	twl_rtc->rtc->ops = &twl_rtc_ops;
 
 	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
 					twl_rtc_interrupt,
@@ -579,7 +577,7 @@ static int twl_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	return 0;
+	return devm_rtc_register_device(twl_rtc->rtc);
 }
 
 /*
Signature · 1 line
2.29.1
#30 lore raw

PATCH 30/59 rtc: s3c: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-s3c.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-s3c.c +7 -3
index 24a41909f049..119ce2c08e00 100644
@@ -527,14 +527,14 @@ static int s3c_rtc_probe(struct platform_device *pdev)
 	}
 
 	/* register RTC and exit */
-	info->rtc = devm_rtc_device_register(&pdev->dev, "s3c", &s3c_rtcops,
-					     THIS_MODULE);
+	info->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(info->rtc)) {
-		dev_err(&pdev->dev, "cannot attach rtc\n");
 		ret = PTR_ERR(info->rtc);
 		goto err_nortc;
 	}
 
+	info->rtc->ops = &s3c_rtcops;
+
 	ret = devm_request_irq(&pdev->dev, info->irq_alarm, s3c_rtc_alarmirq,
 			       0, "s3c2410-rtc alarm", info);
 	if (ret) {
@@ -549,6 +549,10 @@ static int s3c_rtc_probe(struct platform_device *pdev)
 		goto err_nortc;
 	}
 
+	ret = devm_rtc_register_device(info->rtc);
+	if (ret)
+		goto err_nortc;
+
 	if (info->data->select_tick_clk)
 		info->data->select_tick_clk(info);
 
Signature · 1 line
2.29.1
#31 lore raw

PATCH 31/59 rtc: mcp795: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-mcp795.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-mcp795.c +4 -3
index 21cbf7f892e8..04dfd1d0f9ca 100644
@@ -396,11 +396,11 @@ static int mcp795_probe(struct spi_device *spi)
 	/* Clear the 12 hour mode flag*/
 	mcp795_rtcc_set_bits(&spi->dev, 0x03, MCP795_24_BIT, 0);
 
-	rtc = devm_rtc_device_register(&spi->dev, "rtc-mcp795",
-					&mcp795_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&spi->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &mcp795_rtc_ops;
 	spi_set_drvdata(spi, rtc);
 
 	if (spi->irq > 0) {
@@ -420,7 +420,8 @@ static int mcp795_probe(struct spi_device *spi)
 		else
 			device_init_wakeup(&spi->dev, true);
 	}
-	return 0;
+
+	return devm_rtc_register_device(rtc);
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
2.29.1
#32 lore raw

PATCH 32/59 rtc: x1205: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-x1205.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/rtc/rtc-x1205.c +3 -4
index d1d5a44d9122..b1232ebf3ee9 100644
@@ -629,12 +629,11 @@ static int x1205_probe(struct i2c_client *client,
 	if (x1205_validate_client(client) < 0)
 		return -ENODEV;
 
-	rtc = devm_rtc_device_register(&client->dev, x1205_driver.driver.name,
-					&x1205_rtc_ops, THIS_MODULE);
-
+	rtc = devm_rtc_allocate_device(&client->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &x1205_rtc_ops;
 	i2c_set_clientdata(client, rtc);
 
 	/* Check for power failures and eventually enable the osc */
@@ -655,7 +654,7 @@ static int x1205_probe(struct i2c_client *client,
 	if (err)
 		dev_err(&client->dev, "Unable to create sysfs entries\n");
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static int x1205_remove(struct i2c_client *client)
Signature · 1 line
2.29.1
#33 lore raw

PATCH 33/59 rtc: max6902: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-max6902.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-max6902.c +4 -3
index daaeb6fb6c2d..9eed4ee05892 100644
@@ -130,13 +130,14 @@ static int max6902_probe(struct spi_device *spi)
 	if (res != 0)
 		return res;
 
-	rtc = devm_rtc_device_register(&spi->dev, "max6902",
-				&max6902_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&spi->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &max6902_rtc_ops;
 	spi_set_drvdata(spi, rtc);
-	return 0;
+
+	return devm_rtc_register_device(rtc);
 }
 
 static struct spi_driver max6902_driver = {
Signature · 1 line
2.29.1
#34 lore raw

PATCH 34/59 rtc: max6900: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-max6900.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-max6900.c +3 -3
index ab60f13fa3ef..a3b0ed26a8c7 100644
@@ -207,14 +207,14 @@ max6900_probe(struct i2c_client *client, const struct i2c_device_id *id)
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		return -ENODEV;
 
-	rtc = devm_rtc_device_register(&client->dev, max6900_driver.driver.name,
-					&max6900_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&client->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &max6900_rtc_ops;
 	i2c_set_clientdata(client, rtc);
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static const struct i2c_device_id max6900_id[] = {
Signature · 1 line
2.29.1
#35 lore raw

PATCH 35/59 rtc: rx8025: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-rx8025.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/rtc/rtc-rx8025.c +5 -6
index a24f85893f90..3c08cfa779d7 100644
@@ -524,12 +524,9 @@ static int rx8025_probe(struct i2c_client *client,
 	if (err)
 		return err;
 
-	rx8025->rtc = devm_rtc_device_register(&client->dev, client->name,
-					  &rx8025_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rx8025->rtc)) {
-		dev_err(&client->dev, "unable to register the class device\n");
+	rx8025->rtc = devm_rtc_allocate_device(&client->dev);
+	if (IS_ERR(rx8025->rtc))
 		return PTR_ERR(rx8025->rtc);
-	}
 
 	if (client->irq > 0) {
 		dev_info(&client->dev, "IRQ %d supplied\n", client->irq);
@@ -543,13 +540,15 @@ static int rx8025_probe(struct i2c_client *client,
 		}
 	}
 
+	rx8025->rtc->ops = &rx8025_rtc_ops;
 	rx8025->rtc->max_user_freq = 1;
 
 	/* the rx8025 alarm only supports a minute accuracy */
 	rx8025->rtc->uie_unsupported = 1;
 
 	err = rx8025_sysfs_register(&client->dev);
-	return err;
+
+	return devm_rtc_register_device(rx8025->rtc);
 }
 
 static int rx8025_remove(struct i2c_client *client)
Signature · 1 line
2.29.1
#36 lore raw

PATCH 36/59 rtc: asm9260: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-asm9260.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-asm9260.c +7 -3
index 3ab81cdec00b..c74455bce8b4 100644
@@ -284,14 +284,14 @@ static int asm9260_rtc_probe(struct platform_device *pdev)
 	iowrite32(0, priv->iobase + HW_CIIR);
 	iowrite32(BM_AMR_OFF, priv->iobase + HW_AMR);
 
-	priv->rtc = devm_rtc_device_register(dev, dev_name(dev),
-					     &asm9260_rtc_ops, THIS_MODULE);
+	priv->rtc = devm_rtc_allocate_device(dev);
 	if (IS_ERR(priv->rtc)) {
 		ret = PTR_ERR(priv->rtc);
-		dev_err(dev, "Failed to register RTC device: %d\n", ret);
 		goto err_return;
 	}
 
+	priv->rtc->ops = &asm9260_rtc_ops;
+
 	ret = devm_request_threaded_irq(dev, irq_alarm, NULL,
 					asm9260_rtc_irq, IRQF_ONESHOT,
 					dev_name(dev), priv);
@@ -301,6 +301,10 @@ static int asm9260_rtc_probe(struct platform_device *pdev)
 		goto err_return;
 	}
 
+	ret = devm_rtc_register_device(priv->rtc);
+	if (ret)
+		goto err_return;
+
 	return 0;
 
 err_return:
Signature · 1 line
2.29.1
#37 lore raw

PATCH 37/59 rtc: opal: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-opal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-opal.c +3 -3
index 7b9f8bcf86fe..d0e13635921e 100644
@@ -242,14 +242,14 @@ static int opal_rtc_probe(struct platform_device *pdev)
 		opal_rtc_ops.alarm_irq_enable = opal_tpo_alarm_irq_enable;
 	}
 
-	rtc = devm_rtc_device_register(&pdev->dev, DRVNAME, &opal_rtc_ops,
-				       THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &opal_rtc_ops;
 	rtc->uie_unsupported = 1;
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static const struct of_device_id opal_rtc_match[] = {
Signature · 1 line
2.29.1
#38 lore raw

PATCH 38/59 rtc: rc5t583: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-rc5t583.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/rtc/rtc-rc5t583.c +6 -8
index 18684a7026c4..20f150ab6bdb 100644
@@ -247,15 +247,13 @@ static int rc5t583_rtc_probe(struct platform_device *pdev)
 	}
 	device_init_wakeup(&pdev->dev, 1);
 
-	ricoh_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-		&rc5t583_rtc_ops, THIS_MODULE);
-	if (IS_ERR(ricoh_rtc->rtc)) {
-		ret = PTR_ERR(ricoh_rtc->rtc);
-		dev_err(&pdev->dev, "RTC device register: err %d\n", ret);
-		return ret;
-	}
+	ricoh_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(ricoh_rtc->rtc))
+		return PTR_ERR(ricoh_rtc->rtc);
 
-	return 0;
+	ricoh_rtc->rtc->ops = &rc5t583_rtc_ops;
+
+	return devm_rtc_register_device(ricoh_rtc->rtc);
 }
 
 /*
Signature · 1 line
2.29.1
#39 lore raw

PATCH 39/59 rtc: wm8350: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-wm8350.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/rtc/rtc-wm8350.c +6 -8
index 2018614f258f..140efe601c88 100644
@@ -424,13 +424,11 @@ static int wm8350_rtc_probe(struct platform_device *pdev)
 
 	device_init_wakeup(&pdev->dev, 1);
 
-	wm_rtc->rtc = devm_rtc_device_register(&pdev->dev, "wm8350",
-					&wm8350_rtc_ops, THIS_MODULE);
-	if (IS_ERR(wm_rtc->rtc)) {
-		ret = PTR_ERR(wm_rtc->rtc);
-		dev_err(&pdev->dev, "failed to register RTC: %d\n", ret);
-		return ret;
-	}
+	wm_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(wm_rtc->rtc))
+		return PTR_ERR(wm_rtc->rtc);
+
+	wm_rtc->rtc->ops = &wm8350_rtc_ops;
 
 	wm8350_register_irq(wm8350, WM8350_IRQ_RTC_SEC,
 			    wm8350_rtc_update_handler, 0,
@@ -441,7 +439,7 @@ static int wm8350_rtc_probe(struct platform_device *pdev)
 			    wm8350_rtc_alarm_handler, 0,
 			    "RTC Alarm", wm8350);
 
-	return 0;
+	return devm_rtc_register_device(wm_rtc->rtc);
 }
 
 static int wm8350_rtc_remove(struct platform_device *pdev)
Signature · 1 line
2.29.1
#40 lore raw

PATCH 40/59 rtc: r7301: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-r7301.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-r7301.c +4 -3
index aaf1b95e3990..a879313dbb05 100644
@@ -381,11 +381,12 @@ static int __init rtc7301_rtc_probe(struct platform_device *dev)
 
 	platform_set_drvdata(dev, priv);
 
-	rtc = devm_rtc_device_register(&dev->dev, DRV_NAME, &rtc7301_rtc_ops,
-				       THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&dev->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &rtc7301_rtc_ops;
+
 	if (priv->irq > 0) {
 		ret = devm_request_irq(&dev->dev, priv->irq,
 				       rtc7301_irq_handler, IRQF_SHARED,
@@ -398,7 +399,7 @@ static int __init rtc7301_rtc_probe(struct platform_device *dev)
 		}
 	}
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.29.1
#41 lore raw

PATCH 41/59 rtc: max8997: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-max8997.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
drivers/rtc/rtc-max8997.c +9 -12
index 20e50d9fdf88..d4d40851aecd 100644
@@ -475,32 +475,29 @@ static int max8997_rtc_probe(struct platform_device *pdev)
 
 	device_init_wakeup(&pdev->dev, 1);
 
-	info->rtc_dev = devm_rtc_device_register(&pdev->dev, "max8997-rtc",
-					&max8997_rtc_ops, THIS_MODULE);
+	info->rtc_dev = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(info->rtc_dev))
+		return PTR_ERR(info->rtc_dev);
 
-	if (IS_ERR(info->rtc_dev)) {
-		ret = PTR_ERR(info->rtc_dev);
-		dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret);
-		return ret;
-	}
+	info->rtc_dev->ops = &max8997_rtc_ops;
 
 	virq = irq_create_mapping(max8997->irq_domain, MAX8997_PMICIRQ_RTCA1);
 	if (!virq) {
 		dev_err(&pdev->dev, "Failed to create mapping alarm IRQ\n");
-		ret = -ENXIO;
-		goto err_out;
+		return -ENXIO;
 	}
 	info->virq = virq;
 
 	ret = devm_request_threaded_irq(&pdev->dev, virq, NULL,
 				max8997_rtc_alarm_irq, 0,
 				"rtc-alarm0", info);
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
 			info->virq, ret);
+		return ret;
+	}
 
-err_out:
-	return ret;
+	return devm_rtc_register_device(info->rtc_dev);
 }
 
 static void max8997_rtc_shutdown(struct platform_device *pdev)
Signature · 1 line
2.29.1
#42 lore raw

PATCH 42/59 rtc: isl12022: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-isl12022.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/rtc/rtc-isl12022.c +7 -4
index 961bd5d1d109..d45a1128823d 100644
@@ -247,10 +247,13 @@ static int isl12022_probe(struct i2c_client *client,
 
 	i2c_set_clientdata(client, isl12022);
 
-	isl12022->rtc = devm_rtc_device_register(&client->dev,
-					isl12022_driver.driver.name,
-					&isl12022_rtc_ops, THIS_MODULE);
-	return PTR_ERR_OR_ZERO(isl12022->rtc);
+	isl12022->rtc = devm_rtc_allocate_device(&client->dev);
+	if (IS_ERR(isl12022->rtc))
+		return PTR_ERR(isl12022->rtc);
+
+	isl12022->rtc->ops = &isl12022_rtc_ops;
+
+	return devm_rtc_register_device(isl12022->rtc);
 }
 
 #ifdef CONFIG_OF
Signature · 1 line
2.29.1
#43 lore raw

PATCH 43/59 rtc: tps80031: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-tps80031.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/rtc/rtc-tps80031.c +7 -8
index 737f26eb284a..65fba475bf33 100644
@@ -277,13 +277,11 @@ static int tps80031_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-			       &tps80031_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rtc->rtc)) {
-		ret = PTR_ERR(rtc->rtc);
-		dev_err(&pdev->dev, "RTC registration failed, err %d\n", ret);
-		return ret;
-	}
+	rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(rtc->rtc))
+		return PTR_ERR(rtc->rtc);
+
+	rtc->rtc->ops = &tps80031_rtc_ops;
 
 	ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
 			tps80031_rtc_irq,
@@ -295,7 +293,8 @@ static int tps80031_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 	device_set_wakeup_capable(&pdev->dev, 1);
-	return 0;
+
+	return devm_rtc_register_device(rtc->rtc);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.29.1
#44 lore raw

PATCH 44/59 rtc: rs5c372: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

While at it: remove unnecessary label.

---
 drivers/rtc/rtc-rs5c372.c | 36 +++++++++++++-----------------------
 1 file changed, 13 insertions(+), 23 deletions(-)
drivers/rtc/rtc-rs5c372.c +13 -23
index 3bd6eaa0dcf6..d554c891706b 100644
@@ -631,19 +631,15 @@ static int rs5c372_probe(struct i2c_client *client,
 				I2C_FUNC_SMBUS_BYTE_DATA |
 				I2C_FUNC_SMBUS_I2C_BLOCK))
 			smbus_mode = 1;
-		else {
+		else
 			/* Still no good, give up */
-			err = -ENODEV;
-			goto exit;
-		}
+			return -ENODEV;
 	}
 
 	rs5c372 = devm_kzalloc(&client->dev, sizeof(struct rs5c372),
 				GFP_KERNEL);
-	if (!rs5c372) {
-		err = -ENOMEM;
-		goto exit;
-	}
+	if (!rs5c372)
+		return -ENOMEM;
 
 	rs5c372->client = client;
 	i2c_set_clientdata(client, rs5c372);
@@ -659,7 +655,7 @@ static int rs5c372_probe(struct i2c_client *client,
 
 	err = rs5c_get_regs(rs5c372);
 	if (err < 0)
-		goto exit;
+		return err;
 
 	/* clock may be set for am/pm or 24 hr time */
 	switch (rs5c372->type) {
@@ -683,7 +679,7 @@ static int rs5c372_probe(struct i2c_client *client,
 		break;
 	default:
 		dev_err(&client->dev, "unknown RTC type\n");
-		goto exit;
+		return err;
 	}
 
 	/* if the oscillator lost power and no other software (like
@@ -695,7 +691,7 @@ static int rs5c372_probe(struct i2c_client *client,
 	err = rs5c_oscillator_setup(rs5c372);
 	if (unlikely(err < 0)) {
 		dev_err(&client->dev, "setup error\n");
-		goto exit;
+		return err;
 	}
 
 	dev_info(&client->dev, "%s found, %s\n",
@@ -712,23 +708,17 @@ static int rs5c372_probe(struct i2c_client *client,
 			);
 
 	/* REVISIT use client->irq to register alarm irq ... */
-	rs5c372->rtc = devm_rtc_device_register(&client->dev,
-					rs5c372_driver.driver.name,
-					&rs5c372_rtc_ops, THIS_MODULE);
+	rs5c372->rtc = devm_rtc_allocate_device(&client->dev);
+	if (IS_ERR(rs5c372->rtc))
+		return PTR_ERR(rs5c372->rtc);
 
-	if (IS_ERR(rs5c372->rtc)) {
-		err = PTR_ERR(rs5c372->rtc);
-		goto exit;
-	}
+	rs5c372->rtc->ops = &rs5c372_rtc_ops;
 
 	err = rs5c_sysfs_register(&client->dev);
 	if (err)
-		goto exit;
-
-	return 0;
+		return err;
 
-exit:
-	return err;
+	return devm_rtc_register_device(rs5c372->rtc);
 }
 
 static int rs5c372_remove(struct i2c_client *client)
Signature · 1 line
2.29.1
#45 lore raw

PATCH 45/59 rtc: mt7622: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-mt7622.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/rtc/rtc-mt7622.c +7 -3
index f1e356394814..20db5ea43309 100644
@@ -342,14 +342,18 @@ static int mtk_rtc_probe(struct platform_device *pdev)
 
 	device_init_wakeup(&pdev->dev, true);
 
-	hw->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
-					   &mtk_rtc_ops, THIS_MODULE);
+	hw->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(hw->rtc)) {
 		ret = PTR_ERR(hw->rtc);
-		dev_err(&pdev->dev, "Unable to register device\n");
 		goto err;
 	}
 
+	hw->rtc->ops = &mtk_rtc_ops;
+
+	ret = devm_rtc_register_device(hw->rtc);
+	if (ret)
+		goto err;
+
 	return 0;
 err:
 	clk_disable_unprepare(hw->clk);
Signature · 1 line
2.29.1
#46 lore raw

PATCH 46/59 rtc: ds1302: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-ds1302.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/rtc/rtc-ds1302.c +6 -8
index b3de6d2e680a..2ab0d6ea3a1c 100644
@@ -174,15 +174,13 @@ static int ds1302_probe(struct spi_device *spi)
 
 	spi_set_drvdata(spi, spi);
 
-	rtc = devm_rtc_device_register(&spi->dev, "ds1302",
-			&ds1302_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rtc)) {
-		status = PTR_ERR(rtc);
-		dev_err(&spi->dev, "error %d registering rtc\n", status);
-		return status;
-	}
+	rtc = devm_rtc_allocate_device(&spi->dev);
+	if (IS_ERR(rtc))
+		return PTR_ERR(rtc);
 
-	return 0;
+	rtc->ops = &ds1302_rtc_ops;
+
+	return devm_rtc_register_device(rtc);
 }
 
 static int ds1302_remove(struct spi_device *spi)
Signature · 1 line
2.29.1
#47 lore raw

PATCH 47/59 rtc: bq4802: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

While at it: remove unnecessary goto label.

---
 drivers/rtc/rtc-bq4802.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
drivers/rtc/rtc-bq4802.c +12 -18
index 472e75668917..4661dfbddb17 100644
@@ -145,16 +145,15 @@ static int bq4802_probe(struct platform_device *pdev)
 	int err = -ENOMEM;
 
 	if (!p)
-		goto out;
+		return err;
 
 	spin_lock_init(&p->lock);
 
 	p->r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (!p->r) {
 		p->r = platform_get_resource(pdev, IORESOURCE_IO, 0);
-		err = -EINVAL;
 		if (!p->r)
-			goto out;
+			return -EINVAL;
 	}
 	if (p->r->flags & IORESOURCE_IO) {
 		p->ioport = p->r->start;
@@ -163,29 +162,24 @@ static int bq4802_probe(struct platform_device *pdev)
 	} else if (p->r->flags & IORESOURCE_MEM) {
 		p->regs = devm_ioremap(&pdev->dev, p->r->start,
 					resource_size(p->r));
-		if (!p->regs){
-			err = -ENOMEM;
-			goto out;
-		}
+		if (!p->regs)
+			return -ENOMEM;
+
 		p->read = bq4802_read_mem;
 		p->write = bq4802_write_mem;
 	} else {
-		err = -EINVAL;
-		goto out;
+		return -EINVAL;
 	}
 
 	platform_set_drvdata(pdev, p);
 
-	p->rtc = devm_rtc_device_register(&pdev->dev, "bq4802",
-					&bq4802_ops, THIS_MODULE);
-	if (IS_ERR(p->rtc)) {
-		err = PTR_ERR(p->rtc);
-		goto out;
-	}
+	p->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(p->rtc))
+		return PTR_ERR(p->rtc);
+
+	p->rtc->ops = &bq4802_ops;
 
-	err = 0;
-out:
-	return err;
+	return devm_rtc_register_device(p->rtc);
 
 }
 
Signature · 1 line
2.29.1
#48 lore raw

PATCH 48/59 rtc: rs5c313: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-rs5c313.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/rtc/rtc-rs5c313.c +6 -3
index e98f85f34206..3813751d7c86 100644
@@ -371,10 +371,13 @@ static int rs5c313_rtc_probe(struct platform_device *pdev)
 	rs5c313_init_port();
 	rs5c313_check_xstp_bit();
 
-	rtc = devm_rtc_device_register(&pdev->dev, "rs5c313", &rs5c313_rtc_ops,
-				       THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(rtc))
+		return PTR_ERR(rtc);
 
-	return PTR_ERR_OR_ZERO(rtc);
+	rtc->ops = &rs5c313_rtc_ops;
+
+	return devm_rtc_register_device(rtc);
 }
 
 static struct platform_driver rs5c313_rtc_platform_driver = {
Signature · 1 line
2.29.1
#49 lore raw

PATCH 49/59 rtc: em3027: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-em3027.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-em3027.c +3 -3
index 9f176bce48ba..b6c7c0c17c44 100644
@@ -119,14 +119,14 @@ static int em3027_probe(struct i2c_client *client,
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
 		return -ENODEV;
 
-	rtc = devm_rtc_device_register(&client->dev, em3027_driver.driver.name,
-				  &em3027_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&client->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &em3027_rtc_ops;
 	i2c_set_clientdata(client, rtc);
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static const struct i2c_device_id em3027_id[] = {
Signature · 1 line
2.29.1
#50 lore raw

PATCH 50/59 rtc: v3020: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-v3020.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/rtc/rtc-v3020.c +7 -2
index d2da92187d56..e947cd1538a9 100644
@@ -329,13 +329,18 @@ static int rtc_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, chip);
 
-	chip->rtc = devm_rtc_device_register(&pdev->dev, "v3020",
-					&v3020_rtc_ops, THIS_MODULE);
+	chip->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(chip->rtc)) {
 		retval = PTR_ERR(chip->rtc);
 		goto err_io;
 	}
 
+	chip->rtc->ops = &v3020_rtc_ops;
+
+	retval = devm_rtc_register_device(chip->rtc);
+	if (retval)
+		goto err_io;
+
 	return 0;
 
 err_io:
Signature · 1 line
2.29.1
#51 lore raw

PATCH 51/59 rtc: ds1216: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-ds1216.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/rtc/rtc-ds1216.c +5 -3
index 7eeb3f359de8..594f39d4e916 100644
@@ -150,14 +150,16 @@ static int __init ds1216_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->ioaddr))
 		return PTR_ERR(priv->ioaddr);
 
-	priv->rtc = devm_rtc_device_register(&pdev->dev, "ds1216",
-					&ds1216_rtc_ops, THIS_MODULE);
+	priv->rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(priv->rtc))
 		return PTR_ERR(priv->rtc);
 
+	priv->rtc->ops = &ds1216_rtc_ops;
+
 	/* dummy read to get clock into a known state */
 	ds1216_read(priv->ioaddr, dummy);
-	return 0;
+
+	return devm_rtc_register_device(priv->rtc);
 }
 
 static struct platform_driver ds1216_rtc_platform_driver = {
Signature · 1 line
2.29.1
#52 lore raw

PATCH 52/59 rtc: rx4581: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-rx4581.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-rx4581.c +4 -3
index c092e0452347..5d42aa051b4c 100644
@@ -261,13 +261,14 @@ static int rx4581_probe(struct spi_device *spi)
 	if (res != 0)
 		return res;
 
-	rtc = devm_rtc_device_register(&spi->dev, "rx4581",
-				&rx4581_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&spi->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &rx4581_rtc_ops;
 	spi_set_drvdata(spi, rtc);
-	return 0;
+
+	return devm_rtc_register_device(rtc);
 }
 
 static const struct spi_device_id rx4581_id[] = {
Signature · 1 line
2.29.1
#53 lore raw

PATCH 53/59 rtc: m41t93: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-m41t93.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/rtc/rtc-m41t93.c +3 -3
index 9444cb5f5190..7faa8a4f0032 100644
@@ -181,14 +181,14 @@ static int m41t93_probe(struct spi_device *spi)
 		return -ENODEV;
 	}
 
-	rtc = devm_rtc_device_register(&spi->dev, m41t93_driver.driver.name,
-					&m41t93_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&spi->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &m41t93_rtc_ops;
 	spi_set_drvdata(spi, rtc);
 
-	return 0;
+	return devm_rtc_register_device(rtc);
 }
 
 static struct spi_driver m41t93_driver = {
Signature · 1 line
2.29.1
#54 lore raw

PATCH 54/59 rtc: fm3130: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

While at it: remove unnecessary goto label.

---
 drivers/rtc/rtc-fm3130.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/rtc/rtc-fm3130.c +8 -14
index 677ec2da13d8..29e296f2faab 100644
@@ -344,7 +344,6 @@ static int fm3130_probe(struct i2c_client *client,
 			const struct i2c_device_id *id)
 {
 	struct fm3130		*fm3130;
-	int			err = -ENODEV;
 	int			tmp;
 	struct i2c_adapter	*adapter = client->adapter;
 
@@ -390,8 +389,7 @@ static int fm3130_probe(struct i2c_client *client,
 	tmp = i2c_transfer(adapter, fm3130->msg, 4);
 	if (tmp != 4) {
 		dev_dbg(&client->dev, "read error %d\n", tmp);
-		err = -EIO;
-		goto exit_free;
+		return -EIO;
 	}
 
 	fm3130->regs[FM3130_RTC_CONTROL] =
@@ -501,17 +499,13 @@ static int fm3130_probe(struct i2c_client *client,
 
 	/* We won't bail out here because we just got invalid data.
 	   Time setting from u-boot doesn't work anyway */
-	fm3130->rtc = devm_rtc_device_register(&client->dev, client->name,
-				&fm3130_rtc_ops, THIS_MODULE);
-	if (IS_ERR(fm3130->rtc)) {
-		err = PTR_ERR(fm3130->rtc);
-		dev_err(&client->dev,
-			"unable to register the class device\n");
-		goto exit_free;
-	}
-	return 0;
-exit_free:
-	return err;
+	fm3130->rtc = devm_rtc_allocate_device(&client->dev);
+	if (IS_ERR(fm3130->rtc))
+		return PTR_ERR(fm3130->rtc);
+
+	fm3130->rtc->ops = &fm3130_rtc_ops;
+
+	return devm_rtc_register_device(fm3130->rtc);
 }
 
 static struct i2c_driver fm3130_driver = {
Signature · 1 line
2.29.1
#55 lore raw

PATCH 55/59 rtc: rtd119x: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-rtd119x.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/rtc/rtc-rtd119x.c +10 -3
index bb98f2d574a5..547ab60adb3f 100644
@@ -205,10 +205,17 @@ static int rtd119x_rtc_probe(struct platform_device *pdev)
 
 	rtd119x_rtc_set_enabled(&pdev->dev, true);
 
-	data->rtcdev = devm_rtc_device_register(&pdev->dev, "rtc",
-						&rtd119x_rtc_ops, THIS_MODULE);
+	data->rtcdev = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(data->rtcdev)) {
-		dev_err(&pdev->dev, "failed to register rtc device");
+		clk_disable_unprepare(data->clk);
+		clk_put(data->clk);
+		return PTR_ERR(data->rtcdev);
+	}
+
+	data->rtcdev->ops = &rtd119x_rtc_ops;
+
+	ret = devm_rtc_register_device(data->rtcdev);
+	if (ret) {
 		clk_disable_unprepare(data->clk);
 		clk_put(data->clk);
 		return PTR_ERR(data->rtcdev);
Signature · 1 line
2.29.1
#56 lore raw

PATCH 56/59 rtc: msm6242: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-msm6242.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/rtc/rtc-msm6242.c +4 -3
index 80e364baac53..b194f8bff403 100644
@@ -205,13 +205,14 @@ static int __init msm6242_rtc_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	platform_set_drvdata(pdev, priv);
 
-	rtc = devm_rtc_device_register(&pdev->dev, "rtc-msm6242",
-				&msm6242_rtc_ops, THIS_MODULE);
+	rtc = devm_rtc_allocate_device(&pdev->dev);
 	if (IS_ERR(rtc))
 		return PTR_ERR(rtc);
 
+	rtc->ops = &msm6242_rtc_ops;
 	priv->rtc = rtc;
-	return 0;
+
+	return devm_rtc_register_device(rtc);
 }
 
 static struct platform_driver msm6242_rtc_driver = {
Signature · 1 line
2.29.1
#57 lore raw

PATCH 57/59 rtc: as3722: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-as3722.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/rtc/rtc-as3722.c +6 -8
index 0f21af27f4cf..90e70279a5d4 100644
@@ -189,14 +189,11 @@ static int as3722_rtc_probe(struct platform_device *pdev)
 
 	device_init_wakeup(&pdev->dev, 1);
 
-	as3722_rtc->rtc = devm_rtc_device_register(&pdev->dev, "as3722-rtc",
-				&as3722_rtc_ops, THIS_MODULE);
-	if (IS_ERR(as3722_rtc->rtc)) {
-		ret = PTR_ERR(as3722_rtc->rtc);
-		dev_err(&pdev->dev, "RTC register failed: %d\n", ret);
-		return ret;
-	}
+	as3722_rtc->rtc = devm_rtc_allocate_device(&pdev->dev);
+	if (IS_ERR(as3722_rtc->rtc))
+		return PTR_ERR(as3722_rtc->rtc);
 
+	as3722_rtc->rtc->ops = &as3722_rtc_ops;
 	as3722_rtc->alarm_irq = platform_get_irq(pdev, 0);
 	dev_info(&pdev->dev, "RTC interrupt %d\n", as3722_rtc->alarm_irq);
 
@@ -209,7 +206,8 @@ static int as3722_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 	disable_irq(as3722_rtc->alarm_irq);
-	return 0;
+
+	return devm_rtc_register_device(as3722_rtc->rtc);
 }
 
 #ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.29.1
#58 lore raw

PATCH 58/59 rtc: lp8788: stop using deprecated RTC API

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

devm_rtc_device_register() is deprecated. Use devm_rtc_allocate_device() and devm_rtc_register_device() pair instead.

---
 drivers/rtc/rtc-lp8788.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/rtc/rtc-lp8788.c +5 -6
index c0b8fbce1082..c93bf5566e0b 100644
@@ -295,17 +295,16 @@ static int lp8788_rtc_probe(struct platform_device *pdev)
 
 	device_init_wakeup(dev, 1);
 
-	rtc->rdev = devm_rtc_device_register(dev, "lp8788_rtc",
-					&lp8788_rtc_ops, THIS_MODULE);
-	if (IS_ERR(rtc->rdev)) {
-		dev_err(dev, "can not register rtc device\n");
+	rtc->rdev = devm_rtc_allocate_device(dev);
+	if (IS_ERR(rtc->rdev))
 		return PTR_ERR(rtc->rdev);
-	}
+
+	rtc->rdev->ops = &lp8788_rtc_ops;
 
 	if (lp8788_alarm_irq_register(pdev, rtc))
 		dev_warn(lp->dev, "no rtc irq handler\n");
 
-	return 0;
+	return devm_rtc_register_device(rtc->rdev);
 }
 
 static struct platform_driver lp8788_rtc_driver = {
Signature · 1 line
2.29.1
#59 lore raw
In reply to Bartosz Golaszewski
Quoted 10 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

So we now have two functions whose names are easy to confuse. I spent some time and simply converted all RTC drivers to using the preferred interface.

Obviously these have only been compile-tested. I hope I didn't broke too many drivers in the process. Most of the conversions was easy, sometime it required removing unnecessary goto labels. There's also one patch using a different devres helpers in here.

I'm not going to apply this series as this is not how I wanted to proceed (else this would have been done a while ago).

Quoted 126 lines

Bartosz Golaszewski (59):
rtc: da9055: stop using deprecated RTC API
rtc: m41t94: stop using deprecated RTC API
rtc: ds1390: stop using deprecated RTC API
rtc: ds3232: stop using deprecated RTC API
rtc: rx6110: stop using deprecated RTC API
rtc: palmas: stop using deprecated RTC API
rtc: bq32k: stop using deprecated RTC API
rtc: m48t35: stop using deprecated RTC API
rtc: pcf50633: stop using deprecated RTC API
rtc: pcf8583: stop using deprecated RTC API
rtc: efi: stop using deprecated RTC API
rtc: pcf8523: stop using deprecated RTC API
rtc: stm32: stop using deprecated RTC API
rtc: max8925: stop using deprecated RTC API
rtc: max8907: stop using deprecated RTC API
rtc: pxa: stop using deprecated RTC API
rtc: hym8563: stop using deprecated RTC API
rtc: max6916: stop using deprecated RTC API
rtc: max8998: stop using deprecated RTC API
rtc: s5m: use devm_i2c_new_dummy_device()
rtc: s5m: stop using deprecated RTC API
rtc: moxart: stop using deprecated RTC API
rtc: hid: stop using deprecated RTC API
rtc: generic: stop using deprecated RTC API
rtc: lpc24xx: stop using deprecated RTC API
rtc: spear: stop using deprecated RTC API
rtc: max77686: stop using deprecated RTC API
rtc: ds1286: stop using deprecated RTC API
rtc: twl: stop using deprecated RTC API
rtc: s3c: stop using deprecated RTC API
rtc: mcp795: stop using deprecated RTC API
rtc: x1205: stop using deprecated RTC API
rtc: max6902: stop using deprecated RTC API
rtc: max6900: stop using deprecated RTC API
rtc: rx8025: stop using deprecated RTC API
rtc: asm9260: stop using deprecated RTC API
rtc: opal: stop using deprecated RTC API
rtc: rc5t583: stop using deprecated RTC API
rtc: wm8350: stop using deprecated RTC API
rtc: r7301: stop using deprecated RTC API
rtc: max8997: stop using deprecated RTC API
rtc: isl12022: stop using deprecated RTC API
rtc: tps80031: stop using deprecated RTC API
rtc: rs5c372: stop using deprecated RTC API
rtc: mt7622: stop using deprecated RTC API
rtc: ds1302: stop using deprecated RTC API
rtc: bq4802: stop using deprecated RTC API
rtc: rs5c313: stop using deprecated RTC API
rtc: em3027: stop using deprecated RTC API
rtc: v3020: stop using deprecated RTC API
rtc: ds1216: stop using deprecated RTC API
rtc: rx4581: stop using deprecated RTC API
rtc: m41t93: stop using deprecated RTC API
rtc: fm3130: stop using deprecated RTC API
rtc: rtd119x: stop using deprecated RTC API
rtc: msm6242: stop using deprecated RTC API
rtc: as3722: stop using deprecated RTC API
rtc: lp8788: stop using deprecated RTC API
rtc: remove devm_rtc_device_register()

 .../driver-api/driver-model/devres.rst        |  1 -
 drivers/rtc/class.c                           | 36 -------------
 drivers/rtc/rtc-as3722.c                      | 14 +++---
 drivers/rtc/rtc-asm9260.c                     | 10 ++--
 drivers/rtc/rtc-bq32k.c                       |  8 +--
 drivers/rtc/rtc-bq4802.c                      | 30 +++++------
 drivers/rtc/rtc-da9055.c                      | 19 +++----
 drivers/rtc/rtc-ds1216.c                      |  8 +--
 drivers/rtc/rtc-ds1286.c                      | 15 +++---
 drivers/rtc/rtc-ds1302.c                      | 14 +++---
 drivers/rtc/rtc-ds1390.c                      | 13 +++--
 drivers/rtc/rtc-ds3232.c                      |  7 +--
 drivers/rtc/rtc-efi.c                         |  6 +--
 drivers/rtc/rtc-em3027.c                      |  6 +--
 drivers/rtc/rtc-fm3130.c                      | 22 +++-----
 drivers/rtc/rtc-generic.c                     |  6 +--
 drivers/rtc/rtc-hid-sensor-time.c             | 21 ++++----
 drivers/rtc/rtc-hym8563.c                     |  6 +--
 drivers/rtc/rtc-isl12022.c                    | 11 ++--
 drivers/rtc/rtc-lp8788.c                      | 11 ++--
 drivers/rtc/rtc-lpc24xx.c                     | 10 ++--
 drivers/rtc/rtc-m41t93.c                      |  6 +--
 drivers/rtc/rtc-m41t94.c                      |  8 +--
 drivers/rtc/rtc-m48t35.c                      | 10 ++--
 drivers/rtc/rtc-max6900.c                     |  6 +--
 drivers/rtc/rtc-max6902.c                     |  7 +--
 drivers/rtc/rtc-max6916.c                     |  6 +--
 drivers/rtc/rtc-max77686.c                    | 13 ++---
 drivers/rtc/rtc-max8907.c                     | 14 +++---
 drivers/rtc/rtc-max8925.c                     | 14 +++---
 drivers/rtc/rtc-max8997.c                     | 21 ++++----
 drivers/rtc/rtc-max8998.c                     | 13 ++---
 drivers/rtc/rtc-mcp795.c                      |  7 +--
 drivers/rtc/rtc-moxart.c                      | 12 ++---
 drivers/rtc/rtc-msm6242.c                     |  7 +--
 drivers/rtc/rtc-mt7622.c                      | 10 ++--
 drivers/rtc/rtc-opal.c                        |  6 +--
 drivers/rtc/rtc-palmas.c                      | 15 +++---
 drivers/rtc/rtc-pcf50633.c                    |  8 +--
 drivers/rtc/rtc-pcf8523.c                     |  7 +--
 drivers/rtc/rtc-pcf8583.c                     | 10 ++--
 drivers/rtc/rtc-pxa.c                         | 13 ++---
 drivers/rtc/rtc-r7301.c                       |  7 +--
 drivers/rtc/rtc-rc5t583.c                     | 14 +++---
 drivers/rtc/rtc-rs5c313.c                     |  9 ++--
 drivers/rtc/rtc-rs5c372.c                     | 36 +++++--------
 drivers/rtc/rtc-rtd119x.c                     | 13 +++--
 drivers/rtc/rtc-rx4581.c                      |  7 +--
 drivers/rtc/rtc-rx6110.c                      | 12 ++---
 drivers/rtc/rtc-rx8025.c                      | 11 ++--
 drivers/rtc/rtc-s3c.c                         | 10 ++--
 drivers/rtc/rtc-s5m.c                         | 50 ++++++++-----------
 drivers/rtc/rtc-spear.c                       | 10 ++--
 drivers/rtc/rtc-stm32.c                       | 18 ++++---
 drivers/rtc/rtc-tps80031.c                    | 15 +++---
 drivers/rtc/rtc-twl.c                         | 12 ++---
 drivers/rtc/rtc-v3020.c                       |  9 +++-
 drivers/rtc/rtc-wm8350.c                      | 14 +++---
 drivers/rtc/rtc-x1205.c                       |  7 ++-
 include/linux/rtc.h                           |  4 --
 60 files changed, 346 insertions(+), 399 deletions(-)
Signature · 1 line
2.29.1
Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#60 lore raw
Quoted 7 lines · Alexandre Belloni
Quoted 5 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

So we now have two functions whose names are easy to confuse. I spent some time and simply converted all RTC drivers to using the preferred interface.

Quoted 9 lines
Quoted 5 lines

Obviously these have only been compile-tested. I hope I didn't broke too many drivers in the process. Most of the conversions was easy, sometime it required removing unnecessary goto labels. There's also one patch using a different devres helpers in here.

I'm not going to apply this series as this is not how I wanted to proceed (else this would have been done a while ago).

What's the plan then?

Bartosz

#61 lore raw

PATCH 59/59 rtc: remove devm_rtc_device_register()

In reply to Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

All users have been converted to using the devm_rtc_allocate_device() + devm_rtc_register_device() pair. We can remove the deprecated interface.

---
 .../driver-api/driver-model/devres.rst        |  1 -
 drivers/rtc/class.c                           | 36 -------------------
 include/linux/rtc.h                           |  4 ---
 3 files changed, 41 deletions(-)
Documentation/driver-api/driver-model/devres.rst +0 -1
index cd8b6e657b94..f22823af7265 100644
@@ -412,7 +412,6 @@ RESET
   devm_reset_controller_register()
 
 RTC
-  devm_rtc_device_register()
   devm_rtc_allocate_device()
   devm_rtc_register_device()
   devm_rtc_nvmem_register()
drivers/rtc/class.c +0 -36
index e6b44b7c4ad3..e192ea39ff3f 100644
@@ -415,42 +415,6 @@ int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc)
 }
 EXPORT_SYMBOL_GPL(__devm_rtc_register_device);
 
-/**
- * devm_rtc_device_register - resource managed rtc_device_register()
- * @dev: the device to register
- * @name: the name of the device (unused)
- * @ops: the rtc operations structure
- * @owner: the module owner
- *
- * @return a struct rtc on success, or an ERR_PTR on error
- *
- * Managed rtc_device_register(). The rtc_device returned from this function
- * are automatically freed on driver detach.
- * This function is deprecated, use devm_rtc_allocate_device and
- * rtc_register_device instead
- */
-struct rtc_device *devm_rtc_device_register(struct device *dev,
-					    const char *name,
-					    const struct rtc_class_ops *ops,
-					    struct module *owner)
-{
-	struct rtc_device *rtc;
-	int err;
-
-	rtc = devm_rtc_allocate_device(dev);
-	if (IS_ERR(rtc))
-		return rtc;
-
-	rtc->ops = ops;
-
-	err = __devm_rtc_register_device(owner, rtc);
-	if (err)
-		return ERR_PTR(err);
-
-	return rtc;
-}
-EXPORT_SYMBOL_GPL(devm_rtc_device_register);
-
 static int __init rtc_init(void)
 {
 	rtc_class = class_create(THIS_MODULE, "rtc");
include/linux/rtc.h +0 -4
index 55e7beed066c..e3623446a9d7 100644
@@ -150,10 +150,6 @@ struct rtc_device {
 #define RTC_TIMESTAMP_END_2199		7258118399LL /* 2199-12-31 23:59:59 */
 #define RTC_TIMESTAMP_END_9999		253402300799LL /* 9999-12-31 23:59:59 */
 
-extern struct rtc_device *devm_rtc_device_register(struct device *dev,
-					const char *name,
-					const struct rtc_class_ops *ops,
-					struct module *owner);
 struct rtc_device *devm_rtc_allocate_device(struct device *dev);
 int __devm_rtc_register_device(struct module *owner, struct rtc_device *rtc);
 
Signature · 1 line
2.29.1