Skip to content

Commit 15d71e6

Browse files
robherringlag-linaro
authored andcommitted
mfd: mc13xxx-spi/wm831x-spi: Use spi_get_device_match_data()
Use preferred spi_get_device_match_data() instead of of_match_device() and spi_get_device_id() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Lee Jones <[email protected]> tils.feedkeys.call.run(35) all.run(37) all.run(39)
1 parent 9f58744 commit 15d71e6

File tree

2 files changed

+6
-24
lines changed

2 files changed

+6
-24
lines changed

drivers/mfd/mc13xxx-spi.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
*/
99

1010
#include <linux/slab.h>
11+
#include <linux/mod_devicetable.h>
1112
#include <linux/module.h>
1213
#include <linux/platform_device.h>
1314
#include <linux/interrupt.h>
1415
#include <linux/mfd/core.h>
1516
#include <linux/mfd/mc13xxx.h>
16-
#include <linux/of.h>
17-
#include <linux/of_device.h>
1817
#include <linux/err.h>
1918
#include <linux/spi/spi.h>
2019

@@ -151,16 +150,7 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
151150
return ret;
152151
}
153152

154-
if (spi->dev.of_node) {
155-
const struct of_device_id *of_id =
156-
of_match_device(mc13xxx_dt_ids, &spi->dev);
157-
158-
mc13xxx->variant = of_id->data;
159-
} else {
160-
const struct spi_device_id *id_entry = spi_get_device_id(spi);
161-
162-
mc13xxx->variant = (void *)id_entry->driver_data;
163-
}
153+
mc13xxx->variant = spi_get_device_match_data(spi);
164154

165155
return mc13xxx_common_init(&spi->dev);
166156
}

drivers/mfd/wm831x-spi.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <linux/kernel.h>
1111
#include <linux/init.h>
1212
#include <linux/of.h>
13-
#include <linux/of_device.h>
1413
#include <linux/pm.h>
1514
#include <linux/spi/spi.h>
1615
#include <linux/regmap.h>
@@ -21,21 +20,14 @@
2120
static int wm831x_spi_probe(struct spi_device *spi)
2221
{
2322
struct wm831x_pdata *pdata = dev_get_platdata(&spi->dev);
24-
const struct spi_device_id *id = spi_get_device_id(spi);
25-
const struct of_device_id *of_id;
2623
struct wm831x *wm831x;
2724
enum wm831x_parent type;
2825
int ret;
2926

30-
if (spi->dev.of_node) {
31-
of_id = of_match_device(wm831x_of_match, &spi->dev);
32-
if (!of_id) {
33-
dev_err(&spi->dev, "Failed to match device\n");
34-
return -ENODEV;
35-
}
36-
type = (uintptr_t)of_id->data;
37-
} else {
38-
type = (enum wm831x_parent)id->driver_data;
27+
type = (uintptr_t)spi_get_device_match_data(spi);
28+
if (!type) {
29+
dev_err(&spi->dev, "Failed to match device\n");
30+
return -ENODEV;
3931
}
4032

4133
wm831x = devm_kzalloc(&spi->dev, sizeof(struct wm831x), GFP_KERNEL);

0 commit comments

Comments
 (0)