* [PATCH] char/tpm: Use true and false for bools
@ 2012-11-29 0:20 Peter Huewe
2012-11-29 0:25 ` Al Viro
0 siblings, 1 reply; 9+ messages in thread
From: Peter Huewe @ 2012-11-29 0:20 UTC (permalink / raw)
To: Kent Yoder
Cc: Rajiv Andrade, Marcel Selhorst, Sirrix AG, tpmdd-devel,
linux-kernel, Peter Huewe
Bool initializations should use true and false. Bool tests don't need
comparisons. Based on contributions from Joe Perches, Rusty Russell
and Bruce W Allan.
The semantic patch that makes this output is available
in scripts/coccinelle/misc/boolinit.cocci.
More information about semantic patching is available at
http://coccinelle.lip6.fr/
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
drivers/char/tpm/tpm_tis.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 6bdf267..70d4ea5 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -374,7 +374,7 @@ static int probe_itpm(struct tpm_chip *chip)
if (vendor != TPM_VID_INTEL)
return 0;
- itpm = 0;
+ itpm = false;
rc = tpm_tis_send_data(chip, cmd_getticks, len);
if (rc == 0)
@@ -383,7 +383,7 @@ static int probe_itpm(struct tpm_chip *chip)
tpm_tis_ready(chip);
release_locality(chip, chip->vendor.locality, 0);
- itpm = 1;
+ itpm = true;
rc = tpm_tis_send_data(chip, cmd_getticks, len);
if (rc == 0) {
@@ -502,7 +502,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
return IRQ_HANDLED;
}
-static bool interrupts = 1;
+static bool interrupts = true;
module_param(interrupts, bool, 0444);
MODULE_PARM_DESC(interrupts, "Enable interrupts");
@@ -545,7 +545,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
rc = -ENODEV;
goto out_err;
}
- itpm = (probe == 0) ? 0 : 1;
+ itpm = (probe == 0) ? false : true;
}
if (itpm)
@@ -741,10 +741,10 @@ static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
if (pnp_irq_valid(pnp_dev, 0))
irq = pnp_irq(pnp_dev, 0);
else
- interrupts = 0;
+ interrupts = false;
if (is_itpm(pnp_dev))
- itpm = 1;
+ itpm = true;
return tpm_tis_init(&pnp_dev->dev, start, len, irq);
}
--
1.7.8.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] char/tpm: Use true and false for bools
2012-11-29 0:20 [PATCH] char/tpm: Use true and false for bools Peter Huewe
@ 2012-11-29 0:25 ` Al Viro
2012-11-29 0:39 ` [PATCH v2] " Peter Huewe
2012-11-29 0:42 ` [PATCH] " Peter Huewe
0 siblings, 2 replies; 9+ messages in thread
From: Al Viro @ 2012-11-29 0:25 UTC (permalink / raw)
To: Peter Huewe
Cc: Kent Yoder, Rajiv Andrade, Marcel Selhorst, Sirrix AG,
tpmdd-devel, linux-kernel
On Thu, Nov 29, 2012 at 01:20:37AM +0100, Peter Huewe wrote:
> - itpm = (probe == 0) ? 0 : 1;
> + itpm = (probe == 0) ? false : true;
Charming. Not that original had been better, but...
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] char/tpm: Use true and false for bools
2012-11-29 0:25 ` Al Viro
@ 2012-11-29 0:39 ` Peter Huewe
2012-11-29 0:42 ` [PATCH] " Peter Huewe
1 sibling, 0 replies; 9+ messages in thread
From: Peter Huewe @ 2012-11-29 0:39 UTC (permalink / raw)
To: Kent Yoder
Cc: Rajiv Andrade, Marcel Selhorst, Sirrix AG, tpmdd-devel,
linux-kernel, Peter Huewe
Bool initializations should use true and false. Bool tests don't need
comparisons. Based on contributions from Joe Perches, Rusty Russell
and Bruce W Allan.
The semantic patch that makes this output is available
in scripts/coccinelle/misc/boolinit.cocci.
More information about semantic patching is available at
http://coccinelle.lip6.fr/
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
v2:
Removed/changed that silly itpm = (probe == 0) ? 0 : 1;
since probe is here either 0 or 1 -- thanks Al for noticing.
This section and the probing of the itpm can probably be improved anyway,
but I'll wrap that in a different patch soon.
drivers/char/tpm/tpm_tis.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 6bdf267..8b084e0 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -374,7 +374,7 @@ static int probe_itpm(struct tpm_chip *chip)
if (vendor != TPM_VID_INTEL)
return 0;
- itpm = 0;
+ itpm = false;
rc = tpm_tis_send_data(chip, cmd_getticks, len);
if (rc == 0)
@@ -383,7 +383,7 @@ static int probe_itpm(struct tpm_chip *chip)
tpm_tis_ready(chip);
release_locality(chip, chip->vendor.locality, 0);
- itpm = 1;
+ itpm = true;
rc = tpm_tis_send_data(chip, cmd_getticks, len);
if (rc == 0) {
@@ -502,7 +502,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
return IRQ_HANDLED;
}
-static bool interrupts = 1;
+static bool interrupts = true;
module_param(interrupts, bool, 0444);
MODULE_PARM_DESC(interrupts, "Enable interrupts");
@@ -545,7 +545,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
rc = -ENODEV;
goto out_err;
}
- itpm = (probe == 0) ? 0 : 1;
+ itpm = probe;
}
if (itpm)
@@ -741,10 +741,10 @@ static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
if (pnp_irq_valid(pnp_dev, 0))
irq = pnp_irq(pnp_dev, 0);
else
- interrupts = 0;
+ interrupts = false;
if (is_itpm(pnp_dev))
- itpm = 1;
+ itpm = true;
return tpm_tis_init(&pnp_dev->dev, start, len, irq);
}
--
1.7.8.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] char/tpm: Use true and false for bools
2012-11-29 0:25 ` Al Viro
2012-11-29 0:39 ` [PATCH v2] " Peter Huewe
@ 2012-11-29 0:42 ` Peter Huewe
2012-11-29 16:06 ` Kent Yoder
1 sibling, 1 reply; 9+ messages in thread
From: Peter Huewe @ 2012-11-29 0:42 UTC (permalink / raw)
To: Al Viro
Cc: Kent Yoder, Rajiv Andrade, Marcel Selhorst, Sirrix AG,
tpmdd-devel, linux-kernel
Am Donnerstag, 29. November 2012, 01:25:19 schrieb Al Viro:
> On Thu, Nov 29, 2012 at 01:20:37AM +0100, Peter Huewe wrote:
> > - itpm = (probe == 0) ? 0 : 1;
> > + itpm = (probe == 0) ? false : true;
>
> Charming. Not that original had been better, but...
Yeah. Sorry it's late.
The tpm subsection has a lot of nice suprises.
I changed it to itpm = probe; which is equivalent here and sent out a v2.
I'll probably rewrite that code section anytime soon.
Thanks for noticing.
Peter
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] char/tpm: Use true and false for bools
2012-11-29 0:42 ` [PATCH] " Peter Huewe
@ 2012-11-29 16:06 ` Kent Yoder
2012-11-29 21:08 ` [PATCH v3] " Peter Huewe
0 siblings, 1 reply; 9+ messages in thread
From: Kent Yoder @ 2012-11-29 16:06 UTC (permalink / raw)
To: Peter Huewe
Cc: Al Viro, Rajiv Andrade, Marcel Selhorst, Sirrix AG, tpmdd-devel,
linux-kernel
On Thu, Nov 29, 2012 at 01:42:47AM +0100, Peter Huewe wrote:
> Am Donnerstag, 29. November 2012, 01:25:19 schrieb Al Viro:
> > On Thu, Nov 29, 2012 at 01:20:37AM +0100, Peter Huewe wrote:
> > > - itpm = (probe == 0) ? 0 : 1;
> > > + itpm = (probe == 0) ? false : true;
> >
> > Charming. Not that original had been better, but...
> Yeah. Sorry it's late.
> The tpm subsection has a lot of nice suprises.
:-) I'd prefer
itpm = !!probe;
Now I don't have to go look up what the possible return values of
probe_itpm() are...
Kent
> I changed it to itpm = probe; which is equivalent here and sent out a v2.
> I'll probably rewrite that code section anytime soon.
>
> Thanks for noticing.
> Peter
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] char/tpm: Use true and false for bools
2012-11-29 16:06 ` Kent Yoder
@ 2012-11-29 21:08 ` Peter Huewe
2012-11-29 21:54 ` Joe Perches
0 siblings, 1 reply; 9+ messages in thread
From: Peter Huewe @ 2012-11-29 21:08 UTC (permalink / raw)
To: Kent Yoder
Cc: Rajiv Andrade, Marcel Selhorst, Sirrix AG, tpmdd-devel,
linux-kernel, Al Viro, Peter Huewe
Bool initializations should use true and false. Bool tests don't need
comparisons. Based on contributions from Joe Perches, Rusty Russell
and Bruce W Allan.
The semantic patch that makes this output is available
in scripts/coccinelle/misc/boolinit.cocci.
More information about semantic patching is available at
http://coccinelle.lip6.fr/
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
v3 for this tiny patch... shame on me.
drivers/char/tpm/tpm_tis.c | 12 ++++++------
1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
index 6bdf267..10f0b47 100644
--- a/drivers/char/tpm/tpm_tis.c
+++ b/drivers/char/tpm/tpm_tis.c
@@ -374,7 +374,7 @@ static int probe_itpm(struct tpm_chip *chip)
if (vendor != TPM_VID_INTEL)
return 0;
- itpm = 0;
+ itpm = false;
rc = tpm_tis_send_data(chip, cmd_getticks, len);
if (rc == 0)
@@ -383,7 +383,7 @@ static int probe_itpm(struct tpm_chip *chip)
tpm_tis_ready(chip);
release_locality(chip, chip->vendor.locality, 0);
- itpm = 1;
+ itpm = true;
rc = tpm_tis_send_data(chip, cmd_getticks, len);
if (rc == 0) {
@@ -502,7 +502,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id)
return IRQ_HANDLED;
}
-static bool interrupts = 1;
+static bool interrupts = true;
module_param(interrupts, bool, 0444);
MODULE_PARM_DESC(interrupts, "Enable interrupts");
@@ -545,7 +545,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
rc = -ENODEV;
goto out_err;
}
- itpm = (probe == 0) ? 0 : 1;
+ itpm = !!probe;
}
if (itpm)
@@ -741,10 +741,10 @@ static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev,
if (pnp_irq_valid(pnp_dev, 0))
irq = pnp_irq(pnp_dev, 0);
else
- interrupts = 0;
+ interrupts = false;
if (is_itpm(pnp_dev))
- itpm = 1;
+ itpm = true;
return tpm_tis_init(&pnp_dev->dev, start, len, irq);
}
--
1.7.8.6
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3] char/tpm: Use true and false for bools
2012-11-29 21:08 ` [PATCH v3] " Peter Huewe
@ 2012-11-29 21:54 ` Joe Perches
2012-11-29 22:08 ` Kent Yoder
0 siblings, 1 reply; 9+ messages in thread
From: Joe Perches @ 2012-11-29 21:54 UTC (permalink / raw)
To: Peter Huewe
Cc: Kent Yoder, Rajiv Andrade, Marcel Selhorst, Sirrix AG,
tpmdd-devel, linux-kernel, Al Viro
On Thu, 2012-11-29 at 22:08 +0100, Peter Huewe wrote:
> Bool initializations should use true and false. Bool tests don't need
> comparisons
[]
> .v3 for this tiny patch... shame on me.
Don't be silly...
> diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
[]
> @@ -545,7 +545,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
> rc = -ENODEV;
> goto out_err;
> }
> - itpm = (probe == 0) ? 0 : 1;
> + itpm = !!probe;
Even more trivia:
This !! isn't necessary as ints assigned to bool are converted
by the compiler to 0 or 1.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] char/tpm: Use true and false for bools
2012-11-29 21:54 ` Joe Perches
@ 2012-11-29 22:08 ` Kent Yoder
2012-11-29 22:16 ` Peter Hüwe
0 siblings, 1 reply; 9+ messages in thread
From: Kent Yoder @ 2012-11-29 22:08 UTC (permalink / raw)
To: Joe Perches
Cc: Peter Huewe, Rajiv Andrade, Marcel Selhorst, Sirrix AG,
tpmdd-devel, linux-kernel, Al Viro
On Thu, Nov 29, 2012 at 01:54:52PM -0800, Joe Perches wrote:
> On Thu, 2012-11-29 at 22:08 +0100, Peter Huewe wrote:
> > Bool initializations should use true and false. Bool tests don't need
> > comparisons
> []
> > .v3 for this tiny patch... shame on me.
>
> Don't be silly...
>
> > diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c
> []
> > @@ -545,7 +545,7 @@ static int tpm_tis_init(struct device *dev, resource_size_t start,
> > rc = -ENODEV;
> > goto out_err;
> > }
> > - itpm = (probe == 0) ? 0 : 1;
> > + itpm = !!probe;
>
> Even more trivia:
>
> This !! isn't necessary as ints assigned to bool are converted
> by the compiler to 0 or 1.
Good to know, thanks Joe!
Kent
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] char/tpm: Use true and false for bools
2012-11-29 22:08 ` Kent Yoder
@ 2012-11-29 22:16 ` Peter Hüwe
0 siblings, 0 replies; 9+ messages in thread
From: Peter Hüwe @ 2012-11-29 22:16 UTC (permalink / raw)
To: Kent Yoder
Cc: Joe Perches, Rajiv Andrade, Marcel Selhorst, Sirrix AG,
tpmdd-devel, linux-kernel, Al Viro
Am Donnerstag, 29. November 2012, 23:08:11 schrieb Kent Yoder:
> On Thu, Nov 29, 2012 at 01:54:52PM -0800, Joe Perches wrote:
> > >
> > > - itpm = (probe == 0) ? 0 : 1;
> > > + itpm = !!probe;
> >
> > Even more trivia:
> >
> > This !! isn't necessary as ints assigned to bool are converted
> > by the compiler to 0 or 1.
>
> Good to know, thanks Joe!
So v2 is fine.
Peter
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-11-29 22:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-29 0:20 [PATCH] char/tpm: Use true and false for bools Peter Huewe
2012-11-29 0:25 ` Al Viro
2012-11-29 0:39 ` [PATCH v2] " Peter Huewe
2012-11-29 0:42 ` [PATCH] " Peter Huewe
2012-11-29 16:06 ` Kent Yoder
2012-11-29 21:08 ` [PATCH v3] " Peter Huewe
2012-11-29 21:54 ` Joe Perches
2012-11-29 22:08 ` Kent Yoder
2012-11-29 22:16 ` Peter Hüwe
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.