diff options
-rw-r--r-- | drivers/spi/spidev.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index e3c19f30f591..2e05046f866b 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/compat.h> | 29 | #include <linux/compat.h> |
30 | #include <linux/of.h> | 30 | #include <linux/of.h> |
31 | #include <linux/of_device.h> | 31 | #include <linux/of_device.h> |
32 | #include <linux/acpi.h> | ||
32 | 33 | ||
33 | #include <linux/spi/spi.h> | 34 | #include <linux/spi/spi.h> |
34 | #include <linux/spi/spidev.h> | 35 | #include <linux/spi/spidev.h> |
@@ -700,6 +701,43 @@ static const struct of_device_id spidev_dt_ids[] = { | |||
700 | MODULE_DEVICE_TABLE(of, spidev_dt_ids); | 701 | MODULE_DEVICE_TABLE(of, spidev_dt_ids); |
701 | #endif | 702 | #endif |
702 | 703 | ||
704 | #ifdef CONFIG_ACPI | ||
705 | |||
706 | /* Dummy SPI devices not to be used in production systems */ | ||
707 | #define SPIDEV_ACPI_DUMMY 1 | ||
708 | |||
709 | static const struct acpi_device_id spidev_acpi_ids[] = { | ||
710 | /* | ||
711 | * The ACPI SPT000* devices are only meant for development and | ||
712 | * testing. Systems used in production should have a proper ACPI | ||
713 | * description of the connected peripheral and they should also use | ||
714 | * a proper driver instead of poking directly to the SPI bus. | ||
715 | */ | ||
716 | { "SPT0001", SPIDEV_ACPI_DUMMY }, | ||
717 | { "SPT0002", SPIDEV_ACPI_DUMMY }, | ||
718 | { "SPT0003", SPIDEV_ACPI_DUMMY }, | ||
719 | {}, | ||
720 | }; | ||
721 | MODULE_DEVICE_TABLE(acpi, spidev_acpi_ids); | ||
722 | |||
723 | static void spidev_probe_acpi(struct spi_device *spi) | ||
724 | { | ||
725 | const struct acpi_device_id *id; | ||
726 | |||
727 | if (!has_acpi_companion(&spi->dev)) | ||
728 | return; | ||
729 | |||
730 | id = acpi_match_device(spidev_acpi_ids, &spi->dev); | ||
731 | if (WARN_ON(!id)) | ||
732 | return; | ||
733 | |||
734 | if (id->driver_data == SPIDEV_ACPI_DUMMY) | ||
735 | dev_warn(&spi->dev, "do not use this driver in production systems!\n"); | ||
736 | } | ||
737 | #else | ||
738 | static inline void spidev_probe_acpi(struct spi_device *spi) {} | ||
739 | #endif | ||
740 | |||
703 | /*-------------------------------------------------------------------------*/ | 741 | /*-------------------------------------------------------------------------*/ |
704 | 742 | ||
705 | static int spidev_probe(struct spi_device *spi) | 743 | static int spidev_probe(struct spi_device *spi) |
@@ -719,6 +757,8 @@ static int spidev_probe(struct spi_device *spi) | |||
719 | !of_match_device(spidev_dt_ids, &spi->dev)); | 757 | !of_match_device(spidev_dt_ids, &spi->dev)); |
720 | } | 758 | } |
721 | 759 | ||
760 | spidev_probe_acpi(spi); | ||
761 | |||
722 | /* Allocate driver data */ | 762 | /* Allocate driver data */ |
723 | spidev = kzalloc(sizeof(*spidev), GFP_KERNEL); | 763 | spidev = kzalloc(sizeof(*spidev), GFP_KERNEL); |
724 | if (!spidev) | 764 | if (!spidev) |
@@ -789,6 +829,7 @@ static struct spi_driver spidev_spi_driver = { | |||
789 | .driver = { | 829 | .driver = { |
790 | .name = "spidev", | 830 | .name = "spidev", |
791 | .of_match_table = of_match_ptr(spidev_dt_ids), | 831 | .of_match_table = of_match_ptr(spidev_dt_ids), |
832 | .acpi_match_table = ACPI_PTR(spidev_acpi_ids), | ||
792 | }, | 833 | }, |
793 | .probe = spidev_probe, | 834 | .probe = spidev_probe, |
794 | .remove = spidev_remove, | 835 | .remove = spidev_remove, |