diff --git a/drivers/mfd/wm8350-core.c b/drivers/mfd/wm8350-core.c index c7552c0b7797c86c97e3a71e8a28cbaac9ff8eab..071834ba6954fc4d9daf2c274b021988aedacb8d 100644 --- a/drivers/mfd/wm8350-core.c +++ b/drivers/mfd/wm8350-core.c @@ -388,7 +388,8 @@ static int wm8350_create_cache(struct wm8350 *wm8350, int mode) } EXPORT_SYMBOL_GPL(wm8350_create_cache); -int wm8350_device_init(struct wm8350 *wm8350) +int wm8350_device_init(struct wm8350 *wm8350, + struct wm8350_platform_data *pdata) { int ret = -EINVAL; u16 id1, id2, mask, mode; @@ -439,6 +440,15 @@ int wm8350_device_init(struct wm8350 *wm8350) return ret; } + if (pdata->init) { + ret = pdata->init(wm8350); + if (ret != 0) { + dev_err(wm8350->dev, "Platform init() failed: %d\n", + ret); + goto err; + } + } + return 0; err: diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c index 2b0569cf9512f4b570c1d52292b320eae32b5c9c..245b790961aa2a79e1a3d40d30d857b65425e821 100644 --- a/drivers/mfd/wm8350-i2c.c +++ b/drivers/mfd/wm8350-i2c.c @@ -65,7 +65,7 @@ static int wm8350_i2c_probe(struct i2c_client *i2c, wm8350->read_dev = wm8350_i2c_read_device; wm8350->write_dev = wm8350_i2c_write_device; - ret = wm8350_device_init(wm8350); + ret = wm8350_device_init(wm8350, i2c->dev.platform_data); if (ret < 0) goto err; diff --git a/include/linux/mfd/wm8350/core.h b/include/linux/mfd/wm8350/core.h index 94778c1669dc60c376994842f9a3bf668ba32d87..8f2beae6278e5507d787fc1f476ad048e490911b 100644 --- a/include/linux/mfd/wm8350/core.h +++ b/include/linux/mfd/wm8350/core.h @@ -564,10 +564,22 @@ struct wm8350 { u16 *reg_cache; }; +/** + * Data to be supplied by the platform to initialise the WM8350. + * + * @init: Function called during driver initialisation. Should be + * used by the platform to configure GPIO functions and similar. + */ +struct wm8350_platform_data { + int (*init)(struct wm8350 *wm8350); +}; + + /* * WM8350 device initialisation and exit. */ -int wm8350_device_init(struct wm8350 *wm8350); +int wm8350_device_init(struct wm8350 *wm8350, + struct wm8350_platform_data *pdata); void wm8350_device_exit(struct wm8350 *wm8350); /*