Skip to contentSkip to conversation

leds: always true: (x != 1 || x != 2)

PATCH In review Roel Kluin 3 participants 4 messages Feb 3, 2009 – Mar 3, 2009

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 leds: always true: (x != 1 || x != 2)

see vi include/linux/input.h +710:

#define SND_BELL 0x01
#define SND_TONE 0x02

so (code != SND_BELL || code != SND_TONE) is always true

I think this was intended? --------------------->8------------------8<----------------------- (code != SND_BELL || code != SND_TONE) is always true

---

drivers/leds/leds-pca9532.c +1 -1
index 76ec749..6a481cf 100644
@@ -169,7 +169,7 @@ static int pca9532_event(struct input_dev *dev, unsigned int type,
 {
 	struct pca9532_data *data = input_get_drvdata(dev);
 
-	if (type != EV_SND && (code != SND_BELL || code != SND_TONE))
+	if (type != EV_SND && (code != SND_BELL && code != SND_TONE))
 		return -1;
 
 	/* XXX: allow different kind of beeps with psc/pwm modifications */
#1 lore raw

drivers/leds/leds-pca9532.c static int pca9532_event(struct input_dev *dev, unsigned int type, · line 172

Quoted 2 lines
drivers/leds/leds-pca9532.c +1 -1
-	if (type != EV_SND && (code != SND_BELL || code != SND_TONE))
+	if (type != EV_SND && (code != SND_BELL && code != SND_TONE))

Actually more likely seems to be

	if (type != EV_SND || (code != SND_BELL && code != SND_TONE))
author
#2 lore raw

PATCH v2 1/1 leds: Fix &&/|| confusion

Quoted 6 lines · Roland Dreier

Review

Quoted 2 lines
(quoted diff) +1 -1
-	if (type != EV_SND && (code != SND_BELL || code != SND_TONE))
+	if (type != EV_SND && (code != SND_BELL && code != SND_TONE))

Actually more likely seems to be

	if (type != EV_SND || (code != SND_BELL && code != SND_TONE))

Thanks for your review,

----------------------->8--------------8<------------------------------- Fix &&/|| confusion

---

drivers/leds/leds-pca9532.c +1 -1
index 76ec749..11d3f1e 100644
@@ -169,7 +169,7 @@ static int pca9532_event(struct input_dev *dev, unsigned int type,
 {
 	struct pca9532_data *data = input_get_drvdata(dev);
 
-	if (type != EV_SND && (code != SND_BELL || code != SND_TONE))
+	if (type != EV_SND || (code != SND_BELL && code != SND_TONE))
 		return -1;
 
 	/* XXX: allow different kind of beeps with psc/pwm modifications */
maintainer
#3 lore raw

Re: [PATCH v2] leds: Fix &&/|| confusion

Quoted 9 lines · Roel Kluin
Quoted 6 lines · Roland Dreier

Review

Quoted 2 lines
(quoted diff) +1 -1
-	if (type != EV_SND && (code != SND_BELL || code != SND_TONE))
+	if (type != EV_SND && (code != SND_BELL && code != SND_TONE))

Actually more likely seems to be

	if (type != EV_SND || (code != SND_BELL && code != SND_TONE))

Thanks for your review,

I think what I want is:

	if (!(type==EV_SND && (code == SND_BELL || code == SND_TONE)))

Not that I think anyone would send SND_* without EV_SND.

From 725c752a53a83319042dcdaccf072908b29d1c40 Mon Sep 17 00:00:00 2001
From: Riku Voipio <[email protected]>
Date: Tue, 3 Mar 2009 22:06:51 +0200
Subject: [PATCH 19/19] [PATCH v2] leds: Fix &&/|| confusion

Thanks to Roel Kluin <[email protected]> for noticing.

---
 drivers/leds/leds-pca9532.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/leds/leds-pca9532.c +1 -1
index a46d208..dba8921 100644
@@ -169,7 +169,7 @@ static int pca9532_event(struct input_dev *dev, unsigned int type,
 {
 	struct pca9532_data *data = input_get_drvdata(dev);
 
-	if (type != EV_SND && (code != SND_BELL || code != SND_TONE))
+	if (!(type == EV_SND && (code == SND_BELL || code == SND_TONE)))
 		return -1;
 
 	/* XXX: allow different kind of beeps with psc/pwm modifications */
Signature · 1 line
1.6.1.3