linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module
@ 2019-07-25  7:56 Baolin Wang
  2019-07-25  7:56 ` [PATCH 2/3] i2c: sprd: Change to use devm_platform_ioremap_resource() Baolin Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Baolin Wang @ 2019-07-25  7:56 UTC (permalink / raw)
  To: wsa+renesas, orsonzhai, zhang.lyra
  Cc: baolin.wang, vincent.guittot, linux-i2c, linux-kernel

Now there is no need to keep our I2C driver to be initialized so early,
thus changing to module level and let it can be built as a module,
meanwhile adding some module information.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/i2c/busses/Kconfig    |    2 +-
 drivers/i2c/busses/i2c-sprd.c |   10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 09367fc..69f1931 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -977,7 +977,7 @@ config I2C_SIRF
 	  will be called i2c-sirf.
 
 config I2C_SPRD
-	bool "Spreadtrum I2C interface"
+	tristate "Spreadtrum I2C interface"
 	depends on I2C=y && ARCH_SPRD
 	help
 	  If you say yes to this option, support will be included for the
diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index 9611235..8002835 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
@@ -644,8 +645,7 @@ static int __maybe_unused sprd_i2c_runtime_resume(struct device *dev)
 	},
 };
 
-static int sprd_i2c_init(void)
-{
-	return platform_driver_register(&sprd_i2c_driver);
-}
-arch_initcall_sync(sprd_i2c_init);
+module_platform_driver(sprd_i2c_driver);
+
+MODULE_DESCRIPTION("Spreadtrum I2C master controller driver");
+MODULE_LICENSE("GPL v2");
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] i2c: sprd: Change to use devm_platform_ioremap_resource()
  2019-07-25  7:56 [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module Baolin Wang
@ 2019-07-25  7:56 ` Baolin Wang
  2019-08-06 20:41   ` Wolfram Sang
  2019-07-25  7:56 ` [PATCH 3/3] i2c: sprd: Validate the return value of clock initialization Baolin Wang
  2019-08-06 20:41 ` [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module Wolfram Sang
  2 siblings, 1 reply; 6+ messages in thread
From: Baolin Wang @ 2019-07-25  7:56 UTC (permalink / raw)
  To: wsa+renesas, orsonzhai, zhang.lyra
  Cc: baolin.wang, vincent.guittot, linux-i2c, linux-kernel

Use the new helper that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/i2c/busses/i2c-sprd.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index 8002835..bbcb056 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -478,7 +478,6 @@ static int sprd_i2c_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct sprd_i2c *i2c_dev;
-	struct resource *res;
 	u32 prop;
 	int ret;
 
@@ -488,8 +487,7 @@ static int sprd_i2c_probe(struct platform_device *pdev)
 	if (!i2c_dev)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	i2c_dev->base = devm_ioremap_resource(dev, res);
+	i2c_dev->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(i2c_dev->base))
 		return PTR_ERR(i2c_dev->base);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] i2c: sprd: Validate the return value of clock initialization
  2019-07-25  7:56 [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module Baolin Wang
  2019-07-25  7:56 ` [PATCH 2/3] i2c: sprd: Change to use devm_platform_ioremap_resource() Baolin Wang
@ 2019-07-25  7:56 ` Baolin Wang
  2019-08-06 20:41   ` Wolfram Sang
  2019-08-06 20:41 ` [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module Wolfram Sang
  2 siblings, 1 reply; 6+ messages in thread
From: Baolin Wang @ 2019-07-25  7:56 UTC (permalink / raw)
  To: wsa+renesas, orsonzhai, zhang.lyra
  Cc: baolin.wang, vincent.guittot, linux-i2c, linux-kernel

The 'enable' clock of I2C master is required, we should return an error
if failed to get the 'enable' clock, to make sure the I2C driver can be
defer probe if the clock resource is not ready.

Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
 drivers/i2c/busses/i2c-sprd.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sprd.c b/drivers/i2c/busses/i2c-sprd.c
index bbcb056..b432e75 100644
--- a/drivers/i2c/busses/i2c-sprd.c
+++ b/drivers/i2c/busses/i2c-sprd.c
@@ -466,9 +466,9 @@ static int sprd_i2c_clk_init(struct sprd_i2c *i2c_dev)
 
 	i2c_dev->clk = devm_clk_get(i2c_dev->dev, "enable");
 	if (IS_ERR(i2c_dev->clk)) {
-		dev_warn(i2c_dev->dev, "i2c%d can't get the enable clock\n",
-			 i2c_dev->adap.nr);
-		i2c_dev->clk = NULL;
+		dev_err(i2c_dev->dev, "i2c%d can't get the enable clock\n",
+			i2c_dev->adap.nr);
+		return PTR_ERR(i2c_dev->clk);
 	}
 
 	return 0;
@@ -519,7 +519,10 @@ static int sprd_i2c_probe(struct platform_device *pdev)
 	if (i2c_dev->bus_freq != 100000 && i2c_dev->bus_freq != 400000)
 		return -EINVAL;
 
-	sprd_i2c_clk_init(i2c_dev);
+	ret = sprd_i2c_clk_init(i2c_dev);
+	if (ret)
+		return ret;
+
 	platform_set_drvdata(pdev, i2c_dev);
 
 	ret = clk_prepare_enable(i2c_dev->clk);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module
  2019-07-25  7:56 [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module Baolin Wang
  2019-07-25  7:56 ` [PATCH 2/3] i2c: sprd: Change to use devm_platform_ioremap_resource() Baolin Wang
  2019-07-25  7:56 ` [PATCH 3/3] i2c: sprd: Validate the return value of clock initialization Baolin Wang
@ 2019-08-06 20:41 ` Wolfram Sang
  2 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2019-08-06 20:41 UTC (permalink / raw)
  To: Baolin Wang
  Cc: wsa+renesas, orsonzhai, zhang.lyra, vincent.guittot, linux-i2c,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]

On Thu, Jul 25, 2019 at 03:56:16PM +0800, Baolin Wang wrote:
> Now there is no need to keep our I2C driver to be initialized so early,
> thus changing to module level and let it can be built as a module,
> meanwhile adding some module information.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] i2c: sprd: Change to use devm_platform_ioremap_resource()
  2019-07-25  7:56 ` [PATCH 2/3] i2c: sprd: Change to use devm_platform_ioremap_resource() Baolin Wang
@ 2019-08-06 20:41   ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2019-08-06 20:41 UTC (permalink / raw)
  To: Baolin Wang
  Cc: wsa+renesas, orsonzhai, zhang.lyra, vincent.guittot, linux-i2c,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 266 bytes --]

On Thu, Jul 25, 2019 at 03:56:17PM +0800, Baolin Wang wrote:
> Use the new helper that wraps the calls to platform_get_resource()
> and devm_ioremap_resource() together.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] i2c: sprd: Validate the return value of clock initialization
  2019-07-25  7:56 ` [PATCH 3/3] i2c: sprd: Validate the return value of clock initialization Baolin Wang
@ 2019-08-06 20:41   ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2019-08-06 20:41 UTC (permalink / raw)
  To: Baolin Wang
  Cc: wsa+renesas, orsonzhai, zhang.lyra, vincent.guittot, linux-i2c,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 356 bytes --]

On Thu, Jul 25, 2019 at 03:56:18PM +0800, Baolin Wang wrote:
> The 'enable' clock of I2C master is required, we should return an error
> if failed to get the 'enable' clock, to make sure the I2C driver can be
> defer probe if the clock resource is not ready.
> 
> Signed-off-by: Baolin Wang <baolin.wang@linaro.org>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-06 20:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-25  7:56 [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module Baolin Wang
2019-07-25  7:56 ` [PATCH 2/3] i2c: sprd: Change to use devm_platform_ioremap_resource() Baolin Wang
2019-08-06 20:41   ` Wolfram Sang
2019-07-25  7:56 ` [PATCH 3/3] i2c: sprd: Validate the return value of clock initialization Baolin Wang
2019-08-06 20:41   ` Wolfram Sang
2019-08-06 20:41 ` [PATCH 1/3] i2c: sprd: Make I2C driver can be built as a module Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).