tpm_tis_spi: Pass the SPI IRQ down to the driver
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 8 Jun 2018 07:09:07 +0000 (09:09 +0200)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Sat, 28 Jul 2018 14:03:11 +0000 (17:03 +0300)
An SPI TPM device managed directly on an embedded board using
the SPI bus and some GPIO or similar line as IRQ handler will
pass the IRQn from the TPM device associated with the SPI
device. This is already handled by the SPI core, so make sure
to pass this down to the core as well.

(The TPM core habit of using -1 to signal no IRQ is dubious
(as IRQ 0 is NO_IRQ) but I do not want to mess with that
semantic in this patch.)

Cc: Mark Brown <broonie@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
drivers/char/tpm/tpm_tis_spi.c

index 424ff2fde1f2d60e3e42298153cffbf16758cedd..9914f6973463ad3d04b76befa4bb9e3734beca2a 100644 (file)
@@ -199,6 +199,7 @@ static const struct tpm_tis_phy_ops tpm_spi_phy_ops = {
 static int tpm_tis_spi_probe(struct spi_device *dev)
 {
        struct tpm_tis_spi_phy *phy;
+       int irq;
 
        phy = devm_kzalloc(&dev->dev, sizeof(struct tpm_tis_spi_phy),
                           GFP_KERNEL);
@@ -211,7 +212,13 @@ static int tpm_tis_spi_probe(struct spi_device *dev)
        if (!phy->iobuf)
                return -ENOMEM;
 
-       return tpm_tis_core_init(&dev->dev, &phy->priv, -1, &tpm_spi_phy_ops,
+       /* If the SPI device has an IRQ then use that */
+       if (dev->irq > 0)
+               irq = dev->irq;
+       else
+               irq = -1;
+
+       return tpm_tis_core_init(&dev->dev, &phy->priv, irq, &tpm_spi_phy_ops,
                                 NULL);
 }