Commit 2a7f669d authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown

spi: spidev: Replace ACPI specific code by device_get_match_data()

Instead of calling the ACPI specific APIs, use device_get_match_data().
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220323140215.2568-3-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d21b94bf
...@@ -8,19 +8,20 @@ ...@@ -8,19 +8,20 @@
*/ */
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h>
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/property.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/acpi.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/spidev.h> #include <linux/spi/spidev.h>
...@@ -709,10 +710,12 @@ static const struct of_device_id spidev_dt_ids[] = { ...@@ -709,10 +710,12 @@ static const struct of_device_id spidev_dt_ids[] = {
MODULE_DEVICE_TABLE(of, spidev_dt_ids); MODULE_DEVICE_TABLE(of, spidev_dt_ids);
#endif #endif
#ifdef CONFIG_ACPI
/* Dummy SPI devices not to be used in production systems */ /* Dummy SPI devices not to be used in production systems */
#define SPIDEV_ACPI_DUMMY 1 static int spidev_acpi_check(struct device *dev)
{
dev_warn(dev, "do not use this driver in production systems!\n");
return 0;
}
static const struct acpi_device_id spidev_acpi_ids[] = { static const struct acpi_device_id spidev_acpi_ids[] = {
/* /*
...@@ -721,35 +724,18 @@ static const struct acpi_device_id spidev_acpi_ids[] = { ...@@ -721,35 +724,18 @@ static const struct acpi_device_id spidev_acpi_ids[] = {
* description of the connected peripheral and they should also use * description of the connected peripheral and they should also use
* a proper driver instead of poking directly to the SPI bus. * a proper driver instead of poking directly to the SPI bus.
*/ */
{ "SPT0001", SPIDEV_ACPI_DUMMY }, { "SPT0001", (kernel_ulong_t)&spidev_acpi_check },
{ "SPT0002", SPIDEV_ACPI_DUMMY }, { "SPT0002", (kernel_ulong_t)&spidev_acpi_check },
{ "SPT0003", SPIDEV_ACPI_DUMMY }, { "SPT0003", (kernel_ulong_t)&spidev_acpi_check },
{}, {},
}; };
MODULE_DEVICE_TABLE(acpi, spidev_acpi_ids); MODULE_DEVICE_TABLE(acpi, spidev_acpi_ids);
static void spidev_probe_acpi(struct spi_device *spi)
{
const struct acpi_device_id *id;
if (!has_acpi_companion(&spi->dev))
return;
id = acpi_match_device(spidev_acpi_ids, &spi->dev);
if (WARN_ON(!id))
return;
if (id->driver_data == SPIDEV_ACPI_DUMMY)
dev_warn(&spi->dev, "do not use this driver in production systems!\n");
}
#else
static inline void spidev_probe_acpi(struct spi_device *spi) {}
#endif
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static int spidev_probe(struct spi_device *spi) static int spidev_probe(struct spi_device *spi)
{ {
int (*match)(struct device *dev);
struct spidev_data *spidev; struct spidev_data *spidev;
int status; int status;
unsigned long minor; unsigned long minor;
...@@ -764,7 +750,12 @@ static int spidev_probe(struct spi_device *spi) ...@@ -764,7 +750,12 @@ static int spidev_probe(struct spi_device *spi)
return -EINVAL; return -EINVAL;
} }
spidev_probe_acpi(spi); match = device_get_match_data(&spi->dev);
if (match) {
status = match(&spi->dev);
if (status)
return status;
}
/* Allocate driver data */ /* Allocate driver data */
spidev = kzalloc(sizeof(*spidev), GFP_KERNEL); spidev = kzalloc(sizeof(*spidev), GFP_KERNEL);
...@@ -834,7 +825,7 @@ static struct spi_driver spidev_spi_driver = { ...@@ -834,7 +825,7 @@ static struct spi_driver spidev_spi_driver = {
.driver = { .driver = {
.name = "spidev", .name = "spidev",
.of_match_table = of_match_ptr(spidev_dt_ids), .of_match_table = of_match_ptr(spidev_dt_ids),
.acpi_match_table = ACPI_PTR(spidev_acpi_ids), .acpi_match_table = spidev_acpi_ids,
}, },
.probe = spidev_probe, .probe = spidev_probe,
.remove = spidev_remove, .remove = spidev_remove,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment