linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>, Biwen Li <biwen.li@nxp.com>
Cc: aisheng.dong@nxp.com, linux-arm-kernel@lists.infradead.org,
	wsa@the-dreams.de, shawnguo@kernel.org, xiaobo.xie@nxp.com,
	leoyang.li@nxp.com, xiaoning.wang@nxp.com, linux-imx@nxp.com,
	kernel@pengutronix.de, jiafei.pan@nxp.com,
	laurentiu.tudor@nxp.com, festevam@gmail.com,
	linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org
Subject: Re: [v6] i2c: imx: support slave mode for imx I2C driver
Date: Thu, 5 Dec 2019 12:43:46 +0100	[thread overview]
Message-ID: <9a1a00c1-e9fa-36a1-0e79-3492d9b98d9f@pengutronix.de> (raw)
In-Reply-To: <20191204100005.r56huywxa7h3c6zr@pengutronix.de>

Hi,

On 04.12.19 11:00, Sascha Hauer wrote:
> Hi,
> 
> The patch looks ok to me now, but I still do not like the #ifdeffery
> around CONFIG_I2C_SLAVE. With the patch I just sent (You are on Cc:)
> we could apply the following on your patch which makes it more readable
> and increases compile coverage.
> 
> Wolfram, Biwen, what do you think?


RCAR depends on slave:
config I2C_RCAR 

         tristate "Renesas R-Car I2C Controller" 

         depends on ARCH_RENESAS || COMPILE_TEST 

         select I2C_SLAVE
see:
drivers/i2c/busses/i2c-rcar.c

So, I would suggest to do the same in imx.

So far, I tested this patch on iMX6S. It works in one board (i2c-gpio + i2c-imx) and
two board (i2c-imx + i2c-imx) configuration.
Tested-by: Oleksij Rempel <o.rempel@pengutronix.de>


> 
> Sascha
> 
> ---------------------------8<------------------------------
> 
>  From 52f7c2bf59db61d4b27b59ca6404136e3ed77310 Mon Sep 17 00:00:00 2001
> From: Sascha Hauer <s.hauer@pengutronix.de>
> Date: Wed, 4 Dec 2019 10:56:34 +0100
> Subject: [PATCH] fixup! i2c: imx: support slave mode for imx I2C driver
> 
> ---
>   drivers/i2c/busses/i2c-imx.c | 21 ++++++++++-----------
>   1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 40ccfca600bf..c5d9ae8226cd 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -203,9 +203,7 @@ struct imx_i2c_struct {
>   	struct pinctrl_state *pinctrl_pins_gpio;
>   
>   	struct imx_i2c_dma	*dma;
> -#if IS_ENABLED(CONFIG_I2C_SLAVE)
>   	struct i2c_client	*slave;
> -#endif
>   };
>   
>   static const struct imx_i2c_hwdata imx1_i2c_hwdata = {
> @@ -913,12 +911,10 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
>   
>   	dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__);
>   
> -#if IS_ENABLED(CONFIG_I2C_SLAVE)
>   	if (i2c_imx->slave) {
>   		dev_err(&i2c_imx->adapter.dev, "Please not do operations of master mode in slave mode");
>   		return -EBUSY;
>   	}
> -#endif
>   
>   	result = pm_runtime_get_sync(i2c_imx->adapter.dev.parent);
>   	if (result < 0)
> @@ -1068,7 +1064,6 @@ static u32 i2c_imx_func(struct i2c_adapter *adapter)
>   		| I2C_FUNC_SMBUS_READ_BLOCK_DATA;
>   }
>   
> -#if IS_ENABLED(CONFIG_I2C_SLAVE)
>   static int i2c_imx_slave_init(struct imx_i2c_struct *i2c_imx)
>   {
>   	int temp;
> @@ -1159,6 +1154,10 @@ static int i2c_imx_reg_slave(struct i2c_client *client)
>   {
>   	struct imx_i2c_struct *i2c_imx = i2c_get_adapdata(client->adapter);
>   	int ret;
> +
> +	if (!IS_ENABLED(CONFIG_I2C_SLAVE))
> +		return -EINVAL;
> +
>   	if (i2c_imx->slave)
>   		return -EBUSY;
>   
> @@ -1173,6 +1172,9 @@ static int i2c_imx_unreg_slave(struct i2c_client *client)
>   {
>   	struct imx_i2c_struct *i2c_imx = i2c_get_adapdata(client->adapter);
>   
> +	if (!IS_ENABLED(CONFIG_I2C_SLAVE))
> +		return -EINVAL;
> +
>   	if (!i2c_imx->slave)
>   		return -EINVAL;
>   
> @@ -1188,15 +1190,12 @@ static int i2c_imx_unreg_slave(struct i2c_client *client)
>   
>   	return 0;
>   }
> -#endif
>   
>   static const struct i2c_algorithm i2c_imx_algo = {
>   	.master_xfer	= i2c_imx_xfer,
>   	.functionality	= i2c_imx_func,
> -#if IS_ENABLED(CONFIG_I2C_SLAVE)
>   	.reg_slave	= i2c_imx_reg_slave,
>   	.unreg_slave	= i2c_imx_unreg_slave,
> -#endif
>   };
>   
>   static irqreturn_t i2c_imx_isr(int irq, void *dev_id)
> @@ -1208,10 +1207,10 @@ static irqreturn_t i2c_imx_isr(int irq, void *dev_id)
>   
>   	if (status & I2SR_IIF) {
>   		i2c_imx_clr_if_bit(status, i2c_imx);
> -#if IS_ENABLED(CONFIG_I2C_SLAVE)
> -		if (i2c_imx->slave)
> +
> +		if (IS_ENABLED(CONFIG_I2C_SLAVE) && i2c_imx->slave)
>   			return i2c_imx_slave_isr(i2c_imx);
> -#endif
> +
>   		i2c_imx->i2csr = status;
>   		return i2c_imx_master_isr(i2c_imx);
>   	}
> 

Kind regards,
Oleksij Rempel

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-12-05 11:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-03 11:48 [v6] i2c: imx: support slave mode for imx I2C driver Biwen Li
2019-12-04 10:00 ` Sascha Hauer
2019-12-05 11:43   ` Oleksij Rempel [this message]
2019-12-06  7:38     ` Sascha Hauer
2020-03-04  4:13     ` [EXT] " Biwen Li
2020-03-04  5:22       ` Oleksij Rempel
2020-03-04  6:54         ` Biwen Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a1a00c1-e9fa-36a1-0e79-3492d9b98d9f@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=aisheng.dong@nxp.com \
    --cc=biwen.li@nxp.com \
    --cc=festevam@gmail.com \
    --cc=jiafei.pan@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=laurentiu.tudor@nxp.com \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=wsa@the-dreams.de \
    --cc=xiaobo.xie@nxp.com \
    --cc=xiaoning.wang@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).