NFC: st-nci: Disable irq when powering the device up
authorChristophe Ricard <christophe.ricard@gmail.com>
Sun, 25 Oct 2015 21:54:48 +0000 (22:54 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 27 Oct 2015 02:55:14 +0000 (03:55 +0100)
Upon some conditions (timing, CLF errors, platform errors...), the
irq might be already active when powering the device.

Add irq_active variable as a guard to avoid kernel warning message

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/st-nci/i2c.c
drivers/nfc/st-nci/spi.c

index 2a96f1a415e4fa3d6bc06b8a7083f2042951bf71..25e50426e4d7f373d3b2c775b22ba324f6f6e19a 100644 (file)
@@ -50,6 +50,8 @@ struct st_nci_i2c_phy {
        struct i2c_client *i2c_dev;
        struct llt_ndlc *ndlc;
 
+       bool irq_active;
+
        unsigned int gpio_reset;
        unsigned int irq_polarity;
 
@@ -72,8 +74,10 @@ static int st_nci_i2c_enable(void *phy_id)
        gpio_set_value(phy->gpio_reset, 1);
        usleep_range(80000, 85000);
 
-       if (phy->ndlc->powered == 0)
+       if (phy->ndlc->powered == 0 && phy->irq_active == 0) {
                enable_irq(phy->i2c_dev->irq);
+               phy->irq_active = true;
+       }
 
        return 0;
 }
@@ -83,6 +87,7 @@ static void st_nci_i2c_disable(void *phy_id)
        struct st_nci_i2c_phy *phy = phy_id;
 
        disable_irq_nosync(phy->i2c_dev->irq);
+       phy->irq_active = false;
 }
 
 /*
@@ -342,6 +347,7 @@ static int st_nci_i2c_probe(struct i2c_client *client,
                return r;
        }
 
+       phy->irq_active = true;
        r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
                                st_nci_irq_thread_fn,
                                phy->irq_polarity | IRQF_ONESHOT,
index 8897203364743031f5dce21273843cb2ef455621..bf6643c72f53ba93d5140afd3af67d1924d43d22 100644 (file)
@@ -51,6 +51,8 @@ struct st_nci_spi_phy {
        struct spi_device *spi_dev;
        struct llt_ndlc *ndlc;
 
+       bool irq_active;
+
        unsigned int gpio_reset;
        unsigned int irq_polarity;
 
@@ -73,8 +75,10 @@ static int st_nci_spi_enable(void *phy_id)
        gpio_set_value(phy->gpio_reset, 1);
        usleep_range(80000, 85000);
 
-       if (phy->ndlc->powered == 0)
+       if (phy->ndlc->powered == 0 && phy->irq_active == 0) {
                enable_irq(phy->spi_dev->irq);
+               phy->irq_active = true;
+       }
 
        return 0;
 }
@@ -84,6 +88,7 @@ static void st_nci_spi_disable(void *phy_id)
        struct st_nci_spi_phy *phy = phy_id;
 
        disable_irq_nosync(phy->spi_dev->irq);
+       phy->irq_active = false;
 }
 
 /*
@@ -358,6 +363,7 @@ static int st_nci_spi_probe(struct spi_device *dev)
                return r;
        }
 
+       phy->irq_active = true;
        r = devm_request_threaded_irq(&dev->dev, dev->irq, NULL,
                                st_nci_irq_thread_fn,
                                phy->irq_polarity | IRQF_ONESHOT,
This page took 0.026418 seconds and 5 git commands to generate.