[tpmdd-devel,2/2] add irq validity check in tpm_i2c_nuvoton driver
diff mbox

Message ID 1467194329-5543-3-git-send-email-andrew.zamansky@nuvoton.com
State New
Headers show

Commit Message

andrew.zamansky@nuvoton.com June 29, 2016, 9:58 a.m. UTC
if irq==0 (actualy invalid value) then error is printed to dmesg after
trying to register to 0 interrupt 

---
 drivers/char/tpm/tpm_i2c_nuvoton.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Jarkko Sakkinen June 29, 2016, 2:03 p.m. UTC | #1
On Wed, Jun 29, 2016 at 12:58:49PM +0300, andrew zamansky wrote:
> if irq==0 (actualy invalid value) then error is printed to dmesg after
> trying to register to 0 interrupt 
> 
> ---
>  drivers/char/tpm/tpm_i2c_nuvoton.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
> index 75a80e466..3081529 100644
> --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
> +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
> @@ -554,7 +554,9 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
>  	 *   TPM_INTF_INT_LEVEL_LOW | TPM_INTF_DATA_AVAIL_INT
>  	 * The IRQ should be set in the i2c_board_info (which is done
>  	 * automatically in of_i2c_register_devices, for device tree users */
> -	chip->flags |= TPM_CHIP_FLAG_IRQ;
> +	if(chip->flags)
> +		chip->flags |= TPM_CHIP_FLAG_IRQ;
> +
>  	priv->irq = client->irq;
>  
>  	if (chip->flags & TPM_CHIP_FLAG_IRQ) {
> -- 
> 1.9.1
> 

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

PS. There's a style error. "if()" should be "if ()". I don't mind fixing
that. Just remember that next time.

/Jarkko

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
Jason Gunthorpe June 29, 2016, 6:20 p.m. UTC | #2
On Wed, Jun 29, 2016 at 12:58:49PM +0300, andrew zamansky wrote:
> if irq==0 (actualy invalid value) then error is printed to dmesg after
> trying to register to 0 interrupt 

Missing Signed-off-by line.

And this patch should have:

Fixes: 570a36097f30 ("tpm: drop 'irq' from struct tpm_vendor_specific")

There is also no need to re-sent the patch that is being fixed.

> -	chip->flags |= TPM_CHIP_FLAG_IRQ;
> +	if(chip->flags)
> +		chip->flags |= TPM_CHIP_FLAG_IRQ;
> +

Don't forget to run checkpatch

Jason

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
Jarkko Sakkinen July 1, 2016, 8:39 a.m. UTC | #3
On Wed, Jun 29, 2016 at 05:03:39PM +0300, Jarkko Sakkinen wrote:
> On Wed, Jun 29, 2016 at 12:58:49PM +0300, andrew zamansky wrote:
> > if irq==0 (actualy invalid value) then error is printed to dmesg after
> > trying to register to 0 interrupt 
> > 
> > ---
> >  drivers/char/tpm/tpm_i2c_nuvoton.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
> > index 75a80e466..3081529 100644
> > --- a/drivers/char/tpm/tpm_i2c_nuvoton.c
> > +++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
> > @@ -554,7 +554,9 @@ static int i2c_nuvoton_probe(struct i2c_client *client,
> >  	 *   TPM_INTF_INT_LEVEL_LOW | TPM_INTF_DATA_AVAIL_INT
> >  	 * The IRQ should be set in the i2c_board_info (which is done
> >  	 * automatically in of_i2c_register_devices, for device tree users */
> > -	chip->flags |= TPM_CHIP_FLAG_IRQ;
> > +	if(chip->flags)
> > +		chip->flags |= TPM_CHIP_FLAG_IRQ;
> > +
> >  	priv->irq = client->irq;
> >  
> >  	if (chip->flags & TPM_CHIP_FLAG_IRQ) {
> > -- 
> > 1.9.1
> > 
> 
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> 
> PS. There's a style error. "if()" should be "if ()". I don't mind fixing
> that. Just remember that next time.

The commit was broken in two other in addition to those that Jason
already mentioned:

* the subject line was missing subsystem tag
* please adjust 'user.name' in your git config. it's broken

You clearly haven't studied

  https://www.kernel.org/doc/Documentation/SubmittingPatches

that I pointed you last time when I got broken commits.

Anyway, the commit is applied to my master branch and I fixed the
errors in your commit. Please try to do things better next time.
Thanks.

/Jarkko

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape

Patch
diff mbox

diff --git a/drivers/char/tpm/tpm_i2c_nuvoton.c b/drivers/char/tpm/tpm_i2c_nuvoton.c
index 75a80e466..3081529 100644
--- a/drivers/char/tpm/tpm_i2c_nuvoton.c
+++ b/drivers/char/tpm/tpm_i2c_nuvoton.c
@@ -554,7 +554,9 @@  static int i2c_nuvoton_probe(struct i2c_client *client,
 	 *   TPM_INTF_INT_LEVEL_LOW | TPM_INTF_DATA_AVAIL_INT
 	 * The IRQ should be set in the i2c_board_info (which is done
 	 * automatically in of_i2c_register_devices, for device tree users */
-	chip->flags |= TPM_CHIP_FLAG_IRQ;
+	if(chip->flags)
+		chip->flags |= TPM_CHIP_FLAG_IRQ;
+
 	priv->irq = client->irq;
 
 	if (chip->flags & TPM_CHIP_FLAG_IRQ) {