All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
To: jean-jacques hiblot <jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
	jean-jacques hiblot
	<jjhiblot-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH v3 REPOST 2/4] i2c: i2c-ibm-iic: perform the transfer in the interrupt handler
Date: Fri, 3 Jan 2014 16:04:16 +0100	[thread overview]
Message-ID: <20140103150416.GA7132@katana> (raw)
In-Reply-To: <1387552376-12986-3-git-send-email-jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>

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


Hi,

thanks for the submission!

> --- a/drivers/i2c/busses/i2c-ibm_iic.c
> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
> @@ -58,6 +58,8 @@ static bool iic_force_fast;
>  module_param(iic_force_fast, bool, 0);
>  MODULE_PARM_DESC(iic_force_fast, "Force fast mode (400 kHz)");
>  
> +#define FIFO_FLUSH_TIMEOUT 100

100 what? The unit is missing.

> @@ -167,8 +170,8 @@ static void iic_dev_init(struct ibm_iic_private* dev)
>  	/* Clear control register */
>  	out_8(&iic->cntl, 0);
>  
> -	/* Enable interrupts if possible */
> -	iic_interrupt_mode(dev, dev->irq >= 0);
> +	/* Start with each individual interrupt masked*/

Space at the end of comment missing

>  static irqreturn_t iic_handler(int irq, void *dev_id)
>  {
> -	struct ibm_iic_private* dev = (struct ibm_iic_private*)dev_id;
> -	struct iic_regs __iomem *iic = dev->vaddr;
> -
> -	DBG2(dev, "irq handler, STS = 0x%02x, EXTSTS = 0x%02x\n",
> -	     in_8(&iic->sts), in_8(&iic->extsts));
> -
> -	/* Acknowledge IRQ and wakeup iic_wait_for_tc */
> -	out_8(&iic->sts, STS_IRQA | STS_SCMP);
> -	wake_up_interruptible(&dev->wq);
> -
> +	struct ibm_iic_private *dev = (struct ibm_iic_private *) dev_id;
> +	iic_xfer_bytes(dev);

Is iic_xfer_bytes later used when polling, too? Otherwise it could be
simply inserted here.


> +	if ((status & STS_ERR) ||
> +	    (ext_status & (EXTSTS_LA | EXTSTS_ICT | EXTSTS_XFRA))) {
> +		DBG(dev, "status 0x%x\n", status);
> +		DBG(dev, "extended status 0x%x\n", ext_status);
> +		if (status & STS_ERR)
> +			ERR(dev, "Error detected\n");
> +		if (ext_status & EXTSTS_LA)
> +			DBG(dev, "Lost arbitration\n");
> +		if (ext_status & EXTSTS_ICT)
> +			ERR(dev, "Incomplete transfer\n");
> +		if (ext_status & EXTSTS_XFRA)
> +			ERR(dev, "Transfer aborted\n");
> +
> +		dev->status = -EIO;

You could consider returning different fault codes for the different
states. See Documentation/i2c/fault-codes for a guide.

> +	if (dev->msgs == NULL) {
> +		DBG(dev, "spurious !!!!!\n");
> +		dev->status = -EINVAL;
> +		return dev->status;
> +	}

Does that really happen?

And it introduces a build warning:

drivers/i2c/busses/i2c-ibm_iic.c:410:12: warning: 'iic_wait_for_tc' defined but not used [-Wunused-function]


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Wolfram Sang <wsa@the-dreams.de>
To: jean-jacques hiblot <jjhiblot@traphandler.com>
Cc: gregory.clement@free-electrons.com,
	linuxppc-dev@lists.ozlabs.org, linux-i2c@vger.kernel.org,
	jean-jacques hiblot <jjhiblot@gmail.com>
Subject: Re: [PATCH v3 REPOST 2/4] i2c: i2c-ibm-iic: perform the transfer in the interrupt handler
Date: Fri, 3 Jan 2014 16:04:16 +0100	[thread overview]
Message-ID: <20140103150416.GA7132@katana> (raw)
In-Reply-To: <1387552376-12986-3-git-send-email-jjhiblot@traphandler.com>

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


Hi,

thanks for the submission!

> --- a/drivers/i2c/busses/i2c-ibm_iic.c
> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
> @@ -58,6 +58,8 @@ static bool iic_force_fast;
>  module_param(iic_force_fast, bool, 0);
>  MODULE_PARM_DESC(iic_force_fast, "Force fast mode (400 kHz)");
>  
> +#define FIFO_FLUSH_TIMEOUT 100

100 what? The unit is missing.

> @@ -167,8 +170,8 @@ static void iic_dev_init(struct ibm_iic_private* dev)
>  	/* Clear control register */
>  	out_8(&iic->cntl, 0);
>  
> -	/* Enable interrupts if possible */
> -	iic_interrupt_mode(dev, dev->irq >= 0);
> +	/* Start with each individual interrupt masked*/

Space at the end of comment missing

>  static irqreturn_t iic_handler(int irq, void *dev_id)
>  {
> -	struct ibm_iic_private* dev = (struct ibm_iic_private*)dev_id;
> -	struct iic_regs __iomem *iic = dev->vaddr;
> -
> -	DBG2(dev, "irq handler, STS = 0x%02x, EXTSTS = 0x%02x\n",
> -	     in_8(&iic->sts), in_8(&iic->extsts));
> -
> -	/* Acknowledge IRQ and wakeup iic_wait_for_tc */
> -	out_8(&iic->sts, STS_IRQA | STS_SCMP);
> -	wake_up_interruptible(&dev->wq);
> -
> +	struct ibm_iic_private *dev = (struct ibm_iic_private *) dev_id;
> +	iic_xfer_bytes(dev);

Is iic_xfer_bytes later used when polling, too? Otherwise it could be
simply inserted here.


> +	if ((status & STS_ERR) ||
> +	    (ext_status & (EXTSTS_LA | EXTSTS_ICT | EXTSTS_XFRA))) {
> +		DBG(dev, "status 0x%x\n", status);
> +		DBG(dev, "extended status 0x%x\n", ext_status);
> +		if (status & STS_ERR)
> +			ERR(dev, "Error detected\n");
> +		if (ext_status & EXTSTS_LA)
> +			DBG(dev, "Lost arbitration\n");
> +		if (ext_status & EXTSTS_ICT)
> +			ERR(dev, "Incomplete transfer\n");
> +		if (ext_status & EXTSTS_XFRA)
> +			ERR(dev, "Transfer aborted\n");
> +
> +		dev->status = -EIO;

You could consider returning different fault codes for the different
states. See Documentation/i2c/fault-codes for a guide.

> +	if (dev->msgs == NULL) {
> +		DBG(dev, "spurious !!!!!\n");
> +		dev->status = -EINVAL;
> +		return dev->status;
> +	}

Does that really happen?

And it introduces a build warning:

drivers/i2c/busses/i2c-ibm_iic.c:410:12: warning: 'iic_wait_for_tc' defined but not used [-Wunused-function]


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  parent reply	other threads:[~2014-01-03 15:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 15:12 [PATCH v3 REPOST 0/4] i2c : i2c-ibm-iic : use interrupts to perform the data transfer jean-jacques hiblot
2013-12-20 15:12 ` jean-jacques hiblot
     [not found] ` <1387552376-12986-1-git-send-email-jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>
2013-12-20 15:12   ` [PATCH v3 REPOST 1/4] i2c: i2c-ibm-iic: cleanup jean-jacques hiblot
2013-12-20 15:12     ` jean-jacques hiblot
2013-12-20 15:12   ` [PATCH v3 REPOST 2/4] i2c: i2c-ibm-iic: perform the transfer in the interrupt handler jean-jacques hiblot
2013-12-20 15:12     ` jean-jacques hiblot
     [not found]     ` <1387552376-12986-3-git-send-email-jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>
2014-01-03 15:04       ` Wolfram Sang [this message]
2014-01-03 15:04         ` Wolfram Sang
2014-01-03 15:57         ` Jean-Jacques Hiblot
2014-01-03 15:57           ` Jean-Jacques Hiblot
2013-12-20 15:12   ` [PATCH v3 REPOST 3/4] i2c: i2c-ibm-iic: Implements transfer abortion jean-jacques hiblot
2013-12-20 15:12     ` jean-jacques hiblot
     [not found]     ` <1387552376-12986-4-git-send-email-jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>
2014-01-03 15:09       ` Wolfram Sang
2014-01-03 15:09         ` Wolfram Sang
2014-01-03 16:14         ` Jean-Jacques Hiblot
2013-12-20 15:12   ` [PATCH v3 REPOST 4/4] i2c: i2c-ibm-iic: Implements a polling mode jean-jacques hiblot
2013-12-20 15:12     ` jean-jacques hiblot
     [not found]     ` <1387552376-12986-5-git-send-email-jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org>
2014-01-03 15:13       ` Wolfram Sang
2014-01-03 15:13         ` Wolfram Sang

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=20140103150416.GA7132@katana \
    --to=wsa-z923lk4zbo2bacvfa/9k2g@public.gmane.org \
    --cc=gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
    --cc=jjhiblot-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=jjhiblot-dLKeG7h1OhBDOHtkgc7UlQ@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.