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

mfd: as3722: Use devm_mfd_add_devices and devm_regmap_add_irq_chip

Use devm_mfd_add_devices() for adding MFD child devices and
devm_regmap_add_irq_chip() for IRQ chip registration.

This reduces the error code path and .remove callback for removing
MFD child devices and deleting IRQ chip data.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Laxman Dewangan and committed by
Lee Jones
0bbfb87c ae9810e2

+9 -22
+9 -22
drivers/mfd/as3722.c
··· 385 385 return ret; 386 386 387 387 irq_flags = as3722->irq_flags | IRQF_ONESHOT; 388 - ret = regmap_add_irq_chip(as3722->regmap, as3722->chip_irq, 389 - irq_flags, -1, &as3722_irq_chip, 390 - &as3722->irq_data); 388 + ret = devm_regmap_add_irq_chip(as3722->dev, as3722->regmap, 389 + as3722->chip_irq, 390 + irq_flags, -1, &as3722_irq_chip, 391 + &as3722->irq_data); 391 392 if (ret < 0) { 392 393 dev_err(as3722->dev, "Failed to add regmap irq: %d\n", ret); 393 394 return ret; ··· 396 395 397 396 ret = as3722_configure_pullups(as3722); 398 397 if (ret < 0) 399 - goto scrub; 398 + return ret; 400 399 401 - ret = mfd_add_devices(&i2c->dev, -1, as3722_devs, 402 - ARRAY_SIZE(as3722_devs), NULL, 0, 403 - regmap_irq_get_domain(as3722->irq_data)); 400 + ret = devm_mfd_add_devices(&i2c->dev, -1, as3722_devs, 401 + ARRAY_SIZE(as3722_devs), NULL, 0, 402 + regmap_irq_get_domain(as3722->irq_data)); 404 403 if (ret) { 405 404 dev_err(as3722->dev, "Failed to add MFD devices: %d\n", ret); 406 - goto scrub; 405 + return ret; 407 406 } 408 407 409 408 device_init_wakeup(as3722->dev, true); 410 409 411 410 dev_dbg(as3722->dev, "AS3722 core driver initialized successfully\n"); 412 - return 0; 413 - 414 - scrub: 415 - regmap_del_irq_chip(as3722->chip_irq, as3722->irq_data); 416 - return ret; 417 - } 418 - 419 - static int as3722_i2c_remove(struct i2c_client *i2c) 420 - { 421 - struct as3722 *as3722 = i2c_get_clientdata(i2c); 422 - 423 - mfd_remove_devices(as3722->dev); 424 - regmap_del_irq_chip(as3722->chip_irq, as3722->irq_data); 425 411 return 0; 426 412 } 427 413 ··· 458 470 .pm = &as3722_pm_ops, 459 471 }, 460 472 .probe = as3722_i2c_probe, 461 - .remove = as3722_i2c_remove, 462 473 .id_table = as3722_i2c_id, 463 474 }; 464 475