diff mbox

i2c: i801: Drop needless bit-wise OR

Message ID 20160525093702.64d7309c@endymion
State Accepted
Headers show

Commit Message

Jean Delvare May 25, 2016, 7:37 a.m. UTC
The interrupt handling code makes it look like several status values
may be merged together before being processed, while this will never
happen. Change from bit-wise OR to simple assignment to make it more
obvious and avoid misunderstanding.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: Daniel Kurtz <djkurtz@chromium.org>
Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Wolfram Sang <wsa@the-dreams.de>
---
Daniel, was there any reason for this bit-wise OR, which I may be
missing?

 drivers/i2c/busses/i2c-i801.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mika Westerberg May 26, 2016, 8:36 a.m. UTC | #1
On Wed, May 25, 2016 at 09:37:02AM +0200, Jean Delvare wrote:
> The interrupt handling code makes it look like several status values
> may be merged together before being processed, while this will never
> happen. Change from bit-wise OR to simple assignment to make it more
> obvious and avoid misunderstanding.
> 
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Cc: Daniel Kurtz <djkurtz@chromium.org>
> Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Daniel Kurtz May 30, 2016, 2:07 p.m. UTC | #2
Hi Jean,

On Wed, May 25, 2016 at 3:37 PM, Jean Delvare <jdelvare@suse.de> wrote:
> The interrupt handling code makes it look like several status values
> may be merged together before being processed, while this will never
> happen. Change from bit-wise OR to simple assignment to make it more
> obvious and avoid misunderstanding.
>
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Cc: Daniel Kurtz <djkurtz@chromium.org>
> Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> ---
> Daniel, was there any reason for this bit-wise OR, which I may be
> missing?

The only thing I can think of is that I didn't want to assume that we
would always clear priv->status before another interrupt arrived.

>
>  drivers/i2c/busses/i2c-i801.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> --- linux-4.5.orig/drivers/i2c/busses/i2c-i801.c        2016-05-24 11:04:33.169026906 +0200
> +++ linux-4.5/drivers/i2c/busses/i2c-i801.c     2016-05-24 11:05:40.564642488 +0200
> @@ -548,7 +548,7 @@ static irqreturn_t i801_isr(int irq, voi
>         status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS;
>         if (status) {
>                 outb_p(status, SMBHSTSTS(priv));
> -               priv->status |= status;
> +               priv->status = status;
>                 wake_up(&priv->waitq);
>         }
>
>
>
> --
> Jean Delvare
> SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jean Delvare June 1, 2016, 9:37 a.m. UTC | #3
Hi Daniel,

On Mon, 30 May 2016 22:07:55 +0800, Daniel Kurtz wrote:
> On Wed, May 25, 2016 at 3:37 PM, Jean Delvare <jdelvare@suse.de> wrote:
> > The interrupt handling code makes it look like several status values
> > may be merged together before being processed, while this will never
> > happen. Change from bit-wise OR to simple assignment to make it more
> > obvious and avoid misunderstanding.
> >
> > Signed-off-by: Jean Delvare <jdelvare@suse.de>
> > Cc: Daniel Kurtz <djkurtz@chromium.org>
> > Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Cc: Wolfram Sang <wsa@the-dreams.de>
> > ---
> > Daniel, was there any reason for this bit-wise OR, which I may be
> > missing?
> 
> The only thing I can think of is that I didn't want to assume that we
> would always clear priv->status before another interrupt arrived.

Well my question is quite clear: can this actually happen? I can't see
how.

> >  drivers/i2c/busses/i2c-i801.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > --- linux-4.5.orig/drivers/i2c/busses/i2c-i801.c        2016-05-24 11:04:33.169026906 +0200
> > +++ linux-4.5/drivers/i2c/busses/i2c-i801.c     2016-05-24 11:05:40.564642488 +0200
> > @@ -548,7 +548,7 @@ static irqreturn_t i801_isr(int irq, voi
> >         status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS;
> >         if (status) {
> >                 outb_p(status, SMBHSTSTS(priv));
> > -               priv->status |= status;
> > +               priv->status = status;
> >                 wake_up(&priv->waitq);
> >         }
Daniel Kurtz June 1, 2016, 9:38 a.m. UTC | #4
On Wed, Jun 1, 2016 at 5:37 PM, Jean Delvare <jdelvare@suse.de> wrote:
>
> Hi Daniel,
>
> On Mon, 30 May 2016 22:07:55 +0800, Daniel Kurtz wrote:
> > On Wed, May 25, 2016 at 3:37 PM, Jean Delvare <jdelvare@suse.de> wrote:
> > > The interrupt handling code makes it look like several status values
> > > may be merged together before being processed, while this will never
> > > happen. Change from bit-wise OR to simple assignment to make it more
> > > obvious and avoid misunderstanding.
> > >
> > > Signed-off-by: Jean Delvare <jdelvare@suse.de>
> > > Cc: Daniel Kurtz <djkurtz@chromium.org>
> > > Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> > > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > > Cc: Wolfram Sang <wsa@the-dreams.de>
> > > ---
> > > Daniel, was there any reason for this bit-wise OR, which I may be
> > > missing?
> >
> > The only thing I can think of is that I didn't want to assume that we
> > would always clear priv->status before another interrupt arrived.
>
> Well my question is quite clear: can this actually happen? I can't see
> how.

I have no idea.  You'd have to ask Intel, I guess.

>
>
> > >  drivers/i2c/busses/i2c-i801.c |    2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > --- linux-4.5.orig/drivers/i2c/busses/i2c-i801.c        2016-05-24 11:04:33.169026906 +0200
> > > +++ linux-4.5/drivers/i2c/busses/i2c-i801.c     2016-05-24 11:05:40.564642488 +0200
> > > @@ -548,7 +548,7 @@ static irqreturn_t i801_isr(int irq, voi
> > >         status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS;
> > >         if (status) {
> > >                 outb_p(status, SMBHSTSTS(priv));
> > > -               priv->status |= status;
> > > +               priv->status = status;
> > >                 wake_up(&priv->waitq);
> > >         }
>
> --
> Jean Delvare
> SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jean Delvare June 2, 2016, 11:45 a.m. UTC | #5
On Wed, 1 Jun 2016 17:38:27 +0800, Daniel Kurtz wrote:
> On Wed, Jun 1, 2016 at 5:37 PM, Jean Delvare <jdelvare@suse.de> wrote:
> >
> > Hi Daniel,
> >
> > On Mon, 30 May 2016 22:07:55 +0800, Daniel Kurtz wrote:
> > > On Wed, May 25, 2016 at 3:37 PM, Jean Delvare <jdelvare@suse.de> wrote:
> > > > The interrupt handling code makes it look like several status values
> > > > may be merged together before being processed, while this will never
> > > > happen. Change from bit-wise OR to simple assignment to make it more
> > > > obvious and avoid misunderstanding.
> > > >
> > > > Signed-off-by: Jean Delvare <jdelvare@suse.de>
> > > > Cc: Daniel Kurtz <djkurtz@chromium.org>
> > > > Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> > > > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > > > Cc: Wolfram Sang <wsa@the-dreams.de>
> > > > ---
> > > > Daniel, was there any reason for this bit-wise OR, which I may be
> > > > missing?
> > >
> > > The only thing I can think of is that I didn't want to assume that we
> > > would always clear priv->status before another interrupt arrived.
> >
> > Well my question is quite clear: can this actually happen? I can't see
> > how.
> 
> I have no idea.  You'd have to ask Intel, I guess.

You wrote the code based on public documentation, I thought you would
know. But if you can't be bothered, never mind, I'll trust my
understanding of the code.
Daniel Kurtz June 3, 2016, 11:21 a.m. UTC | #6
On Thu, Jun 2, 2016 at 7:45 PM, Jean Delvare <jdelvare@suse.de> wrote:
>
> On Wed, 1 Jun 2016 17:38:27 +0800, Daniel Kurtz wrote:
> > On Wed, Jun 1, 2016 at 5:37 PM, Jean Delvare <jdelvare@suse.de> wrote:
> > >
> > > Hi Daniel,
> > >
> > > On Mon, 30 May 2016 22:07:55 +0800, Daniel Kurtz wrote:
> > > > On Wed, May 25, 2016 at 3:37 PM, Jean Delvare <jdelvare@suse.de> wrote:
> > > > > The interrupt handling code makes it look like several status values
> > > > > may be merged together before being processed, while this will never
> > > > > happen. Change from bit-wise OR to simple assignment to make it more
> > > > > obvious and avoid misunderstanding.
> > > > >
> > > > > Signed-off-by: Jean Delvare <jdelvare@suse.de>
> > > > > Cc: Daniel Kurtz <djkurtz@chromium.org>
> > > > > Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> > > > > Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> > > > > Cc: Wolfram Sang <wsa@the-dreams.de>
> > > > > ---
> > > > > Daniel, was there any reason for this bit-wise OR, which I may be
> > > > > missing?
> > > >
> > > > The only thing I can think of is that I didn't want to assume that we
> > > > would always clear priv->status before another interrupt arrived.
> > >
> > > Well my question is quite clear: can this actually happen? I can't see
> > > how.
> >
> > I have no idea.  You'd have to ask Intel, I guess.
>
> You wrote the code based on public documentation, I thought you would
> know. But if you can't be bothered, never mind, I'll trust my
> understanding of the code.

Here is the documentation:
http://www.intel.com/content/dam/doc/datasheet/io-controller-hub-6-datasheet.pdf
Page 570

I thought maybe there were situations where you could get INTR and an
error condition, but I don't see anything like that in the
documentation, so I think you are right and only one bit will be set
at a time.

Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>


> --
> Jean Delvare
> SUSE L3 Support
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benjamin Tissoires June 8, 2016, 4:30 p.m. UTC | #7
On May 25 2016 or thereabouts, Jean Delvare wrote:
> The interrupt handling code makes it look like several status values
> may be merged together before being processed, while this will never
> happen. Change from bit-wise OR to simple assignment to make it more
> obvious and avoid misunderstanding.
> 
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Cc: Daniel Kurtz <djkurtz@chromium.org>
> Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>
> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
> Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
> ---

Looks good to me:
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>

Cheers,
Benjamin

> Daniel, was there any reason for this bit-wise OR, which I may be
> missing?
> 
>  drivers/i2c/busses/i2c-i801.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- linux-4.5.orig/drivers/i2c/busses/i2c-i801.c	2016-05-24 11:04:33.169026906 +0200
> +++ linux-4.5/drivers/i2c/busses/i2c-i801.c	2016-05-24 11:05:40.564642488 +0200
> @@ -548,7 +548,7 @@ static irqreturn_t i801_isr(int irq, voi
>  	status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS;
>  	if (status) {
>  		outb_p(status, SMBHSTSTS(priv));
> -		priv->status |= status;
> +		priv->status = status;
>  		wake_up(&priv->waitq);
>  	}
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfram Sang June 9, 2016, 8:28 p.m. UTC | #8
On Wed, May 25, 2016 at 09:37:02AM +0200, Jean Delvare wrote:
> The interrupt handling code makes it look like several status values
> may be merged together before being processed, while this will never
> happen. Change from bit-wise OR to simple assignment to make it more
> obvious and avoid misunderstanding.
> 
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Cc: Daniel Kurtz <djkurtz@chromium.org>
> Cc: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
> Cc: Wolfram Sang <wsa@the-dreams.de>

Applied to for-next, thanks!
diff mbox

Patch

--- linux-4.5.orig/drivers/i2c/busses/i2c-i801.c	2016-05-24 11:04:33.169026906 +0200
+++ linux-4.5/drivers/i2c/busses/i2c-i801.c	2016-05-24 11:05:40.564642488 +0200
@@ -548,7 +548,7 @@  static irqreturn_t i801_isr(int irq, voi
 	status &= SMBHSTSTS_INTR | STATUS_ERROR_FLAGS;
 	if (status) {
 		outb_p(status, SMBHSTSTS(priv));
-		priv->status |= status;
+		priv->status = status;
 		wake_up(&priv->waitq);
 	}