Skip to contentSkip to conversation

hwrng: omap - remove incorrect __exit markups

PATCH In review Dmitry Torokhov 2 participants 9 messages Mar 9, 2015 – Mar 11, 2015

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

PATCH 1/4 hwrng: omap - remove incorrect __exit markups

Even if bus is not hot-pluggable, the devices can be unbound from the driver via sysfs, so we should not be using __exit annotations on remove() methods. The only exception is drivers registered with platform_driver_probe() which specifically disables sysfs bind/unbind attributes.

---
 drivers/char/hw_random/omap-rng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/omap-rng.c +2 -2
index d14dcf7..7f3597d 100644
@@ -408,7 +408,7 @@ err_ioremap:
 	return ret;
 }
 
-static int __exit omap_rng_remove(struct platform_device *pdev)
+static int omap_rng_remove(struct platform_device *pdev)
 {
 	struct omap_rng_dev *priv = platform_get_drvdata(pdev);
 
@@ -460,7 +460,7 @@ static struct platform_driver omap_rng_driver = {
 		.of_match_table = of_match_ptr(omap_rng_of_match),
 	},
 	.probe		= omap_rng_probe,
-	.remove		= __exit_p(omap_rng_remove),
+	.remove		= omap_rng_remove,
 };
 
 module_platform_driver(omap_rng_driver);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw

PATCH 2/4 hwrng: omap - remove #ifdefery around PM methods

Instead of using #ifdefs let's mark suspend and resume methods as __maybe_unused which will suppress compiler warnings about them being unused and provide better compile coverage. This will not increase image size.

---
 drivers/char/hw_random/omap-rng.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/char/hw_random/omap-rng.c +3 -12
index 7f3597d..5c171b1 100644
@@ -422,9 +422,7 @@ static int omap_rng_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-
-static int omap_rng_suspend(struct device *dev)
+static int __maybe_unused omap_rng_suspend(struct device *dev)
 {
 	struct omap_rng_dev *priv = dev_get_drvdata(dev);
 
@@ -434,7 +432,7 @@ static int omap_rng_suspend(struct device *dev)
 	return 0;
 }
 
-static int omap_rng_resume(struct device *dev)
+static int __maybe_unused omap_rng_resume(struct device *dev)
 {
 	struct omap_rng_dev *priv = dev_get_drvdata(dev);
 
@@ -445,18 +443,11 @@ static int omap_rng_resume(struct device *dev)
 }
 
 static SIMPLE_DEV_PM_OPS(omap_rng_pm, omap_rng_suspend, omap_rng_resume);
-#define	OMAP_RNG_PM	(&omap_rng_pm)
-
-#else
-
-#define	OMAP_RNG_PM	NULL
-
-#endif
 
 static struct platform_driver omap_rng_driver = {
 	.driver = {
 		.name		= "omap_rng",
-		.pm		= OMAP_RNG_PM,
+		.pm		= &omap_rng_pm,
 		.of_match_table = of_match_ptr(omap_rng_of_match),
 	},
 	.probe		= omap_rng_probe,
Signature · 1 line
2.2.0.rc0.207.ga3a616c
maintainer
#2 lore raw

Re: [PATCH 2/4] hwrng: omap - remove #ifdefery around PM methods

Quoted 41 lines · Dmitry Torokhov

Instead of using #ifdefs let's mark suspend and resume methods as __maybe_unused which will suppress compiler warnings about them being unused and provide better compile coverage. This will not increase image size.

---
 drivers/char/hw_random/omap-rng.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/char/hw_random/omap-rng.c +2 -7
index 7f3597d..5c171b1 100644
@@ -422,9 +422,7 @@ static int omap_rng_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-
-static int omap_rng_suspend(struct device *dev)
+static int __maybe_unused omap_rng_suspend(struct device *dev)
 {
 	struct omap_rng_dev *priv = dev_get_drvdata(dev);
 
@@ -434,7 +432,7 @@ static int omap_rng_suspend(struct device *dev)
 	return 0;
 }
 
-static int omap_rng_resume(struct device *dev)
+static int __maybe_unused omap_rng_resume(struct device *dev)
 {
 	struct omap_rng_dev *priv = dev_get_drvdata(dev);
 
@@ -445,18 +443,11 @@ static int omap_rng_resume(struct device *dev)
 }
 
 static SIMPLE_DEV_PM_OPS(omap_rng_pm, omap_rng_suspend, omap_rng_resume);
-#define	OMAP_RNG_PM	(&omap_rng_pm)
-
-#else

drivers/char/hw_random/omap-rng.c static int omap_rng_resume(struct device *dev) · line 450

Quoted 10 lines
drivers/char/hw_random/omap-rng.c +1 -5
-
-#define	OMAP_RNG_PM	NULL
-
-#endif
 
 static struct platform_driver omap_rng_driver = {
 	.driver = {
 		.name		= "omap_rng",
-		.pm		= OMAP_RNG_PM,
+		.pm		= &omap_rng_pm,

This will cause omap_rng_suspend/omap_rng_resume to be referenced always, thus rendering the __maybe_unused moot, no?

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#3 lore raw

Re: [PATCH 2/4] hwrng: omap - remove #ifdefery around PM methods

Hi Herbert,

Quoted 47 lines · Herbert Xu
Quoted 46 lines · Dmitry Torokhov

Instead of using #ifdefs let's mark suspend and resume methods as __maybe_unused which will suppress compiler warnings about them being unused and provide better compile coverage. This will not increase image size.

---
 drivers/char/hw_random/omap-rng.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/char/hw_random/omap-rng.c +2 -11
index 7f3597d..5c171b1 100644
@@ -422,9 +422,7 @@ static int omap_rng_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-
-static int omap_rng_suspend(struct device *dev)
+static int __maybe_unused omap_rng_suspend(struct device *dev)
 {
 	struct omap_rng_dev *priv = dev_get_drvdata(dev);
 
@@ -434,7 +432,7 @@ static int omap_rng_suspend(struct device *dev)
 	return 0;
 }
 
-static int omap_rng_resume(struct device *dev)
+static int __maybe_unused omap_rng_resume(struct device *dev)
 {
 	struct omap_rng_dev *priv = dev_get_drvdata(dev);
 
@@ -445,18 +443,11 @@ static int omap_rng_resume(struct device *dev)
 }
 
 static SIMPLE_DEV_PM_OPS(omap_rng_pm, omap_rng_suspend, omap_rng_resume);
-#define	OMAP_RNG_PM	(&omap_rng_pm)
-
-#else
-
-#define	OMAP_RNG_PM	NULL
-
-#endif
 
Quoted 8 lines

drivers/char/hw_random/omap-rng.c static int omap_rng_resume(struct device *dev) · line 450

Quoted 5 lines
drivers/char/hw_random/omap-rng.c +1 -1
 static struct platform_driver omap_rng_driver = {
 	.driver = {
 		.name		= "omap_rng",
-		.pm		= OMAP_RNG_PM,
+		.pm		= &omap_rng_pm,

This will cause omap_rng_suspend/omap_rng_resume to be referenced always, thus rendering the __maybe_unused moot, no?

SIMPLE_DEV_PM_OPS() produces an empty omap_rng_pm structure in case of !CONFIG_PM_SLEEP so neither omap_rng_suspend nor omap_rng_resume will end up being referenced.

Thanks.

Signature · 1 line
Dmitry
maintainer
#4 lore raw

Re: [PATCH 2/4] hwrng: omap - remove #ifdefery around PM methods

Quoted 4 lines · Dmitry Torokhov

SIMPLE_DEV_PM_OPS() produces an empty omap_rng_pm structure in case of !CONFIG_PM_SLEEP so neither omap_rng_suspend nor omap_rng_resume will end up being referenced.

OK, could you please resend this patch?

Thanks,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#5 lore raw

Re: [PATCH 2/4] hwrng: omap - remove #ifdefery around PM methods

Quoted 7 lines · Herbert Xu
Quoted 4 lines · Dmitry Torokhov

SIMPLE_DEV_PM_OPS() produces an empty omap_rng_pm structure in case of !CONFIG_PM_SLEEP so neither omap_rng_suspend nor omap_rng_resume will end up being referenced.

OK, could you please resend this patch?

Done.

Thanks!

Signature · 1 line
Dmitry
#6 lore raw

PATCH 3/4 hwrng: octeon - remove incorrect __exit markups

In reply to Dmitry Torokhov

Even if bus is not hot-pluggable, the devices can be unbound from the driver via sysfs, so we should not be using __exit annotations on remove() methods. The only exception is drivers registered with platform_driver_probe() which specifically disables sysfs bind/unbind attributes

---
 drivers/char/hw_random/octeon-rng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/octeon-rng.c +2 -2
index be1c3f6..6234a4a 100644
@@ -105,7 +105,7 @@ static int octeon_rng_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int __exit octeon_rng_remove(struct platform_device *pdev)
+static int octeon_rng_remove(struct platform_device *pdev)
 {
 	struct hwrng *rng = platform_get_drvdata(pdev);
 
@@ -119,7 +119,7 @@ static struct platform_driver octeon_rng_driver = {
 		.name		= "octeon_rng",
 	},
 	.probe		= octeon_rng_probe,
-	.remove		= __exit_p(octeon_rng_remove),
+	.remove		= octeon_rng_remove,
 };
 
 module_platform_driver(octeon_rng_driver);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#7 lore raw

PATCH 4/4 hwrng: pseries-rng - remove incorrect __init/__exit markups

In reply to Dmitry Torokhov

Even if bus is not hot-pluggable, the devices can be unbound from the driver via sysfs, so we should not be using __exit annotations on remove() methods. The only exception is drivers registered with platform_driver_probe() which specifically disables sysfs bind/unbind attributes.

Similarly probe() methods should not be marked __init unless platform_driver_probe() is used.

---
 drivers/char/hw_random/pseries-rng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/pseries-rng.c +2 -2
index bcf86f9..63ce51d 100644
@@ -61,13 +61,13 @@ static struct hwrng pseries_rng = {
 	.read		= pseries_rng_read,
 };
 
-static int __init pseries_rng_probe(struct vio_dev *dev,
+static int pseries_rng_probe(struct vio_dev *dev,
 		const struct vio_device_id *id)
 {
 	return hwrng_register(&pseries_rng);
 }
 
-static int __exit pseries_rng_remove(struct vio_dev *dev)
+static int pseries_rng_remove(struct vio_dev *dev)
 {
 	hwrng_unregister(&pseries_rng);
 	return 0;
Signature · 1 line
2.2.0.rc0.207.ga3a616c
maintainer
#8 lore raw
In reply to Dmitry Torokhov
Quoted 7 lines · Dmitry Torokhov

Even if bus is not hot-pluggable, the devices can be unbound from the driver via sysfs, so we should not be using __exit annotations on remove() methods. The only exception is drivers registered with platform_driver_probe() which specifically disables sysfs bind/unbind attributes.

Patches 1/3/4 applied.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt