diff options
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/Kconfig | 1 | ||||
-rw-r--r-- | drivers/mfd/wm8400-core.c | 31 |
2 files changed, 26 insertions, 6 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 8cd3dd9a69b2..ddfb12b52f54 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -116,6 +116,7 @@ config PMIC_DA903X | |||
116 | 116 | ||
117 | config MFD_WM8400 | 117 | config MFD_WM8400 |
118 | tristate "Support Wolfson Microelectronics WM8400" | 118 | tristate "Support Wolfson Microelectronics WM8400" |
119 | select MFD_CORE | ||
119 | depends on I2C | 120 | depends on I2C |
120 | help | 121 | help |
121 | Support for the Wolfson Microelecronics WM8400 PMIC and audio | 122 | Support for the Wolfson Microelecronics WM8400 PMIC and audio |
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c index 6a0cedb5bb8a..cf30d06a0104 100644 --- a/drivers/mfd/wm8400-core.c +++ b/drivers/mfd/wm8400-core.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/bug.h> | 15 | #include <linux/bug.h> |
16 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/mfd/core.h> | ||
18 | #include <linux/mfd/wm8400-private.h> | 19 | #include <linux/mfd/wm8400-private.h> |
19 | #include <linux/mfd/wm8400-audio.h> | 20 | #include <linux/mfd/wm8400-audio.h> |
20 | 21 | ||
@@ -239,6 +240,16 @@ void wm8400_reset_codec_reg_cache(struct wm8400 *wm8400) | |||
239 | } | 240 | } |
240 | EXPORT_SYMBOL_GPL(wm8400_reset_codec_reg_cache); | 241 | EXPORT_SYMBOL_GPL(wm8400_reset_codec_reg_cache); |
241 | 242 | ||
243 | static int wm8400_register_codec(struct wm8400 *wm8400) | ||
244 | { | ||
245 | struct mfd_cell cell = { | ||
246 | .name = "wm8400-codec", | ||
247 | .driver_data = wm8400, | ||
248 | }; | ||
249 | |||
250 | return mfd_add_devices(wm8400->dev, -1, &cell, 1, NULL, 0); | ||
251 | } | ||
252 | |||
242 | /* | 253 | /* |
243 | * wm8400_init - Generic initialisation | 254 | * wm8400_init - Generic initialisation |
244 | * | 255 | * |
@@ -296,24 +307,32 @@ static int wm8400_init(struct wm8400 *wm8400, | |||
296 | reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT; | 307 | reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT; |
297 | dev_info(wm8400->dev, "WM8400 revision %x\n", reg); | 308 | dev_info(wm8400->dev, "WM8400 revision %x\n", reg); |
298 | 309 | ||
310 | ret = wm8400_register_codec(wm8400); | ||
311 | if (ret != 0) { | ||
312 | dev_err(wm8400->dev, "Failed to register codec\n"); | ||
313 | goto err_children; | ||
314 | } | ||
315 | |||
299 | if (pdata && pdata->platform_init) { | 316 | if (pdata && pdata->platform_init) { |
300 | ret = pdata->platform_init(wm8400->dev); | 317 | ret = pdata->platform_init(wm8400->dev); |
301 | if (ret != 0) | 318 | if (ret != 0) { |
302 | dev_err(wm8400->dev, "Platform init failed: %d\n", | 319 | dev_err(wm8400->dev, "Platform init failed: %d\n", |
303 | ret); | 320 | ret); |
321 | goto err_children; | ||
322 | } | ||
304 | } else | 323 | } else |
305 | dev_warn(wm8400->dev, "No platform initialisation supplied\n"); | 324 | dev_warn(wm8400->dev, "No platform initialisation supplied\n"); |
306 | 325 | ||
326 | return 0; | ||
327 | |||
328 | err_children: | ||
329 | mfd_remove_devices(wm8400->dev); | ||
307 | return ret; | 330 | return ret; |
308 | } | 331 | } |
309 | 332 | ||
310 | static void wm8400_release(struct wm8400 *wm8400) | 333 | static void wm8400_release(struct wm8400 *wm8400) |
311 | { | 334 | { |
312 | int i; | 335 | mfd_remove_devices(wm8400->dev); |
313 | |||
314 | for (i = 0; i < ARRAY_SIZE(wm8400->regulators); i++) | ||
315 | if (wm8400->regulators[i].name) | ||
316 | platform_device_unregister(&wm8400->regulators[i]); | ||
317 | } | 336 | } |
318 | 337 | ||
319 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 338 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |