hc
2024-05-16 8d2a02b24d66aa359e83eebc1ed3c0f85367a1cb
kernel/drivers/platform/chrome/chromeos_laptop.c
....@@ -63,7 +63,7 @@
6363 struct chromeos_laptop {
6464 /*
6565 * 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.
6767 */
6868 struct i2c_peripheral *i2c_peripherals;
6969 unsigned int num_i2c_peripherals;
....@@ -87,8 +87,8 @@
8787 * address we scan secondary addresses. In any case the client
8888 * structure gets assigned primary address.
8989 */
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) {
9292 struct i2c_board_info dummy_info = {
9393 I2C_BOARD_INFO("dummy", info->addr),
9494 };
....@@ -97,22 +97,24 @@
9797 };
9898 struct i2c_client *dummy;
9999
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)) {
103103 pr_debug("%d-%02x is probed at %02x\n",
104104 adapter->nr, info->addr, dummy->addr);
105105 i2c_unregister_device(dummy);
106
- client = i2c_new_device(adapter, info);
106
+ client = i2c_new_client_device(adapter, info);
107107 }
108108 }
109109
110
- if (!client)
110
+ if (IS_ERR(client)) {
111
+ client = NULL;
111112 pr_debug("failed to register device %d-%02x\n",
112113 adapter->nr, info->addr);
113
- else
114
+ } else {
114115 pr_debug("added i2c device %d-%02x\n",
115116 adapter->nr, info->addr);
117
+ }
116118
117119 return client;
118120 }
....@@ -125,7 +127,7 @@
125127 return false;
126128
127129 pdev = to_pci_dev(dev);
128
- return devid == PCI_DEVID(pdev->bus->number, pdev->devfn);
130
+ return devid == pci_dev_id(pdev);
129131 }
130132
131133 static void chromeos_laptop_check_adapter(struct i2c_adapter *adapter)
....@@ -716,6 +718,7 @@
716718 chromeos_laptop_prepare_i2c_peripherals(struct chromeos_laptop *cros_laptop,
717719 const struct chromeos_laptop *src)
718720 {
721
+ struct i2c_peripheral *i2c_peripherals;
719722 struct i2c_peripheral *i2c_dev;
720723 struct i2c_board_info *info;
721724 int i;
....@@ -724,17 +727,15 @@
724727 if (!src->num_i2c_peripherals)
725728 return 0;
726729
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)
732735 return -ENOMEM;
733736
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];
738739 info = &i2c_dev->board_info;
739740
740741 error = chromeos_laptop_setup_irq(i2c_dev);
....@@ -752,16 +753,19 @@
752753 }
753754 }
754755
756
+ cros_laptop->i2c_peripherals = i2c_peripherals;
757
+ cros_laptop->num_i2c_peripherals = src->num_i2c_peripherals;
758
+
755759 return 0;
756760
757761 err_out:
758762 while (--i >= 0) {
759
- i2c_dev = &cros_laptop->i2c_peripherals[i];
763
+ i2c_dev = &i2c_peripherals[i];
760764 info = &i2c_dev->board_info;
761765 if (info->properties)
762766 property_entries_free(info->properties);
763767 }
764
- kfree(cros_laptop->i2c_peripherals);
768
+ kfree(i2c_peripherals);
765769 return error;
766770 }
767771
....@@ -838,18 +842,14 @@
838842 i2c_dev = &cros_laptop->i2c_peripherals[i];
839843 info = &i2c_dev->board_info;
840844
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);
846847 }
847848
848849 for (i = 0; i < cros_laptop->num_acpi_peripherals; i++) {
849850 acpi_dev = &cros_laptop->acpi_peripherals[i];
850851
851
- if (acpi_dev->properties)
852
- property_entries_free(acpi_dev->properties);
852
+ property_entries_free(acpi_dev->properties);
853853 }
854854
855855 kfree(cros_laptop->i2c_peripherals);