Linux-i2c Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional()
@ 2021-04-13 14:37 Andy Shevchenko
  2021-04-13 14:37 ` [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Andy Shevchenko @ 2021-04-13 14:37 UTC (permalink / raw)
  To: linux-i2c, linux-kernel; +Cc: Chris Packham, wsa, Andy Shevchenko

The peripheral clock is optional and we may get an -EPROBE_DEFER error code
which would not be propagated correctly, fix this by using
devm_clk_get_optional().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-mpc.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 3c8bcdfff7e7..6dc029a31d36 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -690,17 +690,18 @@ static int fsl_i2c_probe(struct platform_device *op)
 	 * enable clock for the I2C peripheral (non fatal),
 	 * keep a reference upon successful allocation
 	 */
-	clk = devm_clk_get(&op->dev, NULL);
-	if (!IS_ERR(clk)) {
-		err = clk_prepare_enable(clk);
-		if (err) {
-			dev_err(&op->dev, "failed to enable clock\n");
-			return err;
-		} else {
-			i2c->clk_per = clk;
-		}
+	clk = devm_clk_get_optional(&op->dev, NULL);
+	if (IS_ERR(clk))
+		return PTR_ERR(clk);
+
+	err = clk_prepare_enable(clk);
+	if (err) {
+		dev_err(&op->dev, "failed to enable clock\n");
+		return err;
 	}
 
+	i2c->clk_per = clk;
+
 	if (of_property_read_bool(op->dev.of_node, "fsl,preserve-clocking")) {
 		clock = MPC_I2C_CLOCK_PRESERVE;
 	} else {
@@ -744,8 +745,7 @@ static int fsl_i2c_probe(struct platform_device *op)
 	return 0;
 
  fail_add:
-	if (i2c->clk_per)
-		clk_disable_unprepare(i2c->clk_per);
+	clk_disable_unprepare(i2c->clk_per);
 
 	return result;
 };
@@ -756,8 +756,7 @@ static int fsl_i2c_remove(struct platform_device *op)
 
 	i2c_del_adapter(&i2c->adap);
 
-	if (i2c->clk_per)
-		clk_disable_unprepare(i2c->clk_per);
+	clk_disable_unprepare(i2c->clk_per);
 
 	return 0;
 };
-- 
2.30.2


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

* [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery
  2021-04-13 14:37 [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional() Andy Shevchenko
@ 2021-04-13 14:37 ` Andy Shevchenko
  2021-04-13 18:05   ` kernel test robot
  2021-04-13 23:43   ` Chris Packham
  2021-04-13 14:37 ` [PATCH v1 3/4] i2c: mpc: Use device_get_match_data() helper Andy Shevchenko
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Andy Shevchenko @ 2021-04-13 14:37 UTC (permalink / raw)
  To: linux-i2c, linux-kernel; +Cc: Chris Packham, wsa, Andy Shevchenko

Use __maybe_unused for the suspend()/resume() hooks and get rid of
the CONFIG_PM_SLEEP ifdeffery to improve the code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-mpc.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 6dc029a31d36..2376accd4e8e 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -66,9 +66,7 @@ struct mpc_i2c {
 	struct i2c_adapter adap;
 	int irq;
 	u32 real_clk;
-#ifdef CONFIG_PM_SLEEP
 	u8 fdr, dfsrr;
-#endif
 	struct clk *clk_per;
 };
 
@@ -761,8 +759,7 @@ static int fsl_i2c_remove(struct platform_device *op)
 	return 0;
 };
 
-#ifdef CONFIG_PM_SLEEP
-static int mpc_i2c_suspend(struct device *dev)
+static int __maybe_unused mpc_i2c_suspend(struct device *dev)
 {
 	struct mpc_i2c *i2c = dev_get_drvdata(dev);
 
@@ -772,7 +769,7 @@ static int mpc_i2c_suspend(struct device *dev)
 	return 0;
 }
 
-static int mpc_i2c_resume(struct device *dev)
+static int __maybe_unused mpc_i2c_resume(struct device *dev)
 {
 	struct mpc_i2c *i2c = dev_get_drvdata(dev);
 
@@ -781,12 +778,7 @@ static int mpc_i2c_resume(struct device *dev)
 
 	return 0;
 }
-
 static SIMPLE_DEV_PM_OPS(mpc_i2c_pm_ops, mpc_i2c_suspend, mpc_i2c_resume);
-#define MPC_I2C_PM_OPS	(&mpc_i2c_pm_ops)
-#else
-#define MPC_I2C_PM_OPS	NULL
-#endif
 
 static const struct mpc_i2c_data mpc_i2c_data_512x = {
 	.setup = mpc_i2c_setup_512x,
-- 
2.30.2


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

* [PATCH v1 3/4] i2c: mpc: Use device_get_match_data() helper
  2021-04-13 14:37 [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional() Andy Shevchenko
  2021-04-13 14:37 ` [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery Andy Shevchenko
@ 2021-04-13 14:37 ` Andy Shevchenko
  2021-04-13 23:45   ` Chris Packham
  2021-04-13 14:37 ` [PATCH v1 4/4] i2c: mpc: Drop duplicate message from devm_platform_ioremap_resource() Andy Shevchenko
  2021-04-13 23:34 ` [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional() Chris Packham
  3 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2021-04-13 14:37 UTC (permalink / raw)
  To: linux-i2c, linux-kernel; +Cc: Chris Packham, wsa, Andy Shevchenko

Use the device_get_match_data() helper instead of open coding.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-mpc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 2376accd4e8e..ec9d7d93e80f 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -19,6 +19,7 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 #include <linux/clk.h>
@@ -643,10 +644,9 @@ static struct i2c_bus_recovery_info fsl_i2c_recovery_info = {
 	.recover_bus = fsl_i2c_bus_recovery,
 };
 
-static const struct of_device_id mpc_i2c_of_match[];
 static int fsl_i2c_probe(struct platform_device *op)
 {
-	const struct of_device_id *match;
+	const struct mpc_i2c_data *data;
 	struct mpc_i2c *i2c;
 	const u32 *prop;
 	u32 clock = MPC_I2C_CLOCK_LEGACY;
@@ -655,10 +655,6 @@ static int fsl_i2c_probe(struct platform_device *op)
 	struct clk *clk;
 	int err;
 
-	match = of_match_device(mpc_i2c_of_match, &op->dev);
-	if (!match)
-		return -EINVAL;
-
 	i2c = devm_kzalloc(&op->dev, sizeof(*i2c), GFP_KERNEL);
 	if (!i2c)
 		return -ENOMEM;
@@ -709,8 +705,8 @@ static int fsl_i2c_probe(struct platform_device *op)
 			clock = *prop;
 	}
 
-	if (match->data) {
-		const struct mpc_i2c_data *data = match->data;
+	data = device_get_match_data(&op->dev);
+	if (data) {
 		data->setup(op->dev.of_node, i2c, clock);
 	} else {
 		/* Backwards compatibility */
-- 
2.30.2


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

* [PATCH v1 4/4] i2c: mpc: Drop duplicate message from devm_platform_ioremap_resource()
  2021-04-13 14:37 [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional() Andy Shevchenko
  2021-04-13 14:37 ` [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery Andy Shevchenko
  2021-04-13 14:37 ` [PATCH v1 3/4] i2c: mpc: Use device_get_match_data() helper Andy Shevchenko
@ 2021-04-13 14:37 ` Andy Shevchenko
  2021-04-13 23:45   ` Chris Packham
  2021-04-13 23:34 ` [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional() Chris Packham
  3 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2021-04-13 14:37 UTC (permalink / raw)
  To: linux-i2c, linux-kernel; +Cc: Chris Packham, wsa, Andy Shevchenko

devm_platform_ioremap_resource() prints a message in case of error.
Drop custom one.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/i2c/busses/i2c-mpc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index ec9d7d93e80f..684a8cd17efd 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -664,10 +664,8 @@ static int fsl_i2c_probe(struct platform_device *op)
 	init_waitqueue_head(&i2c->queue);
 
 	i2c->base = devm_platform_ioremap_resource(op, 0);
-	if (IS_ERR(i2c->base)) {
-		dev_err(i2c->dev, "failed to map controller\n");
+	if (IS_ERR(i2c->base))
 		return PTR_ERR(i2c->base);
-	}
 
 	i2c->irq = platform_get_irq(op, 0);
 	if (i2c->irq < 0)
-- 
2.30.2


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

* Re: [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery
  2021-04-13 14:37 ` [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery Andy Shevchenko
@ 2021-04-13 18:05   ` kernel test robot
  2021-04-13 23:43   ` Chris Packham
  1 sibling, 0 replies; 11+ messages in thread
From: kernel test robot @ 2021-04-13 18:05 UTC (permalink / raw)
  To: Andy Shevchenko, linux-i2c, linux-kernel
  Cc: kbuild-all, clang-built-linux, Chris Packham, wsa, Andy Shevchenko


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

Hi Andy,

I love your patch! Yet something to improve:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on next-20210413]
[cannot apply to linux/master linus/master v5.12-rc7]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Andy-Shevchenko/i2c-mpc-Use-devm_clk_get_optional/20210413-223941
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: powerpc64-randconfig-r015-20210413 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 9829f5e6b1bca9b61efc629770d28bb9014dec45)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc64 cross compiling tool for clang build
        # apt-get install binutils-powerpc64-linux-gnu
        # https://github.com/0day-ci/linux/commit/31fed803b49f17742a0bfa9fb3940b5bc487e4dd
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Andy-Shevchenko/i2c-mpc-Use-devm_clk_get_optional/20210413-223941
        git checkout 31fed803b49f17742a0bfa9fb3940b5bc487e4dd
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/i2c/busses/i2c-mpc.c:824:9: error: use of undeclared identifier 'MPC_I2C_PM_OPS'
                   .pm = MPC_I2C_PM_OPS,
                         ^
   1 error generated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for SND_SOC_MPC5200_AC97
   Depends on SOUND && !UML && SND && SND_SOC && SND_POWERPC_SOC && PPC_MPC52xx && PPC_BESTCOMM
   Selected by
   - SND_MPC52xx_SOC_EFIKA && SOUND && !UML && SND && SND_SOC && SND_POWERPC_SOC && PPC_EFIKA


vim +/MPC_I2C_PM_OPS +824 drivers/i2c/busses/i2c-mpc.c

0d1cde235874b0 Jon Smirl      2008-06-30  816  
8c86cb127b2b76 Kumar Gala     2005-07-27  817  /* Structure for a device driver */
1c48a5c93da631 Grant Likely   2011-02-17  818  static struct platform_driver mpc_i2c_driver = {
8c86cb127b2b76 Kumar Gala     2005-07-27  819  	.probe		= fsl_i2c_probe,
0b255e927d47b5 Bill Pemberton 2012-11-27  820  	.remove		= fsl_i2c_remove,
3ae5eaec1d2d9c Russell King   2005-11-09  821  	.driver = {
0d1cde235874b0 Jon Smirl      2008-06-30  822  		.name = DRV_NAME,
4018294b53d1da Grant Likely   2010-04-13  823  		.of_match_table = mpc_i2c_of_match,
0a488c49eac0ad Jingoo Han     2013-07-15 @824  		.pm = MPC_I2C_PM_OPS,
3ae5eaec1d2d9c Russell King   2005-11-09  825  	},
8c86cb127b2b76 Kumar Gala     2005-07-27  826  };
8c86cb127b2b76 Kumar Gala     2005-07-27  827  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 30083 bytes --]

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

* Re: [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional()
  2021-04-13 14:37 [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional() Andy Shevchenko
                   ` (2 preceding siblings ...)
  2021-04-13 14:37 ` [PATCH v1 4/4] i2c: mpc: Drop duplicate message from devm_platform_ioremap_resource() Andy Shevchenko
@ 2021-04-13 23:34 ` Chris Packham
  3 siblings, 0 replies; 11+ messages in thread
From: Chris Packham @ 2021-04-13 23:34 UTC (permalink / raw)
  To: Andy Shevchenko, linux-i2c, linux-kernel; +Cc: wsa


On 14/04/21 2:37 am, Andy Shevchenko wrote:
> The peripheral clock is optional and we may get an -EPROBE_DEFER error code
> which would not be propagated correctly, fix this by using
> devm_clk_get_optional().
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>

None of the systems I have access to make use of the clocks property so 
I can't do much testing. I can say it still handles the absence of a 
clocks property correctly.

> ---
>   drivers/i2c/busses/i2c-mpc.c | 25 ++++++++++++-------------
>   1 file changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 3c8bcdfff7e7..6dc029a31d36 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -690,17 +690,18 @@ static int fsl_i2c_probe(struct platform_device *op)
>   	 * enable clock for the I2C peripheral (non fatal),
>   	 * keep a reference upon successful allocation
>   	 */
> -	clk = devm_clk_get(&op->dev, NULL);
> -	if (!IS_ERR(clk)) {
> -		err = clk_prepare_enable(clk);
> -		if (err) {
> -			dev_err(&op->dev, "failed to enable clock\n");
> -			return err;
> -		} else {
> -			i2c->clk_per = clk;
> -		}
> +	clk = devm_clk_get_optional(&op->dev, NULL);
> +	if (IS_ERR(clk))
> +		return PTR_ERR(clk);
> +
> +	err = clk_prepare_enable(clk);
> +	if (err) {
> +		dev_err(&op->dev, "failed to enable clock\n");
> +		return err;
>   	}
>   
> +	i2c->clk_per = clk;
> +
>   	if (of_property_read_bool(op->dev.of_node, "fsl,preserve-clocking")) {
>   		clock = MPC_I2C_CLOCK_PRESERVE;
>   	} else {
> @@ -744,8 +745,7 @@ static int fsl_i2c_probe(struct platform_device *op)
>   	return 0;
>   
>    fail_add:
> -	if (i2c->clk_per)
> -		clk_disable_unprepare(i2c->clk_per);
> +	clk_disable_unprepare(i2c->clk_per);
>   
>   	return result;
>   };
> @@ -756,8 +756,7 @@ static int fsl_i2c_remove(struct platform_device *op)
>   
>   	i2c_del_adapter(&i2c->adap);
>   
> -	if (i2c->clk_per)
> -		clk_disable_unprepare(i2c->clk_per);
> +	clk_disable_unprepare(i2c->clk_per);
>   
>   	return 0;
>   };

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

* Re: [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery
  2021-04-13 14:37 ` [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery Andy Shevchenko
  2021-04-13 18:05   ` kernel test robot
@ 2021-04-13 23:43   ` Chris Packham
  2021-04-14 12:14     ` Andy Shevchenko
  1 sibling, 1 reply; 11+ messages in thread
From: Chris Packham @ 2021-04-13 23:43 UTC (permalink / raw)
  To: Andy Shevchenko, linux-i2c, linux-kernel; +Cc: wsa


On 14/04/21 2:37 am, Andy Shevchenko wrote:
> Use __maybe_unused for the suspend()/resume() hooks and get rid of
> the CONFIG_PM_SLEEP ifdeffery to improve the code.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/i2c/busses/i2c-mpc.c | 12 ++----------
>   1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 6dc029a31d36..2376accd4e8e 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -66,9 +66,7 @@ struct mpc_i2c {
>   	struct i2c_adapter adap;
>   	int irq;
>   	u32 real_clk;
> -#ifdef CONFIG_PM_SLEEP
>   	u8 fdr, dfsrr;
> -#endif
>   	struct clk *clk_per;
>   };
This has a trivial conflict with my series because I'm also touching 
struct mpc_i2c. git am -3 seems to deal with it but would it be easier 
if I picked up these 4 changes and included them with my next submission?
> @@ -761,8 +759,7 @@ static int fsl_i2c_remove(struct platform_device *op)
>   	return 0;
>   };
>   
> -#ifdef CONFIG_PM_SLEEP
> -static int mpc_i2c_suspend(struct device *dev)
> +static int __maybe_unused mpc_i2c_suspend(struct device *dev)
>   {
>   	struct mpc_i2c *i2c = dev_get_drvdata(dev);
>   
> @@ -772,7 +769,7 @@ static int mpc_i2c_suspend(struct device *dev)
>   	return 0;
>   }
>   
> -static int mpc_i2c_resume(struct device *dev)
> +static int __maybe_unused mpc_i2c_resume(struct device *dev)
>   {
>   	struct mpc_i2c *i2c = dev_get_drvdata(dev);
>   
> @@ -781,12 +778,7 @@ static int mpc_i2c_resume(struct device *dev)
>   
>   	return 0;
>   }
> -
>   static SIMPLE_DEV_PM_OPS(mpc_i2c_pm_ops, mpc_i2c_suspend, mpc_i2c_resume);
> -#define MPC_I2C_PM_OPS	(&mpc_i2c_pm_ops)
> -#else
> -#define MPC_I2C_PM_OPS	NULL
> -#endif
>   
>   static const struct mpc_i2c_data mpc_i2c_data_512x = {
>   	.setup = mpc_i2c_setup_512x,

There's a reference to MPC_I2C_PM_OPS in mpc_i2c_driver which needs 
changing I think the following is needed

diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 1308f749dc75..7fde13472c09 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -862,7 +862,7 @@ static struct platform_driver mpc_i2c_driver = {
         .driver = {
                 .name = DRV_NAME,
                 .of_match_table = mpc_i2c_of_match,
-               .pm = MPC_I2C_PM_OPS,
+               .pm = &mpc_i2c_pm_ops,
         },
  };



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

* Re: [PATCH v1 3/4] i2c: mpc: Use device_get_match_data() helper
  2021-04-13 14:37 ` [PATCH v1 3/4] i2c: mpc: Use device_get_match_data() helper Andy Shevchenko
@ 2021-04-13 23:45   ` Chris Packham
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Packham @ 2021-04-13 23:45 UTC (permalink / raw)
  To: Andy Shevchenko, linux-i2c, linux-kernel; +Cc: wsa


On 14/04/21 2:37 am, Andy Shevchenko wrote:
> Use the device_get_match_data() helper instead of open coding.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
>   drivers/i2c/busses/i2c-mpc.c | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 2376accd4e8e..ec9d7d93e80f 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -19,6 +19,7 @@
>   #include <linux/of_address.h>
>   #include <linux/of_irq.h>
>   #include <linux/of_platform.h>
> +#include <linux/property.h>
>   #include <linux/slab.h>
>   
>   #include <linux/clk.h>
> @@ -643,10 +644,9 @@ static struct i2c_bus_recovery_info fsl_i2c_recovery_info = {
>   	.recover_bus = fsl_i2c_bus_recovery,
>   };
>   
> -static const struct of_device_id mpc_i2c_of_match[];
>   static int fsl_i2c_probe(struct platform_device *op)
>   {
> -	const struct of_device_id *match;
> +	const struct mpc_i2c_data *data;
>   	struct mpc_i2c *i2c;
>   	const u32 *prop;
>   	u32 clock = MPC_I2C_CLOCK_LEGACY;
> @@ -655,10 +655,6 @@ static int fsl_i2c_probe(struct platform_device *op)
>   	struct clk *clk;
>   	int err;
>   
> -	match = of_match_device(mpc_i2c_of_match, &op->dev);
> -	if (!match)
> -		return -EINVAL;
> -
>   	i2c = devm_kzalloc(&op->dev, sizeof(*i2c), GFP_KERNEL);
>   	if (!i2c)
>   		return -ENOMEM;
> @@ -709,8 +705,8 @@ static int fsl_i2c_probe(struct platform_device *op)
>   			clock = *prop;
>   	}
>   
> -	if (match->data) {
> -		const struct mpc_i2c_data *data = match->data;
> +	data = device_get_match_data(&op->dev);
> +	if (data) {
>   		data->setup(op->dev.of_node, i2c, clock);
>   	} else {
>   		/* Backwards compatibility */

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

* Re: [PATCH v1 4/4] i2c: mpc: Drop duplicate message from devm_platform_ioremap_resource()
  2021-04-13 14:37 ` [PATCH v1 4/4] i2c: mpc: Drop duplicate message from devm_platform_ioremap_resource() Andy Shevchenko
@ 2021-04-13 23:45   ` Chris Packham
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Packham @ 2021-04-13 23:45 UTC (permalink / raw)
  To: Andy Shevchenko, linux-i2c, linux-kernel; +Cc: wsa


On 14/04/21 2:37 am, Andy Shevchenko wrote:
> devm_platform_ioremap_resource() prints a message in case of error.
> Drop custom one.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
>   drivers/i2c/busses/i2c-mpc.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index ec9d7d93e80f..684a8cd17efd 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -664,10 +664,8 @@ static int fsl_i2c_probe(struct platform_device *op)
>   	init_waitqueue_head(&i2c->queue);
>   
>   	i2c->base = devm_platform_ioremap_resource(op, 0);
> -	if (IS_ERR(i2c->base)) {
> -		dev_err(i2c->dev, "failed to map controller\n");
> +	if (IS_ERR(i2c->base))
>   		return PTR_ERR(i2c->base);
> -	}
>   
>   	i2c->irq = platform_get_irq(op, 0);
>   	if (i2c->irq < 0)

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

* Re: [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery
  2021-04-13 23:43   ` Chris Packham
@ 2021-04-14 12:14     ` Andy Shevchenko
  2021-04-14 21:17       ` Chris Packham
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2021-04-14 12:14 UTC (permalink / raw)
  To: Chris Packham; +Cc: linux-i2c, linux-kernel, wsa

On Tue, Apr 13, 2021 at 11:43:25PM +0000, Chris Packham wrote:
> On 14/04/21 2:37 am, Andy Shevchenko wrote:
> > Use __maybe_unused for the suspend()/resume() hooks and get rid of
> > the CONFIG_PM_SLEEP ifdeffery to improve the code.

> This has a trivial conflict with my series because I'm also touching 
> struct mpc_i2c. git am -3 seems to deal with it but would it be easier 
> if I picked up these 4 changes and included them with my next submission?

It would be ideal to me!

> > -#define MPC_I2C_PM_OPS	(&mpc_i2c_pm_ops)
> > -#else
> > -#define MPC_I2C_PM_OPS	NULL
> > -#endif
> >   
> >   static const struct mpc_i2c_data mpc_i2c_data_512x = {
> >   	.setup = mpc_i2c_setup_512x,
> 
> There's a reference to MPC_I2C_PM_OPS in mpc_i2c_driver which needs 
> changing I think the following is needed

True. sorry that my build test had been broken.
Tell me if you want v2 with this fixed or you may fold that change since the
above agreement.

> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 1308f749dc75..7fde13472c09 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -862,7 +862,7 @@ static struct platform_driver mpc_i2c_driver = {
>          .driver = {
>                  .name = DRV_NAME,
>                  .of_match_table = mpc_i2c_of_match,
> -               .pm = MPC_I2C_PM_OPS,
> +               .pm = &mpc_i2c_pm_ops,
>          },
>   };
> 
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery
  2021-04-14 12:14     ` Andy Shevchenko
@ 2021-04-14 21:17       ` Chris Packham
  0 siblings, 0 replies; 11+ messages in thread
From: Chris Packham @ 2021-04-14 21:17 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-i2c, linux-kernel, wsa


On 15/04/21 12:14 am, Andy Shevchenko wrote:
> On Tue, Apr 13, 2021 at 11:43:25PM +0000, Chris Packham wrote:
>> On 14/04/21 2:37 am, Andy Shevchenko wrote:
>>> Use __maybe_unused for the suspend()/resume() hooks and get rid of
>>> the CONFIG_PM_SLEEP ifdeffery to improve the code.
>> This has a trivial conflict with my series because I'm also touching
>> struct mpc_i2c. git am -3 seems to deal with it but would it be easier
>> if I picked up these 4 changes and included them with my next submission?
> It would be ideal to me!
OK I've picked them up.
>>> -#define MPC_I2C_PM_OPS	(&mpc_i2c_pm_ops)
>>> -#else
>>> -#define MPC_I2C_PM_OPS	NULL
>>> -#endif
>>>    
>>>    static const struct mpc_i2c_data mpc_i2c_data_512x = {
>>>    	.setup = mpc_i2c_setup_512x,
>> There's a reference to MPC_I2C_PM_OPS in mpc_i2c_driver which needs
>> changing I think the following is needed
> True. sorry that my build test had been broken.
> Tell me if you want v2 with this fixed or you may fold that change since the
> above agreement.
>
I can fold the fix below in. No need for a v2 from you.
>> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
>> index 1308f749dc75..7fde13472c09 100644
>> --- a/drivers/i2c/busses/i2c-mpc.c
>> +++ b/drivers/i2c/busses/i2c-mpc.c
>> @@ -862,7 +862,7 @@ static struct platform_driver mpc_i2c_driver = {
>>           .driver = {
>>                   .name = DRV_NAME,
>>                   .of_match_table = mpc_i2c_of_match,
>> -               .pm = MPC_I2C_PM_OPS,
>> +               .pm = &mpc_i2c_pm_ops,
>>           },
>>    };
>>
>>

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

end of thread, back to index

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13 14:37 [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional() Andy Shevchenko
2021-04-13 14:37 ` [PATCH v1 2/4] i2c: mpc: Remove CONFIG_PM_SLEEP ifdeffery Andy Shevchenko
2021-04-13 18:05   ` kernel test robot
2021-04-13 23:43   ` Chris Packham
2021-04-14 12:14     ` Andy Shevchenko
2021-04-14 21:17       ` Chris Packham
2021-04-13 14:37 ` [PATCH v1 3/4] i2c: mpc: Use device_get_match_data() helper Andy Shevchenko
2021-04-13 23:45   ` Chris Packham
2021-04-13 14:37 ` [PATCH v1 4/4] i2c: mpc: Drop duplicate message from devm_platform_ioremap_resource() Andy Shevchenko
2021-04-13 23:45   ` Chris Packham
2021-04-13 23:34 ` [PATCH v1 1/4] i2c: mpc: Use devm_clk_get_optional() Chris Packham

Linux-i2c Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-i2c/0 linux-i2c/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-i2c linux-i2c/ https://lore.kernel.org/linux-i2c \
		linux-i2c@vger.kernel.org
	public-inbox-index linux-i2c

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-i2c


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git