Skip to contentSkip to conversation

i2c: versatile: Allow compile test build

PATCH RESEND Applied Axel Lin 4 participants 8 messages Jul 9, 2016 – Jul 14, 2016

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH RESEND 1/2 i2c: versatile: Allow compile test build

There is no build dependency for this driver, so enable COMPILE_TEST to get better build coverage.

---
Resend with CC VE maintainers.

 drivers/i2c/busses/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +1 -1
index faa8e68..6e0bba0 100644
@@ -924,7 +924,7 @@ config I2C_UNIPHIER_F
 
 config I2C_VERSATILE
 	tristate "ARM Versatile/Realview I2C bus support"
-	depends on ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS
+	depends on ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS || COMPILE_TEST
 	select I2C_ALGOBIT
 	help
 	  Say yes if you want to support the I2C serial bus on ARMs Versatile
Signature · 1 line
2.5.0
author
#1 lore raw

PATCH RESEND 2/2 i2c: versatile: Convert to use resource managed devm_* APIs

Use devm_* APIs to simplify the code a bit.
This patch also fixes the memory leak when unload the module.

---
Resend with CC VE maintainers.

 drivers/i2c/busses/i2c-versatile.c | 46 +++++++++++---------------------------
 1 file changed, 13 insertions(+), 33 deletions(-)
drivers/i2c/busses/i2c-versatile.c +13 -33
index 240637f..c73d2d2 100644
@@ -70,28 +70,14 @@ static int i2c_versatile_probe(struct platform_device *dev)
 	struct resource *r;
 	int ret;
 
+	i2c = devm_kzalloc(&dev->dev, sizeof(struct i2c_versatile), GFP_KERNEL);
+	if (!i2c)
+		return -ENOMEM;
+
 	r = platform_get_resource(dev, IORESOURCE_MEM, 0);
-	if (!r) {
-		ret = -EINVAL;
-		goto err_out;
-	}
-
-	if (!request_mem_region(r->start, resource_size(r), "versatile-i2c")) {
-		ret = -EBUSY;
-		goto err_out;
-	}
-
-	i2c = kzalloc(sizeof(struct i2c_versatile), GFP_KERNEL);
-	if (!i2c) {
-		ret = -ENOMEM;
-		goto err_release;
-	}
-
-	i2c->base = ioremap(r->start, resource_size(r));
-	if (!i2c->base) {
-		ret = -ENOMEM;
-		goto err_free;
-	}
+	i2c->base = devm_ioremap_resource(&dev->dev, r);
+	if (IS_ERR(i2c->base))
+		return PTR_ERR(i2c->base);
 
 	writel(SCL | SDA, i2c->base + I2C_CONTROLS);
 
@@ -105,18 +91,12 @@ static int i2c_versatile_probe(struct platform_device *dev)
 
 	i2c->adap.nr = dev->id;
 	ret = i2c_bit_add_numbered_bus(&i2c->adap);
-	if (ret >= 0) {
-		platform_set_drvdata(dev, i2c);
-		return 0;
-	}
-
-	iounmap(i2c->base);
- err_free:
-	kfree(i2c);
- err_release:
-	release_mem_region(r->start, resource_size(r));
- err_out:
-	return ret;
+	if (ret < 0)
+		return ret;
+
+	platform_set_drvdata(dev, i2c);
+
+	return 0;
 }
 
 static int i2c_versatile_remove(struct platform_device *dev)
Signature · 1 line
2.5.0
Applied
#2 lore raw

Re: [RESEND][PATCH 2/2] i2c: versatile: Convert to use resource managed devm_* APIs

Quoted 4 lines · Axel Lin

Use devm_* APIs to simplify the code a bit.
This patch also fixes the memory leak when unload the module.

Applied to for-next, thanks!

#3 lore raw
In reply to Axel Lin
Quoted 4 lines · Axel Lin

There is no build dependency for this driver, so enable COMPILE_TEST to get better build coverage.

For the whole series:

Thanks,
Liviu

Quoted 21 lines

---
Resend with CC VE maintainers.

 drivers/i2c/busses/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/Kconfig +1 -1
index faa8e68..6e0bba0 100644
@@ -924,7 +924,7 @@ config I2C_UNIPHIER_F
 
 config I2C_VERSATILE
 	tristate "ARM Versatile/Realview I2C bus support"
-	depends on ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS
+	depends on ARCH_VERSATILE || ARCH_REALVIEW || ARCH_VEXPRESS || COMPILE_TEST
 	select I2C_ALGOBIT
 	help
 	  Say yes if you want to support the I2C serial bus on ARMs Versatile
Signature · 1 line
2.5.0
Signature · 8 lines
====================
| I would like to |
| fix the world,  |
| but they're not |
| giving me the   |
 \ source code!  /
  ---------------
    ¯\_(ツ)_/¯
#4 lore raw
Quoted 9 lines · Liviu Dudau
Quoted 4 lines · Axel Lin

There is no build dependency for this driver, so enable COMPILE_TEST to get better build coverage.

For the whole series:

Thanks Liviu for testing them. Since these are cleanup patches, they need to wait for v4.9, PR for v4.8 already sent and pulled.

Signature · 2 lines
Regards,
Sudeep
#5 lore raw
Quoted 3 lines

Thanks Liviu for testing them. Since these are cleanup patches, they need to wait for v4.9, PR for v4.8 already sent and pulled.

I'd think they should go via my I2C tree anyhow.

#6 lore raw
Quoted 5 lines · Wolfram Sang
Quoted 2 lines

Thanks Liviu for testing them. Since these are cleanup patches, they need to wait for v4.9, PR for v4.8 already sent and pulled.

I'd think they should go via my I2C tree anyhow.

Sorry, I was wrong, I misread the path. Thanks for pulling.

Signature · 2 lines
Regards,
Sudeep