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.
Unified · Split
| @@ -129,8 +129,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev) · 128 unmodified lines | |||
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | err = mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, &ec_cell, 1, | 132 | err = devm_mfd_add_devices(ec_dev->dev, PLATFORM_DEVID_AUTO, &ec_cell, |
| 133 | NULL, ec_dev->irq, NULL); | 133 | 1, NULL, ec_dev->irq, NULL); |
| 134 | if (err) { | 134 | if (err) { |
| 135 | dev_err(dev, | 135 | dev_err(dev, |
| 136 | "Failed to register Embedded Controller subdevice %d\n", | 136 | "Failed to register Embedded Controller subdevice %d\n", |
| @@ -147,7 +147,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev) · 10 unmodified lines | |||
| 147 | * - the EC is responsive at init time (it is not true for a | 147 | * - the EC is responsive at init time (it is not true for a |
| 148 | * sensor hub. | 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 | &ec_pd_cell, 1, NULL, ec_dev->irq, NULL); | 151 | &ec_pd_cell, 1, NULL, ec_dev->irq, NULL); |
| 152 | if (err) { | 152 | if (err) { |
| 153 | dev_err(dev, | 153 | dev_err(dev, |
| @@ -181,14 +181,6 @@ int cros_ec_register(struct cros_ec_device *ec_dev) · 27 unmodified lines | |||
| 181 | } | 181 | } |
| 182 | EXPORT_SYMBOL(cros_ec_register); | 182 | EXPORT_SYMBOL(cros_ec_register); |
| 183 | 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 | |||
| 192 | #ifdef CONFIG_PM_SLEEP | 184 | #ifdef CONFIG_PM_SLEEP |
| 193 | int cros_ec_suspend(struct cros_ec_device *ec_dev) | 185 | int cros_ec_suspend(struct cros_ec_device *ec_dev) |
| 194 | { | 186 | { |
| @@ -317,15 +317,6 @@ static int cros_ec_i2c_probe(struct i2c_client *client, · 316 unmodified lines | |||
| 317 | return 0; | 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 | #ifdef CONFIG_PM_SLEEP | 320 | #ifdef CONFIG_PM_SLEEP |
| 330 | static int cros_ec_i2c_suspend(struct device *dev) | 321 | static int cros_ec_i2c_suspend(struct device *dev) |
| 331 | { | 322 | { |
| @@ -376,7 +367,6 @@ static struct i2c_driver cros_ec_driver = { · 44 unmodified lines | |||
| 376 | .pm = &cros_ec_i2c_pm_ops, | 367 | .pm = &cros_ec_i2c_pm_ops, |
| 377 | }, | 368 | }, |
| 378 | .probe = cros_ec_i2c_probe, | 369 | .probe = cros_ec_i2c_probe, |
| 379 | .remove = cros_ec_i2c_remove, | ||
| 380 | .id_table = cros_ec_i2c_id, | 370 | .id_table = cros_ec_i2c_id, |
| 381 | }; | 371 | }; |
| 382 | 372 | ||
| @@ -327,7 +327,6 @@ static int cros_ec_lpc_probe(struct platform_device *pdev) · 326 unmodified lines | |||
| 327 | 327 | ||
| 328 | static int cros_ec_lpc_remove(struct platform_device *pdev) | 328 | static int cros_ec_lpc_remove(struct platform_device *pdev) |
| 329 | { | 329 | { |
| 330 | struct cros_ec_device *ec_dev; | ||
| 331 | struct acpi_device *adev; | 330 | struct acpi_device *adev; |
| 332 | 331 | ||
| 333 | adev = ACPI_COMPANION(&pdev->dev); | 332 | adev = ACPI_COMPANION(&pdev->dev); |
| @@ -335,9 +334,6 @@ static int cros_ec_lpc_remove(struct platform_device *pdev) · 1 unmodified line | |||
| 335 | acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY, | 334 | acpi_remove_notify_handler(adev->handle, ACPI_ALL_NOTIFY, |
| 336 | cros_ec_lpc_acpi_notify); | 335 | cros_ec_lpc_acpi_notify); |
| 337 | 336 | ||
| 338 | ec_dev = platform_get_drvdata(pdev); | ||
| 339 | cros_ec_remove(ec_dev); | ||
| 340 | |||
| 341 | return 0; | 337 | return 0; |
| 342 | } | 338 | } |
| 343 | 339 | ||
| @@ -685,16 +685,6 @@ static int cros_ec_spi_probe(struct spi_device *spi) · 684 unmodified lines | |||
| 685 | return 0; | 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 | #ifdef CONFIG_PM_SLEEP | 688 | #ifdef CONFIG_PM_SLEEP |
| 699 | static int cros_ec_spi_suspend(struct device *dev) | 689 | static int cros_ec_spi_suspend(struct device *dev) |
| 700 | { | 690 | { |
| @@ -733,7 +723,6 @@ static struct spi_driver cros_ec_driver_spi = { · 32 unmodified lines | |||
| 733 | .pm = &cros_ec_spi_pm_ops, | 723 | .pm = &cros_ec_spi_pm_ops, |
| 734 | }, | 724 | }, |
| 735 | .probe = cros_ec_spi_probe, | 725 | .probe = cros_ec_spi_probe, |
| 736 | .remove = cros_ec_spi_remove, | ||
| 737 | .id_table = cros_ec_spi_id, | 726 | .id_table = cros_ec_spi_id, |
| 738 | }; | 727 | }; |
| 739 | 728 | ||
| @@ -281,16 +281,6 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev, · 280 unmodified lines | |||
| 281 | int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, | 281 | int cros_ec_cmd_xfer_status(struct cros_ec_device *ec_dev, |
| 282 | struct cros_ec_command *msg); | 282 | struct cros_ec_command *msg); |
| 283 | 283 | ||
| 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 | /** | 284 | /** |
| 295 | * cros_ec_register() - Register a new ChromeOS EC, using the provided info. | 285 | * cros_ec_register() - Register a new ChromeOS EC, using the provided info. |
| 296 | * @ec_dev: Device to register. | 286 | * @ec_dev: Device to register. |