Skip to contentSkip to conversation

pwm: Fill in missing .owner fields

PATCH In review Thierry Reding 4 participants 6 messages Jun 12, 2013 – Jun 13, 2013

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

PATCH 1/1 pwm: Fill in missing .owner fields

Some drivers don't set the .owner fields of the struct device_driver or struct pwm_ops, which causes the module usage count to become wrong.

---
 drivers/pwm/pwm-atmel-tcb.c | 1 +
 drivers/pwm/pwm-bfin.c      | 1 +
 drivers/pwm/pwm-imx.c       | 1 +
 drivers/pwm/pwm-lpc32xx.c   | 1 +
 drivers/pwm/pwm-mxs.c       | 1 +
 drivers/pwm/pwm-pca9685.c   | 1 +
 drivers/pwm/pwm-puv3.c      | 1 +
 drivers/pwm/pwm-spear.c     | 1 +
 drivers/pwm/pwm-tegra.c     | 1 +
 9 files changed, 9 insertions(+)
drivers/pwm/pwm-atmel-tcb.c +1 -0
index 09be626..ba6ce01 100644
@@ -434,6 +434,7 @@ MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
 static struct platform_driver atmel_tcb_pwm_driver = {
 	.driver = {
 		.name = "atmel-tcb-pwm",
+		.owner = THIS_MODULE,
 		.of_match_table = atmel_tcb_pwm_dt_ids,
 	},
 	.probe = atmel_tcb_pwm_probe,
drivers/pwm/pwm-bfin.c +1 -0
index 7631ef1..9985d83 100644
@@ -149,6 +149,7 @@ static int bfin_pwm_remove(struct platform_device *pdev)
 static struct platform_driver bfin_pwm_driver = {
 	.driver = {
 		.name = "bfin-pwm",
+		.owner = THIS_MODULE,
 	},
 	.probe = bfin_pwm_probe,
 	.remove = bfin_pwm_remove,
drivers/pwm/pwm-imx.c +1 -0
index c938bae..2b7c4f8 100644
@@ -295,6 +295,7 @@ static int imx_pwm_remove(struct platform_device *pdev)
 static struct platform_driver imx_pwm_driver = {
 	.driver		= {
 		.name	= "imx-pwm",
+		.owner = THIS_MODULE,
 		.of_match_table = of_match_ptr(imx_pwm_dt_ids),
 	},
 	.probe		= imx_pwm_probe,
drivers/pwm/pwm-lpc32xx.c +1 -0
index 8272883..efb6c7b 100644
@@ -171,6 +171,7 @@ MODULE_DEVICE_TABLE(of, lpc32xx_pwm_dt_ids);
 static struct platform_driver lpc32xx_pwm_driver = {
 	.driver = {
 		.name = "lpc32xx-pwm",
+		.owner = THIS_MODULE,
 		.of_match_table = of_match_ptr(lpc32xx_pwm_dt_ids),
 	},
 	.probe = lpc32xx_pwm_probe,
drivers/pwm/pwm-mxs.c +1 -0
index 6489a4b..2c77b81 100644
@@ -182,6 +182,7 @@ MODULE_DEVICE_TABLE(of, mxs_pwm_dt_ids);
 static struct platform_driver mxs_pwm_driver = {
 	.driver = {
 		.name = "mxs-pwm",
+		.owner = THIS_MODULE,
 		.of_match_table = of_match_ptr(mxs_pwm_dt_ids),
 	},
 	.probe = mxs_pwm_probe,
drivers/pwm/pwm-pca9685.c +1 -0
index 2afc904..c9f9e65 100644
@@ -199,6 +199,7 @@ static const struct pwm_ops pca9685_pwm_ops = {
 	.config = pca9685_pwm_config,
 	.request = pca9685_pwm_request,
 	.free = pca9685_pwm_free,
+	.owner = THIS_MODULE,
 };
 
 static struct regmap_config pca9685_regmap_i2c_config = {
drivers/pwm/pwm-puv3.c +1 -0
index ed6007b..a9a2808 100644
@@ -146,6 +146,7 @@ static int pwm_remove(struct platform_device *pdev)
 static struct platform_driver puv3_pwm_driver = {
 	.driver = {
 		.name = "PKUnity-v3-PWM",
+		.owner = THIS_MODULE,
 	},
 	.probe = pwm_probe,
 	.remove = pwm_remove,
drivers/pwm/pwm-spear.c +1 -0
index 6d99e2c..a54d214 100644
@@ -259,6 +259,7 @@ MODULE_DEVICE_TABLE(of, spear_pwm_of_match);
 static struct platform_driver spear_pwm_driver = {
 	.driver = {
 		.name = "spear-pwm",
+		.owner = THIS_MODULE,
 		.of_match_table = spear_pwm_of_match,
 	},
 	.probe = spear_pwm_probe,
drivers/pwm/pwm-tegra.c +1 -0
index a540293..74298c5 100644
@@ -239,6 +239,7 @@ MODULE_DEVICE_TABLE(of, tegra_pwm_of_match);
 static struct platform_driver tegra_pwm_driver = {
 	.driver = {
 		.name = "tegra-pwm",
+		.owner = THIS_MODULE,
 		.of_match_table = tegra_pwm_of_match,
 	},
 	.probe = tegra_pwm_probe,
Signature · 1 line
1.8.2
#1 lore raw

Hi Thierry,

Quoted 2 lines · Thierry Reding

Some drivers don't set the .owner fields of the struct device_driver or struct pwm_ops, which causes the module usage count to become wrong.

Recently a patch [1] was added to solve this issue of missing .owner fileds in struct platform_driver.
Probably something similar could be done for struct pwm_ops too?

[1] https://patchwork.kernel.org/patch/2612961/

Signature · 2 lines
With warm regards,
Sachin
#2 lore raw
Quoted 9 lines · Sachin Kamat

Hi Thierry,

Quoted 2 lines · Thierry Reding

Some drivers don't set the .owner fields of the struct device_driver or struct pwm_ops, which causes the module usage count to become wrong.

Recently a patch [1] was added to solve this issue of missing .owner fileds in struct platform_driver.

Yes I saw that, but thought it might be good to initialize them anyway. Especially since a couple of the drivers are I2C and I believe there's no similar patch for those. It shouldn't be difficult to come up with the corresponding patch, though.

I wonder if it'd make sense to remove all the explicit assignments of .owner = THIS_MODULE in platform drivers once the patch you mentioned has been merged. Cc'ing Greg to find out what he thinks about it.

Quoted 1 line

Probably something similar could be done for struct pwm_ops too?

Possibly. The issue isn't quite as bad in the PWM subsystem since I'm now aware of the problem and will look for it specifically in the future. It's a different matter for struct device_driver since that's used all over the place.

Thierry

Quoted 5 lines

[1] https://patchwork.kernel.org/patch/2612961/

Signature · 2 lines
With warm regards,
Sachin
#3 lore raw
Quoted 11 lines · Thierry Reding
Quoted 9 lines · Sachin Kamat

Hi Thierry,

Quoted 2 lines · Thierry Reding

Some drivers don't set the .owner fields of the struct device_driver or struct pwm_ops, which causes the module usage count to become wrong.

Recently a patch [1] was added to solve this issue of missing .owner fileds in struct platform_driver.

Quoted 8 lines

Yes I saw that, but thought it might be good to initialize them anyway. Especially since a couple of the drivers are I2C and I believe there's no similar patch for those. It shouldn't be difficult to come up with the corresponding patch, though.

I wonder if it'd make sense to remove all the explicit assignments of .owner = THIS_MODULE in platform drivers once the patch you mentioned has been merged. Cc'ing Greg to find out what he thinks about it.

Sure, they can be removed, but it's not really a big deal if they aren't.

greg k-h

#4 lore raw
In reply to Thierry Reding
Quoted 8 lines · Thierry Reding
Quoted 7 lines · Sachin Kamat

Hi Thierry,

Quoted 2 lines · Thierry Reding

Some drivers don't set the .owner fields of the struct device_driver or struct pwm_ops, which causes the module usage count to become wrong.

Quoted 7 lines
Quoted 2 lines

Recently a patch [1] was added to solve this issue of missing .owner fileds in struct platform_driver.

Yes I saw that, but thought it might be good to initialize them anyway. Especially since a couple of the drivers are I2C and I believe there's no similar patch for those. It shouldn't be difficult to come up with the corresponding patch, though.

I2C had the same actually for quite some time now.

#5 lore raw
Quoted 12 lines · Lars-Peter Clausen
Quoted 11 lines · Thierry Reding
Quoted 9 lines · Sachin Kamat

Hi Thierry,

Quoted 2 lines · Thierry Reding

Some drivers don't set the .owner fields of the struct device_driver or struct pwm_ops, which causes the module usage count to become wrong.

Recently a patch [1] was added to solve this issue of missing .owner fileds in struct platform_driver.

Quoted 6 lines
Quoted 4 lines

Yes I saw that, but thought it might be good to initialize them anyway. Especially since a couple of the drivers are I2C and I believe there's no similar patch for those. It shouldn't be difficult to come up with the corresponding patch, though.

I2C had the same actually for quite some time now.

I wasn't aware of that. Thanks for educating me. =)

Thierry