| .. | .. |
|---|
| 30 | 30 | #include <linux/irq.h> |
|---|
| 31 | 31 | #include <linux/mfd/core.h> |
|---|
| 32 | 32 | #include <linux/mfd/tps80031.h> |
|---|
| 33 | | -#include <linux/module.h> |
|---|
| 34 | 33 | #include <linux/pm.h> |
|---|
| 35 | 34 | #include <linux/regmap.h> |
|---|
| 36 | 35 | #include <linux/slab.h> |
|---|
| .. | .. |
|---|
| 438 | 437 | if (tps80031_slave_address[i] == client->addr) |
|---|
| 439 | 438 | tps80031->clients[i] = client; |
|---|
| 440 | 439 | else |
|---|
| 441 | | - tps80031->clients[i] = i2c_new_dummy(client->adapter, |
|---|
| 442 | | - tps80031_slave_address[i]); |
|---|
| 443 | | - if (!tps80031->clients[i]) { |
|---|
| 440 | + tps80031->clients[i] = devm_i2c_new_dummy_device(&client->dev, |
|---|
| 441 | + client->adapter, tps80031_slave_address[i]); |
|---|
| 442 | + if (IS_ERR(tps80031->clients[i])) { |
|---|
| 444 | 443 | dev_err(&client->dev, "can't attach client %d\n", i); |
|---|
| 445 | | - ret = -ENOMEM; |
|---|
| 446 | | - goto fail_client_reg; |
|---|
| 444 | + return PTR_ERR(tps80031->clients[i]); |
|---|
| 447 | 445 | } |
|---|
| 448 | 446 | |
|---|
| 449 | 447 | i2c_set_clientdata(tps80031->clients[i], tps80031); |
|---|
| .. | .. |
|---|
| 453 | 451 | ret = PTR_ERR(tps80031->regmap[i]); |
|---|
| 454 | 452 | dev_err(&client->dev, |
|---|
| 455 | 453 | "regmap %d init failed, err %d\n", i, ret); |
|---|
| 456 | | - goto fail_client_reg; |
|---|
| 454 | + return ret; |
|---|
| 457 | 455 | } |
|---|
| 458 | 456 | } |
|---|
| 459 | 457 | |
|---|
| .. | .. |
|---|
| 462 | 460 | if (ret < 0) { |
|---|
| 463 | 461 | dev_err(&client->dev, |
|---|
| 464 | 462 | "Silicon version number read failed: %d\n", ret); |
|---|
| 465 | | - goto fail_client_reg; |
|---|
| 463 | + return ret; |
|---|
| 466 | 464 | } |
|---|
| 467 | 465 | |
|---|
| 468 | 466 | ret = tps80031_read(&client->dev, TPS80031_SLAVE_ID3, |
|---|
| .. | .. |
|---|
| 470 | 468 | if (ret < 0) { |
|---|
| 471 | 469 | dev_err(&client->dev, |
|---|
| 472 | 470 | "Silicon eeprom version read failed: %d\n", ret); |
|---|
| 473 | | - goto fail_client_reg; |
|---|
| 471 | + return ret; |
|---|
| 474 | 472 | } |
|---|
| 475 | 473 | |
|---|
| 476 | 474 | dev_info(&client->dev, "ES version 0x%02x and EPROM version 0x%02x\n", |
|---|
| .. | .. |
|---|
| 483 | 481 | ret = tps80031_irq_init(tps80031, client->irq, pdata->irq_base); |
|---|
| 484 | 482 | if (ret) { |
|---|
| 485 | 483 | dev_err(&client->dev, "IRQ init failed: %d\n", ret); |
|---|
| 486 | | - goto fail_client_reg; |
|---|
| 484 | + return ret; |
|---|
| 487 | 485 | } |
|---|
| 488 | 486 | |
|---|
| 489 | 487 | tps80031_pupd_init(tps80031, pdata); |
|---|
| .. | .. |
|---|
| 507 | 505 | |
|---|
| 508 | 506 | fail_mfd_add: |
|---|
| 509 | 507 | regmap_del_irq_chip(client->irq, tps80031->irq_data); |
|---|
| 510 | | - |
|---|
| 511 | | -fail_client_reg: |
|---|
| 512 | | - for (i = 0; i < TPS80031_NUM_SLAVES; i++) { |
|---|
| 513 | | - if (tps80031->clients[i] && (tps80031->clients[i] != client)) |
|---|
| 514 | | - i2c_unregister_device(tps80031->clients[i]); |
|---|
| 515 | | - } |
|---|
| 516 | 508 | return ret; |
|---|
| 517 | | -} |
|---|
| 518 | | - |
|---|
| 519 | | -static int tps80031_remove(struct i2c_client *client) |
|---|
| 520 | | -{ |
|---|
| 521 | | - struct tps80031 *tps80031 = i2c_get_clientdata(client); |
|---|
| 522 | | - int i; |
|---|
| 523 | | - |
|---|
| 524 | | - if (tps80031_power_off_dev == tps80031) { |
|---|
| 525 | | - tps80031_power_off_dev = NULL; |
|---|
| 526 | | - pm_power_off = NULL; |
|---|
| 527 | | - } |
|---|
| 528 | | - |
|---|
| 529 | | - mfd_remove_devices(tps80031->dev); |
|---|
| 530 | | - |
|---|
| 531 | | - regmap_del_irq_chip(client->irq, tps80031->irq_data); |
|---|
| 532 | | - |
|---|
| 533 | | - for (i = 0; i < TPS80031_NUM_SLAVES; i++) { |
|---|
| 534 | | - if (tps80031->clients[i] != client) |
|---|
| 535 | | - i2c_unregister_device(tps80031->clients[i]); |
|---|
| 536 | | - } |
|---|
| 537 | | - return 0; |
|---|
| 538 | 509 | } |
|---|
| 539 | 510 | |
|---|
| 540 | 511 | static const struct i2c_device_id tps80031_id_table[] = { |
|---|
| .. | .. |
|---|
| 542 | 513 | { "tps80032", TPS80032 }, |
|---|
| 543 | 514 | { } |
|---|
| 544 | 515 | }; |
|---|
| 545 | | -MODULE_DEVICE_TABLE(i2c, tps80031_id_table); |
|---|
| 546 | 516 | |
|---|
| 547 | 517 | static struct i2c_driver tps80031_driver = { |
|---|
| 548 | 518 | .driver = { |
|---|
| 549 | | - .name = "tps80031", |
|---|
| 519 | + .name = "tps80031", |
|---|
| 520 | + .suppress_bind_attrs = true, |
|---|
| 550 | 521 | }, |
|---|
| 551 | 522 | .probe = tps80031_probe, |
|---|
| 552 | | - .remove = tps80031_remove, |
|---|
| 553 | 523 | .id_table = tps80031_id_table, |
|---|
| 554 | 524 | }; |
|---|
| 555 | 525 | |
|---|
| .. | .. |
|---|
| 558 | 528 | return i2c_add_driver(&tps80031_driver); |
|---|
| 559 | 529 | } |
|---|
| 560 | 530 | subsys_initcall(tps80031_init); |
|---|
| 561 | | - |
|---|
| 562 | | -static void __exit tps80031_exit(void) |
|---|
| 563 | | -{ |
|---|
| 564 | | - i2c_del_driver(&tps80031_driver); |
|---|
| 565 | | -} |
|---|
| 566 | | -module_exit(tps80031_exit); |
|---|
| 567 | | - |
|---|
| 568 | | -MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>"); |
|---|
| 569 | | -MODULE_DESCRIPTION("TPS80031 core driver"); |
|---|
| 570 | | -MODULE_LICENSE("GPL v2"); |
|---|