diff options
Diffstat (limited to 'drivers/gpio/gpio-max732x.c')
-rw-r--r-- | drivers/gpio/gpio-max732x.c | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index 5e4102e7b1f9..5fb0bcf31142 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c | |||
@@ -649,12 +649,12 @@ static int max732x_probe(struct i2c_client *client, | |||
649 | case 0x60: | 649 | case 0x60: |
650 | chip->client_group_a = client; | 650 | chip->client_group_a = client; |
651 | if (nr_port > 8) { | 651 | if (nr_port > 8) { |
652 | c = i2c_new_dummy(client->adapter, addr_b); | 652 | c = devm_i2c_new_dummy_device(&client->dev, |
653 | if (!c) { | 653 | client->adapter, addr_b); |
654 | if (IS_ERR(c)) { | ||
654 | dev_err(&client->dev, | 655 | dev_err(&client->dev, |
655 | "Failed to allocate I2C device\n"); | 656 | "Failed to allocate I2C device\n"); |
656 | ret = -ENODEV; | 657 | return PTR_ERR(c); |
657 | goto out_failed; | ||
658 | } | 658 | } |
659 | chip->client_group_b = chip->client_dummy = c; | 659 | chip->client_group_b = chip->client_dummy = c; |
660 | } | 660 | } |
@@ -662,12 +662,12 @@ static int max732x_probe(struct i2c_client *client, | |||
662 | case 0x50: | 662 | case 0x50: |
663 | chip->client_group_b = client; | 663 | chip->client_group_b = client; |
664 | if (nr_port > 8) { | 664 | if (nr_port > 8) { |
665 | c = i2c_new_dummy(client->adapter, addr_a); | 665 | c = devm_i2c_new_dummy_device(&client->dev, |
666 | if (!c) { | 666 | client->adapter, addr_a); |
667 | if (IS_ERR(c)) { | ||
667 | dev_err(&client->dev, | 668 | dev_err(&client->dev, |
668 | "Failed to allocate I2C device\n"); | 669 | "Failed to allocate I2C device\n"); |
669 | ret = -ENODEV; | 670 | return PTR_ERR(c); |
670 | goto out_failed; | ||
671 | } | 671 | } |
672 | chip->client_group_a = chip->client_dummy = c; | 672 | chip->client_group_a = chip->client_dummy = c; |
673 | } | 673 | } |
@@ -675,37 +675,33 @@ static int max732x_probe(struct i2c_client *client, | |||
675 | default: | 675 | default: |
676 | dev_err(&client->dev, "invalid I2C address specified %02x\n", | 676 | dev_err(&client->dev, "invalid I2C address specified %02x\n", |
677 | client->addr); | 677 | client->addr); |
678 | ret = -EINVAL; | 678 | return -EINVAL; |
679 | goto out_failed; | ||
680 | } | 679 | } |
681 | 680 | ||
682 | if (nr_port > 8 && !chip->client_dummy) { | 681 | if (nr_port > 8 && !chip->client_dummy) { |
683 | dev_err(&client->dev, | 682 | dev_err(&client->dev, |
684 | "Failed to allocate second group I2C device\n"); | 683 | "Failed to allocate second group I2C device\n"); |
685 | ret = -ENODEV; | 684 | return -ENODEV; |
686 | goto out_failed; | ||
687 | } | 685 | } |
688 | 686 | ||
689 | mutex_init(&chip->lock); | 687 | mutex_init(&chip->lock); |
690 | 688 | ||
691 | ret = max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]); | 689 | ret = max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]); |
692 | if (ret) | 690 | if (ret) |
693 | goto out_failed; | 691 | return ret; |
694 | if (nr_port > 8) { | 692 | if (nr_port > 8) { |
695 | ret = max732x_readb(chip, is_group_a(chip, 8), &chip->reg_out[1]); | 693 | ret = max732x_readb(chip, is_group_a(chip, 8), &chip->reg_out[1]); |
696 | if (ret) | 694 | if (ret) |
697 | goto out_failed; | 695 | return ret; |
698 | } | 696 | } |
699 | 697 | ||
700 | ret = gpiochip_add_data(&chip->gpio_chip, chip); | 698 | ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip); |
701 | if (ret) | 699 | if (ret) |
702 | goto out_failed; | 700 | return ret; |
703 | 701 | ||
704 | ret = max732x_irq_setup(chip, id); | 702 | ret = max732x_irq_setup(chip, id); |
705 | if (ret) { | 703 | if (ret) |
706 | gpiochip_remove(&chip->gpio_chip); | 704 | return ret; |
707 | goto out_failed; | ||
708 | } | ||
709 | 705 | ||
710 | if (pdata && pdata->setup) { | 706 | if (pdata && pdata->setup) { |
711 | ret = pdata->setup(client, chip->gpio_chip.base, | 707 | ret = pdata->setup(client, chip->gpio_chip.base, |
@@ -716,10 +712,6 @@ static int max732x_probe(struct i2c_client *client, | |||
716 | 712 | ||
717 | i2c_set_clientdata(client, chip); | 713 | i2c_set_clientdata(client, chip); |
718 | return 0; | 714 | return 0; |
719 | |||
720 | out_failed: | ||
721 | i2c_unregister_device(chip->client_dummy); | ||
722 | return ret; | ||
723 | } | 715 | } |
724 | 716 | ||
725 | static int max732x_remove(struct i2c_client *client) | 717 | static int max732x_remove(struct i2c_client *client) |
@@ -739,11 +731,6 @@ static int max732x_remove(struct i2c_client *client) | |||
739 | } | 731 | } |
740 | } | 732 | } |
741 | 733 | ||
742 | gpiochip_remove(&chip->gpio_chip); | ||
743 | |||
744 | /* unregister any dummy i2c_client */ | ||
745 | i2c_unregister_device(chip->client_dummy); | ||
746 | |||
747 | return 0; | 734 | return 0; |
748 | } | 735 | } |
749 | 736 | ||