···387387 return 0;388388}389389390390+/* And this is a strict address validity check, used when probing. If a391391+ * device uses a reserved address, then it shouldn't be probed. 7-bit392392+ * addressing is assumed, 10-bit address devices are rare and should be393393+ * explicitly enumerated. */394394+static int i2c_check_addr_validity(unsigned short addr)395395+{396396+ /*397397+ * Reserved addresses per I2C specification:398398+ * 0x00 General call address / START byte399399+ * 0x01 CBUS address400400+ * 0x02 Reserved for different bus format401401+ * 0x03 Reserved for future purposes402402+ * 0x04-0x07 Hs-mode master code403403+ * 0x78-0x7b 10-bit slave addressing404404+ * 0x7c-0x7f Reserved for future purposes405405+ */406406+ if (addr < 0x08 || addr > 0x77)407407+ return -EINVAL;408408+ return 0;409409+}410410+390411/**391412 * i2c_new_device - instantiate an i2c device392413 * @adap: the adapter managing the device···13611340 int err;1362134113631342 /* Make sure the address is valid */13641364- if (addr < 0x03 || addr > 0x77) {13431343+ err = i2c_check_addr_validity(addr);13441344+ if (err) {13651345 dev_warn(&adapter->dev, "Invalid probe address 0x%02x\n",13661346 addr);13671367- return -EINVAL;13471347+ return err;13681348 }1369134913701350 /* Skip if already in use */···1468144614691447 for (i = 0; addr_list[i] != I2C_CLIENT_END; i++) {14701448 /* Check address validity */14711471- if (addr_list[i] < 0x03 || addr_list[i] > 0x77) {14491449+ if (i2c_check_addr_validity(addr_list[i]) < 0) {14721450 dev_warn(&adap->dev, "Invalid 7-bit address "14731451 "0x%02x\n", addr_list[i]);14741452 continue;