.. | .. |
---|
63 | 63 | struct chromeos_laptop { |
---|
64 | 64 | /* |
---|
65 | 65 | * Note that we can't mark this pointer as const because |
---|
66 | | - * i2c_new_probed_device() changes passed in I2C board info, so. |
---|
| 66 | + * i2c_new_scanned_device() changes passed in I2C board info, so. |
---|
67 | 67 | */ |
---|
68 | 68 | struct i2c_peripheral *i2c_peripherals; |
---|
69 | 69 | unsigned int num_i2c_peripherals; |
---|
.. | .. |
---|
87 | 87 | * address we scan secondary addresses. In any case the client |
---|
88 | 88 | * structure gets assigned primary address. |
---|
89 | 89 | */ |
---|
90 | | - client = i2c_new_probed_device(adapter, info, addr_list, NULL); |
---|
91 | | - if (!client && alt_addr) { |
---|
| 90 | + client = i2c_new_scanned_device(adapter, info, addr_list, NULL); |
---|
| 91 | + if (IS_ERR(client) && alt_addr) { |
---|
92 | 92 | struct i2c_board_info dummy_info = { |
---|
93 | 93 | I2C_BOARD_INFO("dummy", info->addr), |
---|
94 | 94 | }; |
---|
.. | .. |
---|
97 | 97 | }; |
---|
98 | 98 | struct i2c_client *dummy; |
---|
99 | 99 | |
---|
100 | | - dummy = i2c_new_probed_device(adapter, &dummy_info, |
---|
101 | | - alt_addr_list, NULL); |
---|
102 | | - if (dummy) { |
---|
| 100 | + dummy = i2c_new_scanned_device(adapter, &dummy_info, |
---|
| 101 | + alt_addr_list, NULL); |
---|
| 102 | + if (!IS_ERR(dummy)) { |
---|
103 | 103 | pr_debug("%d-%02x is probed at %02x\n", |
---|
104 | 104 | adapter->nr, info->addr, dummy->addr); |
---|
105 | 105 | i2c_unregister_device(dummy); |
---|
106 | | - client = i2c_new_device(adapter, info); |
---|
| 106 | + client = i2c_new_client_device(adapter, info); |
---|
107 | 107 | } |
---|
108 | 108 | } |
---|
109 | 109 | |
---|
110 | | - if (!client) |
---|
| 110 | + if (IS_ERR(client)) { |
---|
| 111 | + client = NULL; |
---|
111 | 112 | pr_debug("failed to register device %d-%02x\n", |
---|
112 | 113 | adapter->nr, info->addr); |
---|
113 | | - else |
---|
| 114 | + } else { |
---|
114 | 115 | pr_debug("added i2c device %d-%02x\n", |
---|
115 | 116 | adapter->nr, info->addr); |
---|
| 117 | + } |
---|
116 | 118 | |
---|
117 | 119 | return client; |
---|
118 | 120 | } |
---|
.. | .. |
---|
125 | 127 | return false; |
---|
126 | 128 | |
---|
127 | 129 | pdev = to_pci_dev(dev); |
---|
128 | | - return devid == PCI_DEVID(pdev->bus->number, pdev->devfn); |
---|
| 130 | + return devid == pci_dev_id(pdev); |
---|
129 | 131 | } |
---|
130 | 132 | |
---|
131 | 133 | static void chromeos_laptop_check_adapter(struct i2c_adapter *adapter) |
---|
.. | .. |
---|
716 | 718 | chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop, |
---|
717 | 719 | const struct chromeos_laptop *src) |
---|
718 | 720 | { |
---|
| 721 | + struct i2c_peripheral *i2c_peripherals; |
---|
719 | 722 | struct i2c_peripheral *i2c_dev; |
---|
720 | 723 | struct i2c_board_info *info; |
---|
721 | 724 | int i; |
---|
.. | .. |
---|
724 | 727 | if (!src->num_i2c_peripherals) |
---|
725 | 728 | return 0; |
---|
726 | 729 | |
---|
727 | | - cros_laptop->i2c_peripherals = kmemdup(src->i2c_peripherals, |
---|
728 | | - src->num_i2c_peripherals * |
---|
729 | | - sizeof(*src->i2c_peripherals), |
---|
730 | | - GFP_KERNEL); |
---|
731 | | - if (!cros_laptop->i2c_peripherals) |
---|
| 730 | + i2c_peripherals = kmemdup(src->i2c_peripherals, |
---|
| 731 | + src->num_i2c_peripherals * |
---|
| 732 | + sizeof(*src->i2c_peripherals), |
---|
| 733 | + GFP_KERNEL); |
---|
| 734 | + if (!i2c_peripherals) |
---|
732 | 735 | return -ENOMEM; |
---|
733 | 736 | |
---|
734 | | - cros_laptop->num_i2c_peripherals = src->num_i2c_peripherals; |
---|
735 | | - |
---|
736 | | - for (i = 0; i < cros_laptop->num_i2c_peripherals; i++) { |
---|
737 | | - i2c_dev = &cros_laptop->i2c_peripherals[i]; |
---|
| 737 | + for (i = 0; i < src->num_i2c_peripherals; i++) { |
---|
| 738 | + i2c_dev = &i2c_peripherals[i]; |
---|
738 | 739 | info = &i2c_dev->board_info; |
---|
739 | 740 | |
---|
740 | 741 | error = chromeos_laptop_setup_irq(i2c_dev); |
---|
.. | .. |
---|
752 | 753 | } |
---|
753 | 754 | } |
---|
754 | 755 | |
---|
| 756 | + cros_laptop->i2c_peripherals = i2c_peripherals; |
---|
| 757 | + cros_laptop->num_i2c_peripherals = src->num_i2c_peripherals; |
---|
| 758 | + |
---|
755 | 759 | return 0; |
---|
756 | 760 | |
---|
757 | 761 | err_out: |
---|
758 | 762 | while (--i >= 0) { |
---|
759 | | - i2c_dev = &cros_laptop->i2c_peripherals[i]; |
---|
| 763 | + i2c_dev = &i2c_peripherals[i]; |
---|
760 | 764 | info = &i2c_dev->board_info; |
---|
761 | 765 | if (info->properties) |
---|
762 | 766 | property_entries_free(info->properties); |
---|
763 | 767 | } |
---|
764 | | - kfree(cros_laptop->i2c_peripherals); |
---|
| 768 | + kfree(i2c_peripherals); |
---|
765 | 769 | return error; |
---|
766 | 770 | } |
---|
767 | 771 | |
---|
.. | .. |
---|
838 | 842 | i2c_dev = &cros_laptop->i2c_peripherals[i]; |
---|
839 | 843 | info = &i2c_dev->board_info; |
---|
840 | 844 | |
---|
841 | | - if (i2c_dev->client) |
---|
842 | | - i2c_unregister_device(i2c_dev->client); |
---|
843 | | - |
---|
844 | | - if (info->properties) |
---|
845 | | - property_entries_free(info->properties); |
---|
| 845 | + i2c_unregister_device(i2c_dev->client); |
---|
| 846 | + property_entries_free(info->properties); |
---|
846 | 847 | } |
---|
847 | 848 | |
---|
848 | 849 | for (i = 0; i < cros_laptop->num_acpi_peripherals; i++) { |
---|
849 | 850 | acpi_dev = &cros_laptop->acpi_peripherals[i]; |
---|
850 | 851 | |
---|
851 | | - if (acpi_dev->properties) |
---|
852 | | - property_entries_free(acpi_dev->properties); |
---|
| 852 | + property_entries_free(acpi_dev->properties); |
---|
853 | 853 | } |
---|
854 | 854 | |
---|
855 | 855 | kfree(cros_laptop->i2c_peripherals); |
---|