#include <linux/kernel.h>
#include <linux/of_device.h>
#include <linux/spi/spi.h>
#include <linux/regmap.h>
#include <linux/mfd/wm831x/core.h>
static int wm831x_spi_probe(struct spi_device *spi)
struct wm831x_pdata *pdata = dev_get_platdata(&spi->dev);
const struct spi_device_id *id = spi_get_device_id(spi);
const struct of_device_id *of_id;
of_id = of_match_device(wm831x_of_match, &spi->dev);
dev_err(&spi->dev, "Failed to match device\n");
type = (enum wm831x_parent)of_id->data;
type = (enum wm831x_parent)id->driver_data;
wm831x = devm_kzalloc(&spi->dev, sizeof(struct wm831x), GFP_KERNEL);
spi_set_drvdata(spi, wm831x);
wm831x->regmap = devm_regmap_init_spi(spi, &wm831x_regmap_config);
if (IS_ERR(wm831x->regmap)) {
ret = PTR_ERR(wm831x->regmap);
dev_err(wm831x->dev, "Failed to allocate register map: %d\n",