summaryrefslogtreecommitdiffstats
path: root/drivers/mfd/arizona-spi.c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2021-01-20 22:49:54 +0100
committerLee Jones <lee.jones@linaro.org>2021-02-04 14:54:56 +0100
commit039da225d644e523a3bbec78ee258b25fe0676f9 (patch)
treeae19020336350a4a25671766a1c92c2082f24c26 /drivers/mfd/arizona-spi.c
parentmfd: arizona: Add MODULE_SOFTDEP("pre: arizona_ldo1") (diff)
downloadlinux-039da225d644e523a3bbec78ee258b25fe0676f9.tar.xz
linux-039da225d644e523a3bbec78ee258b25fe0676f9.zip
mfd: arizona: Replace arizona_of_get_type() with device_get_match_data()
Replace the custom arizona_of_get_type() function with the generic device_get_match_data() helper. Besides being a nice cleanup this also makes it easier to add support for binding to ACPI enumerated devices. While at it also fix a possible NULL pointer deref of the id argument to the probe functions (this could happen on e.g. manual driver binding through sysfs). Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/arizona-spi.c')
-rw-r--r--drivers/mfd/arizona-spi.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
index 704f214d2614..798b88295c77 100644
--- a/drivers/mfd/arizona-spi.c
+++ b/drivers/mfd/arizona-spi.c
@@ -23,14 +23,16 @@
static int arizona_spi_probe(struct spi_device *spi)
{
const struct spi_device_id *id = spi_get_device_id(spi);
+ const void *match_data;
struct arizona *arizona;
const struct regmap_config *regmap_config = NULL;
- unsigned long type;
+ unsigned long type = 0;
int ret;
- if (spi->dev.of_node)
- type = arizona_of_get_type(&spi->dev);
- else
+ match_data = device_get_match_data(&spi->dev);
+ if (match_data)
+ type = (unsigned long)match_data;
+ else if (id)
type = id->driver_data;
switch (type) {