Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Mark Brown and committed by
Samuel Ortiz
b8380c1a 44faac31

+26 -6
+1
drivers/mfd/Kconfig
··· 116 116 117 117 config MFD_WM8400 118 118 tristate "Support Wolfson Microelectronics WM8400" 119 + select MFD_CORE 119 120 depends on I2C 120 121 help 121 122 Support for the Wolfson Microelecronics WM8400 PMIC and audio
+25 -6
drivers/mfd/wm8400-core.c
··· 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 ··· 240 239 } 241 240 EXPORT_SYMBOL_GPL(wm8400_reset_codec_reg_cache); 242 241 242 + static int wm8400_register_codec(struct wm8400 *wm8400) 243 + { 244 + struct mfd_cell cell = { 245 + .name = "wm8400-codec", 246 + .driver_data = wm8400, 247 + }; 248 + 249 + return mfd_add_devices(wm8400->dev, -1, &cell, 1, NULL, 0); 250 + } 251 + 243 252 /* 244 253 * wm8400_init - Generic initialisation 245 254 * ··· 307 296 reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT; 308 297 dev_info(wm8400->dev, "WM8400 revision %x\n", reg); 309 298 299 + ret = wm8400_register_codec(wm8400); 300 + if (ret != 0) { 301 + dev_err(wm8400->dev, "Failed to register codec\n"); 302 + goto err_children; 303 + } 304 + 310 305 if (pdata && pdata->platform_init) { 311 306 ret = pdata->platform_init(wm8400->dev); 312 - if (ret != 0) 307 + if (ret != 0) { 313 308 dev_err(wm8400->dev, "Platform init failed: %d\n", 314 309 ret); 310 + goto err_children; 311 + } 315 312 } else 316 313 dev_warn(wm8400->dev, "No platform initialisation supplied\n"); 317 314 315 + return 0; 316 + 317 + err_children: 318 + mfd_remove_devices(wm8400->dev); 318 319 return ret; 319 320 } 320 321 321 322 static void wm8400_release(struct wm8400 *wm8400) 322 323 { 323 - int i; 324 - 325 - for (i = 0; i < ARRAY_SIZE(wm8400->regulators); i++) 326 - if (wm8400->regulators[i].name) 327 - platform_device_unregister(&wm8400->regulators[i]); 324 + mfd_remove_devices(wm8400->dev); 328 325 } 329 326 330 327 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)