@@ -815,6 +815,9 @@ static int ads7846_suspend(struct spi_device *spi, pm_message_t message)
{
struct ads7846 *ts = dev_get_drvdata(&spi->dev);
+ if (WARN_ON_ONCE(!ts))
+ return 0;
+
spin_lock_irq(&ts->lock);
ts->is_suspended = 1;
@@ -833,6 +836,9 @@ static int ads7846_resume(struct spi_device *spi)
{
struct ads7846 *ts = dev_get_drvdata(&spi->dev);
+ if (WARN_ON_ONCE(!ts))
+ return 0;
+
if (device_may_wakeup(&ts->spi->dev))
disable_irq_wake(ts->spi->irq);
@@ -1231,6 +1237,7 @@ static int __devinit ads7846_probe(struct spi_device *spi)
input_free_device(input_dev);
kfree(packet);
kfree(ts);
+ dev_set_drvdata(&spi->dev, NULL);
return err;
}
@@ -1240,6 +1247,9 @@ static int __devexit ads7846_remove(struct spi_device *spi)
device_init_wakeup(&spi->dev, false);
+ if (WARN_ON_ONCE(!ts))
+ return 0;
+
ads784x_hwmon_unregister(spi, ts);
input_unregister_device(ts->input);