diff options
-rw-r--r-- | drivers/spi/spidev.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index 23ad97807797..92c909eed6b5 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -703,6 +703,14 @@ static const struct file_operations spidev_fops = { | |||
703 | 703 | ||
704 | static struct class *spidev_class; | 704 | static struct class *spidev_class; |
705 | 705 | ||
706 | #ifdef CONFIG_OF | ||
707 | static const struct of_device_id spidev_dt_ids[] = { | ||
708 | { .compatible = "rohm,dh2228fv" }, | ||
709 | {}, | ||
710 | }; | ||
711 | MODULE_DEVICE_TABLE(of, spidev_dt_ids); | ||
712 | #endif | ||
713 | |||
706 | /*-------------------------------------------------------------------------*/ | 714 | /*-------------------------------------------------------------------------*/ |
707 | 715 | ||
708 | static int spidev_probe(struct spi_device *spi) | 716 | static int spidev_probe(struct spi_device *spi) |
@@ -711,6 +719,17 @@ static int spidev_probe(struct spi_device *spi) | |||
711 | int status; | 719 | int status; |
712 | unsigned long minor; | 720 | unsigned long minor; |
713 | 721 | ||
722 | /* | ||
723 | * spidev should never be referenced in DT without a specific | ||
724 | * compatbile string, it is a Linux implementation thing | ||
725 | * rather than a description of the hardware. | ||
726 | */ | ||
727 | if (spi->dev.of_node && !of_match_device(spidev_dt_ids, &spi->dev)) { | ||
728 | dev_err(&spi->dev, "buggy DT: spidev listed directly in DT\n"); | ||
729 | WARN_ON(spi->dev.of_node && | ||
730 | !of_match_device(spidev_dt_ids, &spi->dev)); | ||
731 | } | ||
732 | |||
714 | /* Allocate driver data */ | 733 | /* Allocate driver data */ |
715 | spidev = kzalloc(sizeof(*spidev), GFP_KERNEL); | 734 | spidev = kzalloc(sizeof(*spidev), GFP_KERNEL); |
716 | if (!spidev) | 735 | if (!spidev) |
@@ -777,13 +796,6 @@ static int spidev_remove(struct spi_device *spi) | |||
777 | return 0; | 796 | return 0; |
778 | } | 797 | } |
779 | 798 | ||
780 | static const struct of_device_id spidev_dt_ids[] = { | ||
781 | { .compatible = "rohm,dh2228fv" }, | ||
782 | {}, | ||
783 | }; | ||
784 | |||
785 | MODULE_DEVICE_TABLE(of, spidev_dt_ids); | ||
786 | |||
787 | static struct spi_driver spidev_spi_driver = { | 799 | static struct spi_driver spidev_spi_driver = { |
788 | .driver = { | 800 | .driver = { |
789 | .name = "spidev", | 801 | .name = "spidev", |