aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core.c137
1 files changed, 0 insertions, 137 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index dc8bc9131447..d48438908e1e 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1032,144 +1032,7 @@ EXPORT_SYMBOL(i2c_master_recv);
1032 * Will not work for 10-bit addresses! 1032 * Will not work for 10-bit addresses!
1033 * ---------------------------------------------------- 1033 * ----------------------------------------------------
1034 */ 1034 */
1035static int i2c_probe_address(struct i2c_adapter *adapter, int addr, int kind,
1036 int (*found_proc) (struct i2c_adapter *, int, int))
1037{
1038 int err;
1039
1040 /* Make sure the address is valid */
1041 if (addr < 0x03 || addr > 0x77) {
1042 dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",
1043 addr);
1044 return -EINVAL;
1045 }
1046
1047 /* Skip if already in use */
1048 if (i2c_check_addr(adapter, addr))
1049 return 0;
1050
1051 /* Make sure there is something at this address, unless forced */
1052 if (kind < 0) {
1053 if (i2c_smbus_xfer(adapter, addr, 0, 0, 0,
1054 I2C_SMBUS_QUICK, NULL) < 0)
1055 return 0;
1056
1057 /* prevent 24RF08 corruption */
1058 if ((addr & ~0x0f) == 0x50)
1059 i2c_smbus_xfer(adapter, addr, 0, 0, 0,
1060 I2C_SMBUS_QUICK, NULL);
1061 }
1062
1063 /* Finally call the custom detection function */
1064 err = found_proc(adapter, addr, kind);
1065 /* -ENODEV can be returned if there is a chip at the given address
1066 but it isn't supported by this chip driver. We catch it here as
1067 this isn't an error. */
1068 if (err == -ENODEV)
1069 err = 0;
1070
1071 if (err)
1072 dev_warn(&adapter->dev, "Client creation failed at 0x%x (%d)\n",
1073 addr, err);
1074 return err;
1075}
1076
1077int i2c_probe(struct i2c_adapter *adapter,
1078 const struct i2c_client_address_data *address_data,
1079 int (*found_proc) (struct i2c_adapter *, int, int))
1080{
1081 int i, err;
1082 int adap_id = i2c_adapter_id(adapter);
1083
1084 /* Force entries are done first, and are not affected by ignore
1085 entries */
1086 if (address_data->forces) {
1087 const unsigned short * const *forces = address_data->forces;
1088 int kind;
1089
1090 for (kind = 0; forces[kind]; kind++) {
1091 for (i = 0; forces[kind][i] != I2C_CLIENT_END;
1092 i += 2) {
1093 if (forces[kind][i] == adap_id
1094 || forces[kind][i] == ANY_I2C_BUS) {
1095 dev_dbg(&adapter->dev, "found force "
1096 "parameter for adapter %d, "
1097 "addr 0x%02x, kind %d\n",
1098 adap_id, forces[kind][i + 1],
1099 kind);
1100 err = i2c_probe_address(adapter,
1101 forces[kind][i + 1],
1102 kind, found_proc);
1103 if (err)
1104 return err;
1105 }
1106 }
1107 }
1108 }
1109
1110 /* Stop here if we can't use SMBUS_QUICK */
1111 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_QUICK)) {
1112 if (address_data->probe[0] == I2C_CLIENT_END
1113 && address_data->normal_i2c[0] == I2C_CLIENT_END)
1114 return 0;
1115
1116 dev_dbg(&adapter->dev, "SMBus Quick command not supported, "
1117 "can't probe for chips\n");
1118 return -EOPNOTSUPP;
1119 }
1120
1121 /* Probe entries are done second, and are not affected by ignore
1122 entries either */
1123 for (i = 0; address_data->probe[i] != I2C_CLIENT_END; i += 2) {
1124 if (address_data->probe[i] == adap_id
1125 || address_data->probe[i] == ANY_I2C_BUS) {
1126 dev_dbg(&adapter->dev, "found probe parameter for "
1127 "adapter %d, addr 0x%02x\n", adap_id,
1128 address_data->probe[i + 1]);
1129 err = i2c_probe_address(adapter,
1130 address_data->probe[i + 1],
1131 -1, found_proc);
1132 if (err)
1133 return err;
1134 }
1135 }
1136
1137 /* Normal entries are done last, unless shadowed by an ignore entry */
1138 for (i = 0; address_data->normal_i2c[i] != I2C_CLIENT_END; i += 1) {
1139 int j, ignore;
1140
1141 ignore = 0;
1142 for (j = 0; address_data->ignore[j] != I2C_CLIENT_END;
1143 j += 2) {
1144 if ((address_data->ignore[j] == adap_id ||
1145 address_data->ignore[j] == ANY_I2C_BUS)
1146 && address_data->ignore[j + 1]
1147 == address_data->normal_i2c[i]) {
1148 dev_dbg(&adapter->dev, "found ignore "
1149 "parameter for adapter %d, "
1150 "addr 0x%02x\n", adap_id,
1151 address_data->ignore[j + 1]);
1152 ignore = 1;
1153 break;
1154 }
1155 }
1156 if (ignore)
1157 continue;
1158
1159 dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
1160 "addr 0x%02x\n", adap_id,
1161 address_data->normal_i2c[i]);
1162 err = i2c_probe_address(adapter, address_data->normal_i2c[i],
1163 -1, found_proc);
1164 if (err)
1165 return err;
1166 }
1167
1168 return 0;
1169}
1170EXPORT_SYMBOL(i2c_probe);
1171 1035
1172/* Separate detection function for new-style drivers */
1173static int i2c_detect_address(struct i2c_client *temp_client, int kind, 1036static int i2c_detect_address(struct i2c_client *temp_client, int kind,
1174 struct i2c_driver *driver) 1037 struct i2c_driver *driver)
1175{ 1038{