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

mfd / platform: cros_ec: Use devm_mfd_add_devices

Use devm_mfd_add_devices() for adding cros-ec core MFD child devices. This
reduces the need of remove callback from platform/chrome for removing the
MFD child devices.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Enric Balletbo i Serra and committed by
Lee Jones
4bc59c2f 49a57857

+3 -46
+3 -11
drivers/mfd/cros_ec.c
··· 129 129 } 130 130 } 131 131 132 - err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, &ec_cell, 1, 133 - NULL, ec_dev->irq, NULL); 132 + err = devm_mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, &ec_cell, 133 + 1, NULL, ec_dev->irq, NULL); 134 134 if (err) { 135 135 dev_err(dev, 136 136 "Failed to register Embedded Controller subdevice %d\n", ··· 147 147 * - the EC is responsive at init time (it is not true for a 148 148 * sensor hub. 149 149 */ 150 - err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, 150 + err = devm_mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, 151 151 &ec_pd_cell, 1, NULL, ec_dev->irq, NULL); 152 152 if (err) { 153 153 dev_err(dev, ··· 180 180 return 0; 181 181 } 182 182 EXPORT_SYMBOL(cros_ec_register); 183 - 184 - int cros_ec_remove(struct cros_ec_device *ec_dev) 185 - { 186 - mfd_remove_devices(ec_dev->dev); 187 - 188 - return 0; 189 - } 190 - EXPORT_SYMBOL(cros_ec_remove); 191 183 192 184 #ifdef CONFIG_PM_SLEEP 193 185 int cros_ec_suspend(struct cros_ec_device *ec_dev)
-10
drivers/platform/chrome/cros_ec_i2c.c
··· 317 317 return 0; 318 318 } 319 319 320 - static int cros_ec_i2c_remove(struct i2c_client *client) 321 - { 322 - struct cros_ec_device *ec_dev = i2c_get_clientdata(client); 323 - 324 - cros_ec_remove(ec_dev); 325 - 326 - return 0; 327 - } 328 - 329 320 #ifdef CONFIG_PM_SLEEP 330 321 static int cros_ec_i2c_suspend(struct device *dev) 331 322 { ··· 367 376 .pm = &cros_ec_i2c_pm_ops, 368 377 }, 369 378 .probe = cros_ec_i2c_probe, 370 - .remove = cros_ec_i2c_remove, 371 379 .id_table = cros_ec_i2c_id, 372 380 }; 373 381
-4
drivers/platform/chrome/cros_ec_lpc.c
··· 327 327 328 328 static int cros_ec_lpc_remove(struct platform_device *pdev) 329 329 { 330 - struct cros_ec_device *ec_dev; 331 330 struct acpi_device *adev; 332 331 333 332 adev = ACPI_COMPANION(&pdev->dev); 334 333 if (adev) 335 334 acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY, 336 335 cros_ec_lpc_acpi_notify); 337 - 338 - ec_dev = platform_get_drvdata(pdev); 339 - cros_ec_remove(ec_dev); 340 336 341 337 return 0; 342 338 }
-11
drivers/platform/chrome/cros_ec_spi.c
··· 685 685 return 0; 686 686 } 687 687 688 - static int cros_ec_spi_remove(struct spi_device *spi) 689 - { 690 - struct cros_ec_device *ec_dev; 691 - 692 - ec_dev = spi_get_drvdata(spi); 693 - cros_ec_remove(ec_dev); 694 - 695 - return 0; 696 - } 697 - 698 688 #ifdef CONFIG_PM_SLEEP 699 689 static int cros_ec_spi_suspend(struct device *dev) 700 690 { ··· 723 733 .pm = &cros_ec_spi_pm_ops, 724 734 }, 725 735 .probe = cros_ec_spi_probe, 726 - .remove = cros_ec_spi_remove, 727 736 .id_table = cros_ec_spi_id, 728 737 }; 729 738
-10
include/linux/mfd/cros_ec.h
··· 282 282 struct cros_ec_command *msg); 283 283 284 284 /** 285 - * cros_ec_remove() - Remove a ChromeOS EC. 286 - * @ec_dev: Device to register. 287 - * 288 - * Call this to deregister a ChromeOS EC, then clean up any private data. 289 - * 290 - * Return: 0 on success or negative error code. 291 - */ 292 - int cros_ec_remove(struct cros_ec_device *ec_dev); 293 - 294 - /** 295 285 * cros_ec_register() - Register a new ChromeOS EC, using the provided info. 296 286 * @ec_dev: Device to register. 297 287 *