Commit b8380c1a661f1f853418ff2eb798f27a11cade57
Committed by
Samuel Ortiz
1 parent
44faac3155
Exists in
master
and in
7 other branches
mfd: Register WM8400 codec device
Register a child device for the codec in the WM8400. Also switch the unregistration of the MFD devices to use the MFD core since the current code is hand rolling the same thing. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
Showing 2 changed files with 26 additions and 6 deletions Side-by-side Diff
drivers/mfd/Kconfig
drivers/mfd/wm8400-core.c
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | #include <linux/bug.h> |
16 | 16 | #include <linux/i2c.h> |
17 | 17 | #include <linux/kernel.h> |
18 | +#include <linux/mfd/core.h> | |
18 | 19 | #include <linux/mfd/wm8400-private.h> |
19 | 20 | #include <linux/mfd/wm8400-audio.h> |
20 | 21 | |
... | ... | @@ -239,6 +240,16 @@ |
239 | 240 | } |
240 | 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 | 254 | * wm8400_init - Generic initialisation |
244 | 255 | * |
245 | 256 | |
246 | 257 | |
247 | 258 | |
248 | 259 | |
... | ... | @@ -296,24 +307,32 @@ |
296 | 307 | reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT; |
297 | 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 | 316 | if (pdata && pdata->platform_init) { |
300 | 317 | ret = pdata->platform_init(wm8400->dev); |
301 | - if (ret != 0) | |
318 | + if (ret != 0) { | |
302 | 319 | dev_err(wm8400->dev, "Platform init failed: %d\n", |
303 | 320 | ret); |
321 | + goto err_children; | |
322 | + } | |
304 | 323 | } else |
305 | 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 | 330 | return ret; |
308 | 331 | } |
309 | 332 | |
310 | 333 | static void wm8400_release(struct wm8400 *wm8400) |
311 | 334 | { |
312 | - int i; | |
313 | - | |
314 | - for (i = 0; i < ARRAY_SIZE(wm8400->regulators); i++) | |
315 | - if (wm8400->regulators[i].name) | |
316 | - platform_device_unregister(&wm8400->regulators[i]); | |
335 | + mfd_remove_devices(wm8400->dev); | |
317 | 336 | } |
318 | 337 | |
319 | 338 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |